[FEAT] Add CUDA Graphs for cross-round async self-speculation #127
Reviewed at head 9eb01bb (base 9d601ce). The runtime change is small and the ownership model looks right. I found no correctness blocker:
finally: stream.synchronize() in _capture closes the failed-warmup race.
_require_live_batch runs before both replay and fallback.
My main concerns are about what users get by default and under non-lockstep traffic:
1. Default graph limits disable most of the high-concurrency gain (ExecutionConfig.cuda_graph_max_batch_size=128, DeviceRecurrentGraphs.run).
The limit counts rows, not requests. With K=2, verify has 3C rows, so at C≥43 the verify core and coda silently run eager. Above C=128 the draft path does too. The native baseline also falls back above C=128.
The higher-concurrency table raises the limit to max(128, 3C) for all modes, so it does not show the default configuration. The doc example uses K=4, where verify has 5C rows and falls back from C≥26, but every measurement is K=2.
Could the limit be derived from max_num_seqs * (K+1), or could the engine at least warn at startup? Please also state this next to the tables.
2. The exact-row-count cache with 16 entries and no eviction fits only burst workloads (DeviceRecurrentGraphs.run, CodaGraphs.run).
The measurements are lockstep bursts: all requests arrive at once, use ignore_eos and have fixed output lengths. Under that workload shapes barely change, so "0 new captures / 0 fallbacks" is nearly guaranteed.
With staggered arrivals, mixed lengths and natural EOS, the per-offset draft count, verify rows and coda rows all vary. Once 16 shapes are cached, every new shape runs eager permanently. Each lazy capture also calls torch.cuda.synchronize mid-serving, which stalls both in-flight rounds.
Bucketing (padding to capture sizes, as vLLM does), LRU eviction, or pre-capture of expected sizes would make this robust. A test that fills the cache and then sees new shapes would also help.
3. The memory reserve does not scale with the number of graph pools (core/memory.py::plan_cache).
A single cuda_graph_memory_reserve_bytes (1 GiB) now covers four pools: native core/coda and spec core/coda. Each coda entry's output is the full bf16 logits, about 75 MB at 768 rows, so 16 large entries in the spec coda cache alone exceed the reserve. With gpu_memory_utilization planning, this can OOM at capture time.
4. Minor: CodaGraphs clones the full logits on every replay only for argmax. Capturing the argmax, or returning only token IDs on this path, would avoid rows × 49152 × 2 B of copying per call. That copying is likely part of the reported D2D growth from 48 to 198.
5. Test and evidence gaps:
I'm running supplementary tests on H100, Ouro-1.4B 574fa66c:
I'll post results here when they're in.
Reviewed at head9eb01bb(base9d601ce). The runtime change is small and the ownership model looks right. I found no correctness blocker:
> Keying core graphs by row count is valid for Ouro. Depth only selects the block-table plane, which is copied in per replay, and Huginn is rejected for speculation.
Warmup and capture KV writes are idempotent at real positions.
Thefinally: stream.synchronize()in_capturecloses the failed-warmup race.
Outputs are cloned before pool reuse.
_require_live_batch runs before both replay and fallback.
> My main concerns are about what users get by default and under non-lockstep traffic:
> 1. Default graph limits disable most of the high-concurrency gain (ExecutionConfig.cuda_graph_max_batch_size=128,DeviceRecurrentGraphs.run). The limit counts rows, not requests. With K=2, verify has 3C rows, so at C≥43 the verify core and coda silently run eager. Above C=128 the draft path does too. The native baseline also falls back above C=128.
> The higher-concurrency table raises the limit to max(128, 3C) for all modes, so it does not show the default configuration. The doc example uses K=4, where verify has 5C rows and falls back from C≥26, but every measurement is K=2.
> Could the limit be derived from max_num_seqs (K+1), or could the engine at least warn at startup? Please also state this next to the tables.
> 2. The exact-row-count cache with 16 entries and no eviction fits only burst workloads (DeviceRecurrentGraphs.run,CodaGraphs.run). The measurements are lockstep bursts: all requests arrive at once, useignore_eosand have fixed output lengths. Under that workload shapes barely change, so "0 new captures / 0 fallbacks" is nearly guaranteed.
> With staggered arrivals, mixed lengths and natural EOS, the per-offset draft count, verify rows and coda rows all vary. Once 16 shapes are cached, every new shape runs eager permanently. Each lazy capture also calls torch.cuda.synchronize mid-serving, which stalls both in-flight rounds.
> Bucketing (padding to capture sizes, as vLLM does), LRU eviction, or pre-capture of expected sizes would make this robust. A test that fills the cache and then sees new shapes would also help.
> 3. The memory reserve does not scale with the number of graph pools (core/memory.py::plan_cache). A singlecuda_graph_memory_reserve_bytes(1 GiB) now covers four pools: native core/coda and spec core/coda. Each coda entry's output is the full bf16 logits, about 75 MB at 768 rows, so 16 large entries in the spec coda cache alone exceed the reserve. Withgpu_memory_utilizationplanning, this can OOM at capture time.
> 4. Minor:CodaGraphsclones the full logits on every replay only forargmax. Capturing the argmax, or returning only token IDs on this path, would avoid rows × 49152 × 2 B of copying per call. That copying is likely part of the reported D2D growth from 48 to 198.
> 5. Test and evidence gaps:
> No test for new shapes after the cache is full.
No test for high concurrency with default limits.
No test for K=4.
No test for a non-default CUDA device.
All evidence is from H20 with torch 2.14.1 / triton 3.8.
> I'm running supplementary tests on H100, Ouro-1.4B 574fa66c:
> PR GPU tests on head and base.
C16–256 with K=2/4, default vs. raised graph limits, against native async Graph and spec eager.
Staggered/ragged arrivals with natural EOS, counting captures, fallbacks and latency tails.
* A non-default device, two engines in one process, and DP4.
> I'll post results here when they're in.
done
Re-reviewed at head 73cfe4e. Thanks for the quick follow-up. The startup and cache-full warnings, the per-pool graph memory planning and the clarified docs address the "silent" part of my earlier points 1–3.
The measurements below were taken at 9eb01bb. The 73cfe4e delta does not touch replay or fallback selection: _cache_full is equivalent to the old condition, and planning is bypassed by the explicit KV sizes I used. So they apply to the current head.
I'm requesting changes for two reasons.
A. Coverage under non-lockstep traffic (blocking).
With exact-row-count keys and 16 entries, 77–93% of warmed core calls fall back to eager under staggered arrivals. With 64 entries, 44–58% still fall back. Graph then adds only 1–6% over spec eager. A warning documents this but does not fix it.
Please bucket row counts to a fixed set of capture sizes: pad inactive rows, and mask or skip their KV writes. Pre-capture those sizes, or at least use an LRU, so serving traffic reuses graphs. The bucketed path also needs a test that checks outputs stay bitwise equal to eager with padded rows.
B. Performance claims vs. native async Graph (blocking for the docs/README).
On H100 with non-repeated prompts, the gain over native is confined to the steady-state window. End to end, including the tail as requests finish at different times, short-output bursts reach only 0.92–1.00× native at K=2 and 0.71–0.81× at K=4. Longer outputs and inputs show real gains of 1.05–1.20×.
Please report end-to-end throughput next to the window/decode numbers and state where the feature wins. Either drop the K=4 example or benchmark it.
Non-blocking.
3 × 1 GiB of pool headroom plus retained logits for async speculation. Your own measured graph overhead is 96–283 MiB, so memory-planned users lose ~2.5 GB of KV capacity. Consider sizing the per-pool headroom from rows/entries instead of a flat 1 GiB each.cuda_graph_max_batch_size from max_num_seqs (K+1) instead of only warning.CodaGraphs for argmax remains (point 4).---
Supplementary H100 results. Raw JSON/logs are available on request.
Setup
574fa66c, BF16, d=2/D=4, greedy, Triton attention.ouro_delayed at exit_threshold=1, max_loops=4. All early-exit checks are gated on exit_threshold < 1, so it is full depth, matching the PR's native control.graph default uses cuda_graph_max_batch_size=128. graph raised uses (K+1)C rows. Native uses max(128, C) rows.Correctness
- C16–256 at K=2 and K=4
- input/output 512/128
- input/output 64/256
- The one exception is 64 graphs at K=2: 305/320 identical. Arrival steps are fixed, but ticket collection depends on
event.query() timing, so batch composition can still differ between runs. I attribute the divergence to that; it is not proven to be a graph bug.Multi-GPU
cuda:1 (with and without a torch.cuda.device guard), two Graph engines interleaved in one process, and 4 data-parallel replicas all produce identical tokens to the cuda:0 reference: 32/32, and identical digests across all 4 GPUs.Lockstep bursts, input/output 64/64 (tok/s)
"window" is the period in which every request has its first token and none has finished. "total" covers submit to last finish, including the tail as requests finish at different times.
| C / K | native window | spec eager | Graph default | Graph raised | total: native → Graph raised |
|---|---:|---:|---:|---:|---:|
| 16 / 2 | 716 | 414 | 920 | 911 | 687 → 629 (0.92×) |
| 32 / 2 | 1347 | 830 | 1675 | 1675 | 1257 → 1257 (1.00×) |
| 64 / 2 | 2419 | 1567 | 2555 | 2814 | 2103 → 1989 (0.95×) |
| 128 / 2 | 3578 | 2978 | 4094 | 4295 | 2913 → 2892 (0.99×) |
| 192 / 2 | 4649 | 3993 | 3966 | 5029 | 3477 → 3333 (0.96×) |
| 256 / 2 | 5365 | 4802 | 4799 | 5670 | 3863 → 3606 (0.93×) |
| 16 / 4 | 716 | 374 | 873 | 873 | 686 → 484 (0.71×) |
| 64 / 4 | 2414 | 1422 | 2369 | 2572 | 2098 → 1621 (0.77×) |
| 128 / 4 | 3578 | 2744 | 3822 | 3930 | 2913 → 2371 (0.81×) |
| 256 / 4 | 5372 | 4166 | 4163 | 4934 | 3871 → 3075 (0.79×) |
Longer sequences, K=2, total:
DP4 at C128 64/64 K=2 total: native 2791–2814 vs. Graph raised 2697–2760 per GPU (0.97×).
Takeaways:
1. Graph vs. eager is a real gain with raised limits, 1.1–2.2× in the window. With default limits it drops to 1.0× at C192/C256.
2. Versus native async Graph, the gain is confined to the steady-state window. End to end, short-output bursts are 0.71–1.00× native at K=2/4. K=4, the doc's example, is 0.71–0.81×.
3. With default limits, Graph gives no gain over eager at C≥192 (K=2) or C=256 (K=4). In those cells the window equals spec eager, and at C=192/256 it falls below native. This is concern 1 from my review, now measured.
4. Warmed fallbacks are never zero, even in lockstep bursts with raised limits. Per timed trial, the core cache falls back 24–148 times and the coda cache 1–60 times, because the 16-entry cache is filled by tail shapes.
Staggered arrivals (320 requests at 24 req/s, input 32–1021, output 16–375, about half natural EOS, max_num_seqs=128; warm passes):
| K | arm | tok/s | TTFT p50/p99 (s) | TPOT p50/p99 (ms) | core replays / fallbacks |
|---|---|---:|---:|---:|---:|
| 2 | native async Graph | 614–641 | 7.6–8.4 / 26–27 | 112–119 / 273–301 | 190–450 / 2200–2380 |
| 2 | spec eager | 856–892 | 4.7 / 15.0–15.6 | 82–84 / 212–227 | – |
| 2 | spec Graph, 16 graphs | 897–900 | 4.5–4.6 / 15.0–15.2 | 82 / 206–207 | 142–206 / 1736–1800 |
| 2 | spec Graph, 64 graphs | 926–945 | 4.1–4.4 / 13.3–14.2 | 75–78 / 190–210 | 996–1080 / 854–978 |
| 4 | spec eager | 943–983 | 3.6–4.8 / 14.8–16.7 | 82–86 / 217–257 | – |
| 4 | spec Graph, 16 graphs | 1014–1028 | 3.5–4.1 / 14.8–15.0 | 81–82 / 209–219 | 330–410 / 1412–1492 |
| 4 | spec Graph, 64 graphs | 1032–1040 | 3.4–3.9 / 13.9–14.6 | 78–80 / 211–213 | 762–1014 / 844–1050 |
Under realistic arrival patterns, 89–93% (K=2) and 77–82% (K=4) of warmed core calls fall back to eager with the default 16 entries, and still 44–58% with 64 entries. Graph therefore adds only +1–6% over spec eager. That is concern 2 from my review. Speculation itself (eager or Graph) clearly beats native async Graph here. Native's own exact-row-count graph cache shows the same churn: 83–93% of core calls fall back. Speculative cold passes captured 16 or 64 shapes inside the serving window without step-time spikes beyond warm levels (max step 428–499 ms vs. 390–540 ms). Native's first cold pass hit a 1985 ms step.
0z5a
liuyao0322
Required human contributor answers
The contributor explicitly supplied these answers for this implementation.
1. What outcome are you trying to achieve?
Improve low-concurrency Ouro asynchronous speculative inference latency and throughput while preserving correctness.
2. What is the highest-leverage variable for that outcome?
CPU kernel-launch overhead and GPU idle time.
3. How will this work move that variable rather than create busywork?
Use CUDA Graph replay to batch GPU submission and reduce per-operator CPU dispatch on the asynchronous speculative execution path.
4. Who is the customer or user, and what do they actually need?
People deploying Ouro inference services need lower latency and higher throughput at low concurrency, with correctness preserved.
PR necessity and bugfix evidence
The contributor explicitly requested a PR. The existing engine rejects asynchronous speculation with CUDA Graphs, and its synchronous graph wrapper requires host-owned positions. Supporting the combination therefore requires a runtime change. This is an opt-in feature, not a standalone bugfix claim. Refs #43; builds on merged #48, #66 and #115.
Purpose
Allow fixed-depth greedy Ouro asynchronous speculation to replay recurrent-core and LM-head CUDA Graphs with Triton. Device-owned positions and KV frontiers remain authoritative; the scheduler still reserves an upper bound, and two rounds can be submitted before CPU delivery.
Reuse the synchronous graph capture/replay mechanism through a device-metadata entry point that validates allocation identity without consulting or updating CPU written-position state. Clone graph outputs before workspace reuse. Preserve compact round results, copy-stream ordering, cancellation and ticket retirement. Drain the capture stream when warmup fails before an ordinary compute event can be recorded.
The asynchronous speculative core/head use a fixed geometric set of row buckets, bounded by both graph limits and fully pre-captured during engine construction. Each replay stages active rows, zeroes padding, and returns only active cloned outputs. A Triton KV scatter kernel checks a device-resident active-row count before reading write addresses or writing KV. Startup capture uses zero active rows. No speculative graph-cache exhaustion or mid-serving capture occurs for covered row counts. Over-limit rows still execute eagerly; native bootstrap and synchronous/Huginn graphs retain their existing exact-shape behavior. Prelude, metadata staging, argmax, acceptance and device-state updates stay outside capture. Sampling, adaptive exit, preemption and PD remain unsupported in the asynchronous speculative path.
The alternative is to retain eager asynchronous speculation or use synchronous graph speculation. Neither exposes cross-round device-state submission together with graph replay. Whole-round capture is deferred because it also needs replay-safe request-state updates and warmup isolation.
One pre-existing expression in
test_gsm8k_accuracy.pyis reformatted for the installed Ruff version; its behavior is unchanged.Test Plan
vllm-rlt Version / Commit: base
9d601ceaf9af63121c742df5f584467e23630a0b; performance-evidence runtime08d3f99; bucketed inference runtimedfbb0f7is validated separately below; documentation headeba6b30retains identical runtime/test sources. Historical H20 and reviewer-supplied H100 throughput predates bucketing; it must not be treated as performance of the new path.pre-commit run --all-files: Ruff lint/format and CPU regression.Test Result
Current bucketed head: validation (2026-10-16)
The bucketed implementation passes 165 tests with 13 FlashAttention selectors
deselected and no skips on a two-H20 Slurm allocation (job 376). This includes
FP32/BF16 KV sentinels during zero-active warmup/capture, shrinking bucket reuse,
new counts after every bucket is populated, stale allocations, failure cleanup,
K=2/4 ragged arrivals, non-default device and two live engines. With identical
padded inputs, core outputs and logits are bitwise equal to eager computation;
the frozen tiny-model cases also preserve unpadded eager token IDs. Full
pre-commit (Ruff lint/format and CPU regression) passes.
A separate H20 BF16 diagnostic uses Ouro-1.4B
574fa66c, torch 2.14.1+cu130 /Triton 3.8.0, 32 distinct topic prompts clipped/repeated to 32–128 input tokens,
24–44 output limits, natural EOS enabled on half, 16 concurrent slots, a
512-token budget, 128 graph rows and 16 entries. Eight requests arrive at each
of steps 0/12/24/36. One warm workload precedes three unprofiled observations
per arm and K, with explicit identical KV capacity. It deliberately synchronizes
the speculative runner at each step to fix batch composition; it is a controlled
correctness/coverage diagnostic, not a production-arrival latency or throughput
qualification. Arms ran sequentially, not interleaved.
| K | Implementation | Core replay / fallback per trial | Coda replay / fallback per trial | New speculative captures per trial |
| ---: | --- | --- | --- | ---: |
| 2 | Exact rows (
73cfe4e) | 150 / 136 | 55 / 52 | 0 || 2 | Bucketed | 286 / 0 | 107 / 0 | 0 |
| 4 | Exact rows (
73cfe4e) | 254 / 80 | 104 / 35 | 0 || 4 | Bucketed | 334 / 0 | 139 / 0 | 0 |
The counts repeat in all three observations. Bucketed Graph and eager with
the same padded computation agree for 32/32 requests at K=2 and K=4 in all
three trials. Against the original unpadded eager, only 29/32 agree at each K;
the differing continuations are reproduced by padded eager with graph replay
replaced by ordinary model calls. Thus this validates replay of padded
computation, not universal bitwise equivalence to unpadded execution. First
unpadded-eager divergences are at output indices 10/26/35 (K=2) and 18/26/33
(K=4). No end-to-end task-accuracy qualification is inferred from this check.
A warmed complete-round ops-only/full pair for exact-row and bucketed paths
retains shapes, CPU/GPU stacks and memory timelines. Individual CPU kernel
submissions drop from 7,266 to 185, with Graph launches increasing from 3 to 11;
the bucketed trace contains the masked KV scatter kernel. Full capture exports
are nonempty. These instrumented windows diagnose cache coverage and submission,
not unprofiled speed or an end-to-end native-relative gain. Broader asynchronous
arrival performance and H100 testing of the bucketed implementation remain open.
First-divergence investigation (2026-10-16)
The 29/32 unpadded-eager agreement was investigated at frozen runtime
dfbb0f7on one H20-3e, torch 2.14.1+cu130 / Triton 3.8.0, with the same BF16Ouro-1.4B checkpoint, inputs and controlled arrival/collection boundaries as
above. Six traced generations (unpadded eager, bucketed Graph, padded eager at
K=2/4; job 377) reproduced every frozen output exactly. Each first-divergence
comparison below has the same complete prompt and generated prefix, and
uses a verification row actually committed by acceptance, not a rejected draft
continuation. Indices are zero-based. These are correctness diagnostics, not
performance measurements.
| K | Request | First output index | Unpadded → padded token ID | Unpadded / padded top-two gap | Max absolute logit delta | Logit RMS delta |
| ---: | ---: | ---: | --- | --- | ---: | ---: |
| 2 | 21 | 26 | 32 → 37 | 0.0000 / 0.1250 | 0.156250 | 0.034166 |
| 2 | 22 | 10 | 8102 → 3982 | 0.0625 / 0.0000 | 0.125000 | 0.030789 |
| 2 | 28 | 35 | 3159 → 4869 | 0.0000 / 0.1250 | 0.203125 | 0.045824 |
| 4 | 15 | 33 | 314 → 2390 | 0.0000 / 0.1250 | 0.189697 | 0.036859 |
| 4 | 21 | 26 | 32 → 37 | 0.0000 / 0.1250 | 0.125000 | 0.032840 |
| 4 | 28 | 18 | 46816 → 27871 | 0.0625 / 0.0000 | 0.125000 | 0.023880 |
For example, K=2/request 22/index 10 compares token 8102 at 16.0000 versus
3982 at 15.9375 in unpadded eager. Padding makes both 16.0000, so
argmaxselects the lower token index 3982. K=4/request 15/index 33 compares 314 and
2390 tied at 23.5000 in unpadded eager, versus 23.5000/23.6250 with padding.
The first actual output divergence occurs at arrival-loop step 59 for K=2
(request 22), and step 34 for K=4 (request 15). Padded Graph and padded eager
logit vectors are bitwise equal at all six first-divergence rows. Recomputing
only the LM head at exact/padded sizes on the same hidden states produces
identical valid logits at these rows: the differing states already originate
inside the recurrent core, rather than the head or token-ID copy.
The numerical sources were isolated with identical hidden inputs and a cloned
pre-call KV state, then reproduced without any KV cache or CUDA Graph:
step 8, recurrence depth 1, is
model.layers.12.input_layernorm_2(zero-basedlayer/depth), for 6 valid rows padded to 8. Its 12,288 input elements and
their squares match bitwise. The FP32 variance differs by at most
1.862645149e-9; reciprocal RMS by4.768371582e-7. Sixteen normalized BF16elements then differ, with maximum weighted output delta
0.0009765625.At one coordinate, normalized FP32 values
1.3554686307907104versus1.35546875cast to BF161.3515625versus1.359375across a roundingboundary. Standalone RMSNorm reproduces both outputs in 20/20 repetitions.
removes that local normalization difference, but is not a full fix: complete
unpadded/padded generations still agree for only 28/32 (K=2) and 30/32 (K=4),
and the changed precision also changes the original baseline. In this
diagnostic-only control, the next isolated first operator is
model.layers.0.mlp.down_proj, 36 valid rows padded to 64. All 202,752 validinput elements and weights are identical; 121 of 73,728 output elements
differ, by at most
0.000244140625. Standalone BF16 linear calls reproduceboth outputs in 20/20 repetitions. An FP64 GEMM counterfactual removes the
local difference. These precision controls were not applied to production
and do not establish a model-accuracy improvement.
The KV and acceptance checks distinguish numerical values from storage errors:
positions, block tables, write blocks/offsets and context lengths with the
original call arguments, including zeroed inactive rows and trailing pages.
padded computation, but replace the masked kernel with ordinary indexed
writes of only the active rows. Every key/value cache byte and active output
matches the real Graph path. This checks untouched storage as well as valid
writes; the reference never writes padded rows.
rejected proposal, emitted target prefix, next token and next device
position on CPU. All match GPU state and the compact result buffer. Final
delivered outputs match the reconstructed device histories, after ordinary
EOS/discard handling. All six first-divergence cases have identical proposal
IDs across arms; changed target logits correctly explain any changed accepted
length. For K=2/request 21,
[37, 32]is rejected immediately against target32 in unpadded eager, but both proposals are accepted when the padded target
starts with 37; the corresponding frontier increments are 1 and 3.
Within these frozen cases, there is no evidence of wrong KV addressing,
inactive-row writes, or a broken acceptance/frontier rule. Valid KV values
can differ numerically because their upstream computation differs, which is
not the same as overwriting another row's storage. The demonstrated causes are
batch-shape-sensitive reductions and GEMM followed by BF16 rounding and near-tie
greedy decisions. This explains why padding requires its own numerical scope;
it does not promise unpadded bitwise equivalence or qualify general task
accuracy. Fixing only the variance reduction is insufficient. Jobs 378/379 and
382/383 retain operator-level fixtures and standalone controls.
Previous head
73cfe4e: warning/memory-planning validation| Check | Result | Scope |
| --- | --- | --- |
| Full
pre-commit run --all-files| Passed | Ruff lint/format and CPU regression || Two-H20 regression, Slurm job 262 | 108 passed, 13 deselected, no skips, 22.00 s | Async speculation/lifecycle, CUDA Graph and Huginn; FlashAttention selectors excluded |
| Default 128-row limit | Passed | K=2/C43 and K=4/C26: graph-enabled output equals eager output, with verification fallback and graph replay both exercised |
| Full graph caches | Passed | Fill two entries, execute an unseen shape twice via eager fallback, then replay an existing shape; outputs match eager and warnings occur once per cache |
| Automatic KV planning | Passed | Includes all three Ouro graph pools and retained speculative coda logits; a generated request completes using graph replay |
| Non-default CUDA device / two live engines | Passed, not skipped | Eager and graph-enabled engines coexist on
cuda:1while the current device remainscuda:0; outputs match |GPU command for the previous
73cfe4esnapshot:These were tiny-model correctness regressions at
73cfe4e. The H100, natural-EOS, default-versus-raised-limit and DP4 results subsequently supplied by the reviewer are reproduced in full below; they are not tests of the bucketed implementation.Historical validation at performance-evidence runtime
08d3f99Logs, JUnit, source/model hashes and performance artifacts were retained for validation. Raw artifacts and diagnostic measurement scripts are not included in this PR; the linked report records the configuration, methodology, results and limits.
BF16 measurements and source attribution
One Slurm-reserved H20-3e, driver 580.105.08, PyTorch 2.14.1+cu130, Triton 3.8.0, Ouro-1.4B revision
574fa66c, BF16 weights/activations/KV, d=2/D=4/K=2, greedy LAST_EXITED, ignore EOS. Five warmed alternating paired observations per mode/condition, with profiling disabled. Decode excludes the first output token and ends after GPU completion. Inputs are eight distinct texts repeated/clipped to fixed lengths; output length is 64.| Input | Concurrency | Native async Graph tok/s | Async spec eager tok/s | Async spec Graph tok/s | Paired Graph/eager speedup |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 64 | 1 | 65.53 | 31.04 | 97.57 | 3.14x |
| 512 | 1 | 52.48 | 30.74 | 77.22 | 2.51x |
| 64 | 8 | 469.70 | 210.03 | 589.00 | 2.80x |
| 512 | 8 | 378.83 | 206.77 | 482.40 | 2.33x |
K=2 throughout this table; C1/8 fits the default 128-row limit. The K=4 usage example is not real-checkpoint performance evidence.
The versioned report and annotated timeline include observed variability, controls, reproduction and limits. All warmed speculative Graph trials reused captures without fallback. Isolated-engine peak allocated memory increased by 96.5/102.8 MiB at concurrency 1/8 (input/output 64/64).
In an independent C1 input/output 64/8 ops-only decode window, CPU runtime/driver kernel launches fell from 27,844 to 181 plus 27 Graph launches; GPU kernel count stayed approximately unchanged. GPU-active interval union was 65.19/67.48 ms, while the remaining decode interval fell from 372.34 to 14.98 ms. D2D copies increased 48→198. Host synchronization time rose because the CPU submitted faster and waited for GPU completion; this is dispatch reduction, not removal of all waiting. Profile durations are diagnostic, not the throughput evidence above.
C1 input/output 64/8 ops-only decode observations (profiled diagnostics):
| Decode observation | Async spec eager | Async spec Graph |
| --- | ---: | ---: |
| CPU runtime/driver individual kernel launches | 27,844 | 181 |
| CPU Graph launches | 0 | 27 |
| GPU kernels | 27,844 | 27,848 |
| GPU active interval union (ms) | 65.19 | 67.48 |
| Remaining decode interval (ms) | 372.34 | 14.98 |
| Device-to-device copies | 48 | 198 |
| CPU time inside synchronization APIs (ms) | 0.02 | 31.53 |
Full profiles enable shapes, memory and stacks. Both bounded one-round captures have verified nonempty CPU/GPU stacks and memory timelines; the initial oversized whole-request full trace is preserved. Core/head capture removes most individual launches while preserving the existing state machine. Remaining metadata/acceptance launches, copies, cold capture costs and broader workloads remain explicit follow-up work.
A separate production-loader/create_app loopback HTTP test (job 158) ran five warmed alternating paired SSE requests per mode, concurrency 1, the same seven-token prompt and 64-token output. All ten completed with
[DONE], identical text and exact usage. Median E2E fell from 2711.7 to 824.4 ms; TTFT was 55.4 vs 54.4 ms. E2E p95 was 2728.2/824.8 ms, descriptive with five samples per mode. Each response had 27 choice events/64 tokens; these intervals are not per-token ITL. This is a bounded loopback result, not a saturation or natural-EOS qualification.Code-quality self-review applied R02/R12/R16/R17/R21/R23/R25: GPU progress stays runner-owned, logical allocation identity stays cache-owned, failed capture drains its stream, cloned outputs outlive replay, and graph-off/fallback/lifecycle behavior is covered. No unresolved actionable ownership or correctness finding was identified within this scope.
Higher-concurrency qualification
The extended report and scaling plot add 150 unprofiled paired trials, concurrency 16/32/64 at input 64/512, concurrency 128/256 at input 64, and C64 longer-output cohorts (64/512 and 512/256 input/output). All output token IDs matched the matched native baseline, and speculative eager/Graph pairs matched exactly. All warmed speculative trials had zero new captures and zero fallback.
Tuned coverage, not default settings: K=2, with a shared row limit of
max(128, 3C)for all modes. At the default 128 rows, verification core/coda fall back from C43 (K=2) or C26 (K=4); drafting and the native core fall back from C129. The table does not establish default-limit throughput or non-lockstep latency tails.Input lengths 64/512; output length 64:
| Input | Concurrency | Native async Graph tok/s | Async spec eager tok/s | Async spec Graph tok/s | Graph/eager | Graph/native Graph |
| ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| 64 | 16 | 889.21 | 418.05 | 1095.99 | 2.62x | 1.23x |
| 64 | 32 | 1680.14 | 816.76 | 1965.45 | 2.41x | 1.17x |
| 64 | 64 | 2777.62 | 1545.85 | 3147.42 | 2.04x | 1.13x |
| 64 | 128 | 4099.39 | 2789.72 | 4253.05 | 1.53x | 1.04x |
| 64 | 256 | 5086.70 | 4233.01 | 4924.13 | 1.16x | 0.97x |
| 512 | 16 | 716.55 | 419.43 | 866.16 | 2.06x | 1.21x |
| 512 | 32 | 1332.00 | 818.50 | 1504.23 | 1.84x | 1.13x |
| 512 | 64 | 1950.26 | 1535.66 | 2182.76 | 1.42x | 1.12x |
Graph still accelerates speculation relative to eager by 1.16x at C256, but the native Graph baseline is faster there. At input 512/C64, Graph speculation reaches 2182.76 tok/s (1.42x over speculative eager, 1.12x over native Graph). C64 longer-output runs retain approximately 12% native-relative gains. Acceptance stays about 93.3–93.5%, with all counters retained per timed trial. These measurements do not define a universal enable/disable threshold or establish saturation.
All modes within each condition share GPU allocation, model, KV capacity and scheduling controls. The row limit is
max(128, 3C); caches retain the default 16-entry limit. C128/256 raise the common admission scan limit to preserve the all-first-token boundary. An initial C256 warmup with the default scan failed that setup assertion before timing; its diagnostics are retained and both extension conditions were rerun. C1–64 use one physical H20; C128/256 use another H20 on the same host, so the figure separates those points and makes no strict cross-card scaling claim.The C64/input-512 complete-round ops/full pair retains nonempty shapes, CPU/GPU stacks and memory artifacts. Individual runtime/driver kernel submissions fall 12,040→981 plus 11 Graph launches; GPU-active time is 76.38/76.30 ms and the remaining profile interval 129.80/12.92 ms. This is diagnostic attribution, not timed throughput. Isolated warmed decode allocation overhead is 162.4–174.5 MiB for the two C64 long cohorts and 282.8 MiB at C256/input-output 64/64.
800 measured loopback SSE requests at C16/64 completed with valid
[DONE], length and usage. Each concurrency's eager/Graph text matches its native full-depth control. C64 p95 E2E falls 3191.4→1550.6 ms (speculative eager→Graph), with p95 TTFT 222.1→100.9 ms; five finite bursts per mode are not a steady-state capacity test. The C16/C64 continuation split is reproduced by native async Graph at identical input prefixes, first diverging at output index 29 (margin 0.125 versus a tied BF16 top pair); it is not a new speculative eager/Graph disagreement. Cross-batch bitwise invariance remains unqualified.Longer-output decode cohorts
These use the same K=2 and tuned graph coverage. Values are medians of five paired observations. Longer output also changes context lengths, so this is not a duration-only comparison with the 64-output table.
| Input / output | Concurrency | Native Graph tok/s | Spec eager tok/s | Spec Graph tok/s | Graph/eager | Graph/native Graph |
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| 64 / 512 | 64 | 2275.48 | 1554.37 | 2554.26 | 1.65x | 1.12x |
| 512 / 256 | 64 | 1823.15 | 1528.78 | 2055.56 | 1.36x | 1.13x |
Isolated warmed decode memory
Per-engine peak allocated memory after a complete warm cohort; initialization/prefill temporary peaks are excluded. Graph extra MiB is relative to speculative eager. These use explicit KV capacities at runtime
08d3f99, before the automatic-planning change.| Input / output | Concurrency | Native Graph GiB | Spec eager GiB | Spec Graph GiB | Graph extra MiB |
| --- | ---: | ---: | ---: | ---: | ---: |
| 64 / 512 | 64 | 30.091 | 30.111 | 30.281 | 174.5 |
| 512 / 256 | 64 | 41.408 | 41.428 | 41.587 | 162.4 |
| 64 / 64 | 256 | 28.283 | 28.363 | 28.639 | 282.8 |
Loopback HTTP bursts
Production
load_engine/create_app, seven-token prompt, 64 output tokens, ignore EOS; five warmed alternating paired bursts per mode at C16/64. Shared graph row limits are 128/192 respectively, with 16 entries per cache. All 800 measured requests completed with valid[DONE], length and usage, with zero measured speculative captures/fallbacks.| Concurrency | Mode | Complete tok/s | TTFT p50/p95 ms | E2E p50/p95 ms |
| ---: | --- | ---: | --- | --- |
| 16 | Spec eager | 421.62 | 68.1 / 190.2 | 2427.7 / 2494.8 |
| 16 | Spec graph | 1149.61 | 66.1 / 66.9 | 889.7 / 890.4 |
| 64 | Spec eager | 1325.75 | 99.6 / 222.1 | 3086.2 / 3191.4 |
| 64 | Spec graph | 2807.89 | 98.5 / 100.9 | 1455.5 / 1550.6 |
Throughput includes prefill and the complete burst and is the median of five observations. Latency percentiles pool 80 requests per mode at C16 and 320 at C64. Choice events contain multiple tokens, so event gaps are not per-token ITL. These finite bursts do not establish steady-state capacity or arbitrary-arrival latency tails.
No runtime code changed for the higher-concurrency measurements: their runtime hashes match
08d3f99. The subsequent review follow-up below changes warnings and memory planning and has separate regression evidence. This documentation/plot delta was checked for whitespace, links, raw-result coverage, source identities and successful producer completion.Previous review follow-up at
73cfe4emax_num_seqs (K + 1)exceeds coverage. State default-limit fallbacks beside the tables rather than suggesting the tuned results are defaults.cuda:1while the current device remainscuda:0. The existing ragged correctness matrix also covers K=4.Historical validation at
73cfe4e: full pre-commit passed (Ruff lint/format and CPU regression). An isolated source snapshot matching that revision passed 108 tests, 13 deselected on a Slurm two-H20 allocation (job 262): async speculation/lifecycle, CUDA Graph and Huginn tests excluding FlashAttention selectors. The non-default-device test ran with both allocated GPUs; it was not skipped. No new real-checkpoint throughput claim is made for this head.The exact-row cache limitation above describes
73cfe4e; it is superseded by the bucketed implementation described in Purpose and the current validation below. The full-logits clone and flat per-pool headroom remain follow-ups. Reviewer H100 results are reproduced below, attributed to their measured revision.Supplementary H100 review measurements (2026-10-16)
These results were supplied by reviewer 0z5a, measured at
9eb01bb. The reviewer confirmed applicability to73cfe4e: its warnings do not change replay/fallback selection, and the experiments use explicit KV sizes. They have not been rerun on the subsequent bucketed implementation. Raw JSON/logs are available from the reviewer on request; these are attributed external results, not a locally reproduced benchmark.Setup: one H100 per engine, torch 2.12.1 / Triton 3.7.1, Ouro-1.4B
574fa66c, BF16, d=2/D=4, greedy Triton attention. Distinct natural-text slices replace the eight repeated H20 prompts; observed acceptance is 72–91% rather than about 93%. Each arm runs two alternating blocks (ABCD/DCBA), warmed once per exact workload and timed three times per block: six timed observations per arm, reported as medians. Native async Graph is full depth (ouro_delayed, threshold 1, four loops).For speculative Graph, default coverage is 128 rows; raised coverage is
(K+1)C. Native coverage ismax(128, C). In the original table below, “window” starts after all requests receive their first token and stops before any finishes. The speculative eager/default/raised columns are window throughput too. “Total” covers submit through last finish, including prefill and the uneven completion tail. It is not the H20 decode-to-GPU-completion window, so those absolute throughput values should not be combined.Lockstep bursts, input/output 64/64 (tok/s)
| C / K | native window | spec eager | Graph default | Graph raised | total: native → Graph raised |
|---|---:|---:|---:|---:|---:|
| 16 / 2 | 716 | 414 | 920 | 911 | 687 → 629 (0.92×) |
| 32 / 2 | 1347 | 830 | 1675 | 1675 | 1257 → 1257 (1.00×) |
| 64 / 2 | 2419 | 1567 | 2555 | 2814 | 2103 → 1989 (0.95×) |
| 128 / 2 | 3578 | 2978 | 4094 | 4295 | 2913 → 2892 (0.99×) |
| 192 / 2 | 4649 | 3993 | 3966 | 5029 | 3477 → 3333 (0.96×) |
| 256 / 2 | 5365 | 4802 | 4799 | 5670 | 3863 → 3606 (0.93×) |
| 16 / 4 | 716 | 374 | 873 | 873 | 686 → 484 (0.71×) |
| 64 / 4 | 2414 | 1422 | 2369 | 2572 | 2098 → 1621 (0.77×) |
| 128 / 4 | 3578 | 2744 | 3822 | 3930 | 2913 → 2371 (0.81×) |
| 256 / 4 | 5372 | 4166 | 4163 | 4934 | 3871 → 3075 (0.79×) |
The original exact-row implementation wins over speculative eager in many window comparisons, but short-output end-to-end throughput is 0.92–1.00× native at K=2, and 0.71–0.81× at K=4. Even raised-limit lockstep trials have warmed fallbacks (core 24–148, coda 1–60 per trial) as tail shapes fill the caches. These results do not support a general latency/throughput improvement over native async Graph. K=2 is the usage example; K=4 remains supported and benchmarked here, with the regression disclosed.
Longer-sequence end-to-end results, K=2:
| Concurrency | Input / output | Native total tok/s | Spec Graph raised total tok/s | Graph/native |
| ---: | --- | ---: | ---: | ---: |
| 32 | 512 / 128 | 583 | 697 | 1.20x |
| 64 | 512 / 128 | 784 | 827 | 1.05x |
| 64 | 64 / 256 | 2092 | 2318 | 1.11x |
DP4, C128, input/output 64/64, K=2: native 2791–2814 versus speculative Graph raised 2697–2760 tok/s per GPU, approximately 0.97×.
Staggered arrivals: original exact-row caches
320 requests at 24 requests/s, input lengths 32–1021, output lengths 16–375, about half natural EOS,
max_num_seqs=128; warm passes. Values below are the reviewer's original ranges. TPOT uses the reviewer's reporting convention, not per-token SSE timestamps.| K | arm | tok/s | TTFT p50/p99 (s) | TPOT p50/p99 (ms) | core replays / fallbacks |
|---|---|---:|---:|---:|---:|
| 2 | native async Graph | 614–641 | 7.6–8.4 / 26–27 | 112–119 / 273–301 | 190–450 / 2200–2380 |
| 2 | spec eager | 856–892 | 4.7 / 15.0–15.6 | 82–84 / 212–227 | – |
| 2 | spec Graph, 16 graphs | 897–900 | 4.5–4.6 / 15.0–15.2 | 82 / 206–207 | 142–206 / 1736–1800 |
| 2 | spec Graph, 64 graphs | 926–945 | 4.1–4.4 / 13.3–14.2 | 75–78 / 190–210 | 996–1080 / 854–978 |
| 4 | spec eager | 943–983 | 3.6–4.8 / 14.8–16.7 | 82–86 / 217–257 | – |
| 4 | spec Graph, 16 graphs | 1014–1028 | 3.5–4.1 / 14.8–15.0 | 81–82 / 209–219 | 330–410 / 1412–1492 |
| 4 | spec Graph, 64 graphs | 1032–1040 | 3.4–3.9 / 13.9–14.6 | 78–80 / 211–213 | 762–1014 / 844–1050 |
With 16 entries, 89–93% (K=2) and 77–82% (K=4) of warmed speculative core calls fall back; with 64 entries, 44–58% still fall back. Graph adds only about 1–6% over speculative eager with 16 entries. Speculation itself beats native in this workload, so that gain must not be attributed entirely to Graph replay. Native's exact-row cache also falls back on 83–93% of its core calls. These measurements motivated the fixed buckets implemented above; they are not measurements of that fix.
Correctness reported by the reviewer: H100 GPU selections passed (212 tests at head, 183 at base, 16 FlashAttention cases deselected, no skips). Speculative Graph/eager token IDs agree in all lockstep conditions, including K=2/4 and longer sequences. Under ragged arrivals, agreement is 320/320 at default limits for K=2/4 and with 64 entries for K=4, but 305/320 with 64 entries at K=2. Batch composition can vary with asynchronous event collection; this is a hypothesis for the mismatch, not a proven explanation. Speculation/native also diverges on these prompts (eager does too), so native equality in the H20 report is limited to its frozen inputs. Non-default device, interleaved two-engine and DP4 checks passed against their reference outputs.
AI assistance: OpenAI Codex assisted with implementation, tests and documentation.