Skip to content

[Bugfix][Model] Fix FP8 k_scale/v_scale not loaded for Qwen3-MoE - #35656

Merged
Isotr0py merged 4 commits into
vllm-project:mainfrom
oneraghavan:fix/fp8-kv-scale-qwen3-moe-25047
Mar 4, 2026
Merged

Isotr0py merged 4 commits into
vllm-project:mainfrom
oneraghavan:fix/fp8-kv-scale-qwen3-moe-25047

Conversation

@oneraghavan

@oneraghavan oneraghavan commented Mar 1, 2026 •

Copy link
Copy Markdown
Contributor

FP8 KV cache scales from llm-compressor checkpoints (e.g. qkv_proj.k_scale) were silently dropped during weight loading in Qwen3MoeModel, causing fallback to scale=1.0 and accuracy degradation.

Root cause: scale names were caught by ignore_suffixes before maybe_remap_kv_scale_name could remap them to attn.k_scale.

Fix: add early scale remapping (matching Llama's approach) between the get_cache_scale check and the stacked-params loop, and remove k_scale/v_scale from ignore_suffixes so they are no longer blocked.

cc : @DarkLight1337

@oneraghavan
oneraghavan requested a review from sighingnow as a code owner March 1, 2026 14:37
@mergify mergify Bot added qwen Related to Qwen models bug Something isn't working labels Mar 1, 2026

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

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.

Code Review

This pull request fixes a bug where FP8 KV cache scales were not loaded correctly for Qwen3-MoE models, leading to accuracy degradation. The fix involves removing k_scale and v_scale from ignore_suffixes and adding an early remapping for scale names, which aligns with the approach in other models. The changes are correct and well-supported by a comprehensive set of new unit tests that cover various checkpoint formats. The fix effectively addresses the reported issue.

@DarkLight1337
DarkLight1337 requested review from Isotr0py and mgoin March 2, 2026 01:51

@Isotr0py Isotr0py left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you check if this change will affect modelopt quantized models like nvidia/Qwen3-30B-A3B-NVFP4? IIRC, the ignore suffix is workaround for modelopt quantization.

Comment thread vllm/model_executor/models/qwen3_moe.py Resolved
…m-project#25047)

FP8 KV cache scales from llm-compressor checkpoints (e.g.
`qkv_proj.k_scale`) were silently dropped during weight loading in
Qwen3MoeModel, causing fallback to scale=1.0 and accuracy degradation.

Root cause: scale names were caught by `ignore_suffixes` before
`maybe_remap_kv_scale_name` could remap them to `attn.k_scale`.

Fix: add early scale remapping (matching Llama's approach) between the
`get_cache_scale` check and the stacked-params loop, and remove
k_scale/v_scale from `ignore_suffixes` so they are no longer blocked.

Verified compatible with ModelOpt NVFP4 checkpoints (e.g.
nvidia/Qwen3-30B-A3B-NVFP4) — their k_proj.k_scale / v_proj.v_scale
tensors are correctly remapped by maybe_remap_kv_scale_name.

Made-with: Cursor

Signed-off-by: raghavan <oneraghavan@gmail.com>
@oneraghavan
oneraghavan force-pushed the fix/fp8-kv-scale-qwen3-moe-25047 branch from 392aad8 to 3e15456 Compare March 2, 2026 09:46
Extend the fix from the previous commit to qwen3_vl_moe.py, which had
the same bug: ignore_suffixes silently dropped k_scale/v_scale before
maybe_remap_kv_scale_name could remap them.

Also add regression tests for Qwen3-VL-MoE and NVFP4 weight/input
scales to confirm they are not affected by the remap.

Signed-off-by: Raghavan <raghavan@users.noreply.github.com>
Made-with: Cursor

Signed-off-by: raghavan <oneraghavan@gmail.com>
@Isotr0py Isotr0py added the ready ONLY add when PR is ready to merge/full CI is needed label Mar 3, 2026
@Isotr0py
Isotr0py enabled auto-merge (squash) March 3, 2026 03:16
@oneraghavan

Copy link
Copy Markdown
Contributor Author

@Isotr0py Some builds are failing, not sure whats the issue . Please help me how to fix these.

@raghavan-sarvam

Copy link
Copy Markdown

Gentle reminder @mgoin @sighingnow

@Isotr0py
Isotr0py merged commit c8c3935 into vllm-project:main Mar 4, 2026
58 checks passed
Copilot AI pushed a commit to machov/vllm that referenced this pull request Mar 10, 2026
avinashsingh77 pushed a commit to avinashsingh77/vllm that referenced this pull request Mar 12, 2026
wendyliu235 pushed a commit to wendyliu235/vllm-public that referenced this pull request Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working qwen Related to Qwen models 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.

3 participants