Repository navigation
[Bugfix][Model] Fix FP8 k_scale/v_scale not loaded for Qwen3-MoE - #35656
Conversation
There was a problem hiding this comment.
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.
Isotr0py
left a comment
There was a problem hiding this comment.
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.
…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>
392aad8 to
3e15456
Compare
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 Some builds are failing, not sure whats the issue . Please help me how to fix these. |
|
Gentle reminder @mgoin @sighingnow |
…m-project#35656) Signed-off-by: raghavan <oneraghavan@gmail.com>
…m-project#35656) Signed-off-by: raghavan <oneraghavan@gmail.com>
…m-project#35656) Signed-off-by: raghavan <oneraghavan@gmail.com>
…m-project#35656) Signed-off-by: raghavan <oneraghavan@gmail.com>
…m-project#35656) Signed-off-by: raghavan <oneraghavan@gmail.com>
…m-project#35656) Signed-off-by: raghavan <oneraghavan@gmail.com>
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_suffixesbeforemaybe_remap_kv_scale_namecould remap them toattn.k_scale.Fix: add early scale remapping (matching Llama's approach) between the
get_cache_scalecheck and the stacked-params loop, and remove k_scale/v_scale fromignore_suffixesso they are no longer blocked.cc : @DarkLight1337