Skip to content

[Feature][HiSparse] Unify Ascend sparse-cache layouts with GLM-5.3-Flash - #23263

Open
LZZhang-HW wants to merge 2 commits into
vllm-project:mainfrom
LZZhang-HW:hisparse-ascend-feature-kpool
Open

LZZhang-HW wants to merge 2 commits into
vllm-project:mainfrom
LZZhang-HW:hisparse-ascend-feature-kpool

Conversation

@LZZhang-HW

@LZZhang-HW LZZhang-HW commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

Split functional adaptation out of #23142 and introduce capability-based HiSparse layout selection on Ascend. GLM-5.3-Flash on A5 exercises the pooled Indexer path. The same planner recognizes native sparse attention with recurrent-state cache specs.

flowchart LR
    S["Cache specs: sparse KV, Indexer, recurrent state"] --> P["Ascend layout selection"]
    P -->|"Pooled FP8 Indexer"| B["Block-outer KPool and device KDA"]
    P -->|"Native SFA Indexer"| N["Native Indexer pages and recurrent groups"]
    B --> C["Core cache allocation, block tables and slot mapping"]
    N --> C
    C --> R["Ascend binds cache views and resolves logical TopK"]
    R --> A["Paged or gathered sparse attention"]
Loading
  • GLM-5.3-Flash keeps FP8 KPool keys and scales on device. Each 1,152-token manager block contains 288 pooled rows. The allocator places bounded bundles in block-outer order, with the key payload followed by scales within each layer page. Both views use the Core block table and slot mapping. The bundles keep the CANN Indexer's relative byte offsets within 32 bits and remove the private subpage-table expansion.
  • Core continues to manage admission, placement, spill, prefix reuse, and reclamation. Ascend binds 528-byte packed NoPE KV and keeps KDA state on device. The functional path covers masked mixed Prefill, MTP verification with the generic Resolver, and terminal spill on the pinned Core version.
  • To onboard a model such as Kimi K3.1, declare native Indexer and sparse MLA roles and the recurrent state as a Mamba spec. The planner retains the native 128-token Indexer page and groups recurrent state separately. The native-hybrid route currently requires speculative decoding to be disabled. It has planner and binding coverage. Full-model Kimi and A3 INT8 C8 Host refill remain to be verified on this branch.

This PR can merge independently of #23038. Its layout and regression coverage draw on the native page, Core lifecycle, and padded mixed-Prefill practices discussed in that review. Layout and split review · Native-hybrid review

Does this PR introduce any user-facing change?

Yes. GLM-5.3-Flash gains opt-in HiSparse on the single-node 950DT recipe with TP8/EP, Model Runner V2, FP8 main and Indexer KV, and single DP/PP/PCP/DCP ranks. It uses the existing HiSparse configuration and connector.

How was this patch tested?

  • Changed Python sources compiled and Ruff checks passed. On the feature source with Core c410543d, 148 focused CPU tests passed across cache planning, block-outer binding, native hybrid layout and cold/mixed fallback. Added a cache descriptor regression for block-outer byte strides and the address bound. Existing tests exercise grouped placement, view binding, and masked mixed Prefill.
  • A standalone 950DT CANN Indexer test compared 288-row strided storage with identical dense K/scale data. Ordered TopK matched for Q6 and Q8192 at both low page IDs and a jagged table containing page 9821.
  • A same-input test also compared the previous 32-row subpages with the new 288-row pages. Ordered TopK matched in all four low/high-page Q6/Q8192 cases.

Latest GLM-5.3-Flash A5 OFF/ON results

The A5 extension was rebuilt from 261d4e6a2, with production code identical to the current head and official Core c410543d. One 8 × 950DT node ran the community colocated Prefill/Decode MTP5 recipe and the same ordered 32,768-input / 1,024-output requests. Each arm used three rounds of eight requests at both C1 and C8. All 96 timed requests completed. Latency and throughput are three-round medians. MTP accepted length uses total counts across all three rounds. Ascend 950DT reference recipe

Metric C1 OFF → ON C1 change C8 OFF → ON C8 change
Mean ITL (ms) 19.176 → 21.282 +10.98% 51.736 → 54.583 +5.50%
P95 ITL (ms) 19.867 → 22.726 +14.39% 422.943 → 433.103 +2.40%
Mean TPOT (ms) 3.990 → 4.429 +10.98% 11.246 → 11.827 +5.16%
Output throughput (tokens/s) 170.312 → 157.732 -7.39% 378.915 → 362.262 -4.39%
MTP mean accepted length (tokens) 4.8168 → 4.8168 +0.00% 4.6559 → 4.6610 +0.11%
Mean TTFT (ms) 1,929.270 → 1,961.235 +1.66% 8,819.169 → 9,008.672 +2.15%

Independent GSM8K test-split exact match on two ordered 128-question C8 repeats was 119/128 → 119/128 and 118/128 → 118/128. The aggregate was 237/256 (92.58%) in both arms, with zero request errors. All four prefix boundaries returned identical token IDs, and both prefix hits reused 32,256 tokens. Functional accuracy and prefix reuse passed. The feature-only path exceeds the 5% latency target. #23264 provides the A5 MTP5 optimization.

The separate MTP5 pressure test used 32,768 input tokens, 512 output tokens, 512 device KV blocks, and disabled eager host mirroring. The FULL-graph run recorded 1,058,848 misses, 559,071,744 Host-to-NPU bytes, 90 draft steps, 424 accepted draft tokens, and zero preemptions. A diagnostic Eager run reproduced those counts and matched one sampled 528-byte Host/Hot row on every rank. The first positive Q6 gather plan selected 1,168 rows per rank.


Checklist

Testing

  • Boundary / edge-case coverage. Block pitch, high page IDs, aligned scales and padding.
  • Regression test. Block-outer descriptors and cache binding.
  • Error / failure path coverage. Unsupported native-hybrid draft combinations and invalid pooled geometry.
  • Meaningful & reliable tests. Placement, operator input, and logical slot behavior.
  • Performance impact. Exact OFF/ON results recorded above. Standalone latency exceeds the 5% target.

AI assistance is disclosed in the commit trailers.

Adapt the Core cache planner and binding for pooled block-outer KPool, NoPE KV and device recurrent states. Preserve native hybrid layout selection by cache spec and qualify the shared connector lifecycle.

Assisted-by: OpenAI Codex
Signed-off-by: LZZhang-HW <239167139+LZZhang-HW@users.noreply.github.com>
Signed-off-by: LZZhang-HW <239167139+LZZhang-HW@users.noreply.github.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation module:tests labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

🤖 How to trigger CI

CI runs automatically when the PR is opened or reopened. Pushing a new commit no longer re-runs the E2E CI (to save NPU runner resources), so use the comment commands below when needed. They are available to the PR author and users with triage permission or above:

  • /run — run the full PR CI gate on the latest commit.
  • /rerun — re-run the failed CI jobs (e.g. after a flaky failure).
  • /e2e — run selected E2E tests instead of the full gate.
  • /nightly / /presmoke / /weekly — run the corresponding large-scale tests (triage permission or above; blocked during the nightly maintenance window).
  • /cancel — cancel a running CI on this PR.

Note

Until the CI gate has run on a commit, the required ci-gate check stays pending and the PR cannot merge — remember to comment /run after pushing.


Tip

💡 Consider Linking a Related Issue or RFC

Your PR title contains the [Feature] tag, indicating a bug fix or new feature.

Linking a related issue or RFC in the PR description is strongly encouraged — it gives reviewers helpful context and speeds up the review. You can use any of these keywords:

  • Fixes #<issue_number>
  • Closes #<issue_number>
  • Resolves #<issue_number>
  • Refs #<rfc_or_issue_number> (for RFCs)

🙏 Thanks for helping us keep the project well-organized!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces opt-in HiSparse support for single-node GLM-5.3-Flash inference on Ascend 950DT with FP8 KV cache, implementing native hybrid SFA and recurrent-state layouts. Feedback on the changes highlights a critical AttributeError in vllm_ascend/hisparse/binding.py where state_content_size_bytes is used instead of state_content_bytes, and a potential KeyError in vllm_ascend/attention/indexer_kpool.py that should be resolved by using .get() on static_forward_context.

"""Expose HiSparse pooled keys and scales in PA_BBND layout."""
width = spec.head_size
rows = get_storage_block_size(spec)
row_elements = spec.state_content_size_bytes // cache.element_size()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The attribute state_content_size_bytes does not exist on AscendMLAAttentionSpec (or KVCacheSpec). It should be state_content_bytes instead, which is the correct attribute name used throughout the codebase and tests. Using the incorrect attribute name will result in an AttributeError at runtime.

Suggested change
row_elements = spec.state_content_size_bytes // cache.element_size()
row_elements = spec.state_content_bytes // cache.element_size()

Comment on lines +698 to +700
self._hisparse_tail_layer = (
vllm_config.compilation_config.static_forward_context[layer_names[0]] if use_hisparse else None
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

To prevent a potential KeyError if the layer name is not present in static_forward_context (e.g., during certain testing or initialization phases), use .get() instead of direct indexing.

Suggested change
self._hisparse_tail_layer = (
vllm_config.compilation_config.static_forward_context[layer_names[0]] if use_hisparse else None
)
self._hisparse_tail_layer = (
vllm_config.compilation_config.static_forward_context.get(layer_names[0]) if use_hisparse else None
)

@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Total Coverage Diff Coverage
Total 157302 lines 604 lines
Missing 44955 lines 113 lines
Coverage 71% 81%

More info see: Summary

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation module:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant