Repository navigation
[Feature][HiSparse] Unify Ascend sparse-cache layouts with GLM-5.3-Flash - #23263
LZZhang-HW wants to merge 2 commits into
Conversation
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>
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. 🤖 How to trigger CI
Note Until the CI gate has run on a commit, the required Tip 💡 Consider Linking a Related Issue or RFCYour 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:
🙏 Thanks for helping us keep the project well-organized! |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
| row_elements = spec.state_content_size_bytes // cache.element_size() | |
| row_elements = spec.state_content_bytes // cache.element_size() |
| self._hisparse_tail_layer = ( | ||
| vllm_config.compilation_config.static_forward_context[layer_names[0]] if use_hisparse else None | ||
| ) |
There was a problem hiding this comment.
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.
| 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 | |
| ) |
Coverage
More info see: Summary |
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"]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?
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.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 Corec410543d. 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 recipeIndependent 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
AI assistance is disclosed in the commit trailers.