Skip to content

[DSV4] Fix draft-extend CUDA graph padding and WAR ordering - #31270

Open
weireweire wants to merge 2 commits into
sgl-project:mainfrom
weireweire:fix/dsv4-draft-extend-cudagraph-correctness
Open

weireweire wants to merge 2 commits into
sgl-project:mainfrom
weireweire:fix/dsv4-draft-extend-cudagraph-correctness

Conversation

@weireweire

@weireweire weireweire commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Motivation

Follow-up to #30853. Enabling DSV4 draft-extend CUDA graphs exposes two correctness issues:

  1. Graph-bucket padding uses seq_len=1. When the captured draft width is 4, uniform-width expansion produces causal lengths [-2, -1, 0, 1], and therefore negative positions and invalid attention metadata for padded rows.
  2. DSV4 translates out_cache_loc through the live full-to-SWA mapping inside the captured graph. The runner currently publishes the scheduler WAR read-done event before replay, so the schedule stream may overwrite shared mapping state while replay is still reading it.

Changes

  • Clamp DSV4 uniform-width causal lengths to 1, keeping padding on reserved slot 0 while leaving valid requests unchanged.
  • Add an explicit AttentionBackend capability for replay-time shared-buffer reads.
  • Defer the draft-extend WAR read-done event until after replay only for DSV4; other backends retain the pre-replay fast path.
  • Add focused CPU tests for padding metadata and both event-order modes.

This follows the same padded-row underflow diagnosis fixed for DSA in #30378. The WAR ordering follows the existing distinction between snapshot-complete reads (#29541) and replay-time captured-metadata reads (#30261).

Validation

  • Baseline CUDA reproduction: seq_len=1, draft width=4 produced [-2, -1, 0, 1], and source-order inspection confirmed read_done.record() ran before replay.
  • PYTHONPATH=python python -m pytest -q test/registered/unit/spec/test_dsv4_draft_extend_cuda_graph.py: 2 passed, including 2 event-order subtests.
  • pre-commit run --all-files --show-diff-on-failure: passed.
  • Prior 30-minute end-to-end A/B of the post-replay event path completed with zero request errors; average ITL was 7.996 ms before and 7.930 ms after, with p99 11.257 ms before and 10.977 ms after (within expected run variance, no observed regression).

Checklist

  • Format code with pre-commit
  • Add focused tests
  • Verify no existing open PR fixes these DSV4 draft-extend paths

CI States

Latest PR Test (Base): ❌ Run #31584979461
Latest PR Test (Extra): ❌ Run #31584979150

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@nvpohanh

Copy link
Copy Markdown
Collaborator

@weireweire Could you fix lint issue? thanks

@nvpohanh

nvpohanh commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

@weireweire Could you fix the conflicts? thanks!

@weireweire
weireweire force-pushed the fix/dsv4-draft-extend-cudagraph-correctness branch from 4185a35 to 58d5a5b Compare August 4, 2026 09:26
@weireweire

Copy link
Copy Markdown
Contributor Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci label Aug 4, 2026
@b8zhong b8zhong mentioned this pull request Aug 5, 2026
41 tasks
@weireweire
weireweire force-pushed the fix/dsv4-draft-extend-cudagraph-correctness branch from 58d5a5b to 12f96f6 Compare August 5, 2026 06:28
@nvpohanh

nvpohanh commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

/rerun-failed-ci

@nvpohanh

Copy link
Copy Markdown
Collaborator

@weireweire Could you fix the conflicts? thanks!

@nvpohanh

Copy link
Copy Markdown
Collaborator

/rerun-failed-ci

@nvpohanh

Copy link
Copy Markdown
Collaborator

@weireweire could you rebase/merge with main?

Root cause:
CUDA graph bucket padding fills DSV4 request lengths with 1 even when the captured draft width is larger. Expanding those rows produced negative causal lengths and positions. DSV4 also translates the live full-to-SWA mapping inside the captured graph, but the draft-extend runner published its scheduler WAR read-done event before replay.

Fix:
Clamp DSV4 uniform-width causal lengths to the reserved length-1 padding row. Add an explicit attention-backend capability for replay-time shared-buffer reads and defer the WAR event until after replay for DSV4 while preserving the pre-replay fast path for other backends.

Validation:
A baseline CUDA reproduction produced causal lengths [-2, -1, 0, 1] and confirmed the read-done event preceded replay. The focused padding and event-order tests pass in a CUDA 13 SGLang environment, and pre-commit passes on all files.
@weireweire
weireweire force-pushed the fix/dsv4-draft-extend-cudagraph-correctness branch from 07e1f7a to 1313330 Compare August 12, 2026 09:53
@nvpohanh

Copy link
Copy Markdown
Collaborator

@weireweire could you fix the conflicts?

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

Labels

bug Something isn't working deepseek run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants