Skip to content

Avoid device-wide sync during speculative CUDA Graph capture - #2

Draft
0z5a wants to merge 2 commits into
rlt-spec-sched-onlyfrom
perf/spec-graph-stream-sync
Draft

0z5a wants to merge 2 commits into
rlt-spec-sched-onlyfrom
perf/spec-graph-stream-sync

Conversation

@0z5a

@0z5a 0z5a commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Stack and change

This draft targets rlt-spec-sched-only (ThinkFlowLab#52, on top of ThinkFlowLab#48), so the diff contains only the speculative CUDA Graph capture change and its GPU test.

The capture helper now orders the caller stream and capture stream with wait_stream before warmup and before replay. It uses CUDAGraph.capture_begin/end because torch.cuda.graph(...) performs a device-wide synchronize on entry. Graph keys, pool sharing, eager fallbacks, and replay are unchanged. The side-stream handoff follows the pattern used in MiniCPM-o 4.5 Graph capture.

Validation

  • Existing /home/gongji/0z5a environment on RTX 5090, PyTorch 2.13.0+cu130: CPU suite 291 passed, 11 skipped; focused speculative GPU suite 9 passed; new cross-stream capture GPU test 1 passed. Ruff check/format and Python compilation passed.
  • Pinned Ouro-1.4B checkpoint SHA256: 58872a72616c736595b8b7662079c5b12c5a162ec16eae94f21c348dfa9885af. BF16/Triton, K=4, 64 output tokens. Baseline and changed arms produced exactly the same token IDs and exit depths for every paired run at each concurrency. The task copy of the checkpoint was removed after testing.
  • Six alternating paired trials per row, excluding the first cold pair. Model loading and engine construction are outside the timed region. Times are arm medians; speedups are medians of paired baseline/changed ratios. Shared-host GPU activity can affect the timing.
Concurrent requests ThinkFlowLab#52 first batch Stream first batch Paired E2E speedup ThinkFlowLab#52 capture host time Stream capture host time Paired capture speedup Graph cache hit, both
1 847 ms 855 ms 1.004× 114 ms 122 ms 1.023× 99.2%
4 1306 ms 1238 ms 1.030× 340 ms 277 ms 1.154× 98.2%
8 1600 ms 1559 ms 1.032× 507 ms 458 ms 1.107× 97.3%
16 4082 ms 3971 ms 1.018× 1055 ms 947 ms 1.093× 98.1%

Steady-state replay speedups were 1.000×, 0.999×, 0.997×, and 0.999× for 1/4/8/16 requests. Graph cache hit rates and fallback counts were identical between arms. Under a separate synthetic workload with unrelated CUDA stream work queued, median capture host latency fell from 103.37 ms to 0.284 ms; this measures removal of the device-wide wait, not serving throughput.

The speculative draft acceptance rate for this prompt set was 59.2% at 16 requests; running the same 16 prompts individually gave 60.1%. It is distinct from the CUDA Graph cache hit rate above. A separate prompt-level difference between Triton batch sizes is also present in native eager execution, independent of this capture change.

0z5a and others added 2 commits September 28, 2026 21:33
Avoid device-wide waits in the shared capture helper while retaining stream ordering.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
Signed-off-by: 0z5a <Dezhen.lu@student.uni-tuebingen.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant