Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions vllm/config/speculative.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"mtp",
"pangu_ultra_moe_mtp",
]
EagleModelTypes = Literal["eagle", "eagle3", MTPModelTypes]
DFlashModelTypes = Literal["dflash"]
EagleModelTypes = Literal["eagle", "eagle3", MTPModelTypes, DFlashModelTypes]
SpeculativeMethod = Literal[
"ngram",
"medusa",
Expand Down Expand Up @@ -161,7 +162,7 @@ def compute_hash(self) -> str:
factors: list[Any] = []
# Eagle3 affects the computation graph because it returns intermediate
# hidden states in addition to the final hidden state.
factors.append(self.method == "eagle3")
factors.append(self.method in ("eagle3", "dflash"))
hash_str = safe_hash(str(factors).encode(), usedforsecurity=False).hexdigest()
return hash_str

Expand Down Expand Up @@ -341,7 +342,7 @@ def __post_init__(self):
)

# Automatically detect the method
if self.method in ("eagle", "eagle3"):
if self.method in ("eagle", "eagle3", "dflash"):
pass
# examples:
# yuhuili/EAGLE-LLaMA3-Instruct-8B
Expand All @@ -351,6 +352,8 @@ def __post_init__(self):
self.method = "eagle"
elif "eagle3" in self.draft_model_config.model.lower():
self.method = "eagle3"
elif "dflash" in self.draft_model_config.model.lower():
self.method = "dflash"
elif self.draft_model_config.hf_config.model_type == "medusa":
self.method = "medusa"
elif self.draft_model_config.hf_config.model_type == "mlp_speculator":
Expand Down Expand Up @@ -620,7 +623,7 @@ def _verify_args(self) -> Self:

eagle3_target_supported = ["llama", "qwen", "minicpm", "gpt_oss"]
if (
self.method == "eagle3"
self.method in ("eagle3", "dflash")
and self.target_model_config
and not any(
supported_model in self.target_model_config.hf_text_config.model_type
Expand All @@ -635,7 +638,7 @@ def _verify_args(self) -> Self:
return self

def use_eagle(self) -> bool:
return self.method in ("eagle", "eagle3", "mtp")
return self.method in ("eagle", "eagle3", "mtp", "dflash")

def __repr__(self) -> str:
method = self.method
Expand Down
4 changes: 3 additions & 1 deletion vllm/model_executor/models/qwen3.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
def set_aux_hidden_state_layers(self, layers: tuple[int, ...]) -> None:
self.model.aux_hidden_state_layers = layers

def get_eagle3_aux_hidden_state_layers(self) -> tuple[int, ...]:
def get_eagle3_aux_hidden_state_layers(self, method: str | None = None) -> tuple[int, ...]:
if method is not None and method == "dflash":
return [1, 9, 17, 25, 33]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The function get_eagle3_aux_hidden_state_layers is type-hinted to return a tuple[int, ...], but for the dflash method, it returns a list. This violates the type hint and could lead to unexpected behavior. Please return a tuple instead.

Suggested change
return [1, 9, 17, 25, 33]
return (1, 9, 17, 25, 33)

num_layers = len(self.model.layers)
return (2, num_layers // 2, num_layers - 3)

Expand Down
Loading
Loading