Skip to content

[SpecDecode] Skip embedding sharing when target/draft hidden dims differ - #44631

Closed
chaojun-zhang wants to merge 1 commit into
vllm-project:mainfrom
chaojun-zhang:fix/eagle3-embedding-sharing
Closed

chaojun-zhang wants to merge 1 commit into
vllm-project:mainfrom
chaojun-zhang:fix/eagle3-embedding-sharing

Conversation

@chaojun-zhang

@chaojun-zhang chaojun-zhang commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Fix _maybe_share_embeddings in SpecDecodeBaseProposer: when a draft checkpoint has no own embed_tokens (e.g. yuhuili/EAGLE3-LLaMA3.1-Instruct-8B), the target embedding was blindly shared to the draft model even if their hidden dimensions differ. With an EAGLE3-LLaMA3.1-8B draft (hidden_size=4096) paired with a MiniMax-M2 target (hidden_size=3072), the first decoder layer does cat([embed(tokens), hidden_states]) expecting dim 8192 but receives 7168, triggering a torch._assert failure during torch.compile tracing and crashing engine initialization.

Add a dimension guard before sharing; skip and log a warning when dims differ.

Test

pytest -sv tests/models/test_initialization.py::test_can_initialize_large_subset[Eagle3MiniMaxM2ForCausalLM]

Without this fix the test fails with RuntimeError: Engine core initialization failed (root cause: shape mismatch in cat during compile). With this fix the test passes.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify

mergify Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Hi @chaojun-zhang, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10

_maybe_share_embeddings blindly replaces the draft model's embed_tokens
with the target's when the draft checkpoint has no own embedding weights.
This breaks EAGLE3 variants paired with a target of different hidden
size (e.g. EAGLE3-LLaMA3.1-8B draft + MiniMax-M2 target): the first
decoder layer does cat([embed(tokens), hidden_states]) expecting
(N,4096)+(N,4096), but receives (N,3072)+(N,4096) after the bad share.

Add a dimension check before sharing: if target embedding output dim !=
draft hidden size, skip sharing and log a warning. The draft model falls
back to random-initialized embeddings, which is the correct behavior
when dimensions are incompatible.

Fixes Eagle3MiniMaxM2ForCausalLM initialization test.

Signed-off-by: Chaojun Zhang <chaojun.zhang@intel.com>
@chaojun-zhang
chaojun-zhang force-pushed the fix/eagle3-embedding-sharing branch from 7008908 to fcb68e9 Compare June 5, 2026 08:40
@mergify

mergify Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

⚠️ The sha of the head commit of this PR conflicts with #43957. Mergify cannot evaluate rules on this PR. Once #43957 is merged or closed, Mergify will resume processing this PR. ⚠️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant