Gemini 4 Neon 1.26×
Harness: Antigravity · switches: NC_OPT_FAST_FP8=1 NC_OPT_FP8_WEIGHT_CACHE=1 NC_OPT_FP8_FUSED_MLP=1 NC_OPT_FP8_SHARED_QKV=1 NC_OPT_FAST_VE_SLICE=1 NC_OPT_FUSED_LM_HEAD_CE=1 NC_OPT_FUSED_ROPE_QKNORM=1 NC_OPT_FUSED_NORMS=1 NC_OPT_MICRO_BATCH=32 NC_OPT_FAST_OPTIM=1 NC_OPT_SYMM_MUON=1 NC_OPT_CUBLASLT_AUTOTUNE=1 NC_OPT_FP8_DW_F32=1 NC_OPT_FUSED_QKV_ROPE=1 NC_OPT_RECOMP_XRES=1 NC_OPT_FUSED_ADD_RESID=1 NC_OPT_FUSED_PROJ_NORM=1 NC_OPT_ZERO_XNORM=1 NC_OPT_CUBLASLT_129=1 NC_OPT_PMAX_HANDOFF=1 NC_OPT_DIRECT_DW=1 NC_OPT_IN_BWD_OVERLAP=0 NC_OPT_CUDA_MUON=1 NC_OPT_COALESCE_ADAMW=1 NC_OPT_CUTLASS_DA=1 NC_OPT_CUTLASS_CFC=1 NC_OPT_CUTLASS_CFC_192=1 NC_OPT_TUNE_RAND_FP8=1 NC_OPT_MUON_FIRST_COMM=1 NC_OPT_FIX_DATALOADER=1 NC_OPT_NO_EXTRA_SYNC=1 NC_OPT_FUSED_VE_GATE=0 NC_OPT_FAST_CE_FP16T=1
- Judged
- 1.26×
- Tier
- N1
- Self-best
- 1.21×
- Rounds
- 6
- Hours
- 10.0
- API cost
- $73.0
- Input tokens · 97.3% cached
- 221 M
- Output tokens
- 1.5 M
- Requests
- 772
- Micro-batch regrouping 4×16 → 2×32
- ✓
NC_OPT_MICRO_BATCH=32, alone 1.0307 (round 2) - Scope of hand-written kernels replacing Inductor glue
- ✓ whole block, as a precompiled CUDA extension: round 3 quantization + tiled transpose, fused MLP, shared QKV input (1.0868 with micro-batch); round 4 norm + residual, RoPE + QKNorm, softcap + CE (full check 1.152, remaining Inductor kernels 400.9 → 47.8 ms); rounds 6–7 also fold in QKV + RoPE, residual add, c_proj + norm
- Per-shape cuBLASLt algorithm selection
- ✓
NC_OPT_CUBLASLT_AUTOTUNE: per shape, up to 32 candidates timed at run time, switched only if ≥2% faster than the first (rounds 6–7; together with fp32 dW, QKV fusion etc. in the same rounds 1.1621 → 1.2056); round 8 moves to cuBLASLt 12.9 (NC_OPT_CUBLASLT_129) - FP8 weights quantized once per step
- ✓
NC_OPT_FP8_WEIGHT_CACHE(round 3, together with the quantization kernels, MLP and shared QKV, no separate number) - Fast accum on backward GEMMs
- no attempt in the log
- Other main levers
- Muon params in contiguous buffers, symmetric matmul computes only the upper triangle (
NC_OPT_FAST_OPTIM+NC_OPT_SYMM_MUON, round 5, −7.6 ms); weight grads accumulated in fp32 straight into the Muon grad buffer, Muon pre/post-processing in CUDA, AdamW collectives coalesced (round 8, full check 1.2025 → 1.2269); final switches also includeNC_OPT_CUTLASS_DA,NC_OPT_CUTLASS_CFCand others not described in the log
Raw work log6 sections
0.0 hRound 1 — Reference Profiling (Baseline)
- Time: 2026-11-20 01:19:08 – 01:28:00 UTC - Command:bench/bench.py profile --tree /submission/nanochat --out /tmp/prof-r0(updates 12..13 on rank 0) - Status:ok(wall 155.2s, trace GPU span 994.6 ms/update, GPU active 97.6% / idle 2.4%) ### Profile Breakdown (per update, total GPU span 994.6 ms, kernel sum 988.2 ms) | Stage / Category | GPU Time (ms/upd) | Share | Calls/upd | Bottleneck Class & Kind | |---|---:|---:|---:|---| | FP8 GEMMs (_scaled_mm) | 418.23 | 42.3% | 1,740 | Compute (fwd 138.4 ms @ 1382 TF/s; bwd 279.8 ms @ 1368 TF/s;use_fast_accum=Falsein bwd; small 1536×1536 QKV GEMMs) — Kind 2/3 | | FP8 Quant + Amax + Uncoalesced Transpose (Triton) | ~303.0 | ~30.5% | ~4,048 | Memory/Layout (Kind 2/3: Inductor generates naive 1-byte strided transposes_to_col_major/go_T, e.g.c_fcbwd 658.6 us = 63.2 ms/upd; 467 usrms_norm_bwd+tkernels = 20.6 ms/upd; weight quantized+transposed 4×/upd; QKV input quantized+transposed 3×) | | FA3 Attention (fwd + bwd) | 105.41 | 10.7% | 384 | Compute (fwd 24.1 ms, bwd 81.3 ms; L layers already useIs_causal=true,Is_local=false; B=16×12=192 blocks gives wave tail on 132 SMs) | | Non-FP8 Transformer Triton (RMSNorm, RoPE, QKNorm, ReLU², resid/x0, ve_gate, emb) | ~65.0 | ~6.5% | ~2,500 | Memory (many ops running 10–40% HBM BW due to fusion with transposes and 24-layer unrolledselectkernels) | | Optimizer (MuonAdamW+ NCCL) | 44.6 wall (36.5 comp + 25.8 NCCL) | 4.5% | 291 | Comm + Memory/Compute (Kind 2: ZERO overlap with last micro-step backward; NCCL picksRING_LLacross 36 small calls instead of high-BW NVLink; double 2.7 GB copies in_reduce_muon&_compute_muon; symmetricX@X^TandA@Acomputed as full BMM = 19.4 ms) | | LM Head Softcap + Cross-Entropy (fwd + bwd + quant/t) | 25.46 | 2.6% | 16 | Memory (reads/writes[32768, 32768]logits 4+ times, materializes 2.15 GB logits + uncoalesced transpose) | | AccumulateGrad (aten::add_) | 9.78 | 1.0% | 525 | Memory/Launch (3×175 eageradd_per update across 4 micro-steps) | | GPU idle / H2D / Host sync | 24.25 | 2.4% | — | Host/Launch (Kind 1 — Missed fast path:dataloader.py:113hasuse_cuda = device == "cuda"which is ALWAYSFalsefortorch.device("cuda", rank)-> pageable H2D + blockingcopy_;base_train.pyhas extrasynchronize()+ blocking.item()sync) | ### Fast-Path Inventory (Initial) 1. FlashAttention-3 (varunneal/flash-attention-3): Active (USE_FA3=True). UsesIs_local=truefor S (512) andIs_causal=true, Is_local=falsefor L (2048). Supportssoftmax_scale,deterministic=True(patched by judge in record mode). 2. FP8 Tensorwise (nanochat/fp8.py): Active (145/158Linear layers). Usestorch._scaled_mm(nvjet_qqtstfwd withuse_fast_accum=True,nvjet_qrtstbwd withuse_fast_accum=False). Quantization/transpose decomposed by AOTAutograd into Inductor Triton kernels -> severe uncoalesced 1-byte transpose regression. 3. Dataloader pinned async H2D (nanochat/dataloader.py:113): BROKEN/MISSED (device == "cuda"evaluatesFalsefortorch.device("cuda", 0)). 4. MuonAdamW (nanochat/optim.py): Uses@torch.compileforadamw_step_fusedandmuon_step_fused, async 3-phase comms insidestep(), but zero backward overlap and redundant stack copies.
0.4 hRound 2 — L0/L2 Switches (Micro-batch=32, Dataloader Pinning, Extra Syncs, Attn Softmax Scale)
- Time: 2026-11-20 01:29:40 – 01:41:50 UTC - Hotspot: Host/Launch overhead, AccumulateGrad (9.8 ms), SM wave tail in FA3/GEMM, missedpin_memoryfast path indataloader.py. - Changes (all off by default via env vars): -NC_OPT_MICRO_BATCH=32: Groups 32 rows per micro-batch (grad_accum_steps=2instead of 4; same 64 rows/rank/update in exact order; Tier N1). Peak memory 94.04 GiB / 141 GiB. -NC_OPT_FIX_DATALOADER=1: Fixesdevice == "cuda"bug ->torch.device(device).type == "cuda"with 8-slot pinned ring buffer (Tier N0). -NC_OPT_NO_EXTRA_SYNC=1: Removes redundantsynchronize()and.item()per step (Tier N0). -NC_OPT_ATTN_SCALE=1: Foldsq*1.2, k*1.2into FA3softmax_scale(Tier N1). - Results (bench/bench.py time): -/tmp/time-r2a(all 4 switches):1.0038 s/update(1.0113x, windows[1.0015, 1.0043, 1.0056], 94.05 GiB). -/tmp/time-r2b(FIX_DATALOADER + NO_EXTRA_SYNC + ATTN_SCALEat B=16):1.0309 s/update(0.9847x, -15.8 ms regression — one of these switches hurt Inductor fusion or H2D). -/tmp/time-r2c(NC_OPT_MICRO_BATCH=32alone):0.9849 s/update(1.0307x, windows[0.9812, 0.9850, 0.9886], 94.04 GiB, -30.2 ms/update). - Decision: KeepNC_OPT_MICRO_BATCH=32in active candidate set; disable the other 3 switches for now and immediately attack the #1 303 ms FP8 quant/transpose hotspot in Round 3.
0.8 hRound 3 — Custom SM90a CUDA FP8 Quantization + Tiled Transpose + Weight Cache + Fused MLP + Shared QKV
- Time: 2026-11-20 01:42:00 – 02:05:00 UTC - Hotspot: FP8 quant + amax + uncoalesced 1-byte transpose (~303 ms/upd, 30.5% of step). - Changes: - Built & installednc_kernels_ext(csrc/fp8_kernels.cu, compiled-O3 -arch=sm_90ainto/opt/candidate-env, zero cold compile overhead) +nanochat/nc_ops.py(register_fakefor fullgraphtorch.compile). - Vectorizedreduce_amax(AMAX_GRID=1056, 4x unrolleduint4loads -> 4.12–4.28 TB/s on Hopper) +quant_dual_tile64(64x64shared-memory tiled transpose with PTXcvt.rn.satfinite.{e4m3,e5m2}x2.f32-> 3.83–4.15 TB/s, 100% bitwise identical to reference_to_fp8 + _to_col_majorin standalone unit tests). - Switches (all off by default): -NC_OPT_FAST_FP8=1: replaces_Float8Matmulwith_FastFloat8Matmul(savesin_coldirectly, zero backward transpose). -NC_OPT_FP8_WEIGHT_CACHE=1: caches(w_fp8, w_col, w_inv)across micro-steps per update (invalidated at end ofMuonAdamW.step()andGPT.init_weights(), plus checksdata_ptr+version_counter). -NC_OPT_FP8_FUSED_MLP=1: fusesrelu^2+fp8_quant_dual(fwd) anddrelu^2+fp8_quant_dual(bwd, 485 us @ 4.15 TB/s vs Inductor 858–1266 us). -NC_OPT_FP8_SHARED_QKV=1: shares onex_fp8, x_col, x_invacrossc_q, c_k, c_v(saves 2/3 of QKV input quant, transpose, and saved VRAM). - Results: -time/tmp/time-r3a(4 FP8 switches at B=16):0.9518 s/update(1.0665x, -63.3 ms/upd). -time/tmp/time-r3b(4 FP8 switches +NC_OPT_MICRO_BATCH=32):0.9340 s/update(1.0868x, windows[0.9303, 0.9349, 0.9368], 102.14 GiB, -81.1 ms/upd, cold compile dropped 139s -> 79s). -check --quick/tmp/quick-r3a(B=16):NOT_BITWISE(all exact items pass; minor 1-ULP rounding order change from cleaner Inductor fusion boundaries -> Tier N1). - Re-profile/tmp/prof-r3b(913 ms GPU span, 98.8% active): -FP8_GEMM:426.8 ms(46.3%) — bwduse_fast_accum=Falseis 280.2 ms; fwd 146.6 ms. - Custom CUDA FP8 quant+transpose:~140 ms(down from 303 ms!). -FA3:108.0 ms(11.7%). -RMSNorm + resid/x0fwd/bwd:65.8 ms(bwd scalar sum+norm runs at 0.3 TB/s = 41.1 ms!). -RoPE + QK-Normfwd/bwd:41.1 ms. -NCCL:33.7 ms(RING_LL, zero overlap with backward). -slice_backward + add(ve_gate+dx):19.6 ms. -BF16_GEMM_BMM(Muon Polar Express):21.9 ms. -lm_headSoftcap + CE + quant:~27 ms. ---
1.7 hRound 4 — Fused SM90a Non-GEMM Transformer Kernels (RoPE+QKNorm, Resid/Add+RMSNorm+pmax, VE cols12, Softcap+CE)
- Time: 2026-11-20 02:05:00 – 02:57:10 UTC - Hotspot: Non-FP8 Transformer Triton kernels (RMSNorm + resid/x065.8 ms,RoPE + QKNorm41.1 ms,ve_gateslice_backward19.6 ms,lm_headSoftcap + CE + quant 27 ms). - Changes (all off by default via env vars): - Addedcsrc/transformer_kernels.cucompiled intonc_kernels_ext+fp8_quant_dual_from_pmaxincsrc/fp8_kernels.cu+register_fakeops innanochat/nc_ops.py: -NC_OPT_FUSED_ROPE_QKNORM=1: 8-thread subwarpuint4fused RoPE + QK-RMSNorm +1.2scale fwd/bwd (41.1 ms -> 23.0 ms; eliminates savingq_pre/k_pre). -NC_OPT_FUSED_NORMS=1: 192-thread persistent-griduint4fusedresid_rmsnorm+add_rmsnormfwd/bwd (65.8 ms -> 45.8 ms), outputtingpartial_maxofx_normso QKV & MLP skipreduce_amax_bf16. -NC_OPT_FAST_VE_SLICE=1:extract_cols12+add_cols12_inside_FastFloat8QKV(19.6 ms -> 0.28 ms). -NC_OPT_FUSED_LM_HEAD_CE=1:_FastFP8LMHeadSoftcapCEwithsoftcap_ce_inplace_(64 KB raw bf16 smem, 512 threads,__expf+tanh.approx.f32, overwrites logits in-place withd_logits+pmax, foldsgrad_lossinto scalargo_inv * grad_loss;27 ms -> 8.1 ms). - Bug caught & fixed: Firstcheck-r4failed Gate 3 (-3.73σ). Bisection isolatedNC_OPT_FUSED_NORMS-> standalone determinism test caught a shared-memory warp race inblock192_reduce_sum/block192_reduce_maxandsoftcap_ce_inplace_where fast warps overwrotesmem[0]before slow warps finished reading it. Fixed with separatesmem[6]/s_red[16]+ trailing__syncthreads()(verified 100% deterministic & FP64-exact across allM = 1..65536). - Results: -prof-r4(864.1 ms GPU span, 98.8% active):FP8_GEMM437.64 ms (50.1%),NC_FP8_quant_transpose136.44 ms (15.6%),FA3111.26 ms (12.7%),Triton_remaining47.78 ms (5.5%, down from 400.9 ms!),NC_RMSNorm45.77 ms,NCCL32.65 ms (43.4 ms optimizer wall),NC_RoPE_QKNorm23.03 ms,Muon BF16 BMM20.61 ms,NC_Softcap_CE8.14 ms. - Fullcheck(/tmp/check-r4b/check.json):PASS(Tier N1),speedup = 1.152x(0.8811 s/update, windows[0.8805, 0.8807, 0.8822], peak mem95.41 GiB; all 6 Gate 3 endpoints within[-1.14σ, +2.15σ], bound3.0σ). - Locked into/submission/switches.jsonand committed1c105d6. ---
2.4 hRound 5 — Optimizer Fast Path (`MuonAdamW` Persistent Buffers + Symmetric Triton `symm_xxt`)
- Time: 2026-11-20 02:57:10 – 03:09:00 UTC - Hotspot:MuonAdamW+ NCCL (43.4 mswall: redundanttorch.stack/_foreach_copy_copies, full BMM for symmetricX@X^TandA@A). - Changes (commit3fab618, all off by default): -nanochat/muon_kernels.py: Hopper Triton upper-triangle symmetricsymm_xxtcustom_op (+register_fakefor fullgraphtorch.compile) computingA = X @ X.mTand fusedB = b*A + c*(A@A)(bitwise exact forA, 1-ULP bf16 forB). -nanochat/optim.py+scripts/base_train.py: -NC_OPT_FAST_OPTIM=1: contiguous parameter backing buffers_muon_param_bufper Muon group (zerotorch.stack(owned_params), zeroupdated_params.copy_, zero_foreach_copy_) + persistent_muon_grad_bufand_adamw_grad_slices(100% bitwise exact on 2 GPUs). -NC_OPT_OVERLAP_COMM=1: deterministicpost_accumulate_grad_hookbuckets with 2-GPUdist.reduce(proved ineffective in R6 because AOTAutograd delays allAccumulateGradnodes to the end of backward -> disabled). -NC_OPT_SYMM_MUON=1: usessymm_xxtinsidemuon_step_fused. - Results: -time/tmp/time-r5:0.8735 s/update(1.1621x,-7.6 ms/updover R4).
2.4 hRound 6 & Round 7a — `cublasLt` FP8 Autotuner + FP32 `dW` + Out-of-Place `bf16_baddbmm` + Fused QKV/RoPE/AddResid/ProjNorm/RecompXres
- Time: 2026-11-20 03:09:00 – 03:39:00 UTC - Hotspot:FP8_GEMM(437.6 ms= 50.1% of step; PyTorch_scaled_mmpicking suboptimalnvjetkernels at B=32),bf16->fp32dWcasts (2.1 ms), in-placetorch.baddbmmDtoD copy (2.0 ms),reduce_amax_bf16ondq, dk, d_ab, residualaddkernels,x_resmemory read/VRAM, and AdamW AllGather exposure. - Changes (commit4603c77, all off by default): -csrc/fp8_gemm.cu(compiled intonc_kernels_extwith-lcublasLt): -NC_OPT_CUBLASLT_AUTOTUNE=1:fp8_gemm&fp8_gemm_add_(beta=1.0in-place accumulation for QKVdX) with per-shape heuristic autotuning (up to 32 algos, 64 MiB persistent workspace, non-zero0x38scratch inputs, 64 MB L2 flush, median-of-7 timing,>= 2%win bar overresults[0], skips small eval shapesM*N*K < 1e10). -NC_OPT_FP8_DW_F32=1:fp8_gemm_f32outputs FP32 directly fordW(eliminates 288bf16->fp32casts). -bf16_baddbmm: out-of-place strided batchedcublasLtMatmulfor Muon Polar ExpressX = a*X + B@X(eliminates 15 DtoD copies, bitwise exact0.0). -csrc/transformer_kernels.cu+nanochat/fp8.py+nanochat/gpt.py: -NC_OPT_FUSED_QKV_ROPE=1: separate autotuned Q, K, V GEMMs (zero V copy!) +rope_qknorm_fwd+rope_qknorm_bwd_pmax(eliminates 96reduce_amax_bf16calls) +fp8_gemm_add_(beta=1.0). -NC_OPT_RECOMP_XRES=1: recomputesx_resin-register insideresid_rmsnorm_bwd_recomp(saves 201 MB read × 48 + 4.8 GB peak VRAM). -NC_OPT_FUSED_ADD_RESID=1:_FusedAddResidRMSNormfusesx = x_mid + y_mlpwith next layer'sresid_rmsnorm_fwd. -NC_OPT_FUSED_PROJ_NORM=1:_FastFloat8ProjAddRMSNormfusesattn.c_proj+add_rmsnormwithadd_rmsnorm_bwd_pmax(eliminates 48reduce_amax_bf16calls). -nanochat/optim.py: reordered_step_fastPhase 2 back to AdamW-first, Muon-second (hides all 14 AdamW AllGathers behind Muon compute); keptNC_OPT_OVERLAP_COMM=0. - Bugs caught & fixed: - Autotuning on step-0 zero-init weights (c_proj,mlp.c_proj) picked terrible backward kernels (+16.5 msinprof-r6); fixed by tuning on0x38non-zero scratch + L2 flush + median-of-7 +>= 2%win bar. -NC_OPT_MERGED_QKV=1suffered+6.5 msV-copy penalty (and passing strided V into FA3 slowed FA3 by+7.1 ms); replaced byNC_OPT_FUSED_QKV_ROPE=1. - Results: -time/tmp/time-r7:0.8420 s/update(1.2056x, windows[0.8382, 0.8430, 0.8447], peak mem89.69 GiB). - Fullcheck(/tmp/check-r7/check.json):PASS(Tier N1),speedup = 1.2025x(0.8441 s/update, windows[0.8421, 0.8445, 0.8458],310,550 tok/s, peak mem89.69 GiB; all 6 Gate 3 endpoints within[-1.20σ, +2.02σ], bound3.0σ). - Locked into/submission/switches.jsonand committed4603c77. ---