Skip to content
Merged
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
1 change: 1 addition & 0 deletions vllm/config/speculative.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ def _verify_args(self) -> Self:
"kimi_k25",
"minimax_m2",
"gemma4",
"laguna",
]
if (
self.method in ("eagle3", "extract_hidden_states", "dflash")
Expand Down
24 changes: 20 additions & 4 deletions vllm/model_executor/models/laguna.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
default_weight_loader,
maybe_remap_kv_scale_name,
)
from vllm.model_executor.models.interfaces import SupportsLoRA, SupportsPP
from vllm.model_executor.models.interfaces import (
EagleModelMixin,
SupportsEagle3,
SupportsLoRA,
SupportsPP,
)
from vllm.model_executor.models.utils import (
AutoWeightsLoader,
PPMissingLayer,
Expand Down Expand Up @@ -554,7 +559,7 @@ def forward(


@support_torch_compile
class LagunaModel(nn.Module):
class LagunaModel(nn.Module, EagleModelMixin):
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
super().__init__()

Expand Down Expand Up @@ -633,15 +638,26 @@ def forward(
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(
[], self.start_layer, hidden_states, residual
)
for layer_idx, layer in enumerate(
islice(self.layers, self.start_layer, self.end_layer),
start=self.start_layer,
):
hidden_states, residual = layer(positions, hidden_states, residual)
self._maybe_add_hidden_state(
aux_hidden_states, layer_idx + 1, hidden_states, residual
)

if not get_pp_group().is_last_rank:
return IntermediateTensors(
{"hidden_states": hidden_states, "residual": residual}
)
Comment on lines 654 to 656
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

When aux_hidden_states are being collected (e.g., during speculative decoding with EAGLE or DFlash), the model's forward method is expected to return a tuple containing both the primary output and the auxiliary hidden states. The current implementation for non-last pipeline parallel ranks only returns the IntermediateTensors object, which will cause a crash or missing data in the model runner when speculative decoding is enabled.

To ensure consistency with the last rank's return logic (lines 659-661), this path should also return the auxiliary hidden states if they are present.

Suggested change
return IntermediateTensors(
{"hidden_states": hidden_states, "residual": residual}
)
output = IntermediateTensors(
{"hidden_states": hidden_states, "residual": residual}
)
if len(aux_hidden_states) > 0:
return output, aux_hidden_states
return output


hidden_states, _ = self.norm(hidden_states, residual)
if len(aux_hidden_states) > 0:
return hidden_states, aux_hidden_states
return hidden_states

def get_expert_mapping(self) -> list[tuple[str, str, int, str]]:
Expand Down Expand Up @@ -821,7 +837,7 @@ def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
return loaded_params


class LagunaForCausalLM(nn.Module, SupportsPP, SupportsLoRA):
class LagunaForCausalLM(nn.Module, SupportsPP, SupportsLoRA, SupportsEagle3):
fall_back_to_pt_during_load = False

packed_modules_mapping = {
Expand Down
Loading