Skip to content

Conversation

wwl2755
Copy link
Contributor

@wwl2755 wwl2755 commented Sep 10, 2025

  1. Fix the bug of model_initialization. The model should be initializated by a target model which is different from the speculative_model.

  2. After changing to the correct target model, I faced another error which is because of the dfferent shape in hidden_states + residual

Root cause is the num_layers is initialized to 1 in the test (https://github.com/vllm-project/vllm/blob/v0.10.2rc1/tests/models/utils.py#L387). However, the aux_hidden_layer is determine as (2, num_layers // 2, num_layers - 3). (https://github.com/vllm-project/vllm/blob/v0.10.2rc1/tests/models/utils.py#L387)

# In the test: 
DEBUG: self.aux_hidden_state_layers: (2, 0, -2)

# It is supposed to be:
DEBUG: self.aux_hidden_state_layers: (2, 20, 37)

So, before this PR, it will treat the layer-0 as the aux-layer and entering the code path of hidden_states + residual (where hidden_states is a tensor and residual is None).

Solution: we set some of the eagle3 models to have the original number of layers.

cc: @DarkLight1337 @WoosukKwon @LiuXiaoxuanPKU @22quinn @benchislett

Tests

All passed.

VLLM_WORKER_MULTIPROC_METHOD=spawn pytest -v -s models/test_initialization.py::test_can_initialize[EagleLlamaForCausalLM]
VLLM_WORKER_MULTIPROC_METHOD=spawn pytest -v -s models/test_initialization.py::test_can_initialize[Eagle3LlamaForCausalLM]
VLLM_WORKER_MULTIPROC_METHOD=spawn pytest -v -s models/test_initialization.py::test_can_initialize[LlamaForCausalLMEagle3]

python $HOME/vllm/examples/offline_inference/spec_decode.py --method eagle3 --num-prompts 10 --model-dir Qwen/Qwen3-14B --eagle-dir AngelSlim/Qwen3-14B_eagle3

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively addresses two bugs related to speculative decoding tests. First, it corrects the model initialization to use the proper target model instead of the speculative model. Second, it resolves a shape mismatch for aux_hidden_layers by introducing a mechanism to use the original number of layers from the model config during testing. The changes are logical and well-implemented. I have one suggestion to improve the robustness of how the layer count is determined in the test utilities.

Comment on lines +419 to +420
num_layers = getattr(text_config, 'num_layers', 1)
num_hidden_layers = getattr(text_config, 'num_hidden_layers', 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This logic for determining num_layers and num_hidden_layers can be fragile. If a model config only defines num_hidden_layers (which is common for many models like Llama and Qwen), num_layers will default to 1. This could lead to issues if other parts of the code rely on config.num_layers. A more robust approach would be to fetch the layer count from either attribute and ensure both num_layers and num_hidden_layers are consistent.

Suggested change
num_layers = getattr(text_config, 'num_layers', 1)
num_hidden_layers = getattr(text_config, 'num_hidden_layers', 1)
num_layers = getattr(text_config, "num_hidden_layers", getattr(text_config, "num_layers", 1))
num_hidden_layers = num_layers

@ywang96
Copy link
Member

ywang96 commented Sep 10, 2025

@wwl2755 If I understand correctly - this is just to fix our CI setup right?

@ywang96 ywang96 added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 10, 2025
@ywang96
Copy link
Member

ywang96 commented Sep 10, 2025

I turned on ready label to see if it fixes the issue.

@wwl2755
Copy link
Contributor Author

wwl2755 commented Sep 10, 2025

@wwl2755 If I understand correctly - this is just to fix our CI setup right?

Yes. It enables some tests to used the original num_layers instead of 1.

All the modification is under /tests. And there will be no any new commit coming unless requested in comment.

Signed-off-by: wwl2755 <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Cyrus Leung <[email protected]>
@vllm-bot vllm-bot merged commit 6c8deac into vllm-project:main Sep 11, 2025
5 of 14 checks passed
@wwl2755 wwl2755 deleted the fix-test branch September 11, 2025 19:54
skyloevil pushed a commit to skyloevil/vllm that referenced this pull request Sep 13, 2025
…_hidden_layers (vllm-project#24613)

Signed-off-by: wwl2755 <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Cyrus Leung <[email protected]>
Co-authored-by: Roger Wang <[email protected]>
Co-authored-by: Cyrus Leung <[email protected]>
dsxsteven pushed a commit to dsxsteven/vllm_splitPR that referenced this pull request Sep 15, 2025
…_hidden_layers (vllm-project#24613)

Signed-off-by: wwl2755 <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Cyrus Leung <[email protected]>
Co-authored-by: Roger Wang <[email protected]>
Co-authored-by: Cyrus Leung <[email protected]>
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
…_hidden_layers (vllm-project#24613)

Signed-off-by: wwl2755 <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Cyrus Leung <[email protected]>
Co-authored-by: Roger Wang <[email protected]>
Co-authored-by: Cyrus Leung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants