Add P-EAGLE training support#575
Open
thyways wants to merge 27 commits into
Open
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closes #541.
P-EAGLE shows speed comparable to DFlash while also supporting parallel decoding, so SpecForge should support P-EAGLE training.
This PR adds P-EAGLE training support to SpecForge, following the algorithmic direction from:
The implementation adapts the P-EAGLE idea to SpecForge's existing online EAGLE3 training pipeline.
Demo model:
https://huggingface.co/thyways/qwen3_8b_peagle_demo
Modifications
This PR adds P-EAGLE training support.
Main changes:
PEagleDraftModel, including the P-EAGLE multi-layer draft architecture.OnlinePEagleModelwith COD parallel sampling, P-EAGLE attention masking, loss, and per-depth accuracy metrics.scripts/train_peagle.pyfor online P-EAGLE training with FSDP, TP/DP support, checkpoint save/resume, mask-token resolution, and wandb logging.from/valuemessages.minimum_valid_tokensfiltering to drop samples without trainable tokens.loss_mask.Implementation notes:
mask_hiddenparameter is used for positions that do not have target hidden states in parallel prediction depths.Related Issues
Closes #541.
Related references:
Accuracy Test
The Qwen3-8B P-EAGLE was trained on 8x A100 GPUs.
Training setup:
Qwen/Qwen3-8Bjihwan1205/perfectblend-qwen3-8b-regen1e-4Training Loss:

The trained demo checkpoint is available at:
https://huggingface.co/thyways/qwen3_8b_peagle_demo
SGLang does not yet support P-EAGLE inference, so model-side inference accuracy was not evaluated through SGLang in this PR. For the current validation, I adapted the exported config for vLLM testing:
{ "architectures": [ "Eagle3LlamaForCausalLM" ], "ptd_token_id": 151669 }Benchmark & Profiling
Evaluation setup:
Due to limited training resources, this checkpoint is not fully trained yet. However, the current results already validate the effectiveness of the implementation, and longer training is expected to further improve the acceptance quality and speedup, consistent with the P-EAGLE paper.
Checklist