Gemini 4 Carbon 1.19×

Harness: Antigravity · switches: NANOCHAT_OPT_FP8=1 NANOCHAT_OPT_NORM_ROPE=1 NANOCHAT_OPT_LOSS=1 NANOCHAT_OPT_RESID=1 NANOCHAT_OPT_OPTIM=1 NANOCHAT_OPT_ROPE16=1 NANOCHAT_OPT_EMBED=1 NANOCHAT_OPT_BWD_FUSE=1 NANOCHAT_OPT_STEP_PIPE=1 NANOCHAT_OPT_QUANT128=1 NANOCHAT_OPT_PIPE_RESID=1 NANOCHAT_OPT_ASYNC_RS=1 NANOCHAT_OPT_R13=1 NANOCHAT_OPT_R14=1

Judged
1.19×
Tier
N1
Self-best
1.19×
Rounds
14
Hours
10.0
API cost
$110
Input tokens · 94.1% cached
186 M
Output tokens
1.5 M
Requests
672
Micro-batch regrouping 4×16 → 2×32
✗ not in the log
Scope of hand-written kernels replacing Inductor glue
✓ whole block plus head and tail, all custom CUDA: quantization (round 1), norm + residual + RoPE/QKNorm (round 2, 1.0300 → 1.0733), loss, embedding backward, cross-block residual add; Inductor kernels 412.1 → 20.4 ms/step by round 8; round 10 moves quantization to 128×128 tiles and drops the norm output write, 1.1376 → 1.1693
Per-shape cuBLASLt algorithm selection
✗ (only tried merged QKV + row-wise scaling in _scaled_mm; cuBLASLt switched to slower CUTLASS kernels, forward 36.96 vs 33.88 ms, reverted)
FP8 weights quantized once per step
✓ inside NANOCHAT_OPT_FP8 (round 1, 1.0300 together with the quantization kernel, MLP and shared QKV); refresh later batched into 2 kernels (round 9) and overlapped with all-gather (round 14)
Fast accum on backward GEMMs
no attempt in the log
Other main levers
wte and value-embedding grads via sorted segments (NANOCHAT_OPT_EMBED, round 7, 1.1176 → 1.1266); Muon params as views into stacked buffers, Muon issued first, reduces ordered by arrival (rounds 9, 13, 14, ~+0.5% each); weight grads accumulated straight into fp32 (round 5); data-fetch device check fixed (round 11, with cross-block residual add 1.1693 → 1.1742)
Raw work log15 sections
0.0 hRound 1 — Coalesced SM90 FP8 Dual-Layout Quantization, Step-Level Weight FP8 Caching, Shared QKV & Fused ReLU^2 MLP
- Start time: 2026-11-19T19:44:00Z
- End time: 2026-11-19T20:26:15Z
- Baseline Profile Findings (/tmp/r1-profile, updates 12..13, 1022.2 ms/step wall, 1019.1 ms/step GPU kernel sum):
  - GEMMs (nvjet cuBLASLt FP8 + Muon BF16 bmm): 455.84 ms/step (44.7%; Fwd 144.18 ms, Bwd 289.85 ms, Opt 21.57 ms)
  - Inductor Triton kernels (7,315 launches/step): 412.12 ms/step (40.4%; Fwd 125.76 ms, Bwd 274.90 ms, Opt 11.47 ms)
    - Hotspot #1 (FP8 quant + uncoalesced 1D transposes + MLP ReLU^2 + Block RMSNorm): 295.56 ms/step (29.0% of total step; includes 65.04 ms/step in a single uncoalesced 1D triton_poi scatter-transpose of [32768, 6144] exceeding L2 cache, 55.16 ms/step Bwd FP8 quant/transpose, 33.18 ms/step Fwd FP8 quant/transpose re-quantizing all 145 FP32 weights 4x/step and QKV input 3x/layer)
    - Hotspot #2 (RoPE + QK RMSNorm + 1.2x): 44.48 ms/step (4.4%; Fwd 19.39 ms, Bwd 25.09 ms)
    - Hotspot #3 (lm_head softcap + cross-entropy + FP8): 27.14 ms/step (2.7%; Fwd 8.30 ms, Bwd 18.84 ms)
    - Hotspot #4 (wte / value_embeds + ve_gate): 27.39 ms/step (2.7%; Fwd 4.35 ms, Bwd 23.04 ms)
  - FlashAttention-3 (SM90): 109.06 ms/step (10.7%; Fwd 25.16 ms, Bwd 83.90 ms)
  - Optimizer (MuonAdamW.step): 42.79 ms/step wall (22.61 ms overlapped NCCL, 4.7 ms exposed NCCL)
  - ATen native grad-accum adds: 10.14 ms/step (525 calls/step)
- What Changed (NANOCHAT_OPT_FP8=1, commit 8e9f27e):
  - Pre-compiled SM90 CUDA C++ vectorized Vec8 (uint4 -> uint2) 64x64 shared-memory coalesced FP8 dual-layout quantizer (nanochat/csrc/fp8_ops.cu, nanochat/_fp8_ops_sm90.so), verified 20/20 bitwise-exact against torch.compile.
  - Fused MLP (c_fc -> ReLU^2 -> c_proj) with fused relu2_fwd and relu2_bwd dual-layout FP8 quantization (_FastFloat8MLP), eliminating [32768, 6144] dh_pre materialization and uncoalesced scatter-transposes.
  - Cached quantized weights (_w_fp8, _w_col_t, _w_inv) across the 4 gradient accumulation micro-steps, refreshed once per optimizer update at the end of MuonAdamW.step().
  - Shared input FP8 dual-quantization across c_q, c_k, c_v in CausalSelfAttention (fp8_qkv_forward).
- time Result (/tmp/r1-time/time.json):
  - Windows: [0.9977, 1.0029, 1.0054] s/update, mean s_per_update: 1.0020 s (261,629 tok/s)
  - speedup_vs_frozen_reference: 1.0300x (cold compile + startup also dropped from 137.0s to 77.9s)
  - Peak memory allocated: 62.66 GiB
- check --quick Result (/tmp/r1-quick/check.json):
  - NOT_BITWISE (exact_items_ok: true, 122/175 params bitwise identical at step 0; fusion boundary change around RMSNorm/lm_head makes this Tier N1).

---
0.7 hFull Check #1 + Round 2 Profile
- Start time: 2026-11-19T20:26:34Z
- Completed: 2026-11-19T20:33:52Z — status: PASS, speedup: 1.0310x, tier: N1 (/tmp/check-r1/check.json). All 6 seed-1 trajectory endpoints within 0.10–0.18 sigma (limit 3.0 sigma).

---
0.7 hRound 2 — Fused SM90 RoPE + QK RMSNorm + 1.2x & Block RMSNorm + Residual + Producer FP8 Amax
- Start time: 2026-11-19T20:33:53Z
- Round 2 Profile Findings (/tmp/r2-profile, updates 12..13, 987.65 ms/step wall, 985.27 ms/step GPU kernel sum, 6,943 launches/step):
  - GEMMs: 458.28 ms/step (46.5%; 436.7 ms FP8 GEMMs + 21.6 ms Muon bmm)
  - Inductor Triton kernels (2,195 calls/step): 193.69 ms/step (19.7%):
    - Block RMSNorm bwd + residual + QKV dx / slice_backward (24 unrolled triton_red ~35 ms + triton_poi_fused_add_fp8_quant_slice_backward 22.27 ms): ~57.3 ms/step
    - RoPE + QK RMSNorm + 1.2x (18.52 ms Fwd + 13.76 ms + 10.04 ms Bwd): 42.32 ms/step
    - Block RMSNorm fwd: ~16.0 ms/step
    - lm_head softcap + cross-entropy (8.35 ms Fwd + 8.52 ms Bwd): 16.87 ms/step
    - wte / value_embeds + ve_gate (embedding_dense_backward): ~19.7 ms/step
  - Custom CUDA FP8 quant/dual (2,226 calls/step): 180.04 ms/step (18.3%), of which standalone amax_bf16_vec8 passes alone take 61.33 ms/step (31.32 ms mode 0 + 18.50 ms mode 2 + 11.51 ms mode 1), while weight FP8 refresh takes only 3.16 ms/step.
  - FlashAttention-3: 110.79 ms/step (11.2%)
  - Optimizer (MuonAdamW.step): 48.06 ms/step wall (24.53 ms NCCL)
- What Changed (NANOCHAT_OPT_NORM_ROPE=1):
  - Added SM90 CUDA C++ kernels in nanochat/csrc/fp8_ops.cu (_fp8_ops_sm90.so):
    - Non-divergent 1-warp-per-head rope_qk_norm_128_fwd_vec4_kernel and rope_qk_norm_128_bwd_vec4_amax_kernel (outputs producer partials[512] for dq_raw and dk_raw).
    - 1-warp-per-row rms_norm_1536_warp_fwd_kernel (+ optional residual add + producer partials[512]) and rms_norm_1536_warp_bwd_kernel (+ optional 3-way dy sum + ve_gate 12-col slice grad + residual grad + producer partials[512]).
    - launch_fp8_quant_from_partials to quantize directly from producer partials[512], skipping standalone HBM amax passes.
  - Wired _FastRMSNorm1536, _FastNormFloat8Linear, _FastNormQKVRoPE, and _FastOutProjResidNormMLP into nanochat/fp8.py and nanochat/gpt.py (commit 78cc82d).
- time Result (/tmp/r2-time/time.json):
  - Windows: [0.9561, 0.9629, 0.9658] s/update, mean s_per_update: 0.9616 s (272,613 tok/s)
  - speedup_vs_frozen_reference: 1.0733x (down 40.4 ms/step from Round 1's 1.0020 s; cold compile + startup also dropped from 77.9s to 48.1s; zero recompile/cudagraph warnings)
  - Peak memory allocated: 63.88 GiB
- check --quick Result (/tmp/r2-quick/check.json):
  - NOT_BITWISE (exact_items_ok: true, problems: []).
- check --n1 Result (/tmp/r2-n1/check.json):
  - status: PASS, tier: N1, verdict: equivalent (all 6 seed-1 trajectory endpoints within 0.21–0.40 sigma vs 3.0 sigma bound).

---
1.7 hRound 3 — Fused `lm_head` Softcap + Online Cross-Entropy + Direct-to-FP8 Backward (`NANOCHAT_OPT_LOSS=1`)
- Start time: 2026-11-19T21:25:00Z
- Round 3 Profile Findings (/tmp/r3-profile, updates 12..13 at 961.6 ms/step, 916.14 ms/step non-NCCL GPU kernel sum):
  - Irreducible Tensor Core compute: 437.56 ms/step FP8 GEMMs + 111.04 ms/step FA3 + 23.58 ms/step Muon BF16 GEMMs = 572.18 ms/step (62.5%).
  - Inductor Triton kernels dropped to 82.89 ms/step (down -80% from 412.12 ms/step baseline):
    - lm_head softcap + cross-entropy: 8.27 ms/step Fwd + 8.50 ms/step Bwd (+ ~7.6 ms/step [32768, 32768] d_logits amax + quant_dual = 24.4 ms/step) — Round 3 target
    - Per-layer resid_lambdas[i] * x + x0_lambdas[i] * x0: 17.9 ms/step Fwd + 8.41 ms/step Bwd = 26.3 ms/step — Round 4 target
    - wte + 12 value_embeds embedding_dense_backward + ve_gate: ~20.2 ms/step — Round 4 target
    - Wgrad bf16 -> fp32 _to_copy (4.83 ms/step) + CUDAFunctor_add<float> (7.41 ms/step): 12.24 ms/step (1,062 launches/step) — Round 5 target
  - Optimizer (MuonAdamW.step): 51.45 ms/step wall (25.71 ms/step NCCL, 3.18 ms/step sequential FP8 weight refresh) — Round 5/6 target
- What Changed (NANOCHAT_OPT_LOSS=1, commit pending -> committed below):
  - Added SM90 hardware-SFU (tanh.approx.f32 + __expf) single-pass softcap_ce_fwd_kernel (computing online log-sum-exp, loss, and exact per-row unit gradient max row_umax in 1 HBM read of [M, V_pad]) and softcap_ce_bwd_fp8_dual_vec8_64x64_kernel (computing d_logits in registers and writing go_fp8 + go_T directly without materializing [32768, 32768] d_logits or [32768, 32768] FP32 logits in HBM; microbenchmark dropped from 24.4 ms/step to 9.63 ms/step with bit-identical inv_scale and 0.000e+00 probe loss diff).
- time Result (/tmp/r3-time/time.json):
  - Windows: [0.9443, 0.9497, 0.9538] s/update, mean s_per_update: 0.9493 s (276,147 tok/s)
  - speedup_vs_frozen_reference: 1.0872x (down 12.3 ms/step from Round 2's 0.9616 s; peak memory allocated dropped -2.0 GiB from 63.88 GiB to 61.88 GiB; startup 47.2s; zero recompile/cudagraph warnings)
- check --quick Result (/tmp/r3-quick/check.json):
  - NOT_BITWISE (exact_items_ok: true, problems: []).

---
2.0 hRound 4 — Fused Per-Layer `resid_lambda * x + x0_lambda * x0` into Pre-Attn RMSNorm Fwd & Bwd (`NANOCHAT_OPT_RESID=1`)
- Start time: 2026-11-19T21:41:30Z
- Target Hotspot (from /tmp/r3-profile):
  - Per-layer x = resid_lambdas[i] * x + x0_lambdas[i] * x0 before each of the 24 Blocks (17.9 ms/step across 17 unrolled Triton add_mul_select fwd kernels + 11.4 ms/step across Triton add_mul_sum bwd reduction kernels + ~2.5 ms/step CUDAFunctor_add<BFloat16> residual branch grad adds = ~31.8 ms/step).
- What Changed (NANOCHAT_OPT_RESID=1, commit 76a306e):
  - Added SM90 resid_rms1536_warp_fwd_kernel and deterministic 2-stage resid_rms1536_warp_bwd_kernel + resid_scalar_reduce_512_kernel in nanochat/csrc/fp8_ops.cu, fusing resid_lambdas[i] * x + x0_lambdas[i] * x0 into _FastResidNormQKVRoPE without saving x_scaled (-2.25 GiB peak VRAM) and matching Inductor's single-round float32 -> bfloat16 FMA (xs rel_l2 = 6.58e-5).
- Full check Result (/tmp/check-r4/check.json):
  - status: PASS, speedup: 1.0943x, tier: N1 (verdict: equivalent, all 6 endpoints within 3.0 sigma, exact_items_ok: true).
  - Windows: [0.9393, 0.9444, 0.9457] s/update, mean s_per_update: 0.9431 s (277,946 tok/s), peak memory allocated: 59.63 GiB (down -4.25 GiB from Round 2).

---
2.4 hRound 5 — Direct Wgrad FP32 Accumulation, Stacked `value_embeds` Comm/AdamW & Zero-Copy Muon (`NANOCHAT_OPT_OPTIM=1`)
- Start time: 2026-11-19T22:06:00Z
- Round 5 Profile Findings (/tmp/r5-profile, updates 12..13 at 943.1 ms/step wall, 896.62 ms/step non-NCCL GPU kernel sum, 46.5 ms/step wall-vs-kernel gap):
  - GEMMs + FA3: 436.14 ms/step FP8 GEMMs + 110.23 ms/step FA3 + 25.69 ms/step Muon BF16 GEMMs = 572.06 ms/step (63.8% of GPU kernel time).
  - Inductor Triton kernels dropped to 45.31 ms/step (5.1%, down -89% from 412.12 ms/step baseline).
  - Hotspot #1 (MuonAdamW.step() 53.61 ms/step wall + 46.5 ms/step wall-vs-kernel gap + 12.25 ms/step wgrad bf16->fp32 _to_copy & CUDAFunctor_add<float> + 57.9 ms/step CPU aten::add_ dispatch):
    - 576 _to_copy (4.78 ms/step) + 486 CUDAFunctor_add<float> (7.47 ms/step) + 525 CPU AccumulateGrad dispatches (57.9 ms/step CPU).
    - MuonAdamW.step(): double torch.stack + copy_ on all Muon grads & shards, 12 separate reduce_scatter + pageable-CPU-sync adamw_step_fused + all_gather on the 12 identical [32768, 1536] value_embeds params, and 290 sequential Python-loop FP8 weight refresh launches (3.22 ms/step).
  - Hotspot #2 (RoPE + QK RMSNorm 51.41 ms/step — 29.12 ms bwd + 22.29 ms fwd): running at ~1.9 TB/s (4-byte __nv_bfloat162 loads/stores) vs 3.8 TB/s HBM ceiling — Round 6 target.
- What Changed (NANOCHAT_OPT_OPTIM=1):
  - Direct in-place bf16 -> fp32 wgrad copy/accumulation (accum_wgrad_bf16_vec8_kernel) writing directly into persistent pre-stacked Muon (padded_num_params, M, N) buffers and lm_head _wgrad_buf, eliminating all 576 _to_copy casts, 435 FP32 AccumulateGrad aten::add_ dispatches, and Muon torch.stack + copy_ overhead.
  - Batched the 12 [32768, 1536] value_embeds AdamW parameters into 1 reduce_scatter_tensor + 1 adamw_step_fused_3d + 1 all_gather_into_tensor, and batched the 5 small AdamW scalar tensors (74 floats) into 1 all_reduce (cutting NCCL collective launches from 41/step to 15/step).
  - Batched FP8 weight refresh (launch_fp8_quant_batch_inplace) across all 145 Float8Linear modules in C++.
  - Verified 100% bitwise identical SHA-256 (d5ba0ad7268ae634 == d5ba0ad7268ae634) and identical state_dtypes vs Round 4 across 2-GPU compiled multi-step training (commit dc3ef0a).
- time Result (/tmp/r5-time/time.json):
  - Windows: [0.9341, 0.9414, 0.9443] s/update, mean s_per_update: 0.9399 s (278,896 tok/s)
  - speedup_vs_frozen_reference: 1.0981x (MuonAdamW.step wall dropped from 54.4 ms to 49.7 ms/step, NCCL launches dropped from 41/step to 15/step; zero recompile/cudagraph warnings)
- check --quick Result (/tmp/r5-quick/check.json):
  - NOT_BITWISE (exact_items_ok: true, problems: []; bitwise identical to Round 4's PASS tree).

---
2.9 hRound 6 — Quarter-Warp `uint4` 16-Byte Vectorized `RoPE + QK RMSNorm` (`NANOCHAT_OPT_ROPE16=1`)
- Start time: 2026-11-19T22:31:30Z
- Round 6 Profile Findings (/tmp/r6-profile, updates 12..13 at 939.9 ms/step wall, 892.76 ms/step non-NCCL GPU kernel sum):
  - rope_qk_norm_128_bwd_vec4_amax_kernel (28.90 ms/step) + rope_qk_norm_128_fwd_vec4_kernel (22.82 ms/step) = 51.72 ms/step — single largest remaining non-GEMM / non-FA3 hotspot (running at ~1.9 TB/s due to 4-byte __nv_bfloat162 loads/stores and runtime int64_t division by non-power-of-2 24/12).
- What Changed (NANOCHAT_OPT_ROPE16=1, commit 44c8761):
  - Added quarter-warp (8 lanes/head, 32 heads/CTA) uint4 (LDG.E.128/STG.E.128, 128B exact cache-line coalesced, uint32 magic-multiply <12, 12, 2048> specialization) rope_qk_norm_128_fwd_vec8_kernel and rope_qk_norm_128_bwd_vec8_amax_kernel.
  - Microbenchmark (96 calls = 1 full step): dropped from 43.14 ms/step (18.16 ms fwd + 24.98 ms bwd) to 27.13 ms/step (9.94 ms fwd @ 3.92 TB/s + 17.19 ms bwd @ 3.39 TB/s, -16.01 ms/step, q_rl2 = 6.29e-6, dxq_rl2 = 1.06e-5, qp_diff = 0.0).
- Full check Result (/tmp/check-r6/check.json):
  - status: PASS, speedup: 1.1176x, tier: N1 (verdict: equivalent, all 6 endpoints within 3.0 sigma, exact_items_ok: true).
  - Windows: [0.9188, 0.9250, 0.9267] s/update (window ratios [1.1193, 1.1173, 1.1161]), mean s_per_update: 0.9235 s (283,861 tok/s), peak memory allocated: 61.13 GiB.

---
3.7 hRound 7 — Shared Two-Level Segmented CSR Embedding Backward & Fused `ve_gate` (`NANOCHAT_OPT_EMBED=1`)
- Start time: 2026-11-19T22:48:00Z
- Round 7 Profile Findings (/tmp/r7-profile, updates 12..13 at 923.5 ms/step wall, 875.67 ms/step non-NCCL GPU kernel sum):
  - wte + 12 value_embeds + ve_gate (embedding_dense_backward 6.02 + 3.65 ms + CUB radix sort/scatter ~3.5 ms + ve_gate Triton fwd/bwd 2.75 + 3.93 ms + aten.embedding 2.33 ms = ~22.2 ms/step, plus 1.2 GiB saved ve activations).
- What Changed (NANOCHAT_OPT_EMBED=1, commit 3b2beb6):
  - Added 16-bit CUB DeviceRadixSort::SortKeys on packed (tok << 16) | pos + 1-CTA CSR builder + 1-CTA bounded <= 16-row segment splitter (launch_prepare_token_csr, computed ONCE per micro-step and shared across wte and all 12 value_embeds).
  - Added deterministic 2-pass segmented CSR embedding backward (embed_csr_1536_pass1_kernel + embed_csr_1536_pass2_heavy_kernel) handling heavy-hitter tokens (max_cnt ~ 1,620 on ClimbMix) without warp serialization, accumulating directly into disjoint ve_grads[k] and wte _wgrad_buf buffers.
  - Added ve_gate_apply_1536_fwd_kernel (v_out rel_l2 = 0.000e+00) and quarter-warp ve_dgate_raw_1536_bwd_kernel (d_gr rel_l2 = 1.41e-5), eliminating the 1.2 GiB saved ve tensors.
  - Caught & fixed an Inductor auto_functionalized_v2 storage-overlap clone trap when all 12 value_embeds shared the [0..1.2 GiB) rs_in view (0.9550s -> 0.9161s, 0 bytes missed reinplacing).
- time Result (/tmp/r7-time2/time.json):
  - Windows: [0.9107, 0.9176, 0.9199] s/update, mean s_per_update: 0.9161 s (286,158 tok/s)
  - speedup_vs_frozen_reference: 1.1266x (peak memory allocated 59.91 GiB, reserved 61.30 GiB, zero compiler/cudagraph warnings)
- check --quick Result (/tmp/r7-quick2/check.json):
  - NOT_BITWISE (exact_items_ok: true, problems: []).

---
4.3 hRound 8 — Sequential `x0` Chain, Cross-Layer Producer FP8 `amax` & Fused MLP `accum_wgrad3` (`NANOCHAT_OPT_BWD_FUSE=1`)
- Start time: 2026-11-19T23:30:00Z
- What Changed (NANOCHAT_OPT_BWD_FUSE=1, commit 3e8bd64):
  - Threaded x0 as a sequential zero-copy view chain across the 24 blocks and fused + dx0_next directly into resid_rms1536_warp_bwd_kernel, eliminating the 24-way dx0 Inductor add tree without mutates_args.
  - Passed 2-KB autograd partials token edges across block boundaries (Block[i] MLP <- Block[i+1] resid_rms1536_bwd, skipping backout_layer) and inside ve blocks (_FastResidNormQKVRoPE <- ve_dgate_raw_bwd), dropping amax_bf16_vec8_kernel<0> calls from 288/step to 152/step (8.98 ms -> 4.74 ms/step).
  - Added single-kernel 3-tensor accum_wgrad3_vec8_kernel for the 3 distinct-storage MLP weights (dw_proj, dw_fc, dw_cproj), cutting 192 custom_op + kernel + cudaMemsetAsync launches/step (0 bytes missed reinplacing).
- Full check Result (/tmp/check-r8/check.json):
  - status: PASS, speedup: 1.1321x, tier: N1 (verdict: equivalent, all 6 endpoints within 3.0 sigma, exact_items_ok: true).
  - Windows: [0.9082, 0.9136, 0.9131] s/update (window ratios [1.1323, 1.1312, 1.1327]), mean s_per_update: 0.9116 s (287,549 tok/s, individual steps down to 0.9000 s), peak memory allocated: 59.91 GiB.
  - Total Inductor Triton kernel time across entire model + optimizer is now 20.37 ms/step (down -95.1% from 412.12 ms/step upstream baseline).

---
4.6 hRound 9 — Zero-Copy Muon `stacked_params`, Pipelined `MuonAdamW.step()` & 2-Kernel FP8 Weight Refresh (`NANOCHAT_OPT_STEP_PIPE=1`)
- Start time: 2026-11-20T00:01:00Z
- Round 9 Profile Findings (/tmp/r9-profile, updates 12..13 at 911.6 ms/step wall, 864.26 ms/step non-NCCL GPU kernel sum):
  - MuonAdamW.step() (~49.5 ms/step wall vs ~38 ms compute) stalled waiting on 1.5 GB of AdamW reduce_scatter before starting 35 ms of Muon Newton-Schulz, copied 1.35 GB (torch.stack(owned_params)) + 2.7 GB (_foreach_copy_), and launched 290 sequential FP8 weight refresh kernels after all gathers finished.
- What Changed (NANOCHAT_OPT_STEP_PIPE=1, commit b9a70a4):
  - Backed all 144 Muon Float8Linear weights directly onto persistent contiguous stacked_params (-3.81 GiB peak VRAM, eliminating torch.stack(owned_params) and torch._foreach_copy_ of 144 tensors, using in-place all_gather_into_tensor).
  - Reordered MuonAdamW.step() execution so Muon + lm_head reduce_scatter -> compute -> all_gather run first and 1.31 GB of wte + 12 value_embeds all_gather overlaps with FP8 weight refresh (self.param_groups order preserved).
  - Replaced 290 sequential FP8 weight refresh launches with 2 descriptor-driven SM90 kernels (batch_amax_f32_vec4_kernel + batch_quant_dual_f32_e4m3_kernel).
  - Verified 100% bitwise-identical 10-step D24 parameter SHA-256 digests (r8["digests"] == r9["digests"] == True), state_dtypes, and hparams against Round 8's full-check PASS record (/tmp/check-r8/record_cand.r0.json).
- time Result (/tmp/r9-time/time.json):
  - Windows: [0.9025, 0.9089, 0.9106] s/update, mean s_per_update: 0.9073 s (288,917 tok/s, individual steps down to 0.8954 s)
  - speedup_vs_frozen_reference: 1.1376x (peak memory allocated 56.10 GiB, down -7.78 GiB from 63.88 GiB; zero compiler/cudagraph warnings)
- check --quick Result (/tmp/r9-quick/check.json):
  - NOT_BITWISE (exact_items_ok: true, problems: []; 100% bitwise identical to Round 8's PASS tree).

---
5.3 hRound 10 — `128x128` XOR-Swizzled `uint4` FP8 Dual Quantizer, Fused `rstd` Norm-Quant & `128x128` Softcap CE Bwd (`NANOCHAT_OPT_QUANT128=1`)
- Start time: 2026-11-20T00:25:00Z
- Bandwidth & L2 Analysis (quant_dual_vec8_64x64_kernel, 112.63 ms/step across 964 calls):
  - 64x64 tiles wrote only 64 bytes (uint2) per row of out_row and per col of out_col (half of a 128-byte DRAM/L2 cache line, causing partial-sector L2 write thrashing) and issued 16 scalar LDS.U8 byte loads per thread with 4-way shared-memory bank conflicts (~2.85–3.18 TB/s).
  - Furthermore, resid_rms1536_warp_fwd_kernel and rms_norm_1536_warp_fwd_kernel materialized [32768, 1536] norm_x / norm_x2 (100.66 MB > 50 MB L2 cache, 196 calls/step = 19.73 GB/step writes) only for fp8_quant_from_partials to read it once and discard it, plus 48 norm_x[:, :12].contiguous() copy kernel launches/step.
- What Changed (NANOCHAT_OPT_QUANT128=1, commit a3f547b):
  - Added quant_dual_vec16_128x128_bf16_kernel<IS_E4M3, DO_ROW, DO_COL, MODE, APPLY_RSTD> using 16.000 KB union shared memory (smem[128][32] XOR-swizzled via ty ^ (tx << 2)), __byte_perm in-register 4x4 byte transpose, LDS.128 (uint4) zero-bank-conflict reads, and full 128-byte cache-line STG.E.128 (uint4) stores on both out_row and out_col (3.18 -> 3.63 TB/s cold-L2 on 1536-dim, 3.81 TB/s on m1, 4.04 TB/s on m2, 100% bit-for-bit identical per kernel).
  - Added APPLY_RSTD fusion (launch_fp8_quant_rstd_from_partials) + WRITE_NORM_X=false / WRITE_Y=false + inline 8B-coalesced uint2 slice12 ([M, 12]) output inside resid_rms1536_warp_fwd_kernel and rms_norm_1536_warp_fwd_kernel, eliminating 19.73 GB/step of HBM norm_x/norm_x2 writes (201 MB -> 100 MB working set per norm) and 48 slice12.contiguous() launches/step.
  - Upgraded softcap_ce_bwd on [32768, 32768] to softcap_ce_bwd_fp8_dual_vec16_128x128_kernel (2.64 -> 3.30 TB/s).
- Full check Result (/tmp/check-r10/check.json):
  - status: PASS, speedup: 1.1693x, tier: N1 (verdict: equivalent, all 6 endpoints within 3.0 sigma: -0.37, -2.37, -2.11, -2.21, -2.41, -2.37 sigma, exact_items_ok: true).
  - Windows: [0.8794, 0.8833, 0.8851] s/update (window ratios [1.1694, 1.1700, 1.1686]), mean s_per_update: 0.8826 s (-24.7 ms/step vs Round 9! 297,018 tok/s, individual steps down to 0.8731 s), peak memory allocated: 56.10 GiB.

---
6.1 hRound 11 — Inter-Block MLP Residual Add Fusion & Async Pinned Ring-Buffer Dataloader (`NANOCHAT_OPT_PIPE_RESID=1`)
- Start time: 2026-11-20T01:02:00Z
- Round 10 Profile Findings (/tmp/r10-profile, updates 12..13 at 882.6 ms/step wall, 843.67 ms/step non-NCCL GPU kernel sum):
  - x2_2d + mlp_out_2d inside _FastOutProjResidNormMLP.forward launched 92 triton_poi_fused_add kernels/step (6.30 ms/step), materializing out_2d right before Block[i+1]'s resid_rms1536_warp_fwd_kernel read it back.
  - Timeline gap analysis caught nanochat/dataloader.py line 113 (use_cuda = device == "cuda") evaluating to False when device = torch.device("cuda", ddp_local_rank), making gpu_buffer.copy_(cpu_buffer, non_blocking=False) an unpinned synchronous copy that called cudaStreamSynchronize (104.6 ms CPU stall) and drained the GPU queue (~0.95 ms GPU idle gap before each micro-batch).
- What Changed (NANOCHAT_OPT_PIPE_RESID=1, commit 56c5e5d):
  - Deferred x2_2d + mlp_out_2d across all 22 non-backout inter-block transitions ((i != backout_layer) and (i < n_layer - 1)), fusing __hadd2(x2, mlp_out) directly inside Block[i+1]'s resid_rms1536_warp_fwd_kernel<HAS_MLP_ADD=true, ...> (-8.8 GB/step HBM traffic, -88 Triton kernel launches/step, 0 extra VRAM).
  - Fixed use_cuda = torch.device(device).type == "cuda" in nanochat/dataloader.py with a race-free 8-slot pinned/GPU ring buffer (cudaEvent guarded), doc_lens list-length cache, and single per-batch torch.tensor conversion (972 ms -> 651 ms over 45 ClimbMix batches, 100% bit-exact), plus async pinned _train_loss_cpu copy and non-redundant synchronize() in scripts/base_train.py.
- Full check Result (/tmp/check-r11/check.json):
  - status: PASS, speedup: 1.1742x, tier: N1 (verdict: equivalent, all 6 endpoints within 3.0 sigma: -0.38, -2.37, -2.02, -2.22, -2.36, -2.37 sigma, exact_items_ok: true).
  - Windows: [0.8766, 0.8798, 0.8804] s/update (window ratios [1.1732, 1.1747, 1.1748]), mean s_per_update: 0.8789 s (298,260 tok/s, individual steps down to 0.8705 s), peak memory allocated: 56.11 GiB.

---
7.7 hRound 12 — Zero-Copy `value_embeds`, Single-Storage Batched QKV `accum_wgrad`, Fused `WTE+Smear` & Fused `Backout+FinalNorm` (`NANOCHAT_OPT_ASYNC_RS=1`)
- Start time: 2026-11-20T02:38:00Z
- End time: 2026-11-20T04:54:00Z
- Profile Findings & Bottlenecks Targeted:
  - MuonAdamW.step() still copied 2.42 GB in rs_in.copy_ (1.95 ms), 0.43 ms in torch.stack(p_slices), and 2.42 GB in torch._foreach_copy_ (0.84 ms) for the 12 value_embeds (3.22 ms/step pure memcpy + 2.82 GiB extra VRAM). Note: an early-ReduceScatter overlap experiment (NANOCHAT_OPT_EARLY_RS=1) was tested first in /tmp/check-r12 (PASS, 1.1733x) and rejected because persistent NCCL RING_LL SMs caused wave-quantization slowdowns on concurrent Block[0..1] GEMMs/FA3 (only 2.57 ms of NCCL was exposed anyway).
  - Attention QKV accum_wgrad_bf16_op launched 288 custom_op + kernel + cudaMemsetAsync calls/step (3.18 ms).
  - Pre-trunk wte -> RMSNorm1536 -> slice[:, 1:, :24] -> smear and post-trunk Block[23] mlp_add -> backout -> Final RMSNorm1536 materialized intermediate 100 MB bf16 tensors across ~48 Triton/copy launches/step.
  - Pre-registering make_fallback lowerings for all nanochat_fp8::* ops in nanochat/_fp8_ext.py eliminated PyTorch 2.9.1's O(2^24) OperatorIssue.operator_str recursive ExternKernel.__str__ overhead, cutting cold-compile startup from ~120 s to 40.4 s.
- What Changed (NANOCHAT_OPT_ASYNC_RS=1, commit 8e3c3d0):
  - Backed all 12 value_embeds weights directly onto a contiguous (12, 32768, 1536) stacked_ve buffer (6 tables owned per rank), eliminating rs_in.copy_, torch.stack, and torch._foreach_copy_ (-3.22 ms/step, -2.91 GiB peak VRAM down to 53.20 GiB).
  - Added accum_wgrad_qkv_bf16_op operating on a single per-block disjoint (3, 1536, 1536) _qkv_wgrad_buf view (mutates_args=("qkv_wg", "flag")), cutting 192 custom_op/kernel launches and 192 cudaMemsetAsync calls/step with 0 auto_functionalized_v2 storage aliasing.
  - Added SM90 wte_rms1536_fwd_kernel (emitting inline 16B-aligned slice24 [B, T-1, 24]), wte_rms1536_bwd_kernel + CSR bwd, and smear_1536_fwd_kernel / smear_1536_bwd_kernel (0 spills).
  - Deferred Block[23]'s mlp_out add and fused (x2_23 + mlp_23) - backout_lambda * x_backout + Final RMSNorm1536 (+ dout_23_partials) in backout_rms1536_warp_fwd_kernel / backout_rms1536_warp_bwd_kernel (0 spills).
- Full check Result (/tmp/check-r12-final/check.json):
  - status: PASS, speedup: 1.1778x, tier: N1 (verdict: equivalent, all 6 endpoints within 3.0 sigma: +1.16, -1.59, -1.26, -1.26, -1.34, -1.36 sigma, exact_items_ok: true).
  - Windows: [0.8717, 0.8777, 0.8793] s/update, mean s_per_update: 0.8762 s (299,175 tok/s, individual steps down to 0.8676 s, startup 40.4 s), peak memory allocated: 53.20 GiB (down -10.68 GiB from 63.88 GiB reference).

---
8.4 hRound 13 — 512B-Coalesced `hw16` Joint-QK `RoPE+QKNorm`, `x_scaled` `ResidRMSNorm` Save & Arrival-Ordered `MuonAdamW` Pipeline (`NANOCHAT_OPT_R13=1`)
- Start time: 2026-11-20T04:56:00Z
- End time: 2026-11-20T05:35:00Z
- Round 12 Profile Findings (/tmp/r12-profile, 835.25 ms/step compute union, 840.33 ms/step GPU union):
  - rope_qk_norm_128_bwd_vec8_amax_kernel (19.67 ms/step) + fwd_vec8 (11.10 ms/step) accessed 4 strided quarter-warps per warp (splitting every LDG.E.128/STG.E.128 across 8 disjoint cachelines) and launched 1024 CTAs split separately across Q and K.
  - resid_rms1536_warp_fwd_kernel<HAS_MLP_ADD=true> (11.91 ms/step, 88 calls) wrote both x_sum (100.66 MB) and x_scaled (100.66 MB), even though resid_rms1536_warp_bwd only used x_sum to recompute x_scaled and one scalar d_rl = (sum(d * x_scaled) - x0l * sum(d * x0)) / rl.
  - MuonAdamW.step() stalled Stream 7 for 1.79–4.91 ms waiting on the 906 MB 96x(1536, 1536) reduce_scatter before starting any compute, and left +0.71 ms of stacked_ve AllGather hanging past batch_quant_dual_f32_e4m3_kernel.
- What Changed (NANOCHAT_OPT_R13=1, commit b31f423):
  - Added non-divergent half-warp (16 lanes/head, 2 heads/warp = 512 contiguous bytes per LDG.E.128/STG.E.128 via XOR-8 register shuffle) joint-QK rope_qk_norm_128_fwd_hw16_kernel and __launch_bounds__(256, 4) rope_qk_norm_128_bwd_hw16_occ4_kernel (+2.18 ms/step cold-L2, dq rmse vs upstream torch.compile improved 0.00457 -> 0.00335).
  - Added WRITE_X_SUM=false + X_IS_SCALED=true on resid_rms1536_warp_{fwd,bwd}_kernel, eliminating 8.86 GB/step of HBM writes (11.71 -> 9.35 ms/step, +2.36 ms/step, -1.56 GiB reserved VRAM down to 56.95 GiB).
  - Reordered MuonAdamW.step() reduces and computes in ascending arrival order (small_ar -> ve_gate -> wte -> lm_head -> mlp.c_proj -> value_embeds -> attn -> mlp.c_fc), starting GPU compute after 29 us instead of 2–5 ms and hiding 1.21 GB value_embeds AllGather 20 ms before step() ends.
- Full check Result (/tmp/check-r13/check.json):
  - status: PASS, speedup: 1.1835x, tier: N1 (verdict: equivalent, all 6 endpoints within 1.51 sigma: +1.31, -1.51, -1.01, -1.12, -1.19, -1.27 sigma, exact_items_ok: true).
  - Windows: [0.8678, 0.8729, 0.8755] s/update, mean s_per_update: 0.8721 s (300,600 tok/s, individual steps down to 0.8617 s, startup 40.4 s), peak memory allocated: 53.20 GiB (reserved 56.95 GiB).

---
9.1 hRound 14 — Register-Packed `udy_arr[6]` `ResidRMSNorm` Backward (`4.08 TB/s`) & 2-Stage Overlapped `MuonAdamW` FP8 Weight Refresh (`NANOCHAT_OPT_R14=1`)
- Start time: 2026-11-20T05:41:00Z
- End time: 2026-11-20T06:24:00Z
- Round 13 Profile & cuobjdump Findings (/tmp/r13-profile, 830.26 ms/step Stream 7 compute union, 834.94 ms/step all-GPU union):
  - resid_rms1536_warp_bwd_kernel (84 calls = 22.02 ms/step, 262.8 us/call = 3.45 TB/s) stored float fdy[48] (48 registers for values already rounded to bfloat16) and loaded ux0 inside Loop 2 when X_IS_SCALED=true, exposing cold DRAM latency on every g=0..5 iteration.
  - MuonAdamW.step() had two remaining Stream 7 idle gaps totaling 3.32 ms/step:
    1. Early 1.77 ms stall waiting on big_muon_gis[0] (mlp.c_proj) ReduceScatter because med_embed (wte, 0.25 ms) and fp8_adamw (lm_head, 0.47 ms) ReduceScatters were queued ahead of big_muon_gis[0] despite having RS_time > Compute_time (violating Johnson's 2-machine flow-shop theorem).
    2. Tail 1.55 ms stall waiting on big_muon_gis[-1] (mlp.c_fc, 24 weights) AllGather before launching refresh_all_fp8_weights() (1.94 ms), even though the first 121 FP8 weights (69% of bytes = 1.34 ms) had already completed AllGather 9–26 ms earlier.
- What Changed (NANOCHAT_OPT_R14=1, commit 6d50067):
  - Replaced float fdy[48] with packed uint4 udy_arr[6] (__hadd bf16 accumulation, -24 registers, STACK=0) and restored unconditional Loop 1 ux0_arr[g] DRAM prefetch in resid_rms1536_warp_bwd_kernel, cutting cold-L2 runtime from 262.82 -> 221.83 us/call (22.08 -> 18.63 ms/step, 4.08 TB/s = 98% of HBM roof, 0.0 bitwise diff across all 5 outputs).
  - Scheduled big_muon_gis[0] ReduceScatter immediately after tiny_muon_gis (Johnson-optimal flow-shop ordering) and added refresh_fp8_weights_split (Stage 0: 121 early weights overlapped on Stream 7 with mlp.c_fc's 1.55 ms AllGather on Stream 17; Stage 1: 24 mlp.c_fc weights after last_fp8_gathers wait).
  - Verified 60/60 exact SHA-256 bitwise match across all parameters and FP8 cached weight buffers on 2 GPUs vs NANOCHAT_OPT_R14=0.
- Full check Result (/tmp/check-r14/check.json):
  - status: PASS, speedup: 1.1884x, tier: N1 (verdict: equivalent, all 6 endpoints within 1.51 sigma: +1.30, -1.51, -0.99, -1.13, -1.21, -1.26 sigma, exact_items_ok: true).
  - Windows: [0.8642, 0.8693, 0.8718] s/update, mean s_per_update: 0.8684 s (301,858 tok/s), peak memory allocated: 53.20 GiB.

---
↑ NanoChat