Skip to content

[Bugfix] Bound KV block zeroing launch geometry - #52058

Merged
njhill merged 1 commit into
mainfrom
agent/fix-dsv4-ci-failures
Aug 13, 2026
Merged

[Bugfix] Bound KV block zeroing launch geometry#52058
njhill merged 1 commit into
mainfrom
agent/fix-dsv4-ci-failures

Conversation

@LucasWilkinson

@LucasWilkinson LucasWilkinson commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Fix the KVBlockZeroer launch overflow reproduced on main nightly #83443, at commit 3e372c5ff2:

OverflowError: signed integer is greater than maximum

DeepSeek-V4 combines 181 KV segments with 9,344- and 292-element pages. The old zeroer selected the largest common power-of-two divisor, so the 292-element page forced every segment to use four-element chunks. Zeroing 6,870 blocks therefore flattened to:

6,870 * 181 * 2,336 = 2,904,745,920 programs

That overflows the signed launch dimension passed by the NVIDIA wrapper.

This change:

  • maps blocks, segments, and chunks directly onto a 3-D grid, keeping block IDs on the large x-axis;
  • uses up to 1,024 elements per program and masks each segment's tail, so small pages no longer shrink all chunks;
  • reduces the failing geometry to (6,870, 181, 10), or 12,434,700 programs (233.6x fewer);
  • preserves one compiled kernel across different block counts.

The H100/H200 sm90_paged_mqa_logits_metadata failures from the same CI build were separate. They are already fixed on current main by #52035; its exact 4xH100 KV-offload job passed both DeepSeek-V4 cases (2 passed).

Duplicate-work check

Required open PR/issue searches were run for KVBlockZeroer overflow, KV block zeroing grid, and signed integer zeroing.

#50485 also proposes a 3-D grid, but this is materially different:

  • [Bugfix][ROCm] Launch KV block zeroing on a 3-D grid #50485 is currently conflicted and predates packed block strides;
  • it puts block IDs on the z-axis, which is limited to 65,535 entries on CUDA;
  • it retains narrow divisor-based chunks;
  • this change puts blocks on x and adds masked wide chunks, addressing both the observed NVIDIA overflow and the 233.6x excess work.

Test plan and results

CUDA_VISIBLE_DEVICES=0 .venv/bin/python -m pytest \
  tests/v1/worker/test_kv_block_zeroer.py \
  tests/v1/worker/test_dsv4_packed_zeroer_geometry.py -q
# 9 passed

CUDA_VISIBLE_DEVICES=0 compute-sanitizer --tool memcheck --error-exitcode 99 \
  .venv/bin/python -m pytest tests/v1/worker/test_kv_block_zeroer.py -q
# 8 passed; ERROR SUMMARY: 0 errors

.venv/bin/pre-commit run --files \
  vllm/v1/worker/utils.py tests/v1/worker/test_kv_block_zeroer.py
# passed

An exact-shape B200 validation launched grid (6870, 181, 10), zeroed all storage, and completed in 0.334 seconds.

No model eval was run because this only changes how already-selected KV-cache bytes are zeroed, not model outputs or scheduling semantics.

Disclosure

AI assistance (OpenAI Codex) was used to investigate the CI history, develop the change, and draft this description. reviewed by the submitter

Breaking PR and overlap

The failure became reachable after #51749 generalized worker-side KV zeroing to every allocating AttentionSpec. That change is needed to prevent stale FP8 sliding-window pages; it exposed a pre-existing launch-geometry scaling bug when DeepSeek-V4 contributes many heterogeneous segments.

#52062 addresses the same observed overflow by reverting #51749. This PR is materially different: it preserves generalized zeroing and bounds the kernel launch using a 3-D grid plus masked wide chunks, fixing the overflow without restoring the stale-cache bug that #51749 corrected.

Use a three-dimensional grid and masked wide chunks so hybrid KV page sizes cannot overflow the launch dimensions or collapse all zeroing work to four-element programs.

Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
@mergify mergify Bot added the bug Something isn't working label Aug 12, 2026
@LucasWilkinson
LucasWilkinson marked this pull request as ready for review August 12, 2026 23:32
@LucasWilkinson
LucasWilkinson requested a review from njhill as a code owner August 12, 2026 23:32

@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 repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@njhill njhill left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@njhill njhill added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 12, 2026
@njhill

njhill commented Aug 12, 2026

Copy link
Copy Markdown
Member

/ci run

@njhill
njhill enabled auto-merge (squash) August 12, 2026 23:35
@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #83624 for commit 5f8ac6872b92.

@LucasWilkinson
LucasWilkinson marked this pull request as draft August 12, 2026 23:45
auto-merge was automatically disabled August 12, 2026 23:45

Pull request was converted to draft

@njhill
njhill marked this pull request as ready for review August 13, 2026 00:28
@njhill
njhill enabled auto-merge (squash) August 13, 2026 02:37
@njhill
njhill merged commit 79f3183 into main Aug 13, 2026
103 checks passed
@njhill
njhill deleted the agent/fix-dsv4-ci-failures branch August 13, 2026 03:42
@zzw09773

Copy link
Copy Markdown

Independently reproduced the engine-killing overflow on 8×MI325X (gfx942) serving
DeepSeek-V4-Flash-0731 at max_model_len=1M: a single 506,470-token prefill raised
OverflowError: signed integer is greater than maximum in _zero_kv_blocks_kernel
and killed the engine (all in-flight requests 500). With this PR backported onto the
08-12 nightly, the same request completes (~90 s prefill, ≈5.6k tok/s). +1 for landing.

calvarado2004 pushed a commit to calvarado2004/vllm that referenced this pull request Aug 15, 2026
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
(cherry picked from commit 79f3183)
calvarado2004 pushed a commit to calvarado2004/vllm that referenced this pull request Aug 15, 2026
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
(cherry picked from commit 79f3183)
calvarado2004 pushed a commit to calvarado2004/vllm that referenced this pull request Aug 15, 2026
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
(cherry picked from commit 79f3183)
calvarado2004 pushed a commit to calvarado2004/vllm that referenced this pull request Aug 15, 2026
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
(cherry picked from commit 79f3183)
zyp2014 pushed a commit to zyp2014/vllm that referenced this pull request Aug 21, 2026
Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants