[Bugfix][MoE] Fix fused block-scale orientation - #50727
Conversation
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
| # contains the global intermediate dimension. Reconstruct that | ||
| # global shape: w1/w3 shard their first data axis and w2 its second. | ||
| expected_global_shape = list(target_shape[-2:]) | ||
| tp_shard_axis = 1 if shard_id == "w2" else 0 |
There was a problem hiding this comment.
This line is duplicate with https://github.com/vllm-project/vllm/pull/50727/changes?diff=split#diff-2c0390799c7c17903d1964888f6639f745335ccf4d13cb28b3dcf3f2316c8a2aR440-R443.
We can directly use intermediate_axis above as tp_shard_axis.
Assisted-by: OpenAI Codex Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Assisted-by: OpenAI Codex Signed-off-by: Andreas Karatzas <akaratza@amd.com>
|
/ci run |
|
✅ Triggered Buildkite CI #82542 for commit |
mgoin
left a comment
There was a problem hiding this comment.
I’m concerned this patch is adding another shape heuristic over the underlying layout problem.
Before #47058, the Qwen3-VL loader explicitly knew that fused expert tensors were transposed. After that logic was centralized, RoutedExperts began inferring orientation from tensor dimensions. #50137 fixed one consequence of that inference for per-channel scales, and this PR adds a destination-shape fallback for block scales. The fallback in the PR works for the reported rectangular, unpadded shapes, but it is not generally safe. For instance, square block-scales would be not handled correctly.
My recommendation is to represent the fused checkpoint layout explicitly rather than infer it from shapes. For example, a fused_checkpoint_layout / is_fused_checkpoint_transposed property passed through FusedMoE to RoutedExperts, set by Qwen3-VL or the quantization scheme.
Ok, that actually makes sense, I wanted minimal diff tbh 😅 But instead of just patching this, I took upon your direction, lmk if the new |
Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: Andreas Karatzas <akaratza@amd.com>
8552723 to
4bf6ca4
Compare
|
/ci run |
|
/ci run |
|
✅ Triggered Buildkite CI #82795 for commit |
|
/ci retry |
|
✅ Queued 4 failed job(s) for retry in Buildkite CI #82795. |
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Andreas Karatzas <Andreas.Karatzas@amd.com>
|
/ci run |
|
✅ Triggered Buildkite CI #82908 for commit |
|
/ci run |
|
✅ Triggered Buildkite CI #83187 for commit |
Leave explicit checkpoint layout handling to #50727. Assisted-by: OpenAI Codex Signed-off-by: Andreas Karatzas <akaratza@amd.com>
|
/ci run |
|
✅ Triggered Buildkite CI #83382 for commit |
Signed-off-by: Andreas Karatzas <akaratza@amd.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
PR #50137 fixed fused per-channel scale loading, but shape-based orientation inference cannot reliably recover the checkpoint layout after both dimensions have been divided by the quantization block size. This causes Qwen3-VL's fused gate/up and down-projection block scales to load in the wrong orientation, producing this large-model acceptance failure.
Represent the fused checkpoint layout explicitly instead of inferring it from tensor shapes.
is_fused_checkpoint_transposedsetting from the model layer throughFusedMoEFactorytoRoutedExperts.Validation
.venv/bin/pre-commit run --files vllm/model_executor/models/qwen3_vl_moe.py.venv/bin/python -m py_compile vllm/model_executor/models/qwen3_vl_moe.pyfc82db14f0686d5709965f868c82d21f5b6b3e5b.Duplicate work
This extends #50137 by handling explicitly transposed fused checkpoints and is not a duplicate of another open fix.
AI assistance
OpenAI Codex was used to inspect the Buildkite failures and prepare the constructor compatibility fix.