Skip to content

Remove blocking reads from FlashInfer planning in the speculative cycle (hostgap) - #120

Merged
SamMausberg merged 22 commits into
mainfrom
hostgap/verify-plan
Oct 1, 2026
Merged

SamMausberg merged 22 commits into
mainfrom
hostgap/verify-plan

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Without a profiler, stock SGLang leaves the GH200 idle an estimated 1.44-1.79 ms of each tuned-MTP cycle for Qwen3.5-4B at held batches of 1-128 requests: 21% of the cycle at B = 1, 9% at B = 128 (derived; the assumption is below). This PR names where that idle comes from, removes the blocking device-to-host reads on the draft and verify planning paths with bitwise-identical plans and outputs (patches 0001-0003), and measures what that buys: MTP cycles 2.7-4.8% shorter, which is 13-16% of the idle at B = 1-8, 27-35% at B = 32-64 and 55% at B = 128. The DFlash change (0.7-1.7%) is not confirmed yet. Evidence and commands: evidence/hostgap/README.md.

How much of the cycle is idle

Stock SGLang bd66ce343e, tuned MTP arm (s3, replayssm-spec, radix off; the same flags as bench's mtp-tuned), windows with exactly B requests decoding. Derived (cycle_profiles.json, derived_idle and before_after): untraced stock cycle time minus the GPU busy time per cycle of the patched engine's host trace from the same session.

B 1 8 32 64 128
Stock cycle, untraced 6.93 ms 7.73 10.08 13.19 20.30
Estimated GPU idle 1.44 (21%) 1.50 (19%) 1.67 (17%) 1.72 (13%) 1.79 (9%)
Removed by 0001-0003 0.19 (13% of the idle) 0.24 (16%) 0.45 (27%) 0.60 (35%) 0.98 (55%)

The estimate assumes the stock cycle does the patched cycle's GPU work (both launch the same graphs and kernels on the same data; stock adds only the small copies the patches remove) and that graph-level tracing does not lengthen kernels. For DFlash (block 8) the estimate is 1.36-1.46 ms (21% at B = 1, 9% at B = 32). The queued hold retakes the stock traces with the same driver, which will replace the borrowed busy time.

So the claim that most idle is host work, not waiting on a read, holds at low batch only; at B = 128 removing the reads took away over half of it. A blocking read costs more than the time spent inside it, because the host work behind it waits until the GPU drains and then runs while the GPU idles: at B = 128 the patches saved 0.98 ms per cycle, while the stock trace shows only 0.29 ms of memcpy and synchronize calls during idle.

Where the idle sits (host-traced, attribution only)

Host tracing slows the host (traced cycle 8.35 ms against 6.93 untraced at B = 1, 22.92 against 20.30 at B = 128), so traced idle (2.6-2.9 ms per MTP cycle) is used only to place the idle:

  • MTP verify: eagle_prepare_for_verify > DecodeCudaGraphRunner.load_batch > init_forward_metadata_out_graph > FlashInferIndicesUpdaterPrefill.call_begin_forward > BatchPrefillWithPagedKVCacheWrapper.plan, 1.1-1.8 ms exposed per traced cycle. FlashInfer's plan() blocks four times per verify: segment_packbits' .item() and three .to("cpu"). SGLang gives DFlash's verify a sync-free plan already; EAGLE keeps a custom mask and cannot use it.
  • MTP draft: FlashInferMultiStepDraftBackend.common_template's kv_indptr.cpu(), about 0.5 ms exposed with fast_decode_plan.
  • DFlash (block 8, FlashInfer draft attention), outside the two sites this work set out to remove: the drafter's sliding-window layers put its backend on two wrappers, which do not take fast_prefill_plan, so the draft forward's plan blocks six times per cycle (1.1-1.2 ms exposed). Bench's dflash-tuned arm uses FA4 draft attention and does not take this path.
  • The stock DFlash B = 32 traced window did not hold B at 32 (two graph shapes, 120 graph cycles against 140 run_batch, traced cycle shorter than untraced); the README lists it with that caveat and leaves it out of every range.
  • At B = 128 the held cycle is 20.3 ms untraced (verify graph 14.2 ms: GEMMs 6.6, GDN state 4.9, attention 1.6; eager kernels 1.83 ms, of which GDN state 1.46 and sampling 0.24). Hypothesis, not measured: the ~32 ms cycle implied by bench's c = 128 throughput is the serving loop around decoding, mostly arrivals' prefills. That derivation assumes 128 requests running throughout, and points.csv records only the maximum.

Change

Engine patches engine/sglang/patches/hostgap/ (apply to the pin; README section in engine/sglang/README.md), each flagged path off by default. 0001-0003 are the validated state and the default apply command:

  • 0001 SGLANG_HOSTGAP_VERIFY_PLAN=1: fast_verify_plan mirrors FlashInfer 0.6.18's plan() (fa2, CUDA-graph mode) step by step with the four reads replaced by values from seq_lens_cpu, installed at the first replay so capture is stock. A per-wrapper event orders reuse of FlashInfer's pinned plan buffer, which the removed reads used to guarantee.
  • 0002 SGLANG_HOSTGAP_DRAFT_INDPTR=1: the draft kv_indptr rows on the host.
  • 0003 SGLANG_HOSTGAP_DFLASH_DRAFT_PLAN=1: the DFlash draft's two wrappers plan from the worker's exact host copy of the lengths.
  • 0004 (no new flag, not yet validated): the host arithmetic of 0001-0003 in numpy and the mask offsets uploaded in one copy. Its GPU check, equality and timing are queued; no saving is claimed for it, and the host timings previously quoted for it (they had no committed artifact) are gone from the README and from its commit message.
  • 0005 (no new flag, not yet validated): fast_verify_plan passes disable_split_kv as plan() does, forced on for NVFP4 KV; no change with this BF16 KV cache. Also corrects the module docstring.
  • SGLANG_HOSTGAP_VALIDATE=1 runs the stock read-back path next to every sync-free plan and raises on any difference.

Tooling in experiments/hostgap/: held-batch cycle profiler (cycle_profile.py), idle attribution by host call site and blocking-call listing from nsys (gap_analysis.py), GPU plan check (plan_equivalence.py, small version in tests/test_hostgap_plan.py), deterministic greedy equality (equality.py), the summary (summarize.py, which now also writes per-label provenance, every counted window, the stock idle estimate, the before/after pairs with their run order and the work queued at the EAGLE seam), A/B sweep runner and the hold scripts.

Validation (engine 02b0e36ec8, patches 0001-0003)

  • GPU plan check: stock plan() against fast_verify_plan on 280 random batches each for the EAGLE verify and the DFlash block (B = 1-128, padding rows): identical plan_info, pinned plan bytes, device buffers and replayed attention output bits; draft kv_indptr equal to the Triton kernel on 160 batches.
  • Serving engine with validation on: every sync-free plan of the equality runs matched the stock path (at least 8,192 verify plans and 8,192 draft index sets for MTP, at least 8,192 DFlash draft plans; the counts are logged at powers of two; the pinned-buffer guard never waited).
  • Greedy outputs, 64 prompts at concurrency 1, 8 and 32, rounds sent as one batched request so batching is identical, empty GPU at start, running limit / KV tokens / mamba slots set, radix cache off: MTP patched, patched + validate and a stock repeat all match stock on every token sequence, verify-step count and correct-draft histogram (192/192 each), with identical pools. DFlash matches on all 192 requests, but its memory-limited KV pool varied by up to 155 tokens between launches (stock against stock too), so its compare files say all_equal: false at the top level for the pools alone; a rerun with a binding cap is queued.
  • tests/test_hostgap_plan.py has not run on a GPU yet; hold_mtp.sh now runs it first, on the engine head of that hold (0001-0005).
  • Without a profiler (same session, three 2 s windows each, stock server then patched server, not interleaved): MTP cycle 6.93 → 6.74 ms at B = 1 (-2.7%), 7.73 → 7.49 (-3.1%), 10.08 → 9.63 (-4.5%), 13.19 → 12.59 (-4.5%), 20.30 → 19.32 (-4.8%) at B = 8/32/64/128, each change at least four times the larger window standard deviation. DFlash -1.0%, -0.7%, -1.7% at B = 1/8/32; at B = 1 and 8 the 0.06 ms change is one to five window standard deviations, which a launch-to-launch shift could produce, so the DFlash gain is unconfirmed until the interleaved sweeps report.

What remains

The idle that is left is a host critical path. After the previous verify finishes, the traced host needs 1.70-1.83 ms to plan and launch the next draft, while the GPU still has 0.54-0.90 ms of work queued (host resolve-to-draft-launch time minus the GPU's idle gap before the draft, 0.93-1.15 ms; a difference of medians from the patched traces, assuming the draft starts when launched). The verify planning then runs past the draft's end. The waits on the previous verify's lengths stay: every plan needs them. Triton attention avoids host planning altogether and is +17% at c = 1 on this arm in bench's tuning data (+11% at c = 8, +2% at c = 32, -14% at c = 128), with different numerics; those are single runs, and other processes' CPU load peaked at 2.2-3.1 cores at c = 8 and 9.6-10.1 at c ≥ 32. Matching that exactly would need cheaper host planning (0004 is a first step) or a scheduler that stops planning the next draft after the previous verify. One cudaStreamSynchronize per cycle remains under the verify's call_begin_forward (0.007-0.009 ms at B ≤ 64, 0.21 ms at B = 128); stock has it too, and its source is not identified yet.

Pending, queued

hold_mtp.sh (in the FIFO queue) and hold_dflash.sh (submitted when the first starts): the GPU test and plan check on 0001-0005, equality for the full series, same-driver stock host traces (patched before stock, so hold 2 and this hold form an A-B / B-A pair), the DFlash pinned-KV equality, and the interleaved serving A/B sweeps at c = 1, 2, 4, 8, 16, 32 (stock / hostgap / hostgap / stock, Triton as a reference). I will add the results to this PR.

Review 5933518035: how each item was handled

  1. Headline idle was traced. The PR body, the README's short answer and a new "How much of the cycle is idle" table lead with the untraced estimate (1.44-1.79 ms MTP, 21% → 9%; 1.36-1.46 ms DFlash), labelled derived with both assumptions stated. summarize.py now writes it into cycle_profiles.json (derived_idle.mtp, gpu_busy_source names the borrowed trace). Traced values appear only in the attribution table, labelled as such.
  2. Scoped by batch size. The removed share (13-16%, 27-35%, 55%) is in the table and the text; "host work, not waiting" is now stated for low batch only. The mechanism sentence is replaced: a read delays the host work behind it, and at B = 128 the saving (0.98 ms) exceeds the 0.29 ms of runtime calls during idle. An interpretation of why the saving grows with B (the verify planning overlaps a longer draft graph) is labelled as one.
  3. Queued work. "0.7-1.2 ms of GPU work queued" is now the idle gap (0.93-1.15 ms), and the queued work is 0.54-0.90 ms, derived as stated; summarize.py writes it per batch (gpu_work_queued_at_resolve_ms).
  4. 0004. Marked not yet validated in the engine README, the evidence README and this body; the default apply command is 000[1-3]-*.patch, with 0004-0005 as a separate optional step. The 46 → 12 / 55 → 19 us numbers are dropped from the README and from 0004's commit message (reworded; its tree is unchanged, ee426e8df4). 0004's check is in hold_mtp.sh.
  5. 32 ms serving loop. Labelled a hypothesis, with the 128-running assumption and the fact that points.csv records only the maximum.
  6. Numbers. py-spy: stock plan() 14.8% against fast_verify_plan 5.4%, common_template 6.2% stock against 9.1% patched, each attributed to its arm. GDN split dropped. DFlash B = 32 traced row caveated and excluded from ranges (DFlash draft planning is now 1.1-1.2 ms). Eager time at B = 128: 1.83 ms in all, GDN state 1.46 and sampling 0.24. DFlash B = 1: -1.0%. Validation counts: "at least 8,192", with the power-of-two logging stated.
  7. Comparison design. The before/after pairs are described as sequential, not interleaved; MTP effects are compared with the window spread; the DFlash gain is called unconfirmed. The Triton figures carry their foreign_cpu_max values.
  8. Public text. The README and this body no longer refer to material readers cannot see (DFlash's site is described as outside the two sites this work targeted); "my own analysis job" reads "a concurrent analysis job"; the test's status is stated (not yet run on a GPU, queued).

Suggestions: the remaining synchronize is described (present in stock as the fifth sync for four copies; source not identified). NVFP4: patch 0005 mirrors plan()'s rule rather than asserting. Run order: hold_mtp.sh and hold_dflash.sh now profile patched before stock. DFlash compare files: one sentence in the README explains the top-level all_equal: false. Provenance: summarize.py writes generated_by, per-label provenance (commits, launch command, flag environment, start time) and every counted window, and cycle_profiles.json is regenerated with it (all values unchanged); stock_traces_hold1.json keeps its README provenance and will be superseded by the same-driver stock traces. Docstring: fixed in 0005.

Codex reviewed 5b62d27 with no findings (no inline comments).

No new dependencies were installed. The shared-slot equality attempt failed (SGLang applies --mem-fraction-static 0.25 to the free memory at start-up, so with ~50 GB held by other shared servers the weights did not fit); the equality runs moved to an exclusive hold.

The branch now includes origin/main (merge e1dc80f); the only conflict was the end of engine/sglang/README.md, where main's backbone section and this hostgap section both stay. Head: e1dc80f.

cycle_profile.py holds C streaming requests in decode and measures
unprofiled cycle time from the decode-pass counter, py-spy shares and
nsys windows; gap_analysis.py attributes GPU idle per cycle to the host
function open on the scheduler thread and lists blocking host calls;
equality.py compares greedy outputs under a deterministic batching
protocol; plan_equivalence.py checks the sync-free plans against
FlashInfer's stock plan on the GPU; ab_sweep.sh and ab_summary.py run
and summarize interleaved bench sweeps.
…e a hung py-spy

The first profile run lost client token counts when http.client's chunked
line iterator failed mid-stream, sampled far past the model's end of text
under ignore_eos, and aborted a step when py-spy hung. Windows now start C
new requests (at most 4,096 tokens), mark any window where a stream ended
early, and py-spy runs under timeout.
… hold

At a shared slot's static memory fraction of 0.25, SGLang sizes the pool
from the memory free at start-up, so with other shared servers resident
the MTP server could not load (all four variants failed on 2026-10-01).
Every server starts on an empty GPU (at least 90 GiB free) with the
running limit, KV tokens and mamba slots set explicitly; launch_summary
records the resolved limits, pool sizes and the running high-water mark,
and compare refuses equality between servers whose pools differ.
…lity, before/after cycle times

Patch 0004 joins the exported series; its GPU check, equality and timing
are queued.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T14:59:32.105652Z e1dc80f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES

Review of the exact head 5b62d27 ("Relate the hostgap arms to bench's tuned arms").

The engine work is sound, and the exactness evidence supports bitwise equality for 0001-0003. What needs changing is how the timing evidence is reported. The headline idle figures come from host-traced runs. One quantity in the mechanism argument is mislabelled. And 0004 is described as equivalent without a check.

What I verified

  • The series reproduces. git am onto bd66ce343e gives tree 94d6c95bc1 after 0003, the tree of 02b0e36ec8, and ee426e8df4 after 0004, the tree of be3a6ccd8e.
  • fast_verify_plan follows FlashInfer 0.6.18's plan(). I compared it line by line with the installed source for the fa2, CUDA-graph path. It removes only segment_packbits' indptr_new[-1].item() and the three .to("cpu") reads; buffer copies, plan_info arguments and wrapper attributes match the defaults SGLang's call uses.
    • It is installed at the first replay, so the capture-time plans are stock.
    • PlanGuard covers every sync-free plan, including stock's fast_prefill_plan on the draft-extend wrapper and fast_decode_plan.
    • The DFlash sliding-window lengths, clamp(seq_lens, window), match SGLang's own prefill formula when prefix_is_full_seq.
    • With every flag unset, the code paths are unchanged.
  • 0004, read but not run. Same integers, uploaded in one copy. Its pinned staging is guarded, and validation now also checks mask_indptr. I found no bug, but it has not run on a GPU (see B4).
  • The numbers mostly match the committed evidence.
    • The stock table matches stock_traces_hold1.json, and the unprofiled table matches cycle_profiles.json. That covers the means, standard deviations, the n = 2 case and the removed idle.
    • Equality: 192/192 on output_ids, verify counts and histograms in every comparison, with identical launch commands apart from the env flags and radix off. MTP pools are equal.
    • The plan check ran 280 batches per kind, with 0 state and 0 output-bit mismatches.
    • The bench citations (539/459 and the 32 ms derivation) and the moonshot plan-stream citation are on main.
  • The core claim holds in the traces. In the stock host traces, the scheduler thread spends 0.24-0.30 ms per cycle inside memcpy or synchronize calls during GPU idle, out of 2.5-2.9 ms. So under tracing, most idle is not spent blocked in a read.
  • Codex finished on 5b62d27 with no findings (summary "Completed" plus a thumbs-up, no inline comments).
  • Checks. Pre-commit passes on all 31 changed files, including the host-identity hook. All 19 commits and 4 patches are by Samuel Mausberg, with no AI lines. The hostname check is clean over the tree, git log -p origin/main..HEAD and the PR text. No committed file cites ~/vp-coord or an unmerged branch.

Blocking

  1. The headline idle is a traced number.
    • The PR body's first sentence, its stock table and the README's short answer give 2.6-2.9 ms (33% at B = 1, 13% at B = 128). Those values come from host-traced windows, which slow the host: the traced cycle is 8.35 ms against 6.93 ms untraced at B = 1, and 22.92 against 20.30 at B = 128. Host-bound idle grows with that slowdown. The README's Limits section says traced runs are used only for attribution, yet the headline uses their magnitudes.
    • The evidence already holds an untraced estimate. cycle_profiles.json derived_idle gives the patched MTP idle as 1.25 / 1.27 / 1.22 / 1.12 / 0.81 ms at B = 1 / 8 / 32 / 64 / 128. Adding the measured reduction gives about 1.44 / 1.50 / 1.67 / 1.72 / 1.79 ms for stock, or 21% / 19% / 17% / 13% / 9% of the cycle. This is derived: it assumes the GPU busy time from the patched trace.
    • Please lead with the untraced estimate, label it as derived and state the assumption. Keep the traced values for attribution only.
  2. Scope the key claim by batch size. On that estimate, removing the reads takes away 13-16% of the idle at B = 1-8, 27-35% at B = 32-64 and about 55% at B = 128. "Most of the exposed time is host work, not waiting" holds at low batch, but not at B = 128.
    • The mechanism sentence, "the reads stalled the host only for as long as the GPU still had work queued, which on this path was little", should cover that case too. At B = 128 the removal saved 0.98 ms per cycle, more than the 0.29 ms of runtime calls that overlapped idle in the trace. A read delays the host work that follows it, not only the idle it overlaps.
  3. "0.7-1.2 ms of GPU work queued" is an idle gap. In "What is left", the range is eagle_seam.gpu_extend_end_to_draft_start_ms, the gap between the extend's end and the draft's start. The work still queued when the host learns the lengths is host_resolve_to_draft_launched_ms minus that gap: about 0.55-0.90 ms in the patched traces. That agrees with the short answer's "about 0.5-1 ms". Please fix the label and state the derivation, since this sentence carries the main argument.
  4. 0004 is described as equivalent without a check.
    • The engine README's 0004 row says "Same integers, same packing kernel", and its apply command (*.patch) includes 0004. No GPU check, equality run or timing has covered it yet.
    • Please mark 0004 as pending validation in the engine README and in the PR body's Change list, and give the command for the validated state (0001-0003).
    • The host timings that motivate it (46 → 12 us, 55 → 19 us) have no committed artifact or command. Commit the measurement or drop the numbers until 0004's hold reports.
  5. The ~32 ms serving-loop attribution is a hypothesis. "Chiefly the prefill passes of arriving requests" is not measured; the README itself says the windows exclude them. The derivation also assumes 128 requests running throughout, but points.csv records only max_running_logged = 128. A lower mean would make the implied cycle shorter. Please label it as a hypothesis and state the assumption, in the README and the PR body.
  6. Numbers that don't match the evidence.
    • py-spy shares. The 15% (call_begin_forward, B = 8) is the stock arm's figure; patched is 5.4%. The 9% (common_template) is patched; stock is 6.2%. Both are quoted in the patched section.
    • GDN split. "Replay-spec kernel 3.38, causal conv update 1.28" is in no committed file; stock_traces_hold1.json has only the class total, 4.86. Commit a per-kernel breakdown or drop the parenthetical.
    • Stock DFlash B = 32 traced row. Its traced cycle (14.55 ms) is shorter than the untraced one (15.76). The window also shows two batch shapes (graph launch counts 120+120 and 23+22; 120 graph cycles against 140 run_batch), so B was not held at 32. Caveat or drop the row.
    • Eager time at B = 128. "Eager kernels 1.6-1.7 ms": GDN state plus sampling is 1.70, and all eager classes sum to 1.83. Say which.
    • DFlash B = 1 change. It is −0.96%, which rounds to −1.0%, not −0.9%.
    • Validation counts. These come from a power-of-two log line, so "at least 8,192", not "more than".
  7. Timing comparison design. BRIEF's standing rule requires paired, interleaved comparisons and flagging of runs under foreign CPU load above 2 cores.
    • Each before/after pair is one stock server, then one patched server, in the same hold, so they are not interleaved. Please say so. The DFlash differences at B = 1 and 8 (0.06 ms) are about one standard deviation of the stock windows, so call the DFlash gain unconfirmed until the interleaved A/B sweeps report. The MTP effects (2.7-4.8%) are well outside the window spread.
    • The bench Triton figures you cite ran with foreign_cpu_max of 2.2-3.1 cores at c = 8 and 9.6-10.1 at c ≥ 32. Add that next to "single runs".
  8. Public-text items.
    • The README says "named in the brief" and the PR body says "a site the brief did not name". The brief is an internal document readers cannot see; name what was targeted instead.
    • "My own analysis job" should read "a concurrent analysis job".
    • State whether tests/test_hostgap_plan.py has run, and on which engine head. Neither the PR nor the README says.

Suggestions (non-blocking)

  • Remaining synchronize. Every patched MTP trace still shows one cudaStreamSynchronize per cycle under call_begin_forward (0.007 ms at B ≤ 64, 0.21 ms at B = 128). Naming its source would complete the "no blocking reads remain" statement.
  • NVFP4 KV. fast_verify_plan always passes disable_split_kv=False, while stock plan() forces it to True for NVFP4 KV (_nvfp4_kv_requires_disabled_split_kv). An assert on kv_data_type would make that configuration fail loudly instead of planning differently from stock when validation is off.
  • Run order. The queued hold_mtp.sh again runs stock before patched. Running patched first there would give an A-B / B-A pair across the two holds.
  • DFlash compare files. The DFlash compare JSONs say "all_equal": false only because the KV pools differ. A sentence in the README would stop readers misreading them.
  • Provenance. cycle_profiles.json and stock_traces_hold1.json carry no repo or engine commit, flags, model or GPU; only the README has them. A small provenance block per file, plus the per-window values (only mean, std and n are committed), would make the timings re-checkable.
  • Docstring. The flashinfer_hostgap.py module docstring says "With either of the first two flags on"; GUARD covers all three.

- Engine series: 0004's commit message no longer quotes host timings that
  have no committed artifact (its tree is unchanged); new 0005 mirrors
  FlashInfer plan()'s NVFP4 disable_split_kv rule and fixes the module
  docstring. The engine README's default apply command is the validated
  0001-0003; 0004-0005 are an optional, not yet validated step.
- summarize.py writes per-label provenance (commits, launch command, flag
  environment, start time), every counted window, the stock idle estimate
  from the patched trace's GPU busy time when stock has no trace of its own,
  the before/after pairs with their start times, and the GPU work queued at
  the EAGLE seam.
- hold_mtp.sh runs tests/test_hostgap_plan.py first; both hold scripts
  profile patched before stock, so with the earlier hold they form an
  A-B / B-A pair.
…claims

Review of PR #120: the headline idle is now the derived untraced estimate
(stock MTP 1.44-1.79 ms, 21% to 9% of the cycle; assumption stated), with
traced values kept for attribution only. The share of idle the patches
remove is given per batch size (13-16% at B <= 8, 55% at B = 128), the
queued GPU work at the seam is 0.54-0.90 ms (the 0.93-1.15 ms figure was
the idle gap), the c = 128 serving-loop attribution is a labelled
hypothesis, the before/after pairs are described as sequential, the DFlash
gain as unconfirmed, and the py-spy, eager-time, DFlash B = 1 and
validation-count figures match the committed files. cycle_profiles.json is
regenerated with the new summary fields; every earlier value is unchanged.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (provisional, on e1dc80f: Codex is still running on this head. I will confirm or withdraw once it finishes.)

Re-review of the commits since 5b62d27: 7e42b57 (code), 2e61ad9 (evidence and README), and e1dc80f (merge of main; the backbone patch files in the stat come from #91 through main).

All eight blocking items from 5933518035 are resolved.

  1. Headline idle. The README and PR body lead with the derived untraced estimate: MTP stock 1.44 / 1.50 / 1.67 / 1.72 / 1.79 ms (21% to 9%), and DFlash 1.36-1.46 ms. cycle_profiles.json derived_idle now holds these values, with gpu_busy_source naming the assumption. Traced idle is used only to place the idle.
  2. Scope by batch. The removed share is 13-16% / 27-35% / 55%, and the text says the "host work" claim holds at low batch only. The mechanism sentence now explains why a read costs more than the time spent inside it.
  3. Queued work is gpu_work_queued_at_resolve_ms: 0.544-0.901 ms, derived from the medians with the formula stated.
  4. 0004 is marked not validated in the engine README, the evidence README and the PR body, and the default apply command is 000[1-3]-*.patch. The 46/55 us timings are gone.
  5. The 32 ms serving loop is labelled a hypothesis, with the 128-running assumption stated.
  6. Numbers.
    • The py-spy shares are per arm: plan() 14.8% stock, fast_verify_plan 5.4% patched; common_template 6.2% stock, 9.1% patched.
    • The GDN split is dropped.
    • The eager figure is now 1.83 ms (GDN 1.46, sampling 0.24).
    • The DFlash B = 32 traced row is caveated and left out of every range.
    • DFlash B = 1 is -1.0%, and the validation counts read "at least 8,192".
  7. Timing design. The text states the pairs are sequential, and the DFlash gain is called unconfirmed. "At least four times the larger window SD" checks out (B = 32: 0.453 against 0.109). The Triton bench points carry their foreign_cpu_max. hold_mtp.sh now runs patched before stock, forming an A-B / B-A pair with hold 2, and runs tests/test_hostgap_plan.py first.
  8. Public text. "The brief" and "my own" are gone. The README says tests/test_hostgap_plan.py has not run on a GPU yet.

Also verified

  • Patch trees. git am onto bd66ce343e gives 94d6c95bc1 (0003), ee426e8df4 (0004, tree unchanged by the reworded message) and 47e10025d1 (0005).
  • 0005 is correct. Stock plan() sets disable_split_kv to _nvfp4_kv_requires_disabled_split_kv(kv_data_type) when the caller passes False, which SGLang's verify does. So fast_verify_plan now matches it, with no change for BF16 KV.
  • cycle_profiles.json. All 2,352 leaf values of the 5b62d27 version are identical in the regenerated file. The new generated_by names 7e42b57, which contains the summarize.py changes. Per-label provenance records clean trees, commits, flag environment and launch command, with no hostname.
  • Checks. Pre-commit passes on the changed hostgap files. The new commits are by Samuel Mausberg, with no AI lines. The hostname check is clean over the tree, git log -p 5b62d27..e1dc80f and the PR text.

Suggestion (non-blocking). The one cudaStreamSynchronize per cycle left under call_begin_forward (0.21 ms at B = 128) is now named, but its source is not yet identified. Finding it would complete "no blocking reads remain on the planning paths".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: e1dc80f176

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE (confirmed on e1dc80f)

Codex finished its review of e1dc80f with no findings: the summary reads "Completed", it reacted with a thumbs-up, and it left no inline comments on this head. The head is unchanged, so my approval stands.

The remaining cudaStreamSynchronize is now explained: FlashInfer's _compute_page_mask_indptr assigns mask_indptr[0] = 0, a 4-byte copy from pageable memory. 0004 is expected to remove it, which hold_mtp's patched traces will test. If the README changes for that, the head moves and I will re-check.

@SamMausberg
SamMausberg merged commit 02a9803 into main Oct 1, 2026
SamMausberg added a commit that referenced this pull request Oct 1, 2026
Fold in evidence/hostgap/ as its README scopes it. The untraced stock idle
is derived (1.44-1.79 ms per tuned MTP cycle, 21% at B = 1 to 9% at 128;
1.36-1.46 ms for DFlash block 8). Patches 0001-0003 keep plans, attention
output bits and greedy outputs equal to stock in the same configuration
(192/192 requests per arm at c = 1, 8, 32, top-k 1 chains, radix off).
The MTP cycle shrinks 2.7-4.8% in held batches, 13-16% of the idle at
B = 1-8, 27-35% at 32-64 and 55% at 128, from sequential (not
interleaved) pairs; the DFlash gain is unconfirmed. Patches 0004-0005,
the serving A/B and retaken stock traces are pending (hostgap-served).

Adds the hostgap register entry and pins-table series, the System
overheads row of the levers table and the H6 status row.
SamMausberg added a commit that referenced this pull request Oct 1, 2026
Fold in evidence/hostgap/ as its README scopes it. The untraced stock idle
is derived (1.44-1.79 ms per tuned MTP cycle, 21% at B = 1 to 9% at 128;
1.36-1.46 ms for DFlash block 8). Patches 0001-0003 keep plans, attention
output bits and greedy outputs equal to stock in the same configuration
(192/192 requests per arm at c = 1, 8, 32, top-k 1 chains, radix off).
The MTP cycle shrinks 2.7-4.8% in held batches, 13-16% of the idle at
B = 1-8, 27-35% at 32-64 and 55% at 128, from sequential (not
interleaved) pairs; the DFlash gain is unconfirmed. Patches 0004-0005,
the serving A/B and retaken stock traces are pending (hostgap-served).

Adds the hostgap register entry and pins-table series, the System
overheads row of the levers table and the H6 status row.
SamMausberg added a commit that referenced this pull request Oct 1, 2026
Appendix E: blocking reads removed from attention planning (#120)
SamMausberg added a commit that referenced this pull request Oct 2, 2026
Sync TASKS.md with #45, #52, #91 and #120-#168; measured, derived and open per hypothesis
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