Skip to content

[AMD] [Fix] Skip split-KV EAGLE-verify fast path for MLA to fix triton spec GPU fault - #30407

Closed
yichiche wants to merge 10 commits into
sgl-project:mainfrom
yichiche:fix/verify-splitkv-mla-guard
Closed

yichiche wants to merge 10 commits into
sgl-project:mainfrom
yichiche:fix/verify-splitkv-mla-guard

Conversation

@yichiche

@yichiche yichiche commented Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator

Complements #30355 (which makes triton MLA correct for prefill/decode on gfx95). Both are needed for --attention-backend triton + EAGLE speculative decoding on DeepSeek MLA. This change is independent and self-contained (a guard in the triton verify helper) and also protects any other MLA model from the same split-KV verify fault.

Motivation

The Triton split-KV EAGLE-verify fast path (verify_splitkv, enabled by default via SGLANG_ENABLE_SPLITKV_VERIFY on gfx95 with speculative_eagle_topk == 1) GPU-faults when the target model uses MLA (e.g. DeepSeek-R1/V3). During target-verify the target model's absorbed MLA attention has head_dim != v_head_dim (576 vs 512) and a shared latent KV cache; the split-KV kernel is built for standard attention and reads out of bounds on that layout.

Symptom (DeepSeek-R1-MXFP4, --attention-backend triton + EAGLE spec, gfx950): Memory access fault by GPU node-X ... Reason: Unknown during decode CUDA-graph capture and again mid-decode. Localized with AMD_SERIALIZE_KERNEL=3:

eagle_worker_v2.verify -> target forward -> forward_absorb_core
  -> triton_backend.forward_extend -> verify_splitkv_fwd -> _run_combine_kernel  ->  GPU fault

can_handle() (the conservative gate that is supposed to fall back to extend_attention_fwd for anything it cannot serve) checked q/k/v-vs-buffer dims but never rejected the MLA head_dim != v_head_dim signature, so MLA verify entered the kernel.

Modifications

python/sglang/srt/layers/attention/triton_ops/verify_splitkv.py: add one guard to can_handle() — return False when q_extend.shape[2] != v_extend.shape[2] (the MLA signature). MLA target-verify then falls back to extend_attention_fwd, which already handles MLA correctly (it is the same kernel used for MLA prefill/extend). Pure shape check — no device→host sync, safe inside a captured HIP graph.

Accuracy Tests

DeepSeek-R1-MXFP4 (Quark MXFP4), MI355X gfx950, tp4, --kv-cache-dtype fp8_e4m3, EAGLE (num_steps 3, topk 1, num_draft_tokens 4), cuda graph enabled, gsm8k (200q):

Before After
Decode CUDA-graph capture (bs=3) GPU fault passes
Sustained spec decode (200q) GPU fault mid-decode no fault
gsm8k crash 0.945

(aiter baseline on the same setup: 0.955.)

Benchmarking and Profiling

N/A — crash fix. Only affects MLA, which was previously faulting; non-MLA models still take the split-KV fast path unchanged.

Checklist

  • Scoped to the MLA case; non-MLA behavior unchanged.
  • Verified on real DeepSeek-R1-MXFP4 with EAGLE spec + cuda graph (0.945, no fault).
  • Follows [Tag] Description commit/PR convention.

CI States

Latest PR Test (Base): ✅ Run #31369149991
Latest PR Test (Extra): ❌ Run #31369149795

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@yichiche yichiche added the run-ci CI: run the baseline test suite on this PR label Jul 7, 2026
@yichiche

yichiche commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

@amd-bot ci-status

@amd-bot

This comment was marked as outdated.

@yichiche

yichiche commented Jul 9, 2026 •

Copy link
Copy Markdown
Collaborator Author
  • Fixed: added test_fallback_mla_head_dim_mismatch to test/registered/attention/test_verify_splitkv.py, which builds an MLA-shaped case (head_dim=576, v_head_dim=512) and asserts can_handle(...) is False.
  • It's pure shape logic (no kernel launch), already registered on CUDA base-b + AMD stage-b-test-1-gpu-small-amd-mi35x, so it runs in PR CI, not nightly-only. Proven guard: with the q_extend.shape[2] != v_extend.shape[2] line removed the test fails; with the fix
python -m pytest \
    ../test/registered/attention/test_verify_splitkv.py::TestVerifySplitKV::test_fallback_mla_head_dim_mismatch``
    
../test/registered/attention/test_verify_splitkv.py::TestVerifySplitKV::test_fallback_mla_head_dim_mismatch PASSED                                                                 [ 25%]

All pass.

@HaiShaw

HaiShaw commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@yichiche

Copy link
Copy Markdown
Collaborator Author

@HaiShaw CI completed, ready to merge.

@yichiche

Copy link
Copy Markdown
Collaborator Author

@amd-bot ci-status

@amd-bot

This comment was marked as outdated.

@HaiShaw

HaiShaw commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

@amd-bot ci-status

@amd-bot

This comment was marked as outdated.

@yichiche

yichiche commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

@amd-bot ci-status

@amd-bot

amd-bot commented Aug 2, 2026

Copy link
Copy Markdown

@yichiche

CI Status for PR #30407

Merge verdict: ❌ Do not merge on the current signal — PR CI is incomplete AND this PR's changed code was never exercised. Every executed failure is infra or pre-existing (a b200 runner comms flake, a pre-existing ROCm-7.0 compile error, an MLX config bug) — zero are caused by this PR. But because those failures fast-fail-cascaded the exact stages that run this PR's test, the new MLA guard in verify_splitkv.py and its test got no coverage. Green elsewhere proves nothing about this change.

Caution

This PR's changed code is not exercised by any PR-CI test that ran. test/registered/attention/test_verify_splitkv.py is registered to CUDA base-b / 1-gpu-small and AMD stage-b-test-1-gpu-small-amd-mi35x. On NVIDIA, all base-b jobs were fast-fail-skipped by an unrelated b200 runner-communication flake; on AMD, stage-b was never reached because stage-a fast-failed on a pre-existing ROCm compile error. Re-run CI until base-b (NVIDIA) and stage-b (AMD MI35x) actually execute, and confirm test_fallback_mla_head_dim_mismatch passes, before merging.

Changed files: python/sglang/kernels/ops/attention/verify_splitkv.py (+6/-0), test/registered/attention/test_verify_splitkv.py (+14/-0)

Executed CI failure attribution: AMD: 2 root failures (0 related) · NVIDIA: 1 root failure (0 related) · MLX: 1 root failure (0 related) · Extra pipelines: benign opt-in gate (0 related) · ~40 downstream jobs fast-fail-skipped (not tested) · NPU/Xeon/XPU still pending.

AMD Executed Failures

Job Test File Test Function Error Related? Why
jit-kernel-unit-test-amd test/registered/kernels/ops/kv_canary/test_verify_hand.py TestViolationRing/TestBoundarySweep/TestVerifyExpectedInputIds (91 failed) RuntimeError: ninja exited with status 1 → amd_warp_sync_functions.h:306: static assertion failed 'sizeof(unsigned int)==8' 🟢 ROCm-7.0 HIP warp-sync compile error in kv_canary kernels; PR touches attention/verify_splitkv.py, a different kernel. Pre-existing infra.
jit-kernel-benchmark-test-amd N/A N/A Same AMD stage-a jit-kernel build (log purged / BlobNotFound) 🟢 Same ROCm-7.0 stage-a jit-kernel compile root cause; unrelated to PR.

stage-a-test-1-gpu-small-amd, wait-for-stage-a-amd, pr-test-amd-finish are cascade-skips of the above → AMD stage-b (the PR's test) never ran.

Other Executed Failures

Job Test File Test Function Error Related? Why
jit-kernel-b200-test N/A N/A The self-hosted runner lost communication with the server 🟢 Runner infra flake, not a code failure. Fast-failed all NVIDIA base-b.
stage-a-unit-test-mlx test/registered/unit/hardware_backend/mlx/test_attn_dp_request_capacity.py (module setup) ValueError: config namespace 'exec' not published 🟢 MLX/arm64 runtime-config bug in an unrelated backend test. Pre-existing.

All 32 base-b-test-* shards + wait-for-base-b + pr-test-finish are collapsed cascade-skips of the b200 flake (verified: Fast-fail: skipping — root cause job(s): call-jit-kernel-tests / jit-kernel-b200-test). PR Test Extra / PR Test Extra (AMD) failed only on the pr-gate "Missing required label run-ci-extra" — a benign opt-in gate, not a defect. NPU + Xeon are queued, XPU in progress — not counted as passed.

Details / what to do before merge

  • Coverage gap is the only thing that matters here. The change is small and self-consistent (reject q_extend.shape[2] != v_extend.shape[2] so MLA falls back to extend_attention_fwd; the new test_fallback_mla_head_dim_mismatch asserts can_handle(...) is False for a 576/512 shape). But no CI job ran it. Re-trigger CI and confirm:
    • NVIDIA base-b-test-1-gpu-small actually runs test_verify_splitkv.py (needs the b200 runner flake to clear so fast-fail doesn't skip base-b).
    • AMD stage-b-test-1-gpu-small-amd-mi35x is reached (needs stage-a ROCm-7.0 kv_canary compile error resolved, or bypass-fastfail label to force full signal — use sparingly).
  • None of the red jobs block on this PR's correctness, but do not read them as "safe to merge" — they're masking the fact that the change is untested.
  • Optionally run locally: pytest test/registered/attention/test_verify_splitkv.py -k mla_head_dim_mismatch to self-verify before CI clears.

Generated by amd-bot using Claude Code CLI

@yichiche

yichiche commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

@amd-bot ci-status

@amd-bot

amd-bot commented Aug 5, 2026

Copy link
Copy Markdown

@yichiche

CI Status for PR #30407

Merge verdict: No executed CI failure is related to this PR — all 5 executed failures are pre-existing/unrelated (perf thresholds, accuracy thresholds, an XPU infra gap, and an already-fixed circular import). However, PR CI is incomplete: the CUDA base-b-test-1-gpu-small job that runs this PR's own new test was fast-fail skipped because of an unrelated circular import in base-a that is already fixed on main. The AMD suite that owns this test did run and is green. Recommend: update/rebase the branch (to pull in #33371), which will clear base-a and let CUDA also exercise the change; then it is safe to merge.

Warning

This PR's new test test/registered/attention/test_verify_splitkv.py is registered on AMD (stage-b-test-1-gpu-small-amd-mi35x) and CUDA (base-b, 1-gpu-small). The AMD suite ran and passed ✅ — the primary target of this AMD fix is covered. But the CUDA base-b-test-1-gpu-small job was skipped (fast-fail cascade from an unrelated base-a circular import), so the CUDA path of the same test did not run. Also note the actual GPU-fault-avoidance is only validated end-to-end by the nightly ROCm spec accuracy test (per the file's own docstring), not by PR CI — the added unit test only asserts can_handle() returns False. Update the branch and re-run to get full CUDA signal.

Changed files: python/sglang/kernels/ops/attention/verify_splitkv.py (+6/-0), test/registered/attention/test_verify_splitkv.py (+14/-0)

Executed CI failure attribution: AMD: 2 failures (0 related) · Others: 3 failures (0 related) · CUDA base-b-* + jit-kernel-b200-test skipped by fast-fail (not tested); NPU single-node-poc shards cancelled.

AMD Executed Failures

Job Test File Test Function Error Related? Why
stage-b-test-1-gpu-large-amd (1) test/registered/perf/test_bench_serving_1gpu_part2.py test_score_api_batch_scaling AssertionError: 84.98/89.63 not less than 80 (avg_latency_ms bound) 🟢 Perf latency threshold on the score API benchmark; PR only adds a can_handle fallback guard in the split-KV verify path — no serving-latency impact.
stage-b-test-large-8-gpu-mi35x-disaggregation-amd test/registered/amd/disaggregation/test_disaggregation_pp.py test_gsm8k (TestDisaggregationPrefillPPDynamicChunkAccuracy) KeyError: 'answer' → retry() exceed maximum number of retries 🟢 PP disaggregation gsm8k accuracy eval; unrelated to EAGLE-verify MLA guard.

Other Executed Failures

Job Test File Test Function Error Related? Why
base-a-test-1-gpu-small (0) (NVIDIA) test/registered/core/test_basic_sanity.py server startup ImportError: cannot import name 'PrefillCPBCGInput' from partially initialized module 'sglang.srt.layers.cp.bcg' (circular import) 🟢 PR does not touch cp/bcg.py. Pre-existing, already fixed on main by d48ab2d3 (#33371, merged 2026-08-03); PR branch is behind it. This is the root cause of the base-b + jit-kernel-b200-test skips.
stage-b-test-1-gpu-xpu (XPU) test/registered/xpu/test_deepseek_ocr.py (server never started) TimeoutError: Server failed to start + OSError: libavutil.so.58 … No such file (torchcodec) 🟢 XPU image missing ffmpeg/torchcodec shared libs; environment/infra, not code.
stage-b-test-4-npu-a3 (0) (NPU) test/registered/npu/basic_function/dp_attn/test_npu_dp_attention.py test_gsm8k (TestDPAttentionMixedChunk) AssertionError: 0.335 not >= 0.343035 (gsm8k accuracy) 🟢 NPU DP-attention accuracy threshold barely missed; unrelated backend.

Collapsed fast-fail cascades (not counted as executed failures): jit-kernel-b200-test (log) explicitly skipped — Fast-fail: skipping — root cause job(s): wait-for-base-a, base-a-test-1-gpu-small (0); base-b-test-* (incl. base-b-test-1-gpu-small) skipped via wait-for-base-b; NPU single-node-poc shards cancelled.

Details / what to do before merge

  • Update/rebase the branch onto current main. This pulls in #33371 (d48ab2d3), clearing the base-a circular import so the fast-fail cascade stops and base-b-test-1-gpu-small runs this PR's test_verify_splitkv.py on CUDA — the one coverage gap that matters here. (git merge-base confirms the fix is not in the PR head cfdac928.)
  • The change itself is a pure-Python early return False in can_handle() (arch-agnostic), and its new unit test test_fallback_mla_head_dim_mismatch already ran and passed on AMD MI35X (stage-b-test-1-gpu-small-amd-mi35x ✅). For full confidence in the real GPU-fault avoidance, run the nightly ROCm EAGLE-spec MLA accuracy test on gfx95 (the E2E path the docstring points to); PR CI does not exercise it.
  • The 4 other executed failures (AMD perf, AMD PP-disagg gsm8k, XPU infra, NPU accuracy) are pre-existing/unrelated — no action required from this PR, but confirm they are green on a clean main run before merge.

Generated by amd-bot using Claude Code CLI

@yichiche

Copy link
Copy Markdown
Collaborator Author

Content is merged in PR #29677. Close this PR.

@yichiche yichiche closed this Aug 10, 2026
@yichiche
yichiche deleted the fix/verify-splitkv-mla-guard branch August 10, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jit-kernel run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants