Repository navigation
Conversation
inureyes
force-pushed
the
update/b200-nvfp4-gemma4-perf
branch
from
December 1, 2026 23:42
6da7851 to
f49e174
Compare
This was referenced Dec 2, 2026
Start a running optimization log for gemma-4-31b-it-nvfp4 on B200 (sm_100). It records the checkpoint's decode byte budget (11.7 GB NVFP4 MLP, 17 GB bf16 attention, 2.8 GB lm_head per token), the pp512/tg128 baseline (2900 tok/s prefill, 51.3 tok/s decode with graphs off, 63.7 with graphs on), and an nsys breakdown showing decode is 97% GPU-busy with the NVFP4 GEMV streaming at 1.5 TB/s. A standalone microbenchmark of the GEMV shows a load-only floor of 6 TB/s and that CUDA-core variants stop at about 2.2 TB/s because they are instruction-issue bound, which sets up the tensor-core GEMV as the next step.
On B200 the stock fp_qmv_single dequantizes every e2m1 weight on CUDA cores and multiplies in fp32. It is instruction-issue bound and streams Gemma 4 31B's MLP weights at about 1.5 TB/s, 42% of decode time. The CUDA overlay of qmm/fp_qmv.cu adds fp_qmv_tc_single for one NVFP4 vector on compute capability 10.x: hardware cvt.rn.f16x2.e2m1x2 unpack, exact f16 pre-scaling by the e4m3 block scale, f16 mma.sync m16n8k16 with fp32 accumulation, K split across the warps of a block, and x staged once per block as f16 times a power of two so bf16 inputs stay exact. CMake compiles fp_qmv.cu for the architecture-specific image as it already does for fp_quantize.cu; the plain image keeps a software unpack. MLXCEL_FP_QMV_TC=0 restores the stock kernel. Microbenchmark: 44 us to 21.4 us (gate/up) and 25.6 us (down), same error against an fp64 reference. Model tg128 decode (test-fast): 51.3 to 57.1 tok/s with CUDA graphs off, 60.4 to 79.4 with graphs on. Greedy output through mlxcel-server: 5 of 8 prompts identical over 200 tokens, the rest first differ at near-ties. Also fixes the logit_trace example for the #3643 adapter rename, adds the microbenchmark source, and renames the record to Gemma4_sm100_Optimization_Report.md with a per-run CSV.
Gemma 4 loads have forced MLX_USE_CUDA_GRAPHS=0 on every CUDA device since #688, a decode collapse seen on GB10 whose cause was never found. On a B200 it does not reproduce: greedy Gemma 4 31B NVFP4 output through mlxcel-server is token-identical with capture on and off (8 prompts, 200 tokens, first and repeated passes), and captured decode is 63.2 against 51.7 tok/s on the stock kernels and 79.4 against 57 to 62 with the tensor-core NVFP4 GEMV. cuda_graph_hazard_cleared_on() leaves capture on when the device reports compute capability 10.x (B200, B300). GB10 and every other or unknown capability keep the #688 default, and an explicit MLX_USE_CUDA_GRAPHS still wins. With no environment set the benchmark now decodes at 80.3 tok/s. The report gains the release measurement matrix for the GEMV kernel, this step, and measured build times on this 8-core host.
kernel_sdpav_1pass launches one 1024-thread block per query head and row. Upstream moves to the 2-pass kernel only above 1024 keys, so every sliding-window layer of a 1024-window model stays on the 1-pass grid: 32 blocks on a 148-SM B200 for Gemma 4 31B, about 27 us per layer and 1.3 ms per decoded token at a 640-token context. The SDPA overlay now routes decode to the 2-pass kernel on compute capability 10.x when the 1-pass grid is under 64 blocks and the KV length is at least MLXCEL_SDPA_VECTOR_SPLIT_MIN_KL (default 256, 0 disables). tg128 decode goes from 79.5 to 83.0 tok/s. The 2-pass kernel sums the softmax in a different order. With the split forced from 16 keys, greedy output through mlxcel-server matches for 4 of 8 prompts over 200 tokens; the rest first differ at near-ties (chosen-token logprob -0.625 to -1.0).
The stock fp_qmv_single handles 2 to 8 input rows by giving each row its own grid row, so every row streams the whole NVFP4 weight again. An MTP verify forward at block 4 therefore read the Gemma 4 31B MLP weights four times, and speculative decoding ran at 53.1 tok/s, below classic decode. fp_qmv_tc_multi carries up to eight bf16 rows in the eight columns of the mma B operand and reads the weights once (34 to 41 us per GEMV for M = 1 to 8, against 432 to 546 us for a per-row kernel at M = 2). Its A operand is the same exact e2m1 x e4m3 product in bf16, and its k order, warp split and accumulation match fp_qmv_tc_single, so each row is bit-identical to the single-row kernel (0 mismatches in a microbenchmark), which keeps verify blocks byte-identical to decode steps for the MTP exactness probe. MTP at block 4 goes from 53.1 to 78.8 tok/s; classic decode on the same prompt is 89.1, so MTP remains opt-in. The report records the block sweep, the nsys view of the MTP window and the batched-decode comparison.
On a B200, qmm_sm80 (the Ampere-generation mma.sync kernel that dequantizes inside its mainloop) is 63% of a 2048-token Gemma 4 31B prefill, 1.72 ms per 2048 x 21504 x 5376 projection, about 275 TFLOPS. NVFP4 QuantizedMatmul calls with at least MLXCEL_NVFP4_DEQUANT_GEMM_MIN_ROWS rows (default 64, 0 disables) on compute capability 10.x now dequantize the weight with MLX's fp_dequantize into a temporary and run a cuBLASLt GEMM. e2m1 times e4m3 is exact in bf16 and f16, so the GEMM multiplies the same weights and only the fp32 accumulation order changes. Decode (one row) and verify blocks (up to 8 rows) keep the matrix-vector kernels. pp512 prefill goes from 2933 to 4536 tok/s and pp2048 from 4430 to 7661 tok/s; decode is unchanged. With the path forced from 2 rows, greedy output through mlxcel-server matches for 4 of 8 prompts over 200 tokens and the rest first differ at near-ties. The report also records an f16 multi-row GEMV variant that was measured and not integrated.
MLXCEL_NVFP4_W4A4_PREFILL=1 sends prefill-sized NVFP4 QuantizedMatmul calls on compute capability 10.x to cuBLASLt's block-scaled FP4 GEMM, following upstream QQMatmul: a device tensor amax of x, fp_quantize of x with that amax, both scale planes swizzled to the 128 x 4 tile layout, and alpha = amax / (448 * 6). Gemma 4 31B pp512 prefill goes from 4552 to 10069 tok/s and pp2048 from 7662 to 11253 tok/s. Two defects were found and fixed on the way. The CUDA allocator serves requests of 8 bytes or less from a managed-memory pool, where 4-byte amax/alpha/beta buffers made the amax atomics take 7.5 ms per call; the scalars are now 16 bytes. The encoder clears registered inputs and outputs at every node, so each launch now registers its own, which orders the amax reduction after its initialisation and after the kernel writing x. The new nvfp4_w4a4_probe example compares every NVFP4 path against x @ dequantize(w).T: 1.66e-3 for all W4A16 paths, 9.5e-2 for W4A4 on gaussian input. Greedy W4A4 output is coherent but departs from W4A16 within 5 to 25 tokens, and no teacher-forced quality gate is available for Gemma 4 yet, so the path stays off by default.
Release build, back to back: against the shipped default, this branch's defaults take Gemma 4 31B NVFP4 from 2920 to 4491 tok/s prefill and 51.7 to 83.1 tok/s decode at 512 tokens, and from 4335 to 7655 tok/s prefill and 45.3 to 79.6 tok/s decode at 2048 tokens. The opt-in W4A4 prefill reaches 10304 and 11223 tok/s.
Same checkpoint, one B200, `vllm bench serve` as the client for all engines (512 in, 128 out): SGLang 1.0.0 decodes at 6.90 ms TPOT single stream and 2390 tok/s at concurrency 32, vLLM 0.34.0 at 8.18 ms and 2532 tok/s, mlxcel-server at 22.5 ms and 153 tok/s. Server batched decode grows almost linearly with the batch, which is the largest gap. The report adds the vLLM-to-mlxcel option mapping and why 32 slots exhausted memory in mlxcel (the fused paged-decode slab is sized for every layer at the full slot window in fp16) but not in vLLM. It also corrects the earlier claim that logit_trace loses Gemma 4 context: mlx-lm's reference trace matches mlxcel on gemma-4-e4b (NLL 5.936 against 5.921, 36% top-1 both), and both checkpoints are normal on easy text; the high absolute NLL on raw markdown is the instruction-tuned checkpoints, not the harness.
…code In the server's batched decode a step folds its rows into M = 8 or more, which is not below the qmv cutoff, so Gemma 4 31B's MLP went to qmm_sm80 at about 212 us per call, 55% of decode kernel time with 8 concurrent requests. fp_qmv_tc_multi now carries up to four groups of eight mma B columns that share each dequantized A fragment, so 2 to 32 rows read and unpack the NVFP4 weights once. QuantizedMatmul sends 2 to 32 NVFP4 rows on compute capability 10.x there first, and the dequantize + cuBLASLt path starts at 33 rows. Each row stays bit-identical to a single-row launch. Local validation: nvfp4_w4a4_probe (now also checking row invariance) for 1 to 48 rows on both MLP shapes, all at 1.66e-3 relative error and bit-identical for 1 to 32 rows. Server TPOT at concurrency 8 goes from 74.9 to 50.3 ms and at 32 from 187.6 to 144.0 ms; the rest of the gap to vLLM is host time.
…essure on CUDA The batch scheduler released MLX's whole buffer cache after every prefill, snapshot boundary, model-owned slot release and warm-up. On CUDA that makes the next decode step allocate its buffers again and update every captured graph whose addresses moved; the decode loops already skip their periodic release on CUDA (#627), and the scheduler's was the remaining unconditional one. On Metal the release is kept: it follows mlx-lm's BatchGenerator, bounds unified-memory residency, and costs nothing measurable there. `memory::clear_cache_between_steps` takes the policy from MLXCEL_STEP_CACHE_CLEAR: `pressure` by default on CUDA (release above 80% of the allocator limit), `always` elsewhere; all seven scheduler call sites use it. The new variable and the four CUDA overlay switches added on this branch are documented in docs/environment-variables.md. Gemma 4 31B NVFP4 server on a B200: TPOT at concurrency 1 goes from 23.1 to 17.9 ms and at 8 from 48.6 to 42.6 ms. At 32 the GPU stays at its memory limit because MLX's cache holds freed buffers up to 95% of memory; MLXCEL_CACHE_LIMIT=16GB brings it to 138.8 ms. Local validation: the new policy unit tests and scripts/ci/check_env_var_docs.py.
inureyes
force-pushed
the
update/b200-nvfp4-gemma4-perf
branch
from
December 2, 2026 02:09
c615244 to
ad91b3d
Compare
ModelOpt leaves `self_attn` in bf16 in exports such as nvidia/Gemma-4-31B-IT-NVFP4, which is more than half of the bytes a decoded token streams. MLXCEL_DENSE_ATTN_QUANT=mxfp8|nvfp4 requantizes the dense text q/k/v/o projections at load and records their layout, and Gemma 4 now resolves attention projections through `quant_params_for`, since an 8-bit group-32 plane has the same packed shape as a 4-bit group-64 one. The dequantize + cuBLASLt prefill path also takes MXFP8. On a B200 (pp512/tg128): bf16 84.2 tok/s decode, MXFP8 87.8, NVFP4 90.6, with prefill 4444, 3658 and 3768 tok/s. Against bf16, the teacher-forced trace changes 0.68% of top-1 choices on decided positions for MXFP8 (none above a gap of 3.1) and 14.9% for NVFP4, so the switch stays opt-in and MXFP8 is the one to use. This also restores the environment-variable rows for the CUDA overlay switches that the rebase conflict resolution dropped, and records the #3334 regression bisect (fixed in #3676) in the report. Local validation: the Gemma 4 and sanitize lib tests (617 passed) including a new parse test, and scripts/ci/check_env_var_docs.py.
A decoded Gemma 4 token spent 3.4 ms in single-row RMSNorm on a B200: each `rms_norm_small` reads its row, reduces, then reads the weight, two dependent rounds of cold loads behind a 65 MB GEMV. Two CUDA kernels in `gemma_norm.cpp` now run the five ops after attention in a dense layer: post-attention norm, residual add and pre-feed-forward norm in one, post-feed-forward norm, residual add and layer scalar in the other. Each issues all its loads before the first reduction and keeps the row in registers, so rows are limited to 8192 wide; wider rows, MoE layers, the sub-op timer and the exactness probe keep the separate ops. Rounding follows the separate ops. `MLXCEL_GEMMA_FUSED_NORMS=0` turns it off. Gemma 4 31B NVFP4, pp512/tg256, three alternating runs: decode 83.1 to 88.5 tok/s, prefill unchanged, greedy text byte-identical. Report Step 13 and CSV rows record the runs. Local validation: new parity tests against the separate ops (bf16 and f16, widths 1024 to 8192, declines for mixed dtypes and wider rows), the fused-norm parity tests, Gemma 4 lib tests (313 passed), kernel dtype keys check (new launcher pinned). Also drops an unnecessary cast clippy flags in `sanitize.rs`.
A CUDA kernel doing the Gemma 4 q/k/v head norms, RoPE and layout in one launch raised graphs-off decode from 61.4 to 75.4 tok/s but gained nothing with CUDA graphs on in steady state (88.4 against 88.4 tok/s, pp512/tg256), so it is parked outside the tree. Report Step 14 records the trial and two measurement lessons: per-call host-written kernel inputs produce a 250 to 900 us launch tail (constants belong in template args), and the bench's default 20-token warmup left first-touch costs in the measured window, making the fused path look 7 to 9% slower. A/B runs now use a 200-token warmup; Step 13's gain holds under it (83.0 to 88.4 and 89.3 tok/s).
7 tasks done
…ma4-perf # Conflicts: # src/lib/mlxcel-core/src/memory.rs # src/models/sanitize.rs
inureyes
added a commit
that referenced
this pull request
Dec 2, 2026
## Summary Unit of epic #3671. On CUDA the scheduler's decode step no longer builds its per-step inputs as host arrays: token ids, RoPE offsets, paged page tables and plan arrays, KV write slots and token-bias rows are written to a pinned staging slot and uploaded with at most two `cudaMemcpyAsync` calls per step into one device buffer whose address is fixed for the scheduler's life (`mlxcel_core::step_inputs::StepInputBuffers`). Pooled decode steps are padded to bucket sizes from `decode_bucket_for`, the single source #3668 reuses. The CUDA allocator overlay counts the unified buffers it hands out (`mlxcel_core::memory::unified_alloc_count()`), and `/metrics` exposes that count and the padded steps. ## Path statement - Pooled families (Llama, Qwen): persistent inputs and padding are on by default on CUDA. Both the synchronous step (what a server with an explicit `--ctx-size` runs) and the lookahead pipeline (the default without it) are covered. - Gemma 4 on CUDA decodes from dense per-sequence caches by default (`MLXCEL_PAGED_SLIDING` off since #3676; that default is not changed here, the decision belongs to the end of #3668). Its host arrays (token ids, RoPE offsets, the pooled full-attention layers' page tables) move to the persistent buffer on both the default path and `MLXCEL_PAGED_SLIDING=1`. It is not padded: dense and scheduler-owned rows have no slot for a pad row without a model rewrite. - Metal, ROCm, CPU: unchanged. `step_inputs::enabled_from(env, backend)` is false off CUDA whatever the environment says, so the buffers are never constructed, and every consumer calls `stage_i32` / `stage_f32`, which are exactly `from_slice_*` when no step is active on the thread. Unit-tested for every backend; `cargo check -p mlxcel --lib --tests` at default features passes. `MLXCEL_STEP_INPUTS=0` and `MLXCEL_DECODE_PADDING=0` restore the old step on CUDA. ## What the measurement changed The issue's 99k `cudaMallocManaged` / `cudaFree` figures came from the unmerged #3650 branch, which released the allocator cache between steps. Main does not (`clear_cache_between_steps`, `MLXCEL_STEP_CACHE_CLEAR` and the Gemma4 sm100 report do not exist on main and are not added), so its size-keyed buffer cache already absorbs the host arrays: on GB10 main was under the issue's nsys thresholds before this PR. The arrays were still requested every step, which is what the counter shows and what #3668 cannot replay, so the counter counts requests, not driver calls. GB10, four concurrent requests (about 430 prompt tokens, greedy), 10 s steady window, `--parallel 8 --ctx-size 65536`. "Requests" is unified buffer requests per decode step from `/metrics` (before = same binary with `MLXCEL_STEP_INPUTS=0`); nsys counts are per window, with steps in the window in brackets. The nsys rows were taken on a19f081 plus the pad-row eviction change; the last commit adds only the two `/metrics` counters and tests, and the parity and counter runs below are on the final commit. | Config | Requests per step | `cudaMallocManaged` | `cudaFree` / `cudaFreeAsync` | `cudaMallocAsync` | `cudaMemcpyAsync` after | |---|---|---|---|---|---| | Llama 3.2 1B 4bit, pooled | 163 -> 0 | 18, 16 -> 0 | 0 / 6, 7 -> 0 / 0 | 0 -> 1 | 1990 (994 steps) | | Gemma 4 12B 4bit, `MLXCEL_PAGED_SLIDING=1` | 483 -> 0 | 0 -> 0 | 0 -> 0 | 204, 176 -> 176 (about 126 steps) | 254 | | Gemma 4 12B 4bit, default dense | 99 -> 0 | 0 -> 0 | 0 -> 0 | 322, 322 -> 322, 322 (about 118 steps) | 117 | The remaining `cudaMallocAsync` (1.4 to 2.7 per step on Gemma, under the issue's 8) is identical with and without this change, so it does not come from host arrays; it was not attributed further (the release binary is stripped and an unstripped run showed 2 calls in its window). `cudaGraphLaunch` per step on Llama is unchanged at 17.2. ## Deviations from the issue text - No `V2Context::from_persistent` and no `mlxcel_step_inputs_upload` function: `V2Context::build` and the other consumers call the staging helpers, and the upload is a lazy MLX node the staged views depend on, so ordering with the encoder comes from the graph and a failed copy surfaces as the step's eval error with the CUDA error string. - The buffers are created at the scheduler's first decode step (the server's startup warmup), because the slab sizes that size them are installed after construction. - A pad row is a real pool-backed sequence rewound to one token before each padded forward, not an empty CSR range: a zero-page request breaks the paged plan's chunk-per-request assumption and gives NaN rows. - The fused sampler's temperature, top-p, top-k and seed are scalars passed by value, so only the token-bias rows moved. The cascade launch (off by default), the per-row sampler chain, prefill and speculative or MTP verify steps keep host arrays. Sampled token readback needed no change: the allocator moves a token buffer to unified memory once and then reuses it, so moves are 0 in every steady window measured (the Gemma 4 lookahead test arm shows about 1030 moves during prefill and warmup, 0 in its measured window). - Fallbacks. A batch the buffers cannot hold (inputs past the capacity, which also covers a row with more blocks than the plan sized for): the rest of that step builds host arrays, logged once. KV pool growth during decode: the grown layer leaves the fused read as before (multi-slab decline, already logged once per outcome) and its gather indices still stage or fall back by size. Speculative and MTP verify steps (L > 1) never open a step scope, so they keep today's path; every caller of the padded entry points is a single-token decode tick. No pool slot or KV block for a pad row: the step runs unpadded, logged once. Pad rows give their slots and blocks back before a request is refused or anything is evicted: every block reclaim (decode reservation, prefill admission, chunked-prefill reservation) first calls `PagedBlockReclaimer::release_spare_blocks`, which closes the pad rows, and a pad row is not opened when no block is free beyond the real rows' need plus the admission headroom. Known minor gaps: the batched-prefill window (`paged_prefill_room`) and the prompt-lookup verify fit checks count free blocks without reclaiming, so pad rows can shrink a batched prefill or turn a verify step into a plain decode; surplus pad rows after a bucket shrink stay open until the batch empties or a reclaim runs, and they count in the `active_count()` gauge. ## FP8 KV pool (#3666, merged into this branch) The staging and padding do not branch on pool dtype; FP8 per-layer scales are scalars, not per-step host arrays. With `--cache-type-k fp8 --cache-type-v fp8` the persistent inputs and padding work unchanged (server smoke below). One observation that is not introduced here: with an FP8 pool, a request's greedy tokens depend on the batch shape late in a long generation. With `MLXCEL_STEP_INPUTS=0` and no padding, request 0 alone vs in a batch of 3 or 4 diverges near token 47 on Llama 3.2 1B, while the f16 pool does not; consequently padded vs unpadded FP8 runs diverge between about token 100 and 150 at 160 tokens (each arm is deterministic, and 64-token runs match). The FP8 arm of the padding test therefore compares the first 32 tokens; the f16 arm compares every token. This looks like an FP8 decode-kernel property from #3666 and is left for a follow-up. ## Test plan - [x] Server test `scheduler_step_inputs` (Llama 3.2 1B 4bit, 4 rows, 50 steady steps): +0 unified requests on the gather, fused v2 and lookahead arms. Checked failing first on main plus the counter (stage A commit): +12150, +8630, +12132 (all three arms ran the gather path at that commit; the fused arm got its slab size in stage B). Gemma 4 12B own-path arms: +0 with and without `MLXCEL_PAGED_SLIDING=1`. - [x] Padding: three rows in the 4-row bucket give the same 114 greedy tokens per request as with padding off (gather, fused, lookahead arms). `decode_bucket_for` unit tests cover 1..=32, 33..=64, the cap and the panic. - [x] `step_inputs` unit tests (13): values, fixed device address, an in-flight step surviving the next step's staging, stale evaluation error, overflow fallback, scopes dropped out of order, negative and oversized staging shapes, the gates. - [x] Greedy parity on `mlxcel-server` against the main 11f1c0a binary, 64 tokens, two repetitions each, compared repetition for repetition (main's own two repetitions differ in one row at c=5 and on Gemma, so each is matched to its counterpart): Llama c=4 4/4, c=3 (padded) 3/3, c=5 (padded to 8) 5/5; Gemma 4 12B default 4/4 and `MLXCEL_PAGED_SLIDING=1` 4/4. - [x] Server counters (Llama 3.2 1B): 0 unified requests over 566 steps at c=4, 673 at c=3 (672 padded), 374 at c=5 (all padded), 648 at temperature 0.7, and 790 pipelined steps without `--ctx-size`. Gemma 4 12B without `--ctx-size`: 0 over 74 steps (default) and 76 (`MLXCEL_PAGED_SLIDING=1`); it stays on the synchronous step there, so the Gemma pipeline is covered by the scheduler test only. - [x] After merging main (FP8 pool): `batch::scheduler` 349 passed; core `step_inputs` 13, `paged_` 285; `scheduler_step_inputs --ignored` 8/8 on the f16 pool and 8/8 on the FP8 pool (`MLXCEL_STEP_INPUTS_FP8=1`, test-only); `block_reclaim` 31 including 7 pad-row reclaim tests. Before the merge: core `paged_v2` 94, `paged_batch` 31, `engine::` 86, `memory::` 27, `sampling` 216; Gemma 3 `scheduler_real_batch_parity` 2 passed; scoped clippy on both crates, fmt, `make verify-*` contract checks. - [x] Server smoke after merging main, release binary, 4 concurrent greedy requests, 64 tokens, two prompt lengths, default vs `MLXCEL_STEP_INPUTS=0` on the same binary: token-identical 4/4 on Llama 3.2 1B 4bit (f16 pool), Llama 3.2 1B 4bit FP8 pool, Gemma 4 12B 4bit default, Gemma 4 12B 4bit `MLXCEL_PAGED_SLIDING=1` with FP8, and Qwen3 1.7B 4bit. Unified buffer requests over each whole run (prefill included), default vs kill switch: 161 vs 18458, 226 vs 18462, 1338 vs 13810, 1728 vs 61093, 351 vs 31544. No `unevaluated`, stale-view or capacity warnings in any server log. - Timing, indicative only (shared host, load 2.4 to 8.8, n=2): Llama 3.2 1B decode steps per second at c=8, main 93, 90 against this branch 90, 90 (paired -3.2%, -0.6%); padding on against off on this branch, c=3 119, 115 against 109, 112, c=5 78, 83 against 77, 81. The c=1/8/32 `serving_compare.py` table was not run, per the 2026-12-02 decision that timing is optional. ## Changes during review - Pad rows now release their KV blocks on every reclaim path (prefill admission and chunked-prefill reservation were missing), not only on the decode reservation and slot paths. - `StepInputScope` holds an `Rc` in the thread-local, so scopes dropped out of order cannot leave a dangling pointer; failed construction releases its pinned slots and events; `capacity_for` saturates instead of overflowing; staging rejects negative and oversized shapes and no longer builds a placeholder array per staged input. - A pad row is not opened when the pool has no block to spare, instead of opening and closing it every tick under pressure. - `docs/CONTINUOUS_BATCHING.md` gained a "Persistent step inputs and bucket padding on CUDA" section. ## Deferred to the B200 follow-up measurement issue - nsys over a 25 s c=8 512/128 window on Gemma 4 31B NVFP4 (managed plus `cudaFree` under 100, `cudaMallocAsync` per step at most 8). - The c=1, 8, 32 serving table with the 3% regression bound, and any 31B number (the 31B was not loaded here). - The cost of padding between buckets on a B200, including 5 to 7 rows padding to 8 past the 7-row amortizing kernel. - Remaining host arrays left for #3668: the one-element `params` array per paged v2 launch, the cascade launch arrays, and the FP8 `full_f32` scale constant when a checkpoint declares a scale other than 1.0. Closes #3667
The tensor-core NVFP4 GEMV issued one 16-byte weight load per row pair and used it before the next, which kept the Gemma 4 31B down projection (5376 x 21504) at 29.6 us, 2.2 TB/s on a B200. Taking the idea from CUTLASS's block-scaled GEMV, each warp now loads `nv` consecutive k steps before using any of them. `fp_qmv_tc_config` picks 8 warps x 3 steps for K = 21504 (23.9 us) and 4 x 2 for K = 5376 (21.3 us, was 22.1), and keeps the old layouts where the wider load does not divide K. `fp_qmv_tc_single` and `fp_qmv_tc_multi` take the same split, so a token verified in an MTP block still sums each row exactly as it does alone. A new test holds that with a cancellation input that exposes the summation order after bf16 rounding; it fails when the multi-row path is given the old split. Gemma 4 31B NVFP4, B200, pp512/tg256, warmup 200: decode 88.5 to 91.2 tok/s, greedy text unchanged. Scoped mlxcel-core NVFP4/qmv/qmm tests (42) and clippy pass. Step 15 of the optimization report also records the rejected variants (TMA bulk copy, split-K, gate/up stacked into one GEMV).
Three measured but unmerged changes lived only in a session scratch directory, where they could disappear without notice. They now sit in `src/lib/mlxcelverse/parked/` as plain diffs that apply cleanly to the current branch, with a README recording each patch's switch, measurement, the reason it was parked and when to revisit it: the merged Gemma 4 gate/up GEMV (Step 15), the fused q/k/v norm and RoPE prologue (Step 14) and the cuBLASLt W4A4 decode MLP (Step 12). Nothing there is built; CMake reads only `overlays/` and `kernels/`. The optimization report now links to the directory instead of saying the patches are kept outside the tree.
With `MLXCEL_GEMMA4_ENABLE_FUSED_QKV` set, the q branch and the k/v branch of the Gemma 4 attention each called the concatenated projection, and MLX does not merge two identical matmul nodes, so every step ran the whole q/k/v GEMV twice. The q branch now hands its k and v to `project_kv_tensors`. On Gemma 4 31B NVFP4 (B200, pp512/tg256, warmup 200) the fixed path replaces 61.7 us of sliding-layer projection kernels with one 29.0 us GEMV and leaves greedy text unchanged, but decode stays at 91.0 to 91.4 tok/s against 90.9 to 91.2 separate: the CUDA graph already runs the three independent GEMVs concurrently. The path therefore stays opt-in; Step 16 of the optimization report has the trace analysis.
Step 12's W4A4 decode (activations quantized to NVFP4, FP4 tensor-core GEMM) lost with CUDA graphs on because each cuBLASLt call is captured as a child graph on every step. CUTLASS 4.4.2, which MLX already fetches, has the sm100 block-scaled GEMM vLLM and SGLang use through FlashInfer. `mlxcel_nvfp4_w4a4_gemm` builds it with 128 x 64 tiles (weight as operand A, quantized rows as operand B, alpha from a device pointer) and adds it with `add_kernel_node_ex`; it reads the 128 x 4 tiled scales that Step 12's activation kernel writes, so `MLXCEL_NVFP4_W4A4_DECODE=1` now applies the parked patch with CUTLASS in place of cuBLASLt, which stays the fallback. Standalone on a B200 the GEMM takes 17.0 us for 21504 x 5376 and 20.4 us for 5376 x 21504 against 21.3 and 23.9 us for the W4A16 GEMV. In Gemma 4 31B decode the path rises from 73.1 (cuBLASLt) to 81 to 83 tok/s but stays below the W4A16 default at 91: activation quantization runs once per projection with a full-row amax and serializes gate and up. It stays opt-in and is documented; Step 17 records the measurements and the next steps. The parked cuBLASLt patch is removed. Scoped NVFP4/qmv tests and the env-doc and kernel dtype-key checks pass.
Profiling SGLang on the same B200 and Gemma 4 31B NVFP4 checkpoint showed its bf16 attention projections running through FlashInfer's DirectDenseGemmKernel, where every thread requests all of its 16-byte weight slices before using any. MLX's gemv_single walks K with one load in flight per thread. A new gemv.cu overlay adds gemv_direct in that shape (96, 128 or 256 threads, two to eight slices per thread, one or two rows per CTA) for a single bf16 or f16 vector; other shapes, batched calls and MLXCEL_GEMV_DIRECT=0 keep gemv_single. Decode goes from 90.9 to 92.8 tok/s (pp512/tg256, warmup 200) and the sliding q projection from 26.9 to 18.5 us. Accumulation is fp32 in a different order, so outputs are not bit-identical to gemv_single; the greedy reference text is unchanged. A new test checks every layout and the fallback against an f32 reference, and an nsys run confirms each variant launches. Report Step 18 adds SGLang's per-layer breakdown (103 us against mlxcel's 156 to 179 us, the MLP the largest gap). The kernel dtype-key self-test expected 11 in-scope files; gemma_norm.cpp from Step 13 made it 12. Refs #3650
Step 17's W4A4 decode lost to W4A16 because of everything around the GEMM: a dynamic amax per projection, gate and up quantizing the same row twice, and separate global-scale and GELU kernels. MLXCEL_NVFP4_W4A4_MLP=1 now runs a Gemma 4 decode MLP (up to 32 rows) as one MLX primitive, the way vLLM and SGLang serve ModelOpt NVFP4: one quantization of the input with the checkpoint's static input_scale (kept through the load only under the switch), gate and up as CUTLASS block-scaled FP4 GEMMs, GELU x up fused into the down projection's quantization, and input_scale * weight_scale_2 in each GEMM epilogue. The loader declines the path when gate and up do not share their scales. Decode goes from 92.7 to 98.0 and 99.5 tok/s (pp512/tg256, warmup 200); the MLP takes 59 us a layer against 71 to 94 us for W4A16 and 43 us in SGLang. It changes the numerics and the quality measurements do not show it better or worse than W4A16 (chunk trace 16.9% decided disagreement with 16.7% lower perplexity; greedy agreement with vLLM 595 against 539 characters), so it stays off by default. A new test checks the primitive against an f32 reference of the dequantized weights for each row of a five-row block, and fails with a doubled down alpha. Scoped NVFP4 and Gemma 4 tests pass. Refs #3650
Under MLXCEL_NVFP4_W4A4_MLP=1 the Gemma 4 loader stacks each layer's gate and up NVFP4 planes into one (gate rows first) and points both projections at views of it, so the weights are not held twice. The W4A4 MLP primitive now runs one 43008-row block-scaled GEMM into a [rows, 2N] buffer, and the GeGLU quantization reads gate and up from the two halves of each row; the static-scale quantization splits each 16-value group over four lanes. Decode goes from 98 to 99.5 to 101.1 to 103.4 tok/s (W4A16 92.7 to 93.1, pp512/tg256, warmup 200); the MLP takes 55 us a layer against SGLang's 43. The load-time peak rises from 38.6 to 40.4 GB. The math is unchanged from two GEMMs: the primitive's test errors and the greedy text match the previous commit exactly. Scoped NVFP4 and Gemma 4 tests pass. Refs #3650
Single-query decode at head dim 256 and 512 now runs a split-KV kernel pair in the CUDA SDPA overlay instead of sdpa_vector. A block owns one KV head, up to four of the query heads that share it and one slice of the keys, scores every query head against each key it loads with 16-byte loads, and writes one online-softmax partial per head and slice; a combine kernel folds the slices and applies sinks. sdpa_vector read each key once per query head, and head dim 512 (Gemma 4 full-attention layers) fell to the materializing fallback (GEMV, softmax, GEMV); supports_sdpa_vector now accepts 512 for this shape only. MLXCEL_SDPA_DECODE_GQA=0 restores the old routing, MLXCEL_SDPA_DECODE_MIN_CHUNK sets the slice size (16). Gemma 4 31B NVFP4 on B200 (pp512/tg256): decode 93 to 99.5 tok/s, and 103 to 110 tok/s with MLXCEL_NVFP4_W4A4_MLP=1. Attention per layer goes from 16.5 to 9.1 us (sliding) and about 30 to 12.2 us (full). A new test checks four shapes against the materializing reference and fails when the combine drops a slice; a decode-width logit trace disagrees with the old kernels on 0 of 121 decided positions, and greedy chat output is identical for 400 tokens on three prompts. Report Step 21 also records a reverted split-K trial for the W4A4 down GEMM (no gain at 126 CTAs). Refs #3650
Report Step 22 records a PDL experiment in the CUDA command encoder (programmatic graph edges, griddepcontrol.wait in the GEMV, Gemma norms, decode SDPA, NVFP4 quant and W4A4 GEMMs). W16 decode rose from 98.3-98.6 to 100.3-101.0 tok/s and W4A4 was unchanged, but greedy output was wrong with several launch-site combinations although every kernel waits before reading its inputs and standalone graphs with the same edge shapes ordered correctly. The work is kept as src/lib/mlxcelverse/parked/cuda-pdl-graph-edges.patch with its site bitmask; the parked README lists it. Refs #3650
The MLX CUDA allocator puts buffers of eight bytes or less in a managed-memory pool, and on a discrete GPU each kernel read of one is a PCIe round trip (1.39 us per kernel from device memory against 3.36 us from the pool, measured on B200). The fused Gemma norms read eps and the row count from per-call scalar arrays; they now take eps as a template argument and the row count from the input shape. A new `device_resident_scalar` helper places one-element arrays read every step (Gemma 4 layer_scalar, the W4A4 MLP scales and alphas, every NVFP4 global_scale sidecar) in device memory without changing their value. Decode on Gemma 4 31B NVFP4 (B200, pp512/tg256): W16 about 98.6 to 101.7 tok/s, W4A4 about 109 to 115-117 tok/s. Greedy chat output is byte-identical in both modes. Two allocator-level variants were slower (72.6 to 80.9 tok/s) and are recorded as rejected. The scoped Gemma 4 tests also caught a regression from the Step 21 decode kernel: masked single-query verify rows still took the materializing fallback, so they were no longer byte-equal to decode rows. The decode kernel now takes an additive mask, so both go through the same arithmetic. The head-dim-512 route is limited to bf16 and f16 queries. Validation: 316 Gemma 4 unit tests, 103 mlxcel-core SDPA/attention tests, gemma_norm/nvfp4 tests, new device_scalar tests, and greedy comparisons. Report Step 23 and CSV rows s23-01..13.
Each Gemma 4 dense layer ended with the fused post-feed-forward kernel writing h, and the next layer started with a separate rms_norm launch that read h back. gemma_norm_add_scale_norm now writes h and the next layer's input_layernorm(h) from one kernel, and the layer loop passes the result on. It is skipped across the per-row verify path, at the KV-shared tail trim, and wherever the unfused path runs. MLXCEL_GEMMA_FUSED_NEXT_NORM=0 turns it off. The first version changed greedy output from token 1 and disagreed with the off arm on 3 of 122 decided trace positions. These kernels summed squares in a different order than MLX's rms_norm_small, so a norm here could be one ulp from the next layer's own. All three Gemma norm kernels now copy MLX's launch shape, per-lane order, and cg::reduce, while still loading one vector per thread (the 128-lane shape itself cost 7% of decode). Tests now require bit identity with the separate ops for bf16 and f16, 1 to 512 rows, and widths 1024 to 8192. Gemma 4 31B NVFP4 on B200, pp512/tg256 decode: W16 100.9-102.5 to 104.2-104.4 tok/s, W4A4 117.2-118.2. The decode-width trace agrees with the off arm at all 192 positions. W16 greedy is unchanged, and W4A4 greedy matches MLXCEL_GEMMA_FUSED_NORMS=0. 316 Gemma 4 tests and the gemma_norm tests pass. Report Step 24, CSV s24-01..09.
Three Gemma 4 decode experiments on B200, all without gain, recorded as report Steps 25 to 27 with CSV rows. - Moving every checkpoint weight under 16 KB to device memory at load left decode unchanged (W16 about 104, W4A4 about 118 tok/s). The load hook is removed; `device_resident` (formerly `device_resident_scalar`) now takes any small array, with tests for one-element, small and large arrays. - Deterministic stream-K split-K for the W4A4 down GEMM made decode slower (117.9 to 114.1 tok/s at 1 to 4 splits). It repeats Steps 17 and 21 and is parked as `parked/cuda-w4a4-split-k.patch` so it is not retried. - An L2 prefetch of `o_proj` during the attention core made W4A4 decode slower (118.7 to 115.1). Parked as `parked/cuda-l2-weight-prefetch.patch`. Greedy output is unchanged on the kept path. Clippy, fmt and the `device_scalar_tests` pass locally.
Timed alone, the W4A4 down GEMM grows linearly with K at about 82 GB/s per CTA on its 42 CTAs, so it is limited by the bytes each CTA keeps in flight. Each pipeline stage carries a 64-column activation tile of which one column is used at decode, and 64 is the smallest N CUTLASS takes for block-scaled MMA. W4A4 GEMMs whose row count is a multiple of 256 now use CUTLASS's 2SM block-scaled kernel (256x64x256 tile on a 2x1 cluster). Each SM of a pair holds half the activation tile and fits more stages. On a B200 with Gemma 4 31B NVFP4, gate+up drops from 26.2 to 22.7 us and down from 19.1 to 17.6 us; W4A4 decode goes from 117.8 to 121.3 tok/s. Greedy output is identical and the logit trace agrees at all 192 positions. `MLXCEL_NVFP4_W4A4_2SM=0` restores the 1SM kernel. A direct NVFP4 GEMV for the W16 path (CUDA-core dequantization, no shared-memory stage) was issue-bound and slower (104.1 to 99.8 tok/s); it is parked as `parked/cuda-fp4-gemv-direct.patch`. Report Steps 28 and 29.
Blackwell's 32-byte vector load (`ld.global.v8.u32`) lets `gemv_direct`'s layout keep twice the bytes in flight per instruction. Measured standalone on a B200 with a cold L2, the Gemma 4 31B output projection runs in 14.4 us instead of 15.8 (K = 8192) and 26.4 instead of 28.7 (K = 16384). At K = 5376 the 16-byte kernel stays faster, and FlashInfer's streaming cache hint made no difference. `gemv_direct32` takes K = 128 x 16 x (4 to 8) with two rows per CTA on compute capability 10.x; `MLXCEL_GEMV_DIRECT32=0` turns it off. W4A4 decode goes from 122.2 to 123.3 tok/s, W16 from 104.1 to 104.4. The summation order differs: errors against fp64 match the 16-byte kernel, and the decode-width trace disagrees on 2 of 123 decided positions, the size of earlier one-ulp changes on this model. The existing GEMV layout test now covers the new kernel. Report Step 30.
A decode step has one activation row, and the 64-wide CUTLASS tile spent a third of each pipeline stage on zero-filled rows and scales. FlashInfer's M = 1 tactic is a 128 x 8 tile; timed directly, its 64-wide tiles match ours, so the tile width is the gap. CUTLASS v4.4.2 rejects N below 64 for block-scaled GEMMs, so whole-file overlays of sm100_common.inl and sm100_blockscaled_mma_warpspecialized.hpp (overlays/cuda/cutlass/include, first on the mlx target's include path) accept 8 and 16. The narrow tile is taken only when the rows fit in its first tile; MLXCEL_NVFP4_W4A4_NARROW=0 keeps 64. Gemma 4 31B NVFP4 on a B200 under W4A4: down GEMM 17.6 to 15.9 us, decode 122.6 to 124.9 against 124.0 to 126.1 tok/s. Logit trace 0/192 disagreements; a new test checks rows are bit-identical through the 8-, 16- and 64-wide tiles and fails when the 8-wide tile runs past its first tile. Also records Step 33 (row-wide bf16 GEMV, parked) and split-K on the narrow tile (slower).
FlashInfer's direct bf16 GEMM beat mlxcel's port of it by 4 to 7% at every attention shape. Its SASS shows why: the products are FHFMA.BF16 (PTX fma.rn.f32.bf16), one instruction per product, where mlxcel's dot8 converted both operands and issued an FFMA. The product of two 16-bit floats is exact in fp32, so the fused form is bit-identical to the converted FFMA. On compute capability 10+, dot8 now uses fma.rn.f32.bf16 / .f16, and a new one-row-per-CTA layout with three or four 16-byte slices per thread (pick_row_layout) runs ahead of the two-row gemv_direct and gemv_direct32 layouts. MLXCEL_GEMV_ROW_CTA=0 restores the previous layouts. Cold-L2 microbenchmarks: o_proj 5376x8192 14.2 to 13.5 us, q 8192x5376 14.3 to 13.4, k/v 8.1 to 7.4. Gemma 4 31B NVFP4 on a B200: W16 decode 105.2 to 106.1 tok/s, W4A4 125.5 to 126.2, MTP with the bf16 drafter 82.7 to 84.4. The summation order changes with the slice split: the W16 logit trace disagrees at 2 of 125 decided positions. Llama 3.2 3B and Qwen3 0.6B produce the same greedy text. The GEMV layout test now covers K = 4096 and 14336 and f16, and fails when the f16 FMA pairs the wrong halves. Recorded as Step 35 of the sm_100 optimization report.
Following vLLM's fused add/RMSNorm/FP4 quant kernel, the post-attention norm kernel quantized the W4A4 MLP input itself (inline PTX e4m3/e2m1 conversions, tiled scale writes) and the MLP took the packed input. It is bit-identical (logit trace byte-identical, unit test over rows 1, 5, 21 in bf16 and f16), but W4A4 decode fell from 126.6 to 125.3 tok/s: the norm kernel runs one CTA per row, so the quantization tail ran on one SM (5.2 to 6.2 us) on the critical path, almost the cost of the separate 42-CTA launch it removed. Parked as parked/gemma4-w4a4-norm-fp4-quant.patch with a README row; recorded as Step 36 of the sm_100 optimization report.
Brings in the server refactoring epic #3671 (paged sliding state for Gemma 4 on CUDA by default, decode-step graphs, step-input staging). The only conflict was docs/environment-variables.md, where main's MLXCEL_PAGED_SLIDING row and this branch's MLXCEL_STEP_CACHE_CLEAR row both stay.
Since #3668 Gemma 4 on CUDA decodes through the paged pool in the CLI, the bench and the server, and W4A4 decode of Gemma 4 31B NVFP4 on a B200 fell from 126 to 75 tok/s. Three causes: - `can_unwind_lookahead` refused the lookahead pipeline for Gemma 4's scheduler-owned layer state although every layer is pool-backed; it now accepts the same case the scheduler's pipelined graph ticks do (`pool_layer_state_unwinds`). - `DirectEngine` built each step's page tables as host arrays in managed memory; it now opens a step-input scope per submitted step, like the scheduler. - The paged v2 kernels cost 17 + 6.5 us per sliding layer. New `paged_decode_split` / `paged_decode_combine` kernels (head dim 256 and 512, bf16/f16/f32 query, 16-bit or FP8 pool) take 6.4 + 3.5 us, against 5.5 + 3.2 us for the dense ring. `MLXCEL_PAGED_DECODE_SPLIT=0` restores v2. W4A4 decode is now 116 tok/s (dense ring 126.5), W16 108.4 (109.8). Server c=1 TPOT 13.50 to 12.89 ms. Logit trace against the dense ring: 1/168 decided disagreements on docs/architecture.md, as for v2. New unit test against the gathered window for both pool dtypes (RMS about 5e-4), and it fails with a broken page lookup. paged_v2, cache, engine and step_inputs tests pass (909).
The report gains Step 37 (the #3668 regression, its three causes, the paged split kernel's times, server TPOT, the logit trace and the in-model split-vs-v2 check), plan rows and CSV runs s37-01 to s37-16. The v2 vector-load attempt, bit-identical and no faster, is parked as cuda-paged-v2-vector-loads.patch.
DirectEngine's fused lookahead pipeline now submits each greedy step through Engine::submit_graph_padded and feeds the next step its token on the device, as the scheduler's graph pipeline does (#3668, #3669). The pipeline moved to engine/direct_decode_graphs.rs; MLXCEL_DECODE_GRAPH_PIPELINE=0 keeps the eager pipeline, and the verify and eager modes run graph steps synchronously. Three fixes made replay faster than evaluation. MlxcelNvfp4GeluMlp gains is_equivalent, without which every W4A4 replay was refused as a parameter mismatch. The step-graph capture points small host-built constants at device copies for the capture (the graph holds them, the model's arrays are restored), and every allocation during the capture is a fresh device buffer, so replays no longer fault managed pages the host shares with the graph (72 tok/s before). The allocator frees device scalars instead of caching them, since a cached one was moved to a new cudaMallocManaged allocation by the next host scalar request (prefill 4050 to 2000 tok/s). MLXCEL_STEP_GRAPH_DEVICE_CONSTANTS=0 captures the managed buffers. Gemma 4 31B NVFP4 on B200, pp512/tg256: W4A4 decode 115.6 to 129.4 tok/s, prefill 4064 to 4246; W4A16 108.5 to 106.8. MLXCEL_DECODE_GRAPHS=verify ran 300 greedy tokens with no mismatch for W4A4 and W4A16, text identical to replay. Scoped mlxcel-core tests (engine, step_graph, step_inputs, decode_graph, paged) pass; clippy clean. Report Step 38.
Step 24 fused each layer's input norm into the previous layer's post-feed-forward kernel, but only in the ordinary forward. Gemma 4's paged decode runs forward_batched_decode, which still launched a one-CTA rms_norm_small (6.3 us) per layer. It now hands the next layer's input norm, and the final norm after the last layer, to finish_layer_with_next, and the next layer takes the normalized input. MLXCEL_GEMMA_FUSED_NEXT_NORM=0 still disables it. Gemma 4 31B NVFP4 on B200, pp512/tg256 with decode replay: W4A4 129.4 to 134.3 tok/s, W16 106.8 to 110.3. 300 greedy tokens are byte-identical with the fusion on and off for both. Clippy clean. Report Step 39.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Raise
gemma-4-31b-it-nvfp4(ModelOpt NVFP4) throughput on B200 (sm_100), with B300 (sm_103) as the second target. Each step lands as its own commit. The running record with method, numbers and failed attempts isdocs/benchmark_results/Gemma4_sm100_Optimization_Report.md, and every measurement is a row indocs/benchmark_results/Gemma4_sm100_Optimization_Runs.csvfor progress charts.Result (release, B200)
MLXCEL_NVFP4_W4A4_PREFILL=1Against vLLM and SGLang (serving, same client, 512 in / 128 out)
--parallel 32 --ctx-size 65536)MLXCEL_CACHE_LIMIT=16GB)The remaining gap is the server's per-step dynamic graphs and allocations; details in the report.
Status
fp_qmv_tc_single: 44 us to 21.4/25.6 us per GEMV; release tg128 decode 63.2 to 79.4 tok/s with graphs on, 51.5 to 57-62 with graphs offMLXCEL_NVFP4_W4A4_PREFILL=1: pp512 4552 to 10069 tok/s, pp2048 7662 to 11253; numerics change (4-bit activations), so off by default100a/103abuildsValidation
Steps 2, 4 and 6 change fp32 summation order only; Step 3 changes nothing numerically (graphs on and off are token-identical). Step 2: Greedy output through
mlxcel-server(8 prompts, 200 tokens) is identical for 5 prompts; the other 3 first differ at near-ties (tokens 76, 117, 150). The teacher-forcedexamples/logit_tracedid not compile after #3643 (fixed here) and, once built, does not carry Gemma 4 context (stock arm mean NLL 10.6), so it cannot judge this change yet; that harness defect is recorded in the report.Every number so far comes from a release build on a B200 with the checkpoint on local disk; kernel experiments use a standalone microbenchmark because Nsight Compute counters are blocked in this container.