resume | github | huggingface | linkedin | email home | projects | blog


AWS Trainium Frontier

Train a language model from scratch in 30 minutes on one AWS Trainium chip. PyTorch, NKI kernels, AI agents.

source | write-up

The AWS Trainium Frontier is a competition run on AWS's own ML chips. Phase 1 gives every team a single Trn2 chip and exactly 30 minutes of training, then scores the model on held-out web text in bits per byte, where lower is better. You can change anything in the training script: the architecture, the optimizer, the data sampling, and even the hardware kernels, which on Trainium are written in NKI, a Python kernel language. I'd never touched a Trainium chip before this.

Between August 31 and September 30 I took the organizers' baseline from 1.259 to 0.959 bits/byte on the public validation shard, across 106 submission versions and about 750 logged training runs, and finished in the top 15 of 100 teams. The top 10 advanced to Phase 2; I was 10th for a while before three late teams pushed me just below the cut.

Diagram of the model: a 14-layer transformer with U-net skips, a hashed bigram embedding, and an n-gram model mixed into the output logits

The final model. The n-gram tables are counted from the training data during the run, so nothing outside the training loop goes into it.

how I worked

The competition treats AI-assisted research as a first-class way to enter, and that is how I did it. I came up with the ideas and made the calls about what to try next, and AI coding agents (Claude Code) wrote most of the code, ran the experiments on the dev box, and kept a written record of every result. The interesting part of the project was learning how to run that loop well: how to tell a real gain from noise, and how to catch an agent confidently explaining a result that turned out to be a bug.

what's in the final model

where the gains came from

Roughly in order: getting torch.compile working on Neuron, moving the hot path into NKI kernels so steps got cheap enough to afford more layers, fixing a slow embedding update that was mostly padding, tuning the weight averaging, and finally the n-gram mix. Almost every architecture change I tried was a wash. Width and depth anywhere in a wide range landed within 0.002 of each other, because a bigger model costs nearly as much in lost steps as it gains in quality.

challenges

The longer story, with the mistakes, is in the write-up.


back to projects