Added peagle speculators support (#41826)

Signed-off-by: shanjiaz <zsjwpianpian@gmail.com>
This commit is contained in:
shanjiaz
2026-05-12 07:55:57 -07:00
committed by GitHub
parent 7a9cc5e7f0
commit 6ccb10d794
6 changed files with 139 additions and 50 deletions
+2
View File
@@ -591,6 +591,8 @@ _SPECULATIVE_DECODING_MODELS = {
"EagleLlama4ForCausalLM": ("llama4_eagle", "EagleLlama4ForCausalLM"),
"EagleMiniCPMForCausalLM": ("minicpm_eagle", "EagleMiniCPMForCausalLM"),
"DFlashDraftModel": ("qwen3_dflash", "DFlashQwen3ForCausalLM"),
"PEagleDraftModel": ("llama_eagle3", "Eagle3LlamaForCausalLM"),
"PeagleLlamaForCausalLM": ("llama_eagle3", "Eagle3LlamaForCausalLM"),
"Eagle3LlamaForCausalLM": ("llama_eagle3", "Eagle3LlamaForCausalLM"),
"Eagle3MiniMaxM2ForCausalLM": ("llama_eagle3", "Eagle3LlamaForCausalLM"),
"LlamaForCausalLMEagle3": ("llama_eagle3", "Eagle3LlamaForCausalLM"),
@@ -43,6 +43,37 @@ def update_eagle3(config_dict: dict, pre_trained_config: dict) -> None:
]
@register_speculator("peagle")
def update_peagle(config_dict: dict, pre_trained_config: dict) -> None:
"""
Apply PEagle (Parallel Eagle) specific configuration transformations to
the `dict` used to construct the Transformers PreTrainedConfig.
PEagle specific fields:
- draft_vocab_size: Size of the draft model's vocabulary
- target_hidden_size: Hidden size of the target model
- norm_before_residual: Whether to apply norm before residual connection
- norm_before_fc: Whether to apply RMSNorm before the fc projection
- mask_token_id (required): Token ID used for parallel drafting mask
placeholders, mapped to pard_token for the proposer
- eagle_aux_hidden_state_layer_ids: Layer indices from the target model
whose intermediate hidden states are used as auxiliary inputs
"""
pre_trained_config["architectures"] = ["PeagleLlamaForCausalLM"]
pre_trained_config["draft_vocab_size"] = config_dict.get("draft_vocab_size")
if config_dict.get("target_hidden_size") is not None:
pre_trained_config["target_hidden_size"] = config_dict["target_hidden_size"]
pre_trained_config["norm_before_residual"] = config_dict.get(
"norm_before_residual", False
)
pre_trained_config["norm_before_fc"] = config_dict.get("norm_before_fc", False)
pre_trained_config["pard_token"] = config_dict["mask_token_id"]
if config_dict.get("eagle_aux_hidden_state_layer_ids"):
pre_trained_config["eagle_aux_hidden_state_layer_ids"] = config_dict[
"eagle_aux_hidden_state_layer_ids"
]
@register_speculator("dflash")
def update_dflash(config_dict: dict, pre_trained_config: dict) -> None:
"""
@@ -131,7 +131,10 @@ class SpeculatorsConfig(PretrainedConfig):
)
# Build base vLLM speculative configuration
return {
result = {
"method": config_dict.get("speculators_model_type"),
"num_speculative_tokens": num_speculative_tokens,
}
if result["method"] == "peagle":
result.update({"method": "eagle3", "parallel_drafting": True})
return result