Repository navigation
[HiSparse][Kimi K3.1] Support Kimi-K3.1's hybrid KDA + DSA layout - #67262
Open
MatthewBonanni wants to merge 21 commits into
Open
MatthewBonanni wants to merge 21 commits into
MatthewBonanni wants to merge 21 commits into
Conversation
HiSparse shrank the MLA specs to the kernel block, so K3.1's 69 KDA state layers sized every device row (one 112 MB group) and admission fell to ~3x vs 34x without HiSparse. Keep the scheduler's packed block, split state groups to fit the indexer row, and align hot pages to kernel rows instead of whole pages. HiSparse now owns grouping over a model-declared grouping instead of rejecting it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
SelfAddressedMLASpec declares the indexer needs no slot mapping, but its builder still read the group's slot mapping as a PAD mask. HiSparse puts the indexer in its own group, whose slot mapping is then disabled, so every indexer write was dropped. Let self-addressed callers pass no slot mapping and take DCP ownership from the rank instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
MatthewBonanni
marked this pull request as ready for review
November 12, 2026 18:21
MatthewBonanni
requested review from
ApostaC,
LucasWilkinson,
WoosukKwon,
ZJY0516,
alexm-redhat,
heheda12345,
ivanium,
njhill,
orozery,
pavanimajety,
robertgshaw2-redhat,
wzhao18 and
ywang96
as code owners
November 12, 2026 18:21
Shrink HiSparse MLA specs to the common kernel block unless the indexer is self-addressed and every sparse attention backend supports the scheduler block. Expose the hot buffer as exact-length kernel pages and pass that page size to the sparse MLA hot-cache kernels. Size state-group splits by their largest page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
6 tasks done
…ecewise steps MRv2 passed attn_metadata to the KV connector's pre_forward only for FULL CUDA graph steps. On piecewise and eager steps HiSparse skipped its per-forward setup, and models whose attention layers do not prepare HiSparse themselves (Kimi-K3.1) overflowed the swap rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
…n pages on SM100 The quantized kernel reads 64-token pages on every platform. Declaring MultipleOf(64) keeps HiSparse hot caches, whose block stride is otherwise only row-aligned, readable as whole pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
A padded indexer page that is not whole rows cannot be viewed as manager blocks: the row view of the last indexer layer ran past the pool block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
The K3.1 indexer's slot-mapping kernel variant (no group slot mapping) is now registered for JIT warmup, and dcp_rank is no longer specialized, so every DCP rank shares one compiled kernel. A builder-level test pins that K3.1 writes at block-table slots when its group's slot mapping is all padding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
…w pages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
…dget - Pick the pool row that minimizes device bytes per request. - Release clean resident blocks before allocating the hot region; count the peak of the two, not their sum, in capacity checks. - Pack consecutive host pages into each resident and hot block when the backend needs smaller blocks than the row fits (FlashMLA fp8), with per-page host transfers and restores of a prefix hit's partial block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Matthew Bonanni <mbonanni@redhat.com> # Conflicts: # vllm/v1/attention/backends/mla/index_group.py # vllm/v1/hisparse/binding.py # vllm/v1/hisparse/coordinator.py # vllm/v1/hisparse/layout.py
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
Upstream's reclaim hook already releases them once the hot region exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
Signed-off-by: Matthew Bonanni <mbonanni@redhat.com> # Conflicts: # tests/v1/core/test_prefix_caching.py
Signed-off-by: Matthew Bonanni <mbonanni@redhat.com> # Conflicts: # vllm/v1/hisparse/coordinator.py
1 of 5 tasks
Member
Author
|
/ci run |
|
✅ Triggered Buildkite CI #105730 for commit |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthew Bonanni <mbonanni@redhat.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
HiSparse doesn't start on Kimi-K3.1 on
main. This PR makes it start and serve correctly with pages offloaded to host, without using more GPU KV memory per request than serving without HiSparse.Repro on
main(4×B200):Changes
Starting and serving
GPU memory per request
max(resident window, hot + active tail)instead of their sum: when a request's hot region is allocated, the reclaim hook ([Bugfix][HiSparse] Reclaim resident pages before allocating the next prefill chunk #67185) releases its clean resident blocks, so it never holds both for long.Manager-block view (
vllm/v1/worker/utils.py): the view used to zero freed blocks is now exactly a manager block's kernel blocks ([..., kernel_blocks, kernel_rows, C]). Rounding a page that ends mid-row up to whole rows ran past the pool and crashed startup.FlashMLA fp8 KV (
flashmla_sparse.py): the fp8 kernel reads KV as 64-token pages, so it now declaresMultipleOf(64)block-stride alignment on SM100 as it already does elsewhere. HiSparse's 64-token hot blocks sit at arbitrary row strides in the shared pool, which caused an illegal memory access on K3.1's first host read. Non-HiSparse K3.1 fp8 TP4 is unaffected: 39,149,568 bytes per block before and after.Test Plan
Server: the repro command with
--gpu-memory-utilization 0.80; for FlashMLA add--kv-cache-dtype fp8 --attention-backend FLASHMLA_SPARSE --gpu-memory-utilization 0.88.vllm:hisparse_host_to_device_bytes_total.python tests/evals/gsm8k/gsm8k_eval.py --port 8000.Test Results
Accuracy (TP4)
main)GSM8K scores are for the 75%-pruned test checkpoint; CI's threshold for
Kimi-K3-pruned75on the same eval is 0.33.Passkey runs alongside 64 long-decoding requests, so passkey requests move to their hot regions and read from host; alone, every prompt fits its resident window and nothing is read from host.
Capacity (4×B200, 20k-token requests, GPU KV memory per request at admission)
main)GLM-5.3-Flash (4×B200, TP4, HiSparse,
--gpu-memory-utilization 0.80): same device pool asmain(60,381 blocks, 62.7 GiB). Reported max concurrency rises from 189× to 213× because a request no longer counts its resident window and hot region together.Note: with a small fixed pool (
--num-gpu-blocks-overrideor--kv-cache-memory-bytes), CUDA graph capture fails withHiSparse layer 0 mirrored twice, also onmain.Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.
🤖 Generated with Claude Code