← Back to Pull requests

[Perf][SM120][MLA] Use compact FP8 KV rows for NoPE models #58305

Merged
lucifer1004 merged 11 files (240 lines) on Oct 28, 2026 04:32 UTC
View on GitHub
lucifer1004 lucifer1004 commented on Sep 23, 2026 08:05 UTC
Author

Purpose

Follow-up to merged #55277: use compact 528-byte fp8_ds_mla rows for native NoPE on the FlashInfer SM120 backend. Rebased onto upstream main e6674262f1. Only tests conflicted: #55528 made the MLA KV-spec test's fake layer carry attn_backend, and the HiSparse test helper gained max_union_rows; both were resolved by keeping both sides. The two commits are now aab1e922fa and e879b2ef44 (head), and the branch merges cleanly into current main.

The row contains 512 FP8 latent bytes and four FP32 group scales. There is no RoPE payload. A single backend-owned row-size method supplies both the KV spec and early HiSparse registration. On SM120, compact selection depends solely on kv_lora_rank=512 and qk_rope_head_dim=0, independent of model name, connector, or offloading configuration. Other backend layouts are unchanged; real RoPE64 fp8_ds_mla retains 656-byte rows. No new dtype or CLI option is added.

The writer accepts NoPE 528/656, preserves legacy zero-tail behavior for 656, and rejects RoPE64 with 528. It distinguishes logical row width from physical stride. The fixed 576-dimensional gather rejects compact input. HiSparse uses actual row widths for byte movement and rejects incompatible shared-staging layouts.

No connector changes, layout negotiation, or old-cache migration are added. Local prefix caching remains supported. External connectors were not tested end to end.

Duplicate-work check: #53969/#55778/#55543 use padded compatibility layouts; #55219/#57169 address broader paging/stride plumbing, not this compact writer/spec change. The community B12X GLM_NEXT path already uses the same 528-byte encoding; that is a useful precedent, not the FlashInfer backend wiring implemented here. Reference: local-inference-lab/vllm cff8aebfeb73de96c97b4c5a0550c5a49f27451c, b12x_mla_sparse.py. FlashInfer compact-row support was merged in flashinfer-ai/flashinfer#5075.

Test Plan

Validation used 4x RTX PRO 6000 Blackwell for official NVIDIA GLM-5.3-Flash-NVFP4, TP4, BF16, no speculation, text-only, context 65536, max sequences 32, batched tokens 4096, FULL_AND_PIECEWISE graphs. FlashInfer source: dc04f50c9aa3eabcdaa5feb0934edb3d85e9529a.

Commands below are shown without local environment wrappers, not as verbatim execution transcripts. Paths are relative to the vLLM checkout unless noted. The following checks were rerun after the rebase onto main:

python -m pytest tests/kernels/attention/test_cache.py \
  -k concat_and_cache_ds_mla -q -rs
python -m pytest tests/kernels/test_cp_gather_fp8.py -q
python -m pytest -q \
  tests/v1/attention/test_mla_backends.py::test_mla_kv_cache_spec_uses_layer_cache_dtype \
  tests/v1/attention/test_sparse_mla_backends.py::test_hisparse_index_group_preserves_row_width \
  tests/v1/attention/test_sparse_mla_backends.py::test_hisparse_shared_staging_requires_uniform_row_width \
  tests/v1/attention/test_sparse_mla_backends.py::test_hisparse_swap_in_preserves_rows_across_eviction \
  tests/v1/attention/test_sparse_mla_backends.py::test_hisparse_gather_prefill_cache_prefers_resident_rows
prek run --from-ref c843f0cab78b413f2b0a5c2282cb71e3a3937b11 --to-ref bea90f7efee

Earlier validation from the FlashInfer checkout, not rerun after the rebase:

python -m pytest tests/attention/test_sparse_mla_sm120.py \
  -k glm53_nope_compact_rows -q

Model validation preceded gate removal and was not rerun after the rebase. It used GSM8K and random-8k1k workloads with FLASHINFER_MLA_SPARSE_SM120 explicitly selected. As in #55277, successful runs used the disclosed distributed-autotune workaround:

VLLM_FLASHINFER_AUTOTUNE_SKIP_OPS=fp4_gemm,trtllm::fused_moe::gemm1,trtllm::fused_moe::gemm2

This PR does not fix that separate autotune issue or the noncanonical-layout calibration restriction. FlashInfer 0.6.18.post1, pinned in upstream vLLM, is not the dependency used for this validation.

Test Result

Revalidation after the rebase onto e6674262f1 (head e879b2ef44)

Run on 4x RTX PRO 6000 Blackwell with FlashInfer built from main (includes flashinfer-ai/flashinfer#5075) and vLLM's CUDA extension rebuilt from a tree containing this branch:

  • CUDA writer (test_cache.py -k concat_and_cache_ds_mla): 9 passed, 3 skipped. Fixed-layout gather (test_cp_gather_fp8.py): 18 passed. KV-spec tests (test_mla_backends.py -k kv_cache_spec): 10 passed.

  • tests/v1/attention/test_sparse_mla_backends.py: 119 passed, 7 failed. All 7 fail identically on e6674262f1 without this PR: test_sparse_backend_prefill_correctness[-auto-masked_mha] for deepseek_hd192_v128, glm5_hd256_v256 and glm53_flash_nope_hd256_v256, and test_hisparse_speculative_rows_resolve_host_misses_consistently[long_mtp].

  • GLM-5.3-Flash-NVFP4, TP4, text-only, context 65536, max sequences 32, batched tokens 8192, --kv-cache-dtype fp8, default FlashInfer autotune (no skip-ops workaround). GSM8K through the chat template (1,319 problems, flexible-extract, concurrency 32):
  • | | Without this PR (656-byte rows) | With this PR (528-byte rows) |
    |---|---:|---:|
    | Engine-reported KV tokens | 3,234,669 | 3,972,729 (+22.8%) |
    | GSM8K (chat, flexible-extract) | 0.973 | 0.972 |

    Both evaluations ran on the same integration tree with unrelated changes for other models; one run each.

    Earlier results (before this rebase)

    At head bea90f7efee:

  • Selected spec and HiSparse width/guard/data-path tests: 31 passed, no skips. Includes uint8 528/656 host miss, hit, eviction/reload, and prefill byte gather. No claim of a complete model-level HiSparse deployment or external-connector end-to-end test.

  • CUDA writer: 9 passed, 3 existing unsupported-geometry/input-size skips. Includes compact/padded rows, row/page gaps, invalid slots, and legacy payload parity.

  • Fixed-layout gather regression: 18 passed.

  • All applicable prek hooks passed across all 10 changed files, including Ruff, formatting, and mypy.
  • Earlier validation, not rerun after the rebase:

  • FlashInfer compact/padded/sliced cache attention parity and CUDA graph replay: 3 passed (before gate removal).

  • Broader test_mla_backends.py attempt stopped after 53 passes at an SM100 CUTLASS-only operator unavailable in this SM90/SM120 build. The complete cross-architecture suite was not qualified.

  • GSM8K strict match, #55277 parent → compact: 1223/1319 (92.72%) → 1228/1319 (93.10%), concurrency 32, max output 2048. The compact evaluation gate passed; +5 samples is not evidence of a meaningful accuracy gain. Its recipe initially failed the immediate cleanup check; a subsequent managed stop verified all allocated devices freed.

  • Random 8K/1K: both runs completed 252/252 requests with zero failures, with 4 × concurrency requests per level. Matrix server cleanup verified.
  • KV-cache capacity

    Compared with #55277 on the same hardware and serving configuration:

    | Metric | #55277 | Compact |
    |---|---:|---:|
    | Encoded bytes per KV row | 656 | 528 (−19.51%) |
    | Engine-reported KV token capacity | 4,301,231 | 5,282,546 (+22.81%) |
    | Available KV-cache memory | 40.57 GiB | 40.57 GiB |

    The benefit is more KV capacity within the same memory budget, not a throughput claim or a 19.51% reduction in total GPU allocation. Capacity is engine-reported, not saturation-tested; the validation runs used dirty source trees with differing build metadata.

    Developed with AI assistance. Opened as a draft pending human line-by-line review; automated validation is not represented as human review. No changes were pushed to #55277.

    ---
    <details>
    <summary> Essential Elements of an Effective PR Description Checklist </summary>

  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".

  • The test plan, such as providing test command.

  • The test results, such as pasting the results comparison before and after, or e2e results

  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

  • </details>

    Diff: 240 lines (+176 / -64) across 11 files Reviewer: zyongye Review duration: 50187m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.50) × (1 − Review Confidence (0.82)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 240 lines diff across 11 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.80 · 5 substantive comment(s)
    0.80
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    82%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.328
    Real PR Conversation Timeline
    18 items
    claude[bot] claude[bot] commented on Sep 23, 2026 09:15 UTC
    Reviewer

    Claude Code Review

    This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

    mergify[bot] mergify[bot] commented on Sep 25, 2026 06:08 UTC
    Bot

    This pull request has merge conflicts that must be resolved before it can be
    merged. Please rebase the PR, @lucifer1004.

    https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

    lesj0610 lesj0610 commented on code on Oct 10, 2026 10:42 UTC
    Code Review
    vllm/v1/attention/backends/mla/flashinfer_mla_sparse_sm120.py:1
    @@ -35,6 +36,11 @@ class FlashInferMLASparseSM120Impl(SparseMLACommonImpl[FlashInferMLASparseMetada
         is_sparse = True
         supports_dense_mha_prefill = False
     
    +    def get_fp8_ds_mla_row_bytes(self) -> int:
    +        if self.kv_lora_rank == 512 and self.qk_rope_head_dim == 0:

    The pinned FlashInfer 0.7.0.post1 still requires 656-byte rows for GLM53_NOPE. Its decode binding rejects a 528-byte row, so this would break NoPE decode on the pinned dependency. The FlashInfer update containing compact-row support needs to land before this is enabled.

    mergify[bot] mergify[bot] commented on Oct 12, 2026 20:25 UTC
    Bot

    This pull request has merge conflicts that must be resolved before it can be
    merged. Please rebase the PR, @lucifer1004.

    https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

    lesj0610 lesj0610 commented on code on Oct 15, 2026 01:39 UTC
    Code Review
    vllm/v1/attention/backends/mla/flashinfer_mla_sparse_sm120.py:1
    @@ -35,6 +36,11 @@ class FlashInferMLASparseSM120Impl(SparseMLACommonImpl[FlashInferMLASparseMetada
         is_sparse = True
         supports_dense_mha_prefill = False
     
    +    def get_fp8_ds_mla_row_bytes(self) -> int:
    +        if self.kv_lora_rank == 512 and self.qk_rope_head_dim == 0:

    The dependency blocker I raised here is resolved by #60948. The pinned FlashInfer 0.7.1 supports compact 528-byte GLM53_NOPE rows, so my earlier comment no longer blocks this change.

    mergify[bot] mergify[bot] commented on Oct 19, 2026 17:41 UTC
    Bot

    This pull request has merge conflicts that must be resolved before it can be
    merged. Please rebase the PR, @lucifer1004.

    https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

    zyongye zyongye approved these changes on Oct 26, 2026 20:22 UTC
    Approved Reviewer

    Approved these changes.

    zyongye zyongye commented on Oct 26, 2026 20:23 UTC
    Contributor

    Thanks for the fix. Let's fix the pre-commit and trigger the CI

    mergify[bot] mergify[bot] commented on Oct 26, 2026 20:26 UTC
    Bot

    Hi @lucifer1004, the pre-commit checks have failed. Please run:

    ``bash
    uv pip install pre-commit>=4.5.1
    pre-commit install
    pre-commit run --all-files
    `

    Then, commit the changes and push to your branch.

    For future commits, pre-commit` will run automatically on changed files before each commit.

    zyongye zyongye commented on Oct 27, 2026 02:57 UTC
    Contributor

    /ci run

    github-actions[bot] github-actions[bot] commented on Oct 27, 2026 02:57 UTC
    Bot

    ✅ Triggered Buildkite CI #97491 for commit 8cf7913246e8.

    zyongye zyongye commented on Oct 27, 2026 16:30 UTC
    Contributor

    /ci retry

    github-actions[bot] github-actions[bot] commented on Oct 27, 2026 16:31 UTC
    Bot

    ✅ Queued 5 failed job(s) for retry in Buildkite CI #97491.

    zyongye zyongye commented on Oct 27, 2026 19:12 UTC
    Contributor

    /ci run

    github-actions[bot] github-actions[bot] commented on Oct 27, 2026 19:13 UTC
    Bot

    ✅ Triggered Buildkite CI #97726 for commit d76d076968d2.

    zyongye zyongye commented on Oct 28, 2026 04:23 UTC
    Contributor

    /ci retry

    github-actions[bot] github-actions[bot] commented on Oct 28, 2026 04:24 UTC
    Bot

    ✅ Queued 1 failed job(s) for retry in Buildkite CI #97726.

    Reviewers
    Assignees
    lucifer1004 lucifer1004
    Labels
    risk: low confidence: 82.1% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.5% (MEDIUM) · Higher = larger blast radius
    50.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 82.1% · Lower = rushed or shallow review
    82.1%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 9% · Safe to merge
    9%