Skip to content

[Feature][HiSparse] Support Kimi K3.1 on Ascend A3 and A5 - #23038

Draft
wang6788 wants to merge 1 commit into
vllm-project:mainfrom
wang6788:codex/kimi-k31-hisparse
Draft

wang6788 wants to merge 1 commit into
vllm-project:mainfrom
wang6788:codex/kimi-k31-hisparse

Conversation

@wang6788

@wang6788 wang6788 commented Nov 24, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it?

Enable HiSparse for Kimi K3.1's hybrid DSA and KDA cache layout with
Model Runner V2 on Ascend A3 and A5.

  • Use HiSparse planning for DSA Main KV and preserve the native 128-token
    Ascend Indexer page. Keep the paired SFA path for HiSparse OFF.
  • Group KDA states separately and select the grouping using upstream vLLM's
    device memory estimate. Reuse upstream vLLM's HiSparse allocation and
    request lifecycle.
  • Bind raw KDA pages as convolution and recurrent state views through the
    existing MRV2 layer binder. Apply the C8 page alignment required by the
    shared Resident and Hot allocation.

Ascend HiSparse foundation · Upstream Kimi K3.1 HiSparse planning

How was this patch tested?

Platform Metric HiSparse OFF HiSparse ON Performance degradation
A3 GSM8K 5-shot accuracy (%) TBD TBD —
A3 P95 TTFT (ms) TBD TBD TBD
A3 Mean TPOT (ms) TBD TBD TBD
A3 Output throughput (tokens/s) TBD TBD TBD
A5 GSM8K 5-shot accuracy (%) TBD TBD —
A5 P95 TTFT (ms) TBD TBD TBD
A5 Mean TPOT (ms) TBD TBD TBD
A5 Output throughput (tokens/s) TBD TBD TBD

Checklist

  • A3 INT8 C8 serving and Host refill verified on the PR revision.

  • A5 FP8 C8 serving and Host refill verified on the PR revision.

  • Matched ON/OFF accuracy and capacity results recorded.

  • Supported combinations of HiSparse with other features verified.

  • Full CI passed on the PR revision.

  • vLLM main: vllm-project/vllm@c410543

@github-actions github-actions Bot added documentation Improvements or additions to documentation module:tests module:core labels Nov 24, 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 support for native hybrid SFA HiSparse layout planning and recurrent state grouping on Ascend NPUs, including documentation for Kimi K3.1 on 950DT, platform checks requiring Model Runner V2, and extensive unit tests. The review feedback suggests defensively accessing attention_config and mamba_page_size_padded via getattr in vllm_ascend/worker/v2/attn_utils.py to prevent potential AttributeError exceptions across different vLLM versions.

Comment thread vllm_ascend/worker/v2/attn_utils.py Outdated
kv_cache_spec: dict[str, KVCacheSpec] = {}
attention_layer_names: list[str] = []
mamba_specs: dict[str, MambaSpec] = {}
hisparse_enabled = vllm_config.attention_config.hisparse_config is not 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

Directly accessing vllm_config.attention_config.hisparse_config can raise an AttributeError if attention_config is None or if hisparse_config is not defined on the AttentionConfig class (which can happen depending on the vLLM version or configuration).

Using getattr defensively is safer and aligns with how hisparse_config is accessed in other parts of the codebase (e.g., in vllm_ascend/platform.py and vllm_ascend/hisparse/layout.py).

Suggested change
hisparse_enabled = vllm_config.attention_config.hisparse_config is not None
attention_config = getattr(vllm_config, "attention_config", None)
hisparse_enabled = getattr(attention_config, "hisparse_config", None) is not None

Comment thread vllm_ascend/worker/v2/attn_utils.py Outdated
page_size_padded=None,
)
specs = resolve_hisparse_specs(vllm_config, kv_cache_spec, attn_layers)
state_padding = vllm_config.cache_config.mamba_page_size_padded

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

Directly accessing vllm_config.cache_config.mamba_page_size_padded can raise an AttributeError if mamba_page_size_padded is not defined on the CacheConfig class in the current vLLM version.

Using getattr defensively is safer and prevents potential runtime crashes.

Suggested change
state_padding = vllm_config.cache_config.mamba_page_size_padded
state_padding = getattr(vllm_config.cache_config, "mamba_page_size_padded", None)

@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Total Coverage Diff Coverage
Total 156699 lines 137 lines
Missing 45800 lines 6 lines
Coverage 71% 95%

More info see: Summary

@wang6788 wang6788 changed the title [Feature][HiSparse] Support Kimi K3.1 on Ascend A5 [Feature][HiSparse] Support Kimi K3.1 on Ascend A3 and A5 Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Recipe preview

Current PR commit: 146b0a57242da88e245bfc4840367947d9b33a68 (not a deployment status).

This PR no longer has the recipe label, so it is not eligible for a recipe preview.

@wang6788
wang6788 force-pushed the codex/kimi-k31-hisparse branch 2 times, most recently from 58ee63c to 4211e85 Compare November 25, 2026 09:17
Plan native Indexer and KDA state groups for the HiSparse layout and bind raw KDA pages in Model Runner V2. Preserve paired SFA planning with HiSparse disabled and cover missing Worker configuration fields.

Validated with 32 focused CPU cases on each pinned upstream vLLM revision.

Signed-off-by: TheWang <91782251+wang6788@users.noreply.github.com>

This branch was successfully deployed

1 active (outdated) deployment
recipes-preview — 08c622d6 Deployed Nov 25, 2026 by wang6788 via dispatch #501
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant