Skip to content

gpu: Bolt prompt path — the nvfp4p GEMM, the barrierless Mamba-2 scan, the relu_sqr fold, the common router, -ub - #400

Closed
midagedev wants to merge 36 commits into
mainfrom
bolt-r7
Closed

midagedev wants to merge 36 commits into
mainfrom
bolt-r7

Conversation

@midagedev

Copy link
Copy Markdown
Owner

Bolt's prompt path: NVFP4 on the card, the Mamba-2 scan, the relu_sqr fold, the common router

Supersedes #396 and #328 (this branch is #396's bolt-r6 plus the five commits below; #396's branch is that stack carried to main 753df0aea, with the NVFP4 sites moved from the host-requantized Q8_0 twin to the real NVFP4 GEMM, and the Mamba-2 prompt scan rewritten).

What

  • Prompt API and passes (4ad7c3f40…38e171e6a): a prompt runs as layer-major passes of up to 448 ids; the serve seat, gate_nemotron_serve and generate_qwen3moe run Bolt prompts through prefill.
  • Q8_0 sites past 8 rows (5f875eb61, 943a70bff, 92a075c0e): one gemm32 over the rows' q8 blocks, the prompt path held to mainline (cosine floor).
  • The NVFP4 sites run the nvfp4p GEMM (f610d4833…ebd61fb36): Gemm32Weight::Nvfp4Planes and its entries; the host-requantized Q8_0 twin stays only when the card's room does not hold the planes (5ffec9012); gate_gemm gains the dense and routed NVFP4-plane cases, the short-qs/short-e/NaN-scale refusals and the unsafe pin (e380321a6, 32c79abab); ptx shapes pinned at 0/0 (f639ea1c2).
  • Prompt attention (c22698b5a): the prefill flash's split entry.
  • The Mamba-2 prompt scan (447ee18e5…25ba0f7ea): no per-token barrier — a conv pre-pass and T=8 staging; the scan stages z and holds seven blocks an SM; the y-reduction keeps one transpose-reduce across the four channels for mamba2_steps (prefill, 874f344ad restored by 25ba0f7ea with the dated clause-7 exception), while the decode mamba2_step keeps the per-channel xor butterfly (2c7719e85), which ptxas holds at spill 0 / jit_local 0.
  • The squared ReLU folds into the q8_1 quantize launches (d18261da8, 99cc33d36, 32c79abab): q3k_quantize_q8_1_relu_sqr with the fused path bit-identical to the split planes; gate clause plus a FAIL-first mutant.
  • The wide router scores share the common f32_tile_gemm (77ff640aa, 47a14898d): every family, with the ptx-shape rows moved with it.
  • Kernel entry lint (873018b17): the flat-argument allow with its reason on the quantize/gemv entries.

Per-commit summary

4ad7c3f40 gpu: Bolt's prompt API, passes of up to 512 ids run as steps
6d0617da6 gpu: Bolt's prompt runs layer-major passes of up to 448 ids
236d205e7 gpu-gates: the Bolt seat's prompt runs the batched prefill
38e171e6a gpu-gates: generate_qwen3moe runs a Bolt prompt by its prompt call
5f875eb61 gpu: a Bolt pass past 8 rows runs its Q8_0 sites as one GEMM
943a70bff gpu: a Bolt pass past 8 rows runs its NVFP4 sites as Q8_0 GEMMs
92a075c0e gpu-gates: the Bolt e2e holds the prompt path to mainline
cbee6724e gpu: a Bolt NVFP4 site's Q8_0 twin is filed under a derived. name
91e1d6170 tools: the Bolt prefill's load-time requant spawn is listed, pending triage; cargo fmt
5ffec9012 gpu: Bolt's NVFP4 twins are derived only when the card's room holds them
f610d4833 gpu: Gemm32Weight::Nvfp4Planes and the nvfp4p entries
e380321a6 gpu-gates: the gemm_nvfp4p gate — dense and routed NVFP4-plane cases, refusals, the unsafe pin
f639ea1c2 tools: pin gemm_nvfp4p's ptx shapes at 0/0 in generate_ds41 and gate_e2e
ebd61fb36 gpu: Bolt's prefill runs its NVFP4 sites as the nvfp4p GEMM
c22698b5a gpu: Bolt's prompt attention runs the prefill flash's split entry
447ee18e5 gpu: Mamba-2 prompt pass without a per-token barrier — conv pre-pass and T=8 staging
667128b5e gpu: the Mamba-2 prompt scan stages z and holds seven blocks an SM
874f344ad gpu: the Mamba-2 y-reduction shares one transpose-reduce across the four channels
d18261da8 gpu: the squared ReLU folds into the q8_1 quantize launches
99cc33d36 tools: pin q3k_quantize_q8_1_relu_sqr's ptx shapes at 0/0
77ff640aa gpu: every family's wide router scores run the common f32_tile_gemm
47a14898d tools: the router scores rows move with the wide path to f32_tile_gemm
32c79abab gpu-gates: gate_gemm covers the squared-ReLU quantizer fold and uploads the nvfp4p short planes truncated
873018b17 gpu: the quantize and gemv kernel entries carry the flat-argument allow
eaf975078 gpu-gates: gate_mamba2 runs the prompt pass at head_dim 72
2c7719e85 gpu: the Mamba-2 kernels drop the transpose-reduce, back to the per-channel xor butterfly
25ba0f7ea gpu: the Mamba-2 pass keeps its transpose-reduce, the step its butterfly

Evidence so far

  • Static, on the branch head 25ba0f7ea: box just check rc 0; just mac-fmt-check rc 0; tools/check-unsafe.sh ok — 28 crates, 2909 blocks, 398 fns (every pin the rebase re-derived carries PIN(2026-10-17); gpu 1908/207 and gpu-deepseek41 385 are the measured values).
  • gate_mamba2: clause 7's no-local-depot check holds with one dated exception (mamba2_steps alone, the pass's transpose-reduce, 1/8 — PIN(2026-10-17)), FAIL-first from the strict clause red before the exception; the head_dim-72 clause is a host-twin comparison, steps and pass each bit-identical 13/13; the hd-round16 geometry mutant KILLED on the final shape.
  • gate_gemm: the relu_sqr clause compares the fused q8_1 planes with the split quantizer bit for bit (K 768/2048 x cols 1/8/64/4096) and refuses NaN blocks; the relu-sqr-square mutant KILLED; the nvfp4p refusals cover a K-mismatched act and short qs/e planes and a NaN scale.
  • ptx shapes: gemm_nvfp4p and q3k_quantize_q8_1_relu_sqr pinned at spill 0 / jit_local 0; the router rows moved with f32_tile_gemm in tools/ref/ptx-shapes.tsv.

Added on bolt-r7

f84e317f8 gpu: -ub sets the prompt pass size through one common chooser
c6cf1c382 ref: bin_arms_distinct checks only bin: arms   (main 528fc08a2)
c3c038b5d lint: clear 35 clippy warnings; the ratchet goes 41 -> 33   (main c69c033c4)
e3a35bee5 tools: ptx-compare's cold-run clause reads TMPDIR without its trailing slash   (main bbcdac326)
49a2bf3af tools: the per-arch shape tables drop the three router_scores rows
  • -ub: crates/gpu/src/model/fit.rs owns the arena fit rule that the Qwen3.5 ubatch arena and the Bolt prefill pass buffers both use; each family keeps its candidate sizes and need function. bloomery-serve takes -ub/--ubatch-size; generate_qwen3moe takes --pass-rows.
  • Static on 49a2bf3af: just remote-static origin/bolt-r6 lint 32 (ratchet 33), check-ptx-names ok; check-recipes red only on tools/review/local.py --self-test (a 20 s wait for a child pid under the second Mac's load; 3 of 3 green on a re-run, not touched by this branch).

GPU Evidence

  • Release batch on 25ba0f7ea (fixture tier, both cards): DONE total=150 red=4 wall=2249s. The four reds are environment: gate-gpu-gemma4a (mmproj file absent on the box), gate-gpu-qwen38-nodes-remote (BLOOMERY_TIER_NODES empty), gate-gpu-nemotron-serve and gate-gpu-nemotron-e2e (rc 66, no Nano fixture).
  • The -ub change on its own tree: gate-gpu-nemotron-h-moe-e2e green in the fixture and real tiers on both cards; just canon-check 895/895 entries the same program.
  • The bolt-r7 head batch and the prefill numbers follow in a comment.

Written by a bot (Claude agent) for the maintainer.

🤖 Generated with Claude Code

midagedev and others added 30 commits October 17, 2026 13:11
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]>
… refusals, the unsafe pin

The kernel entry landed one commit below (WIP finished on the Mac). This adds
its gate on the g32 family's model: g32_nvfp4_dense over Bolt's two NVFP4
projections' shapes (ssm_in 18560x4096, ssm_out 4096x8192) and 128 rows at
both K for 1, 9, 64 and 448 columns, and g32_nvfp4_routed under uniform and
same-expert routings with an id past the stack (refused slots NaN, the rest
the clean run's bits); every output inside gamma(2K/32 + 4) of the f64
reference (ggml's dequant_row x scale against the dequantized q8 column) and
bit for bit gemm32::dot32_nv, the new one-owner host transcription of the
module doc's contract; a rerun and a graph replay bit-identical. The
reference check generalizes to a dot closure (check's four call sites pass
row_dot; the band's rounding count moves to the caller). g32_refuse gains
the four NVFP4 refusals (K not a multiple of 64, a short qs, a short e, a
non-finite scale). unsafe-ratchet: gpu 1863 -> 1865 blocks, the nvfp4p relays
of w32! (each with its SAFETY line).

Clean run: gate_gemm --case nvfp4 PASS on the 3090 (all 29 case lines, band
worst 0.022, bits 0, refused [5, 9]).

Co-Authored-By: Claude Code <[email protected]>
The add-class proof's last piece: just gate-ptx-spill was red on exactly the
two unpinned rows (measured spill=0 jit_local=0 on both, the family's every
other entry all zeroes too) and is green over the pinned table on a rerun —
generate_ds41 333/333, gate_e2e 266/266, gate_qwen3vl_tower 16/16, violations 0.

Co-Authored-By: Claude Code <[email protected]>
A pass past 8 rows runs every NVFP4 site (ssm_in, ssm_out) as the
32-value GEMM over its resident NVFP4 planes (Gemm32Weight::Nvfp4Planes,
#342), the twin Q8_0 derivation dropped: no card derives twins at load,
and the 8-column gemv runs the sites were falling back to are half the
P=4096 prefill (nsys s1927). The GEMM arm no longer reads the card's
room.

Co-Authored-By: Claude Code <[email protected]>
The pass's whole row set in one enqueue_split (the group of 16 as two
group-of-eight sub-group launches), in place of the MAX_PASS_ROWS loop of
plain group-16 passes. The sub-group scratch (rows × n_kv × GROUP × HEAD
f32 ×2) joins PassBufs at load and resident_bytes; Body loads
FlashGqaPrefill once beside the trunk's flash.

Co-Authored-By: Claude Code <[email protected]>
…and T=8 staging

mamba2_conv_rows, one fully parallel launch, writes every token's conv
outputs (conv_out, the step's exact taps and sum order, now one
(token, head)'s σ and dA into Mamba2PassScratch, so no block of the scan
recomputes its group's channels again. mamba2_steps reads the scratch and
stages STAGE_T = 8 tokens double-buffered — 2 · 8 · 274 · 4 = 17 536 B of
static shared memory, five blocks an SM at sm_86's 100 KB — so a token is
a barrier only each eighth; the staging loops are not unrolled (the
unrolled index arithmetic pushed the scan to the register cap, measured by
ptx-scan; regs 96 as pinned). The scan's per-token operations, their order,
the fault rule and the single state store are unchanged, so the pass stays
bit for bit u steps. enqueue_steps is conv_rows, steps, ring_tail and, with
a gain, norm_rows: three or four launches. StepsArgs gains the scratch; a u
past its max_u and a scratch of another shape are refused by name, read
before the buffer lengths so a short rows cannot mask them. The Nano
prefill owns its scratch at load; the Bolt prefill gets the minimal wiring
the engine's cherry-pick supersedes. gate_mamba2 stages the boundary
lengths u ∈ {T−1, T, T+1, 2T+3}, pins the captured pass at four nodes and
the two scratch refusals; ptx-shapes.tsv and unsafe-ratchet.txt pin
mamba2_conv_rows.

Co-Authored-By: Claude Code <[email protected]>
mamba2_steps read z from global memory once per (token, channel), after the
shuffle chain, and 89 registers with 17.5 KB of stage capped the SM at five
blocks: a 512-block grid ran in 1.25 waves. z now stages with B, C, x, sigma
and dA; STAGE_T 8 -> 5 brings the stage to 11.6 KB; launch_bounds(128, 7)
with a register diet (one state-row index a warp, 32-bit channel predicates
and stage walk) gives 72 registers, spill 0, seven blocks an SM: one wave on
84 SMs. Every output bit is unchanged (gate_mamba2 bit for bit; the Bolt e2e
prefill and step lines byte-equal on both cards). Also documents the sigma/dA
load's unsafe block, which clippy refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…our channels

Both scan sites (the prompt pass and the staged step) ran the xor
butterfly per channel — five shuffles a channel, twenty a warp. The four
channels now share one tree: two shuffle-downs at 16 and 8 halve each
channel's partials, a gather puts channel c's halves on lanes c*8 ..
c*8+7, and the xor 4, 2, 1 quarter sums each group, so every lane of
group c holds channel c's total and the group's first lane stores its y
(fifteen shuffles a warp). The pairing tree is the xor butterfly's,
value for value — proven bit-equal on 10^6 random and adversarial
accumulator sets in exact f32 — so every y, the state and the ring keep
their bits; the collectives now sit outside the channels' liveness
guards, and the y phase re-reads z's staged value in its own unsafe
block (ratchet 1878 -> 1879).

Co-Authored-By: Claude Code <[email protected]>
The relu_sqr elem pass over each up buffer (four sites of the prompt
pass, the step path's slots and shared expert) is folded into the
quantizer that read the buffer next: q3k_quantize_q8_1_relu_sqr
applies elem's relu_sqr rule to each value inside its load, through
q8_1_quant_block_relu_sqr, and the f32 activation buffers between the
two (PassBufs' act/sh_act, MoeScratch's act/sh_act) are gone. The
plain entries keep their signatures (an underscore core holds the
launcher both share); bit for bit, the squared ReLU rule is the elem
kernel's, value for value, and the q8_1 form of a transformed value is
the form the buffer pass produced.

Co-Authored-By: Claude Code <[email protected]>
The relu_sqr-fold quantizer's entry in generate_ds41 and gate_e2e,
pinned from the scan the fold landed on (spill 0, jit_local 0, both
bins; the tower bin gains no entry).

Co-Authored-By: Claude Code <[email protected]>
The batch score launch of each router instance (nemotron's five, glm5next,
mimo2 through the shared instance macro, deepseek41's own copy) computed
its scores as per-(token, expert) f32 gemvs, eight a tile, re-reading the
router rows once a token tile and the activations once a row tile. The
wide path now runs them all as one F32 tile GEMM — the common
f32_tile_gemm, whose contract is bit for bit f32_gemv's, and whose lane
walk (f32_lane_partials) and warp tree (gemv_lane_sums) are the same code
the score bodies ran — followed by the score's scalar over the logits in
place (elem's sigmoid_rows, softplus_rows for deepseek41's
sqrt_softplus); the pick launch is unchanged. The five scores entries,
scores_body and deepseek41's inline copy are gone; the instances' launch
plumbing carries the gpu and wide handles the tile call needs.

Co-Authored-By: Claude Code <[email protected]>
The thirteen *_scores entries the scans no longer print (eight of
generate_ds41, five of gate_e2e) leave the table, and elem's
sigmoid_rows and softplus_rows — the score scalars the wide path writes
over the tile GEMM's logits — pin at 0/0 in both bins.

Co-Authored-By: Claude Code <[email protected]>
…ds the nvfp4p short planes truncated

The relu_sqr case pins the fold's contract (step 2's coverage gap, whose
square-drop mutant survived every e2e floor): enqueue_quantize_gemm_relu_sqr
bit for bit enqueue_relu_sqr then enqueue_quantize_gemm at K 768 and 2048
for 1, 8, 64 and 4096 columns, the scales and code sums the host
transcription gives from the transformed rows, the transform itself each
value's f32 bits, and a NaN input the named QuantColumn fault with its
block refused. FAIL-first: relu-sqr-square (r*r -> r) reds the case's
planes and host checks, clean green (mutant-run, 1 killed).

The gemm_nvfp4p short-plane refusals (e61be01) upload their leading
columns instead of full data at a shrunk cols, so the refusal tested is
the gemm's, not upload's length check (it exited 1 before the clause:
data.len() 1536 != rows*cols = 32*47).

Co-Authored-By: Claude Code <[email protected]>
Five #[kernel] entries (q3k_quantize_q8_1, its relu_sqr fold, q6k_gemv,
q3k_gemv, q5_quantize_q8) were missing the too_many_arguments allow every
other flat kernel entry in these files carries: the launch ABI is flat by
cuda_module's contract (rust-quality R8, the reason line names it). The
host-side enqueue wrappers left warning in elem.rs and q5.rs are the
argument-struct round's.

Co-Authored-By: Claude Code <[email protected]>
head_dim 72 (576 as 8 heads of one group) is the geometry where a head's
channels are not a multiple of the staging block: the pass's staged z and x
hold masked channels, and channel_live is load-bearing at the reads (the y
and state stores stay in bounds only because of it). The gate's machinery
(weights, tokens, Dev, both runs) now takes a Shape derived from the Geom;
every existing case runs at MAIN (= GEOM, bits unchanged) and one new
clause runs a warmed pass of 2*STAGE_T + 3 rows against as many steps,
bit for bit.

FAIL-first: hd-round16.patch (channel_live's bound rounded down to the
staging block, < head_dim & !15) is behaviour-preserving at head_dim 80
and leaves y holding the poison at channels 64..71 of every head here.

Co-Authored-By: Claude Code <[email protected]>
…hannel xor butterfly

The transpose-reduce (fc114f6) carried local depot into both mamba2_step
and mamba2_steps (gate_mamba2's shape clause: ld_local=1 st_local=8 each;
the tsv pins 0/0). Every kernel keeps its contract of no local memory:
both y-reductions return to the per-channel five-shuffle xor butterfly,
bit for bit the same pairing tree, and the unsafe ratchet goes back to
1878 with fc114f6's pin line.

Co-Authored-By: Claude Code <[email protected]>
7c69607 dropped the transpose-reduce from both kernels to close the
local-depot red it carried. The lead's call (11:4x): the prefill pass is
where the shared reduction tree pays, the decode step is not — so this
restores fc114f6's mamba2_steps (prefill) alone; mamba2_step (decode)
keeps the per-channel five-shuffle xor butterfly of 7c69607, bit for
bit the same pairing tree.

mamba2_steps's PTX-level local use is pinned, not hidden: gate_mamba2's
shape clause holds it to exactly depot with ld_local 1, st_local 8
(PIN(2026-10-17); FAIL-first: the strict no-local-depot clause reds on the
restored tree before the exception) while the other three entries stay at
zero. The JIT columns ptxas measures stay 0/0 for both kernels (the scan
on gate_e2e: mamba2_steps spill 0, jit_local 0; mamba2_step 0/0), so
tools/ref/ptx-shapes.tsv is untouched — the regression nvf4occ measured
(jit_local 16) was the decode kernel's alone, and the revert closed it. The gate's head_dim 72 clause is rewritten against the host twin
(both the steps and a past-two-stages pass), so a defect one kernel alone
carries cannot hide behind a matching one in the other — the symmetric
pass-vs-steps form could. The unsafe ratchet returns to 1879 with the
steps-only attribution.

Co-Authored-By: Claude Code <[email protected]>
model/fit.rs owns the arena fit rule the Qwen3.5 ubatch arena and the Bolt's
prefill pass buffers both ask; each family keeps its candidate sizes and need
function. bloomery-serve takes -ub/--ubatch-size as llama-server spells it,
and generate_qwen3moe takes --pass-rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A plain ours arm carries the ours binary in A_BIN too, so the guard refused every run
that had one, on its own sha and tree (the r6 sitting's first submit, exit 64 before the
lease). The guard now reads A_KIND and checks only kind=bin arms; the self-test cases set
A_KIND, and a new case holds a plain arm to pass.

FAIL-first: with the kind check removed, plain-arm-passes fails (rc 64, "lives in this
tree"); with it, the self-test is 18 checks, 0 failures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
as_chunks for the asserted-multiple chunk walks, iter_mut over the AVX2
accumulator arrays, a let chain, type aliases for two tuple shapes, and
fewer arguments in three gate helpers. No kernel moved: the narrow scan's
four pairs are identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
midagedev and others added 2 commits October 17, 2026 14:22
…g slash

macOS sets TMPDIR with a trailing slash; the base's ceiling is the dirname of
its temp dir, so the self-test compared ".../T" with ".../T/" and failed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The wide router scores moved to the common f32_tile_gemm; ptx-shapes.tsv
dropped their rows, the sm_86 and sm_121 tables beside it kept them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@midagedev midagedev 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 17, 2026
@github-actions github-actions Bot added host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja serve The HTTP server: crates/serve tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 17, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MUST_FIX: -ub is documented for bloomery-serve but nothing reads it, and two elements are not needed.

Must fix

1. serve::flag::UBATCH has no consumer; bloomery-serve -ub is not wired

crates/serve/src/flag.rs:18 is used only by its own test. bind.rs:485-499 has no arm for it, and no seat's own() reads it (Grep over crates/ finds -ub only here). bloomery-serve -ub 256 fails with unknown argument, while the PR body says serve takes -ub. The new test compares the constant with its own literals, so it guards nothing.
Cost: a dead constant plus a false claim, and the flag spelling gets fixed before any seat uses it.
Fix: delete UBATCH, its doc lines, the module-doc mention and the_ubatch_flag_takes_llama_servers_spellings. Or wire it: one arm in bind.rs and NemotronHMoeModel::open_with_pass_rows in the Bolt seat's open.

2. Two elements the change does not need

  • prefill.rs:394: Prompt::need only forwards to PassSizes::bytes. It has two callers (lines 270 and 474). Call sizes.bytes(rows) and delete it.
  • prefill.rs:695: GemmWeight::from_ggml(IQ2_XXS).ok() drops an Err that cannot happen (grouped.rs:186 always returns Ok). If the arm ever returns Err, a prompt of more than 8 rows fails later with "no q8_1 slot form of N columns", which does not name the cause.
let gemm = (m > COLS).then_some(GemmWeight::Iq2Xxs);

Non-blocking

⚠ Body::enqueue_pass is 228 lines (crapper: new, 46): prefill.rs:906. R12 allows two screens. The Mamba and attention arms are inline, while the MoE arm already lives in moe_rows. Move them to mamba_rows and attn_rows beside it.
⚠ The --pass-rows rule is written twice: generate_qwen3moe.rs:1603 and choose_pass_rows (prefill.rs:288). I kept the early refusal, since the load runs after the weights upload. Export one predicate from prefill.rs and call it from both.
⚠ History in comments: bin-label.sh:143 ("the r6 sitting's first run was…"). bolt-mamba-ncu.card:1,12,17 names "orca engine.md 04:2x", "r4 tree" and "lead 04:02", which a reader cannot resolve. check-comments.sh does not cover these files. State the test's intent and move the rest to the commit message.
⚠ Question for the author: the decode moe_layer now uses the fused quantize (moe.rs:353,375). That removes 2 elem launches per MoE layer per token, so it is a launch-count change on the decode step. Please add the gate run and the timed A/B on your card, with the nvidia-smi line and both hashes.

Optimization headroom

  • E. Less work: prefill.rs:1041-1043 project_rows re-quantizes the same buf.xn for q, k and v when m > 8 (WideActs::quantize does no dedupe). Quantizing once per norm output removes 2 launches per attention layer per pass.

Checked

  • Duplicates: about 30 new items checked. Hit: the --pass-rows rule (⚠). The fit.rs move removed the old copies of act_col_bytes, act32_col_bytes and route_bytes. Dryer found 0 pairs, and it did not search crates/gpu*, so I grepped by hand.
  • Complexity: enqueue_pass is the new function that is complex on its own (⚠). The relu_sqr_case and nvfp4_*_case gate cases and Prompt::new are linear setup. check (+8) and mamba2_steps (+6, a kernel body: read for correctness only) are even growth.
  • Silent failure: 9 sites followed (.ok(), unwrap_or(0) and max defaults on empty sets, the u32::try_from(..).ok() that errors by name). One finding (2). The Mamba and NVFP4-plane launch checks refuse by name.
  • Tests: largest_fit boundary test. A <= → < mutant turns it red at 399/400. The UBATCH test has no production line behind it (finding 1). The GPU gates were not run here.
  • Gates: pins moved with dated PIN(2026-10-17) and a reason: clause 7 for mamba2_steps, the ptx-shapes rows, unsafe-ratchet. The lint ratchet goes down 41 → 33.
  • Escape catalog: C1 to C4 checked in bin-label.sh and ptx-compare.sh. No match.

Notes

  • The PR body has no nvidia-smi line, no commit hashes with commands and output for the head 49a2bf3af, and no prefill numbers yet (the body says they follow in a comment). The -ub change was gated on its own tree only.

Card check: needs-gpu. This pull request changes crates/gpu-deepseek41/src/chain/ffn.rs, crates/gpu-deepseek41/src/chain/ffn/batch.rs, crates/gpu-deepseek41/src/router.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

TOP_K * 4096 slots still fit one route table and one GEMM form
(GEMM_MAX_SLOTS), so the const assert holds. The load-time chooser
still picks the largest pass that fits the card's room, so a smaller
card keeps smaller passes.

A6000, pp4096, n=6 (s2695): 2100.35 -> 2168.00 tok/s, one pass instead
of two. gate-gpu-nemotron-h-moe-e2e passed on that tree; its
prefill_pass_size_invariant clause holds the logits bit-identical
between pass sizes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the last review: the advertised serve flag still fails before model load (item 1). The new commit only raises PASS_ROWS_MAX; earlier design, comment and evidence requests concern unchanged code.

Verdict: MUST_FIX: the advertised -ub/--ubatch-size serve option is rejected.

Must fix

1. The advertised prompt-pass flag prevents server startup

The contract at crates/serve/src/flag.rs:18 and the PR body advertise both spellings, but neither reaches the parser or Bolt load.

Kind A failure path: with a valid Bolt model and supported driver, bloomery-serve --model nemotron -m <Bolt.gguf> -ub 256 reaches nemotron.rs:256, which calls SeatFlags::parse with an always-false callback. There is no common arm for either spelling, so bind.rs:497 returns unknown argument "-ub" before the model loads. The long spelling follows the same path. The spelling-only test never exercises this dispatch.

Cost: every attempted use of the advertised option fails at startup.
Fix: parse the existing UBATCH spellings and forward the requested rows through the Nemotron seat to Bolt's existing open_with_pass_rows; cover actual flag forwarding. If serve support is deferred, remove its unused declaration, documentation and spelling-only test, and retract the serve-support claim from the PR body.

Non-blocking

⚠ Larger-pass evidence: prefill.rs:69 doubles the ceiling. For a 4,096-token prompt with enough context and memory to select 4,096 rows, one pass replaces two 2,048-row passes: fixed per-pass launches halve, while buffers proportional to row count double [derived]. Add the owning e2e gate output showing pass_rows=4096 and a timed A/B for the larger launch geometry, with card/driver, both hashes, model, commands and output.

Checked

Duplicates/complexity: the incremental diff adds no function or type and changes no function body; diagnostics describe earlier commits.
Silent failure: no error handling changes.
Gates: 4,096 × 9 = 36,864 slots, exactly GEMM_MAX_SLOTS [derived]; the compile-time bound remains. No numeric tolerance changes.
Tests: the existing pass-size gate compares final logit bits and greedy IDs at full and half capacity. GPU gates were not run by this validator.
Adversarial: the load bounds pass rows by context and available memory.
Escape catalog: C1–C4 do not match the new diff.

Notes

The supplied PR body has no e2e gate or timed A/B output for the 4,096-row change.

Card check: needs-gpu. This pull request changes crates/gpu-deepseek41/src/chain/ffn.rs, crates/gpu-deepseek41/src/chain/ffn/batch.rs, crates/gpu-deepseek41/src/router.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

midagedev and others added 3 commits October 17, 2026 16:40
One launch per pass and layer: a block per head walks the pass in
32-token chunks, keeps the 64x128 state in registers in f32, and runs
C*S^T, the causal half of C*B^T, M*X and the state update as f16 mma
with f32 sums. The intermediates stay on chip, where llama.cpp's
chunk-256 path runs six launches and writes them to DRAM.

Added only: no engine caller yet. ptx-compare: added mamba2_ssd, no
entry removed or changed. gate-gpu-mamba2-ssd holds every y and the
final state within the derived f16 bound of an f64 twin of the scan
rule, bit-identical reruns, the non-finite fault and named refusals;
three mutants (chunk boundary, state carry, group index) are red on it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mamba2Kernels::enqueue_pass takes the scan as an argument (PassScan):
Steps keeps the steps' f32 order bit for bit, and Ssd runs mamba2_ssd.
enqueue_steps is enqueue_pass with Steps. Bolt's prefill now passes Ssd,
so its prompt y rows and state are within the SSD's derived f16 bound
of the exact scan instead of the steps' bits; decode is unchanged.

A6000 eager split (s2674): mamba2_steps was 363.2 ms of the pp4096
prompt, against llama.cpp's whole scan axis of 102.9 ms. Predicted
[derived] pp4096: A6000 -315..-337 ms, 3090 -315..-396 ms.
gate-gpu-nemotron-h-moe-e2e and gate-gpu-mamba2 are green with the
switch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The k32 mma ran each 16-value sub-block with a zeroed half, and ptxas
copied the A quad [a0,a1,0,0] before every one. The k16 form (inline
PTX: the pinned cuda-oxide has no wrapper, nvlabs-ledger row 47) drops
the zero half and the copies, and a full tile walks its eight n-tiles
with no branch. SASS per warp step: 713 -> 583 instructions, static
stalls 1475 -> 886, 128 registers, no spill.

Bits unchanged: gate-gpu-gemm contract_bits_differ=0, the integer sums
in the same order. ptx-compare against e30b8c9: only gemm_nvfp4p
moved in the three bins; its five siblings keep their PTX. Three
mutants are red. Predicted [derived] pp4096: A6000 +3..+11 %.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Oct 17, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the last review: the serve-flag finding is still open at nemotron.rs:256: both advertised spellings still reach “unknown argument”.
The larger-pass evidence request remains open. The added prediction cards do not supply complete gate or timed A/B evidence.

Verdict: MUST_FIX: the startup failure remains, and the new SSD selector breaks supported prompt contracts.

Must fix

1. Keep the existing prompt contracts when selecting the scan

prefill.rs:1028 always selects SSD. A file with inner=10240, heads=128, groups=8, state=128 and four conv taps passes hybrid.rs:604, but its prompt now fails with “head_dim 80 is refused”.

The SSD also rounds carried state to f16 at every launch (mamba2_ssd.rs:260). With one active state, initial state=0, A=0, σ=x=C=1, D=0 and B=[1, 2^-11, 0, …], zero-based token 16's ungated output is 1.00048828125 in one 32-row launch and 1 in two 16-row launches [derived]. The existing pass-size gate:1083 requires identical bits; a 32-row context selects exactly this split.

Cost: enabling this arm now removes accepted model shapes and changes results with the pass size.
Fix: keep the production selector on the existing scan until SSD dispatch and partial-chunk carry preserve these contracts. Replace line 1028 with:

                        PassScan::Steps,

Cover non-64 heads and the 32 versus 16+16 carry case before enabling SSD.

2. Reuse the existing k16 instruction wrapper

gemm32.rs:179 reimplements an existing owner. grouped.rs:449 already calls cuda_device::wmma::mma_m16n8k16_s32_s8 with a zero accumulator and the same fragment layout. The new claim that the pinned dependency lacks this wrapper contradicts that existing import and use (R14).

Cost: this adds a second unsafe implementation and a false upstream-workaround record.
Fix: delete mma_m16n8k16_s32_s8_zero, its kernels32.rs import, the now-unused ptx_asm import, and the new ledger row claiming the wrapper is absent. Update the two doc links to the existing API. Replace the two calls with:

                cuda_device::wmma::mma_m16n8k16_s32_s8([0; 4], [$a[0], $a[1]], $b0),
                cuda_device::wmma::mma_m16n8k16_s32_s8([0; 4], [$a[2], $a[3]], $b1),

Non-blocking

⚠ SSD rollout evidence: mamba2.rs:1605 changes precision, sum order and occupancy. Before enabling it, supply the new family's FAIL-first results, owning e2e gate and timed A/B, including a 4096-row pass. Include card/driver, both hashes, model, commands and output; prediction cards do not establish correctness or speed.

Optimization headroom

  • G, per-launch and per-sync fixed cost: mamba2.rs:1563, folding the conv pre-pass into SSD staging removes one launch per pass per Mamba layer and at least 8 × conv_dim scratch bytes per token per layer [derived].

Checked

Duplicates: confirmed the k16 wrapper duplicates the existing API and fragment layout.
Complexity: enqueue_pass adds scan dispatch; the SSD kernel body is exempt from splitting.
Silent failure: checked the SSD's host refusals and non-finite-output fault branch.
Tests: reproduced the derived f16 carry example with exact half conversion. Static reads connect the causal mask (455), state store (552) and fault raise (525) to band/state/fault checks. GPU gates were not run here.
Gates: the pass-size bit-equality requirement remains; the new unsafe-ratchet entries have dated PINs.
Escape catalog: C1–C4 do not apply to the retained findings. No ledger lessons are in force.

Card check: needs-gpu. This pull request changes crates/gpu-deepseek41/src/chain/ffn.rs, crates/gpu-deepseek41/src/chain/ffn/batch.rs, crates/gpu-deepseek41/src/router.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

state: &mut mm.store.state,
scratch: &mut p.mamba2,
},
PassScan::Ssd,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SSD rejects accepted head widths and changes outputs when a chunk is split across passes.

Suggested change
PassScan::Ssd,
PassScan::Steps,

@midagedev

Copy link
Copy Markdown
Owner Author

Landed on main as part of the Bolt stack, rebased onto main 8d4f29d (head f921073). The release batch ran on the rebased stack. Closing as superseded by that landing.

Written by a bot (Claude agent) for the maintainer.

@midagedev midagedev closed this Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja needs-gpu Changes code a card must check, and carries no gate run on a card serve The HTTP server: crates/serve tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant