Skip to content

gpu, gpu-gates: Bolt's prompt runs as batched passes (nemotron_h_moe prefill) - #328

Closed
midagedev wants to merge 14 commits into
mainfrom
bolt-prefill-g1
Closed

midagedev wants to merge 14 commits into
mainfrom
bolt-prefill-g1

Conversation

@midagedev

@midagedev midagedev commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Bolt (nemotron_h_moe) batched prefill

Before this change, Bolt ran its prompt as decode steps, about 81 tok/s on the A6000. Now a prompt runs as layer-major passes of up to 448 ids:

  • Embed: one Q8_0 embedding launch for the whole pass.
  • Mamba-2: each layer runs one enqueue_steps scan over the pass's rows, bit for bit the steps' scan.
  • Attention (GQA16): the pass's K/V rows are appended to the planes, then the group-16 flash runs in runs of MAX_PASS_ROWS.
  • Latent MoE:
    • router rows: two launches for the whole pass;
    • routed up / ReLU² / down over the pass's 9·m slots;
    • shared expert over m slots;
    • the weighted sum, then latent up.
  • Projections:
    • up to 8 rows: the family's multi-column gemv (also the verify arm);
    • past 8 rows, Q8_0 sites: gemm32 on the rows' q8 blocks of 32, over a dense one-expert route;
    • past 8 rows, NVFP4 sites: the same GEMM over a Q8_0 twin of the weight, requantized on the host at load. That costs about 4.7 GB more resident (derived).
  • Experts: the grouped IQ2_XXS GEMM when the build has the entry (G1), otherwise _sel.
  • Callers: the serve seat, gate_nemotron_serve and generate_qwen3moe (--prefill auto) now run Bolt prompts through prefill.
  • Gate: gate_nemotron_h_moe_e2e gains prefill_near_mainlines(_real) and prefill_then_step_near_mainlines(_real).

Change class: float sum order / precision. A pass past 8 rows reads q8 blocks of 32 at its Q8_0 and NVFP4 sites, so it is held to mainline (cosine floor), not to the step path's bits.

Stacked on #327 (the grouped GEMM's IQ2_XXS entry, d63973f5): this branch is bolt-prefill (39fff4df) rebased onto it. Without #327, the experts take _sel.

GPU Evidence

All runs go through the box queue (tools/box.sh, BLOOMERY_BOX_QUEUE=1).

  • Real Bolt, A6000. Command: generate_qwen3moe --prompt <729 ids> -n 24 --prefill step|auto (--prefill auto is the default).

    • f706328 (this branch): loads as load arch=nemotron_h_moe resident_bytes=27414672948 ctx=4096 slots=1 layers=88 graph_nodes=1084 in 8.8 s. The plan is rows:448 x2, and the tokens equal the step arm's: [1010, 1784, 6330, 1307, 1278, 16194, 37691, 19570, 1454, 1278, 34059, 2274, 24806, 4837, 2246, 28462, 1044, 7654, 19797, 2455, 1321, 95254, 1455, 9523].
    • 39fff4d (_sel experts): the same load line, the same 24 ids.
  • Fixture tier at 177f5ae (before the GEMM arms; just gate-gpu-nemotron-h-moe-e2e and -serve, BLOOMERY_TIER=fixture):

    • gate_nemotron_h_moe_e2e PASSED, with 8 clauses run and 3 left to the real tier.
    • gate_nemotron_serve PASSED, with the seat running the batched prefill.
  • Real-tier gate_nemotron_h_moe_e2e at 39fff4d, the tree under this PR with _sel experts (A6000): rc 1, one clause red.

    • PASS: the routing, logits and top-1 mainline clauses.
    • PASS: prefill_near_mainlines_real, 10 of 10 prompts, e.g. prose512 … cosine 0.999992, code4096 … cosine 0.999937, prose64 … cosine 0.999875 (floor 0.999).
    • FAIL: prefill_then_step_near_mainlines_real, 9 of 10. The red prompt:
      prose64 64 tokens, argmax 2082 mainline 2082 step 2082, cosine 0.997937 (floor 0.999), max |delta| 2.5779; the step path's cosine 0.999401, max |delta| 0.6988 FAIL.
      • Not a pass-shape fault, by the other rows: prose512 runs 448 + 63 rows then a step and passes, cosine 0.999993.
      • prose64 is the set's near-tie prompt: on the step path alone, 3 of 40 MoE layers cross mainline's pick at the cut (layers 3, 23 and 61).
      • A crossing on the pass + step state is the suspected cause. Not yet shown: a diagnostic run is queued that prints the layers keeping mainline's experts per path.
      • The floor is not relaxed. That run decides it.
    • The real tier now takes 806 s, past 0.75× of the 900 s bound. Corrected: the binary ran 131 s (gpu-gate.sh: gate_nemotron_h_moe_e2e ran 131 s (exit 1)). The 806 s is the item's wall time, box queue wait and build included. gate-batch's budget check reads that wall time, so it refused a rerun without --over-budget-ok.
  • Real-tier gate_nemotron_h_moe_e2e on f706328, this PR's head with gpu: the grouped GEMM takes IQ2_XXS stacks (Bolt prefill experts) #327's grouped experts (A6000): PASSED, rc 0.

    • clauses: 10 ran, 0 left to the real tier; gpu-gate.sh: gate_nemotron_h_moe_e2e ran 105 s (exit 0).

    • prefill_near_mainlines_real: 10 of 10 prompts gated PASS, with prose64 at cosine 0.999920.

    • prefill_then_step_near_mainlines_real: 9 of 10 prompts gated PASS; prose1 has no pass before its step.

    • Per prompt, cosine on this path / on the step path:

      Prompt This path Step path
      code5 0.999988 0.999988
      code29 0.999999 0.999998
      code4096 0.999980 0.999928
      prose64 0.999466 0.999401
      prose255 0.999996 0.999995
      prose256 0.999982 0.999993
      prose257 0.999970 0.999963
      prose512 0.999994 0.999996
      prose1024 0.999992 0.999998
    • prose64 clears the floor once the experts change their sum order: 0.997937 with _sel at 39fff4d, 0.999466 here. That fits the near-tie explanation, but the diagnostic run is what shows it.

  • Real-tier gate_nemotron_h_moe_e2e at the head 1986367 (room-gated twins, restacked on gpu: the grouped GEMM takes IQ2_XXS stacks (Bolt prefill experts) #327 c0d5fb3):

    • A6000 (twins on): PASSED, rc 0, clauses: 10 ran, 0 left to the real tier; gpu-gate.sh: gate_nemotron_h_moe_e2e ran 107 s (exit 0).
      • prose64: cosine 0.999920 on the prefill path, 0.999466 with a step after. These are f706328's lines, unchanged.
    • RTX 3090 (resident_bytes=22757815860, no twins, so the NVFP4 sites run the 8-column gemv): rc 1, ran 116 s (exit 1). Both prompt-path clauses are red on one prompt, prose64:
      • prefill_near_mainlines_real: prose64 … cosine 0.998342 (floor 0.999), max |delta| 2.7192 … FAIL;
      • prefill_then_step_near_mainlines_real: prose64 … cosine 0.997558 (floor 0.999), max |delta| 2.6105 … FAIL.
      • The other nine prompts pass the floor on both clauses. The routing, logits and top-1 clauses pass.
      • Open, and it blocks this PR. prose64 is the near-tie prompt: on the step path alone, layers 3 and 23 cross mainline's pick at the cut (gap/band 0.008, 0.052).
      • The floor is not relaxed. Models is adding a first-divergence classification to the gate. G5 replaces the 3090's gemv arm with the GEMM the A6000 runs.
  • Fixture e2e at 39fff4d (BLOOMERY_TIER=fixture, A6000): PASSED: gate_nemotron_h_moe_e2e, clauses: 10 ran, 5 left to the real tier.

    • Both prompt-path clauses: 4 of 10 prompts gated PASS, e.g. prose512 … cosine 0.999569 (floor 0.999) … PASS.
    • The other six prompts cross mainline's pick at the cut on one path or the other, so they are printed, not gated.
    • Among those, prose64 stands out: the prefill path gives cosine 0.819054 where the step path gives 0.999514. It is the same prompt that is red on the real tier, so the queued diagnostic run covers it too.
  • FAIL-first mutant at 39fff4d, fixture tier: one line in prefill.rs makes the head read the pass's row 0, (m - 1) * sh.hidden * f → 0 * sh.hidden * f. Result: red=1.

    • prefill_near_mainlines goes red: 4 of 10 prompts gated FAIL, e.g. prose512 … cosine 0.113264 (floor 0.999) … FAIL, with the gated cosines 0.06–0.11.
    • prefill_then_step_near_mainlines stays green, as expected: its last row runs as a step, which never reads the pass's head row.
  • Speed at the head 1986367 (perf; one lease per card, 2 rounds; llama.cpp -ngl 99 -fa on -ub 512 in the same lease):

    Card Arm pp tok/s @ P=512 pp tok/s @ P=4096 decode @ d512 decode @ d4096
    A6000 (s1730) this PR 938.26 989.04 82.07 81.37
    A6000 (s1730) llama.cpp 1549.84 1603.37
    RTX 3090 (s1729) this PR 495.62 501.45 81.79 (r1) 80.54 (r1)
    RTX 3090 (s1729) llama.cpp 1354.70 1374.99
    • The 3090 holds no Q8_0 twins (24 GB). Its NVFP4 sites run the multi-column gemv inside the passes.
    • Not yet at the release line: 0.61× of llama.cpp on the A6000 and 0.37× on the 3090. The work still to come is in "Not in this PR yet" below.
  • Speed: perf's same-lease A/B (box job s1700, A6000, one lease, card bolt-e1-pp-a6000, 2 rounds, 0 FAIL rows; the numbers are as perf reported them).

    Arm pp tok/s @ P=512 pp tok/s @ P=4096
    main d0e8a8e (step) 81.08 80.44
    39fff4d (_sel experts) 330.48 [329.52..331.43] 327.07
    f706328 (this PR) 927.19 [926.74..927.64] 971.66 [971.46..971.87]
    • f706328 is 11.4× main at 512 and 12.1× at 4096 (ratios derived from the rows).
    • Decode is unchanged on every arm: 80.8–81.1 tok/s @ depth 512, 79.9–80.4 @ depth 4096, graph nodes 1084.
    • Derived bands against measured: 39fff4d measured below its derived 500–1000. f706328 is inside its 800–1600 and above the ≥820 target.
    • The term that was wrong: the per-slot _sel expert cost, which is larger than derived. Removing it accounts for most of the 2.8× from 39fff4d to f706328.

Not in this PR yet (the release line: pp ≥ llama.cpp on both cards, offload measured)

  • G5: an NVFP4 arm in gemm32 from the resident planes, with no twins (a GLM round, running). It is the 3090's lever.
  • The by-site nsys at P=4096 on both cards (perf, s1733/s1734), which prices the A6000's remaining 1.65×.
  • The offload row: Bolt's host expert tier (--n-cpu-moe equivalent). Its design is in bolt-host-tier-boundary.md. B1 (the 9-slot handoff and the card-only combine) is running; then B2 (placement), H1 (the host's relu² union) and B3 (the body).
  • prefill_edges: a clause across pass boundaries (models' GLM round).

Not in this PR

🤖 Generated with Claude Code

@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card labels Oct 16, 2026
midagedev and others added 3 commits October 16, 2026 20:34
gemm_iq2xxs decodes the file's 66-byte super-blocks through the IQ2_XXS
grid and the computed signs, keeps 2s + 1 an integer factor of the
block sum and scales by d/8 in the epilogue. gate_gemm runs a routed
top-9 stack and a ragged odd-super-block slab under the four routings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
midagedev and others added 11 commits October 16, 2026 20:47
The JIT scan (gate-ptx-spill on the 3090, sm_86) was red on exactly this
entry in both bins before the rows: spill=0 jit_local=0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
nemotron_h_moe::PASS_ROWS and GpuModel<Body>::prefill / prefill_with, the
surface the batched pass fills in; today each pass runs its ids as steps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A pass embeds its ids, runs each Mamba-2 layer as one scan over its
rows, appends the attention K/V rows and runs the group-16 flash in
runs of MAX_PASS_ROWS, routes the MoE rows in two launches and runs the
routed and shared experts as one _sel launch over the pass's slots.
Projections run their family's multi-column gemv in runs of 8 rows.
Each MoE layer's results are the pass's last row's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Several ids run GpuModel::prefill, one id a step, the Nano's split; the
serve gate's Bolt head feed is the same call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
--prefill auto (the default) and gemm run NemotronHMoeModel::prefill,
pass and step the step chain, the nemotron_h paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The latent pair and the attention projections run gemm32 on the rows'
q8 blocks of 32 over the pass's one-expert table, filled once a pass;
up to 8 rows they keep the multi-column gemv.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each NVFP4 projection gets a Q8_0 twin at load (its rows decoded times
the tensor scale, coded per 32 as quantize_row_q8_0), which a pass past
8 rows runs as one gemm32 on the rows' q8 blocks of 32. The routed and
shared experts take the grouped GEMM where the build has an IQ2_XXS
entry, else their _sel launches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
prefill_near_mainlines and prefill_then_step_near_mainlines, each a
fixture-oracle clause and a real-tier one: every prompt through prefill,
alone and before its last id as a step, keeps the cosine floor against
mainline's logits, the step path's distance printed beside.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A pass past 8 rows runs an NVFP4 site as a GEMM over its Q8_0 twin when
the twins were derived, otherwise as the multi-column gemv runs. The
twins are planned only when the card's room after the body's load holds
every twin and a 2 GiB margin, so a card the twins do not fit (the
3090's 24 GB) loads where main loads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
midagedev added a commit that referenced this pull request Oct 16, 2026
Baseline cards for the engine's g1c head (rebased onto #327 dd369dc +
the split): the derived P=512 row over g1b's measured rates, the per-row
gqa_flash_seg launch term (0.90 s A6000 / 1.06 s 3090 at P=4096, nsys
s1733/s1734) replaced by 48 enqueues a pass-layer.

Co-Authored-By: Claude Code <[email protected]>
midagedev added a commit that referenced this pull request Oct 16, 2026
Baseline cards for the engine's g1c head (rebased onto #327 dd369dc +
the split): the derived P=512 row over g1b's measured rates, the per-row
gqa_flash_seg launch term (0.90 s A6000 / 1.06 s 3090 at P=4096, nsys
s1733/s1734) replaced by 48 enqueues a pass-layer.

Co-Authored-By: Claude Code <[email protected]>
midagedev added a commit that referenced this pull request Oct 16, 2026
midagedev added a commit that referenced this pull request Oct 16, 2026
Baseline cards for the engine's g1c head (rebased onto #327 dd369dc +
the split): the derived P=512 row over g1b's measured rates, the per-row
gqa_flash_seg launch term (0.90 s A6000 / 1.06 s 3090 at P=4096, nsys
s1733/s1734) replaced by 48 enqueues a pass-layer.

Co-Authored-By: Claude Code <[email protected]>
midagedev added a commit that referenced this pull request Oct 16, 2026
@midagedev

Copy link
Copy Markdown
Owner Author

Superseded by #396 (the same stack carried to main 753df0a, with the NVFP4 sites on the real nvfp4p GEMM and the Mamba-2 prompt scan rewritten).

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

Labels

gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant