Modded-nanogpt emerged from a community speedrun launched in 2024 with a clear challenge: train a GPT-2-scale language model from scratch on eight NVIDIA H100 GPUs until reaching a validation loss of 3.28 or lower, and do it as fast as possible. Since that starting point, dozens of contributors have chip away at the time, pushing the benchmark from an initial 45 minutes down to nearly 30 seconds. The project exists as a series of pull requests on a public repository, each one documenting the specific changes that whittled away seconds or minutes from the total runtime.

The attempt described here became the fourth submission in as many weeks. Three weeks prior, the author's second attempt clocked in at 30.67 seconds. Then @caraxesml posted PR #404, achieving 30.25 seconds on Google Kubernetes Engine and 30.05 seconds on a RunPod node. That left the 30-second barrier just 50 milliseconds away. The current attempt, submitted as PR #406 (code) and PR #407 (runs and logs), stacks cleanly on top of #404 with +175 net lines across eight files. The model, data, and 1,053 training steps remain identical — the only variable is less wasted GPU work. On the same 8×H100 node, it shaves 145 milliseconds and crosses cleanly under 30 seconds at 29.90 seconds. The authors note this is Track 1, the standard from-scratch pretraining ruleset. Separate retrieval-hybrid tracks exist that reach 5–10 seconds under different rules allowing exact lookups from training data, but those fall outside this attempt's scope.

Standing on other people's work

Almost every optimization that makes this model fast traces back to a small group of contributors. Keller Jordan originated the speedrun. @francesco-prignano submitted PR #393, a significant jump. @caraxesml followed with PR #404, the previous benchmark-setter. Because different cloud clusters run at slightly different speeds — PR #404 ran 30.25 seconds on GKE versus 30.05 seconds on the same RunPod node — the author timed #404 and the new code back-to-back on the exact same machine to ensure a fair comparison.

Why "same math" can still run faster

Modern GPUs are extraordinarily fast at arithmetic, so they often spend their time waiting on memory traffic or tiny setup overheads rather than pure computation. Two simple ideas account for most of the 145 millisecond gain. The six specific fixes in PR #406 each target a different kind of overhead.

One optimizer pass instead of two

Previously, the optimizer rescaled each weight row, wrote the result out to GPU memory, and immediately read it back to apply weight decay. Combining both into one compiled pass keeps the intermediate value in fast on-chip registers and cuts 61 gigabytes of memory traffic. The before version wrote v_chunk out to GPU memory, applied the scale and type conversion, then called a separate decay update function. The after version fuses both operations: the update equals (v_chunk times eq_scale.type_as(v_chunk)) cast to float, a single compiled kernel with zero round-trip traffic.

Fill the full 128-byte memory line

When packing model weights down to 8-bit (FP8), the GPU was writing 64 bytes at a time — half of an H100's native 128-byte memory line. Widening the tiles to 128×128 fills the whole line in one write, and folding the scale calculation into the same kernel cuts extra kernel launches.

Skip an extra copy in the MoE optimizer

The model's specialist sub-networks, a Mixture-of-Experts configuration, were taking a slower optimizer path that made a separate copy of the weights. Moving them to the fast custom path and hiding that copy on idle GPU cores removes the extra step completely.

Write 16-bit gradients directly

Gradients for the token-copying layer were previously written out as 32-bit floats and then converted to 16-bit (bfloat16) in a second step. Casting on the way out cuts memory traffic in half with identical bits. The before version stored float32 temporaries then cast to bf16 in a second pass. The after version casts (dq * scale) to DQ.dtype.element_ty in a single store.

Spread work evenly across all 132 GPU cores

A 4-line tile tweak in the MoE backward pass, changing tile size from 128×256 to 128×128, creates twice as many independent work blocks. This keeps all 132 compute units on each H100 busy instead of leaving some waiting.

Warm up final-step kernels before the clock starts

PyTorch loads some GPU kernels lazily the first time a code path runs. Triggering the end-of-run weight-averaging path once during untimed setup keeps that one-time loading cost off the stopwatch.

Numbers from the test suite

To rule out hardware drift, the team ran four interleaved rounds on one RunPod 8×H100 node: one run of the previous benchmark (#404), then three runs of the new attempt. Random seeds were used and no runs were dropped. The results:

AttemptRunsMean timeRangeValidation loss
this attempt (#404 + #406)1229.90 s29.87–29.99 s3.2778
#404 interleaved (same node)430.05 s30.04–30.06 s3.2795
#396 (my 2nd attempt, same node)230.58 s30.57–30.59 s3.2786

Twelve out of twelve runs finished under 30.00 seconds and below the 3.28 loss target, with a p-value of 8.98 × 10^-6. The new attempt is 145 milliseconds faster than #404 on the exact same machine (p < 10^-9), and 0.68 seconds faster than the author's previous #396 attempt. Energy consumption came in at 45.0 watt-hours per run (5.42 kilowatts across 8 GPUs at 72 °C maximum, zero throttling) — roughly the electricity needed to boil 400 milliliters of water in a kettle, down from 45.2 watt-hours on #404 and 45.6 watt-hours on #396.

What didn't work

Not every idea measured up once tested on real hardware. The authors tested every optimization on a cheap single H100 pod first (about $2 total) before committing to 8×H100 runs, saving hours of expensive cluster time. Three dense-MLP rewrites all ran slower — PR #393's kernel was already sitting at about 96% of the H100's hardware limit. Widening the attention-prep backward kernel crashed NVIDIA's GPU compiler with a ptxasSIGSEGV error. Sorting validation IDs on CPU looked tidy on paper but accidentally added 537 milliseconds before the team caught and reverted the change. The authors also threw away a working 10 millisecond win: an extra 132-line optimization pushed the run to 29.88 seconds (also passing n = 12, p = 0.0058), but they cut it from the PR to respect the repo's cleanliness rule — 132 lines for 10 milliseconds wasn't worth the complexity.

What's next

A final GPU profile of the winning run shows roughly 10% of GPU time still goes to multi-GPU communication — gradient exchanges and n-gram lookups. Trimming or overlapping more of that looks like the cleanest path toward 29 seconds flat. The author credits Keller Jordan for starting the speedrun, @francesco-prignano for #393, and especially @caraxesml for #404. Even if #406/#407 doesn't hold up on maintainer hardware, breaking 30 seconds on a rented node — and seeing which ideas survived reality — was a lot of fun.

How this attempt was made

The author used Google Antigravity with Gemini agents running in parallel for GPU profiling, Triton/PyTorch kernel work, single-GPU parity checks, RunPod provisioning, and clean zero-interference 8×H100 runs. Development and dead-end screening ran on single H100 pods (about $2), followed by 2 hours 48 minutes on one 8×H100 SXM node on RunPod for the interleaved certification runs and final profile. Every run is counted, and every log embeds the exact source code that produced it. The submission, its claims and any mistakes are the author's alone.