[Spec] Fix Qwen3.5 text model EAGLE3/DFLASH aux-layer capture (#42002)

This commit is contained in:
Yuhao Wang
2026-10-02 14:05:01 -07:00
committed by GitHub
parent a64725d407
commit 0098b9d29d
+11 -10
View File
@@ -127,6 +127,17 @@ class Qwen3_5ForCausalLM(nn.Module):
[layer_id + 1 for layer_id in layer_ids]
)
def set_eagle3_layers_to_capture(self, layer_ids: Optional[list[int]] = None):
if not self.pp_group.is_last_rank:
return
self.capture_aux_hidden_states = True
if layer_ids is None:
num_layers = len(self.model.layers)
layers_to_capture = [2, num_layers // 2, num_layers - 3]
else:
layers_to_capture = [val + 1 for val in layer_ids]
self.model.set_eagle3_layers_to_capture(layers_to_capture)
def get_embed_and_head(self):
# PP splits embedding and lm_head across first/last stages; the draft keeps
# its own copy of whichever half its stage cannot receive.
@@ -146,16 +157,6 @@ class Qwen3_5ForCausalLM(nn.Module):
current_platform.empty_cache()
current_platform.synchronize()
def set_dflash_layers_to_capture(self, layers_to_capture: list[int]):
if not self.pp_group.is_last_rank:
return
if layers_to_capture is None:
raise ValueError(
"DFLASH requires explicit layer ids for aux hidden capture."
)
self.capture_aux_hidden_states = True
self.model.set_dflash_layers_to_capture(layers_to_capture)
@torch.no_grad()
def forward(
self,