Skip to content

[Bugfix][KV Connector] Pass attention metadata to the connector on piecewise steps - #67318

Closed
MatthewBonanni wants to merge 1 commit into
vllm-project:mainfrom
MatthewBonanni:mrv2-piecewise-connector-attn-metadata
Closed

MatthewBonanni wants to merge 1 commit into
vllm-project:mainfrom
MatthewBonanni:mrv2-piecewise-connector-attn-metadata

Conversation

@MatthewBonanni

Copy link
Copy Markdown
Member

Overview

MRv2 passes attn_metadata to the KV connector's pre_forward only on FULL CUDA graph steps. On piecewise and eager steps the HiSparse connector gets None, so prepare_forward skips 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_batch themselves. Kimi-K3.1's fused DSA path doesn't, so the step counter keeps growing across mixed steps until the worker raises:

ValueError: HiSparse swap rows exceed the configured speculative decode capacity: stop=76, capacity=64.

A probe showed one layer's swap_in handling 28 rows in one forward and 59 in the next, with no reset in between. The fix passes the same attn_metadata on 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 from vllm:hisparse_cache_misses_total and vllm:hisparse_host_to_device_bytes_total.

Model Hardware Revision GSM8K Host misses / H2D
Kimi-K3.1-Pro-pruned75, TP4, --gpu-memory-utilization 0.88, pool 64 GiB 4x B200 #67262 head crash (error above) –
same 4x B200 #67262 head + this PR 0.371 123M / 80.6 GB
GLM-5.3-NVFP4, TP8, --gpu-memory-utilization 0.45, pool 128 GiB, concurrency 64 8x B200 main 0.911 3.7G / 9.0 TB
same 8x B200 main + this PR 0.904 3.4G / 8.3 TB

Unit test, run on CPU:

pytest tests/v1/worker/test_gpu_model_runner_v2.py -k kv_connector_receives_attn_metadata

test_kv_connector_receives_attn_metadata[PIECEWISE] fails on main and passes with this PR. The FULL case pins the existing behavior.


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (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

…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>
@mergify mergify Bot added mrv2 Model Runner V2 specific bug Something isn't working labels Nov 12, 2026
@MatthewBonanni
MatthewBonanni marked this pull request as ready for review November 12, 2026 21:36

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@MatthewBonanni

Copy link
Copy Markdown
Member Author

Folded into #67262; the same runner change is also in #61243.

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

Labels

bug Something isn't working mrv2 Model Runner V2 specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant