Repository navigation
[Bugfix][KV Connector] Pass attention metadata to the connector on piecewise steps - #67318
Closed
MatthewBonanni wants to merge 1 commit into
Closed
MatthewBonanni wants to merge 1 commit into
MatthewBonanni wants to merge 1 commit into
Conversation
…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>
MatthewBonanni
marked this pull request as ready for review
November 12, 2026 21:36
MatthewBonanni
requested review from
WoosukKwon,
njhill and
yewentao256
as code owners
November 12, 2026 21:36
Member
Author
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.
Overview
MRv2 passes
attn_metadatato the KV connector'spre_forwardonly on FULL CUDA graph steps. On piecewise and eager steps the HiSparse connector getsNone, soprepare_forwardskips its per-forward setup. That setup resets the swap-row step counter and binds the batch's decode/prefill state.DeepSeek-V3.2 and GLM hide this because their attention layers call
prepare_for_batchthemselves. Kimi-K3.1's fused DSA path doesn't, so the step counter keeps growing across mixed steps until the worker raises:A probe showed one layer's
swap_inhandling 28 rows in one forward and 59 in the next, with no reset in between. The fix passes the sameattn_metadataon both branches. The only connector that reads this kwarg is HiSparse, so no other connector sees a change.Validation
HiSparse args for every run:
--kv-cache-dtype fp8 --attention-backend FLASHMLA_SPARSE --max-model-len 20480 --max-num-seqs 64 --attention-config '{"hisparse_config":{}}' --kv-transfer-config '{"kv_connector":"HiSparseConnector","kv_role":"kv_both","kv_connector_extra_config":{"host_pool_gib":<N>}}'.GSM8K:
python tests/evals/gsm8k/gsm8k_eval.py --port 8123 [--max-concurrency 64](1319 questions, 5-shot). Host traffic comes fromvllm:hisparse_cache_misses_totalandvllm:hisparse_host_to_device_bytes_total.--gpu-memory-utilization 0.88, pool 64 GiB--gpu-memory-utilization 0.45, pool 128 GiB, concurrency 64mainuntil [HiSparse][Kimi K3.1] Support Kimi-K3.1's hybrid KDA + DSA layout #67262 lands. That PR doesn't touch this path; it lists this crash as a known issue.Unit test, run on CPU:
test_kv_connector_receives_attn_metadata[PIECEWISE]fails onmainand passes with this PR. The FULL case pins the existing behavior.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