[Bugfix][SM70] Isolate MXFP4 direct-order offsets (#326)
Prevent M2-M8 active-expert compaction from poisoning B1 direct-order graph capture by selecting the immutable one-row slot offsets. CUDA kernels, arithmetic, route order, defaults, and rollbacks remain unchanged.
Reported-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Original-commit: 052312c66f
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
This commit is contained in:
1 parent
9bbc554e1d
commit
b06f54cee3
3 files changed
+37
-1
No files matched your search
@@ -43456,6 +43456,14 @@ Interpretation:
|
||||
token counts, expert mappings, top-k shapes, dtypes, and devices retain the
|
||||
existing path. This is operator performance evidence, not a full endpoint
|
||||
throughput claim.
|
||||
- The first matched endpoint reached `69.949 token/s`, but its quality gate
|
||||
failed with incoherent output and is rejected as a speed baseline. M2--M8
|
||||
warmup and verifier compaction can overwrite `compact_expert_offsets` before
|
||||
the B1 graph is captured, while direct-order incorrectly assumed that buffer
|
||||
still contained `[0, 1, ..., 6]`. Direct-order now reads the immutable
|
||||
`slot_expert_offsets` buffer. This restores the proven one-row-per-route
|
||||
contract without changing the kernel, route order, or default-on/rollback
|
||||
policy; a poisoned-workspace regression covers the failure mode.
|
||||
- The exact TP4 QNorm/RoPE plus FP8-KV insertion route combines the existing
|
||||
16 Q-head programs and eight packed-KV writers into one graph node without
|
||||
changing their arithmetic. Across 64 changing-input CUDA Graph patterns,
|
||||
|
||||
@@ -22,6 +22,7 @@ from vllm.model_executor.layers.quantization.mxfp4 import (
|
||||
from vllm.model_executor.layers.quantization.mxfp4_sm70_moe import (
|
||||
Mxfp4SM70MoEMethod,
|
||||
_compact_mxfp4_active_experts,
|
||||
_select_mxfp4_direct_order_offsets,
|
||||
_select_mxfp4_stage_dispatch,
|
||||
validate_mxfp4_sm70_moe_contract,
|
||||
validate_mxfp4_sm70_moe_weight_layout,
|
||||
@@ -210,6 +211,21 @@ def test_mxfp4_sm70_b1_dispatch_selects_six_runtime_experts(monkeypatch):
|
||||
assert count == 6
|
||||
|
||||
|
||||
def test_mxfp4_sm70_direct_order_ignores_compacted_offsets():
|
||||
buffers = {
|
||||
# Reproduce M8 compaction state left before the B1 graph is captured.
|
||||
"compact_expert_offsets": torch.tensor(
|
||||
[0, 8, 9, 16, 24, 32, 48], dtype=torch.int32
|
||||
),
|
||||
"slot_expert_offsets": torch.arange(7, dtype=torch.int32),
|
||||
}
|
||||
|
||||
offsets = _select_mxfp4_direct_order_offsets(buffers)
|
||||
|
||||
assert offsets is buffers["slot_expert_offsets"]
|
||||
torch.testing.assert_close(offsets, torch.arange(7, dtype=torch.int32))
|
||||
|
||||
|
||||
def test_mxfp4_sm70_b1_dispatch_rejects_incompatible_permute_fastpath(
|
||||
monkeypatch,
|
||||
):
|
||||
|
||||
@@ -185,6 +185,18 @@ def _select_mxfp4_stage_dispatch(
|
||||
return buffers["expert_offsets"], buffers["dense_expert_ids"], num_experts
|
||||
|
||||
|
||||
def _select_mxfp4_direct_order_offsets(
|
||||
buffers: dict[str, torch.Tensor],
|
||||
) -> torch.Tensor:
|
||||
"""Return immutable one-row offsets for B1 direct-order decode.
|
||||
|
||||
Active-expert compaction overwrites ``compact_expert_offsets`` during
|
||||
M2--M8 warmup and verifier calls. Direct-order B1 has one row per route,
|
||||
so it must use the separately maintained slot offsets instead.
|
||||
"""
|
||||
return buffers["slot_expert_offsets"]
|
||||
|
||||
|
||||
def validate_mxfp4_sm70_moe_contract(
|
||||
*,
|
||||
global_num_experts: int,
|
||||
@@ -739,7 +751,7 @@ class Mxfp4SM70MoEMethod(Mxfp4MoEMethod):
|
||||
)
|
||||
if direct_order:
|
||||
route_ids = topk_ids.view(-1)
|
||||
route_offsets = buffers["compact_expert_offsets"]
|
||||
route_offsets = _select_mxfp4_direct_order_offsets(buffers)
|
||||
sm70_ops.mxfp4_moe_dense_stage_sm70_out(
|
||||
buffers["gate_up"],
|
||||
x,
|
||||
|
||||
Reference in new issue
Block a user