[Spec Decode] Support non-MTP speculation for NemotronH (#43130)

Signed-off-by: Benjamin Chislett <bchislett@nvidia.com>
This commit is contained in:
Benjamin Chislett
2026-05-20 09:15:52 -04:00
committed by GitHub
parent 19cf334207
commit 0a508743d4
+16 -2
View File
@@ -64,9 +64,12 @@ from vllm.model_executor.model_loader.weight_utils import (
maybe_remap_kv_scale_name,
)
from vllm.model_executor.models.interfaces import (
EagleModelMixin,
HasInnerState,
IsHybrid,
MixtureOfExperts,
SupportsEagle,
SupportsEagle3,
SupportsLoRA,
SupportsMambaPrefixCaching,
SupportsPP,
@@ -539,7 +542,7 @@ ALL_DECODER_LAYER_TYPES = {
@support_torch_compile
class NemotronHModel(nn.Module):
class NemotronHModel(nn.Module, EagleModelMixin):
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
super().__init__()
@@ -605,18 +608,27 @@ class NemotronHModel(nn.Module):
hidden_states = intermediate_tensors["hidden_states"]
residual = intermediate_tensors["residual"]
for layer in islice(self.layers, self.start_layer, self.end_layer):
aux_hidden_states = self._maybe_add_hidden_state([], 0, hidden_states, residual)
for idx, layer in enumerate(
islice(self.layers, self.start_layer, self.end_layer)
):
hidden_states, residual = layer(
positions=positions,
hidden_states=hidden_states,
residual=residual,
)
self._maybe_add_hidden_state(
aux_hidden_states, idx + 1, hidden_states, residual
)
if not get_pp_group().is_last_rank:
return IntermediateTensors(
{"hidden_states": hidden_states, "residual": residual}
)
hidden_states, _ = self.norm_f(hidden_states, residual)
if len(aux_hidden_states) > 0:
return hidden_states, aux_hidden_states
return hidden_states
def is_spec_layer(self, config: NemotronHConfig, weight_name: str) -> bool:
@@ -767,6 +779,8 @@ class NemotronHForCausalLM(
HasInnerState,
SupportsLoRA,
SupportsPP,
SupportsEagle,
SupportsEagle3,
IsHybrid,
SupportsQuant,
MixtureOfExperts,