One kernel launch per GPU

Five agents run the same trip side by side; the wins, in the order they happen, are the tree

Top: one trip drawn large, left to right: an agent proposes a diff; the generator turns a layer graph and a sequence length into CuTe DSL; NVIDIA's compilers lower it to PTX and ptxas lowers that to SASS, which we edit directly; eight H100s compute the reward; the reward comes back and a win becomes a new node, otherwise it is dropped. A soft colored stroke under each stage is the key for the trips below. Middle: five agents start together on the left and their lanes spread out over time; each lane is a row of soft trips of that shape, and most are dropped. Colored arcs between lanes, in the gaps between trips, are messages: plan, review, execute. Bottom: each win drops to a tree drawn on the same time axis. The trunk runs through six versions; a branch leaves the second and is carried back into the fourth; another leaves the fourth and loops layers.

The megakernel runs on NVIDIA H100s, so here's a quick primer on what this GPU actually is. An H100 has 132 streaming multiprocessors (SMs), and each thread block runs on one SM. An SM holds 65,536 registers, which are the fastest storage on the chip, and 228 KB of shared memory, a scratchpad that all the threads of a block can read and write. One block can only use up to 227 KB of it, because CUDA keeps a little bit left over for miscellaneous stuff. The hardware schedules warps of 32 threads, and four consecutive warps form a of 128 threads. Hopper's tensor cores execute matrix instructions at the scope of a warp group. Everything else lives in the GPU's 80 GB of , behind a 50 MB L2 cache. HBM has about 3.35 TB/s of bandwidth but hundreds of cycles of read latency, while a read from shared memory takes a few dozen cycles.

A normal CUDA program is a sequence of kernel launches. Each launch places fresh blocks on the SMs, and when a kernel ends, the hardware discards the blocks' registers and shared memory, and only what the kernel wrote to HBM survives. Each operation runs as its own kernel, so every intermediate tensor has to take a slow round-trip through HBM on its way to the next kernel. The host (the CPU) handles everything between kernel launches, like sequencing, the data pipeline, logging, etc. The Nsight trace above of NVIDIA's Megatron-LM shows the thousands of kernel launches in a single training step.

One alternative is a : a launch that admits only as many thread blocks as the GPU can run at once. In a cooperative grid, every block is what I call resident, meaning that it stays on its SM from the start of the kernel to the end. Resident blocks can synchronize with each other in the middle of the kernel through a grid barrier: every block adds one to a counter in device memory and waits until every block has arrived. A barrier is cheap-ish (a few microseconds), but as with any sync, it's bad when you have stragglers. Since the kernel doesn't end between operations, nothing forces an operation to write its result to HBM just so the next one can read it. A program that contains every operation can decide where each value should go instead of just writing everything to HBM by default.

A kernel boundary empties the SMs, and a grid barrier keeps their state

Two time lines of the same three operations, projection, attention, and normalization, on four representative SMs of 132, with the host above and HBM below. Top, a normal CUDA program: the host launches each operation as its own kernel. Each kernel places fresh blocks on the SMs; between kernels the SMs are empty, the blocks' registers and shared memory are discarded, and each intermediate result goes out to HBM and is read back by the next kernel. Bottom, a cooperative grid: the host launches once, and each SM keeps one resident block from the first operation to the last. Between operations, blocks that finish early wait at a grid barrier for the slowest block, keeping their registers and shared memory, and the program decides which values go to HBM. Both time lines take about the same total time.

Hatching is a resident block waiting at a barrier for the slowest block; a blank stretch is an SM with no block at all. Widths are schematic.

Our megakernel is one such launch on each GPU: 132 blocks of 384 threads, one block per SM. The blocks stay put from the first embedding lookup through forward, loss, backward, communication, and the optimizer, then into the next step, and the next, and the next. I'll explain how we handle looping, and how we handle things like logging and checkpointing.

On an H100 node, eight GPUs are connected via the NVLink fabric, which lets the GPUs read and write each other's memory. We can't run communication through NCCL, because that would entail new kernel launches, so the megakernel has to handle communication as well, as I'll show. The eight launches form one distributed program. The host launches each GPU's function once, and the function exits when the requested number of optimizer steps is done.

What counts as a megakernel

To the best of my knowledge, megakernels so far have fused a forward pass or a single layer, never a training step.Hazy Research, No Bubbles (2025) and the tensor-parallel Llama-70B megakernel (2025); Mirage MPK (2025); Luminal (2026); Cursor, Mixture-of-Kittens (2026). What is a megakernel? I take it to mean one host-visible CUDA function per GPU, and our megakernel contains the entire training loop inside of that one CUfunction.

The megakernel iceberg meme. From the tip down: a large
                       fused kernel is a megakernel; GPU-side scheduling is a
                       megakernel; a CUDA graph is a megakernel; a
                       device-launched CUDA graph is a megakernel; PDL is a
                       megakernel; fine-grained overlap is a megakernel; the
                       GPU is a megakernel.

Our megakernel is pretty different from what I've seen in the literature. The inference megakernels are interpreters. Each SM runs a loop that fetches its next instruction (a small piece of one operation) from its own list or a shared queue, waits on counters in global memory until that instruction's inputs are ready, and then runs it. The point is to remove the gaps between the many small operations of low-latency decoding, where each operation is limited by memory bandwidth rather than arithmetic. Ours is one compiled program. All 132 blocks run the same sequence of operations, and the only scheduling that happens at runtime is which block takes which tile inside an operation.

Our compiler writes the kernel

We have a Python compiler for the megakernel that takes as input the number of layers and the number of tokens per GPU and writes CuTe DSL.CuTe DSL is NVIDIA's Python language for writing CUDA kernels, built on CUTLASS's CuTe library of tensor layouts. The compiler doesn't search. Each operation has one implementation, and every choice in it, from tile shapes to which activations to keep, was made by the agents while they built and tuned the megakernel (The Climb describes how they decided what to keep). The compiler lays out the one shared-memory page that every operation shares and fixes the layout of the address tables the kernel reads. We choose to write CuTe DSL so that we can just take advantage of FlashAttention 4 and Quack. The CuTe DSL compiler lowers the result to PTX,PTX is NVIDIA's virtual instruction set, the assembly-like language that CUDA compilers emit. NVIDIA's assembler, ptxas, turns PTX into machine code for a specific GPU. and NVIDIA's assembler turns that into . You can download the built kernel from the GitHub release or compile it yourself in about fourteen minutes on one H100.

If a kernel runs and doesn't save its output to HBM, did it really run?

By default, kernels write their results to HBM because the next kernel launch needs to read that result. Most intermediates in our megakernel still live in HBM too. The difference is that the whole step is one program, so every operation that will ever read an intermediate is known in advance, and there are three options: write the result to where it's needed, keep it if we don't want to recompute it, or delete work whose result we don't need.

Write it where it's read

One example: the attention-output projection adds its residual in its epilogueThe epilogue is the last stage of a matrix multiplication, where the finished results leave the registers. Small elementwise work, like adding a residual, can happen there before the write. and writes the sum where the next operation reads it, which saves a 256 MiB round-trip through HBM. At the vocabulary head, cross entropy overwrites the 9.3 GiB of logits with their own gradient, and the weight-gradient multiplication writes its result straight into the cross-GPU reduction buffer.

The memory plan fills 77.6 of 80 GiB, a quarter of it with activations kept for backward

A strip for one H100's 80 GiB, split into ten allocations, with one row per allocation below it; each row starts where the row above ends. this rank's eighth of the model: FP32 master, gradient, two AdamW moments, BF16 copy: 17.16 GiB; every layer's input, kept for backward (37 × 256 MiB): 9.25 GiB; attention output and normalizer for 26 layers (nine more are in the gradient buffer): 6.86 GiB; post-attention residuals for the last 12 layers: 3.00 GiB; logits, overwritten in place with their gradient (32,768 × 151,936 BF16): 9.27 GiB; other vocabulary-head buffers: 2.16 GiB; two slots of per-layer intermediates that backward refills by recomputing: 14.00 GiB; attention working state and FP32 accumulators: 4.05 GiB; NVLink arenas and rings: streamed weights, gradient slots, head buffers, embedding buffers: 7.14 GiB; driver stack backing, the CUDA context, and allocator overhead: 4.7 GiB. The three kinds of kept activation, 19.1 GiB together, are teal. The named allocations sum to 72.9 GiB and the measured peak is 77.6 GiB of the card's 80.

Each row starts where the one above ends, so the rows add up to the strip. The first row is this GPU's eighth of the model. Teal is kept for backward instead of recomputed: every layer's input, attention outputs for 26 layers (nine more share a gradient buffer), and residuals for the last 12.

Keep what's expensive to recompute

Keeping every forward intermediate for backward would take about 404 GiB per GPU, so, like Megatron, the megakernel saves each layer's input and recomputes the layer's forward during backward. Where it differs is in how it packs the rest of the card. Every allocation in the figure above has a fixed address and a lifetime known at compile time, so tensors whose lifetimes don't overlap share memory. The agents picked these placements and wrote them into the compiler as constants. The attention checkpoints for the top nine layers, for example, sit in the part of the optimizer's gradient buffer that the backward pass writes to last, and they've been read by the time it gets there. The megakernel uses the room to keep activations that are expensive to recompute, like attention outputs, and peaks at a measured 77.6 GiB. Megatron recomputes them, so it executes 19.0 PFLOP per step to the megakernel's 16.8.

Megatron also has a selective-recompute mode that keeps more activations, but it doesn't fit in memory at our workload. It does fit for a 72-layer model at sequence length 8,192, so we built a megakernel for that workload with the same compiler and timed all three. The megakernel took 2,096 ms per step, Megatron with selective recomputation 2,169 ms, and Megatron with full recomputation 2,386 ms.

Selective recomputation buys Megatron 10 percent over full recomputation, but it saves the attention module's whole autograd state for every layer. On this run it used about 70.4 GiB, against 44.5 GiB with full recomputation. The megakernel saves individual tensors: the attention output and normalizer for nearly every layer, plus twelve mid-layer residuals. It used about 54.7 GiB and was faster than both.

Megatron could implement the same policy with a custom attention autograd path that saves exactly these tensors, but who wants to write that PR into Megatron?

What it takes to run the megakernel on a different workload, from the released compiler.
ChangeWhat it takes
Data, step count, learning rate, document lengthsNothing; set when the run starts
Depth from 2 to 82 layers, 1,024 to 32,768 tokens per GPU in multiples of 1,024, as far as memory allows (at most 41 layers at 32,768 tokens)A recompile, 4 to 14 minutes on one H100. The checkpoint plan is derived again, correct but not re-timed.
Hidden width, head counts, head dimension, more documents per GPU, more GPUs or nodes, another architecture or GPUAgents. The register split and tile shapes were tuned for these constants.

Delete what nobody reads

When backward recomputes a layer's forward, it stops after the gate/up projection. Nothing in backward reads the down projection's output or the residual sum after it, and the megakernel already keeps that sum as the next layer's input, so our compiler leaves the down projection and its residual add out of every layer's recomputation. It deletes copies the same way, with backward alternating between its two gradient buffers instead of copying the activation gradient from one to the other. It deletes allocations too, since the forward multiplications read strided, transposed views of the weights, so the megakernel never stores a transposed copy.

One size fits most

The host launches a normal per-operation kernel with a configuration chosen for it alone: its own grid shape, register budget, and shared-memory layout. Every operation in the megakernel instead inherits one fixed allocation, chosen once for the whole program, and some operations don't fit into this allocation very well.

Three warp groups, one register file

Each 384-thread block contains three 128-thread warp groups. During a Hopper matrix multiplication, one group, the producer, moves operands into shared memory, and the other two, the consumers, issue the tensor-core instructions and hold the accumulators, so the consumers need far more registers than the producer. Hopper lets a warp group return registers to the block's pool or take more from it.The instruction is setmaxnreg: a warp group executes it to lower or raise the number of registers each of its threads can use. I call the division of the block's registers among its three warp groups the register split.

The 36 decoder layers run as a loop, and inside a loop NVIDIA's assembler gives each warp group the most registers it needs anywhere in the loop body, so every operation in a layer has to share one split. FlashAttention's own split is 24/240/240, with its producer in the first warp group, and Quack's is 232/232/40, with its producer in the last. The whole decoder, forward and backward, runs at 56/224/224 instead: Quack's producer moves to the first warp group, where FlashAttention's runs, and both consumer groups get 224 registers, fewer than either library asks for. Only the vocabulary head, which runs once per step outside the layer loop, switches to Quack's own split and back.

The figure below shows that the per-warp union of FlashAttention's and Quack's native splits needs more registers than the block can allocate. A warp group that needs more than its share spills the excess to local memory, which is in HBM, so we end up having to run the attention backward on 64-by-64 tiles.

Together, the two libraries' register splits need 26,624 more registers than the block has

Six horizontal bars, one per register split, each with three segments for the block's three warp groups in physical order, giving registers per thread. A full bar is the block's 64,512 registers. FlashAttention's own split: 24 producer, 240, 240. Quack's own split: 232, 232, 40 producer. The larger of the two for each warp group: 232, 240, 240, which runs 26,624 registers past the end of the block. What the megakernel runs: the decoder layers, forward and backward, at 56 producer, 224, 224, with the producer first and consumers that get fewer registers than either library's, so attention backward runs on 64 by 64 tiles; the vocabulary head at Quack's own 232, 232, 40 producer, outside the layer loop; kernel entry and re-entry at 168, 168, 168. Values are read from the kernel's role dispatch, the head's split transitions, and the two libraries' own register requests.

Each number is registers per thread for one of the block's three 128-thread warp groups, so a full bar is the block's 64,512 registers. One loop containing both libraries would need the third row.

The block also requests 226 KB of shared memory, 1 KB under the limit, and nearly all of it is one page that every operation shares: during attention the blocks fill it with key and value tiles, and during a projection they fill it with tiles of the activations and weights. The blocks cross a grid barrier between operations, 2,133 of them in one optimizer step.

Keeping all 132 blocks busy

Every tile of a projection costs the same, but the blocks don't all start an operation at the same time. In every forward layer but the last, 48 of the blocks first push their GPU's slice of the next layer's weights to all the GPUs.Each GPU stores an eighth of every weight matrix, so before a layer runs, every GPU sends its slice to all of them. The section on communication explains how. In backward, blocks 1 to 48 push the weights of the layer that backward visits next, while block 0 reduces two small normalization-weight gradients. With a fixed assignment of tiles, those blocks would finish last while the rest wait at the grid barrier. So the blocks share projection work through a dynamic queue: a block claims a tile with one atomic add on the queue's counter, computes it, and claims another, and a block that started late simply claims fewer.

Attention's tiles don't cost the same: under the causal mask, a block that takes an early key block of a document visits many times more query blocks than one that takes a late key block. So attention balances its tiles ahead of time, from document lengths that are set when the run starts, instead of through a queue. In backward, the tiles go to the 132 blocks in round-robin order, and our compiler numbers the odd-numbered query heads' key blocks in reverse, so a block that takes an expensive early key block in one head takes a cheap late one in the next. In forward, the host sorts the tiles longest first and assigns each one to the block with the least work so far.

Reversing the key-block walk brings the busiest block from 2.4% to 1.0% above the mean

Two bar charts of 132 bars each, one bar per block, showing how far each block's modeled work in one attention-backward phase is above or below the mean block, in percent. The work is the number of query blocks each block visits, and every GPU's window holds segments of 10902, 10901, 10901, 64 positions. Top, tiles dealt in order: blocks range from 2.4% below to 2.4% above the mean of 10,696. Bottom, with the key-block walk reversed for odd query heads: from 0.7% below to 1.0% above. Counted, not timed.

Counted from the document lengths, not timed. Every GPU packs its window the same way, so all eight look like this. Every block waits at the next grid barrier, so a phase lasts as long as its busiest block.

Even the smallest operations, RMSNorm, query/key normalization, and the rotary encoding, get their own specialized layouts, to keep every warp busy and to avoid extra trips through HBM.

Faster than Megatron...

I use Megatron-LM as a baseline because it is the standard for pretraining codebases. We tuned different configurations for it, and it is definitely possible that Megatron runs faster if you know all the right knobs. Still, every one of the megakernel's steps in the matched run is faster than every one of Megatron's.

Every megakernel step is faster than every Megatron-LM step

Histograms of per-step wall time for the matched 1,000-step runs, both on one time axis, measured as intervals between consecutive log records at the log's 0.06-second resolution; bar heights are on a square-root scale. The megakernel's 999 steps take 4.02, 4.08, or 4.14 seconds (14, 626, and 359 steps), median 4.08. Megatron-LM's 999 steps start at 4.92 seconds: 10 at 4.92, 661 at 4.98, 273 at 5.04, then 54 steps spread from 5.10 to 5.94 seconds and one at 6.66, median 4.98. No step of either run falls between 4.14 and 4.92 seconds.

Step times are intervals between consecutive log records, which the log resolves to 0.06 s. Bar heights follow the square root of the step count, so single slow steps stay visible.

Megatron's median step takes 4.98 seconds and the megakernel's 4.08, a ratio of 1.22.These step times, like the ones in the figure above, are intervals between the log records of consecutive steps, so they include up to one 20 ms poll and Weights & Biases' own buffering. They are not device timings. The kernel publishes loss, norm, clip, and the update count, but no step duration. Of that 1.22, a factor of 1.13 is work that Megatron does and the megakernel does not (19.0 PFLOP per step against 16.8, from the recomputation described above), and the remaining factor of 1.08 is how fast each program executes the work it has.

The strongest baseline for our megakernel is the staged CUDA graph that the same agents built from the same FlashAttention 4 and Quack tile code. It is one captured graph per GPU that replays 3,837 individually configured kernel launches per step. On the same node, the staged graph is 2 percent faster than the megakernel: 4,076 ms per step against 4,159.

One Qwen3-8B optimizer step on eight H100s, the mean of 50 consecutive steps in both run orders.
ProgramStep timePositions per second
Staged CUDA graph, as built4,076 ms64,300
… without the down-projection recompute3,920 ms66,900
… with the megakernel's memory plan3,688 ms71,100
Megakernel4,159 ms63,000

The memory plan isn't specific to the megakernel. Giving the staged graph the same checkpoints and dropping its down-projection recompute makes it 388 ms faster, with 17 GiB of memory still free. With the same plan, the staged graph beats the megakernel by 471 ms, or 13 percent.

Most of the megakernel's extra time comes from fitting one register split

A waterfall chart in milliseconds per step. The staged CUDA graph as built takes 4,076 ms. Skipping its down-projection recompute removes 156 ms and keeping the megakernel's checkpoints removes 232, for 3,688 ms with the megakernel's memory plan. From there, four operations rewritten to fit the megakernel's register split add 357 ms: attention backward on 64×64 tiles 224, query/key normalization and rotary 77, the attention backward preprocess 29, and attention forward with two options off 27. The down-projection backward adds 67, restoring saved attention outputs 9, and everything else 30, with no single operation over 17. The megakernel's other normalization and elementwise work removes 21. Measurement overhead accounts for the last 29, ending at the megakernel's 4,159 ms.

Per-operation bars are from the timestamped megakernel and the profiled staged graph.

Most of that gap comes from operations rewritten to fit the megakernel's single register split. FlashAttention's backward runs on the 64×64 tiles described earlier instead of 64×128. That costs 224 ms, and the same tile slows the staged graph by 215. The backward's preprocessing pass also runs on the 56-register producer warp group, so it is a scalar loop running at a third of the speed of FlashAttention's own kernel (+29 ms). Query/key normalization and the rotary encoding keep their rows in shared memory instead of registers, and they take 98 ms per step against the compiled kernels' 21 (+77 ms). FlashAttention's forward runs with two register-hungry options turned off (+27 ms).

The rest is smaller. Every matrix multiplication shares one tile configuration, which accounts for 32 of the 67 extra ms in the down projection's backward. Restoring the saved attention outputs takes 9 ms, and the megakernel's other normalization and elementwise work comes out 21 ms ahead. These costs don't add exactly, because changing one kernel's configuration can move its neighbors by 20 to 30 ms. Releasing all 2,133 barriers costs 2.7 ms per step, against about 15 for the gaps between the staged graph's kernels, so none of the gap is launch overhead.

Putting 64×128 back doesn't work inside one kernel. Run on its own at the megakernel's register split, the larger tile is 13 percent faster. In the megakernel it spills inside the layer loop, and because registers are allocated for the whole kernel at once, it slows every other operation too. The step gets 1.1 seconds slower. In a CUDA graph, a tile choice only affects its own kernel.

So the staged graph wins today, mostly because every operation in the megakernel has to fit one register split. And the megakernel has collected almost none of what megakernels are supposed to offer. At each barrier, every block waits for the slowest, 76 ms per step on average. A counter would let the down projection start as soon as its own chunk of input is written, which is what Hazy Research's No Bubbles megakernel does. Most intermediates still go out to HBM and come back, where the next stage could read them from the shared memory of the SM that produced them. And the next stage's weight loads could start while the current stage is still computing. A CUDA graph can't do any of these: each kernel starts with empty registers and shared memory and ends by writing its output to HBM, and the only dependency the graph expresses is that one kernel finishes before another starts. Programmatic dependent launch lets the next kernel begin its setup early, but it still reads its input from HBM.

...349,040 machine instructions long...

NVIDIA's assembler turns every operation in this article into one function of 349,040 machine instructions. A function call anywhere inside it would force one register convention on both sides of the call and serialize the asynchronous tensor-core work, so our compiler inlines every operation body.

The loop is one patched instruction

We don't just write Python and CuTe DSL, we also read, audit, and edit SASS directly. To understand the benefits of working at the lowest level of abstraction (the machine code itself), let's consider how our compiler implements looping the megakernel to run multiple optimizer steps. Writing the obvious for step in range(n) around the step runs about 59 percent slower. Why?

It's because of the register split. A launch gives every warp group the same 168 registers per thread, and three setmaxnreg instructions at the top of the step move them into the 56/224/224 split. When the programmer (us) writes a loop around that step, and the CuTe DSL compiler lowers it to PTX, ptxas drops those instructions from the entire kernel, because the loop leaves it unable to prove which warp group is running which code.

With a loop, each warp jumps from the end of one step back to the top, still holding its share of the split. At the top, the kernel picks each warp's role with a branch that ptxas can't resolve at compile time. So for all ptxas knows, the producer, with 56 registers, might run the consumers' code, which needs 224. As a result, there's no split, and ptxas serializes the tensor-core matrix instructions instead of issuing them in batches.

One instruction changes: the step's exit becomes a branch to entry

The end of the benchmarked image's machine code, listed with addresses, as a diff. Address 0x000000 is the function entry, where a launch begins, followed by the rest of one optimizer update. At 0x51c340 an ISETP instruction sets predicate P0 on the last requested step. As compiled, the next instruction, at 0x51c350, is a predicated EXIT that ends the launch on every step but the last. The patch replaces that one sixteen-byte instruction with a predicated branch to address 0x000000, drawn as an arrow back up to entry, changing nine of its bytes and no other byte. The five instructions after it load a pointer, store the sentinel value 0x76543210 for the host, and exit; they now run only after the last step.

Nine of the sixteen bytes at 0x51c350 change, and no other byte in the kernel. The patch tool finds this exit by the sentinel store below it.

How do we get around ptxas? Well, the compiler first just produces one optimizer step with no loop, so ptxas only ever sees a program that runs straight through. Every step but the last leaves at a conditional exit. The last step falls through it, stores a sentinel value, and exits. After assembly, a patching tool finds the conditional exit by the sentinel store that follows it and rewrites nine bytes of that 16-byte instruction into a branch back to the function's first instruction, as the figure shows. Before taking the branch, the warp groups return to the launch's even 168/168/168 split, so the three setmaxnreg instructions at the top of the step can set up 56/224/224 exactly as they do after a launch.

...able to train a large language model in a single kernel launch.

Besides the update itself, a training run needs fresh data every step, checkpoints to resume from, and a record of its progress. All of that happens inside the one launch: ordinary CPU threads keep the loop fed through fixed-size slots and rings. The counters that coordinate them, the logging ring, and the checkpoint slots live in host-mapped memory, which is CPU memory the driver has registered so that the megakernel can load and store to it directly over PCIe. Every handoff uses the same pattern: the producer writes its bytes, then advances a counter with a release store, and the consumer polls the counter, never the buffer.

Let's assume that we have preprocessed our corpus, like DCLM,DCLM (DataComp for Language Models) is an open pretraining corpus of filtered web text. The runs in this article train on it. into properly chunked segments. During the run, a producer thread for each GPU stays one step ahead of the grid through two input slots in device memory. While the grid trains on one slot, the producer reads the next record, builds the labels and the rest of the step's inputs on the CPU, and copies them into the other slot, so it has one full step to do this work.

The host asks for a checkpoint by writing a step number into a mapped header. When the grid's update count reaches that step, all 50,688 of its threads stream the rank'sA rank is one of the eight processes in the run, one per GPU. 11.4 GiB of FP32 state out through two 256 MiB slots of pinned host memory, with no cudaMemcpy: while a host worker writes one slot to disk, the grid fills the other. The grid stalls for the whole exchange, which took 12 to 21 seconds in our runs, the time of three to five training steps. Almost none of that is the copy, which takes about a third of a second. The rest is host-side writing and agreement between the ranks.

After the optimizer, one thread of block 0 writes all the metadata we want to log into a small ring of slots in host-mapped memory. A logger process on rank 0's host maps all eight rings, polls them, and writes to disk and to W&B while the model is training. The loss curves at the top of the article come from these records.

The agents also had to debug inside the one launch. A full-length run once came back from its single launch with NaN gradients. The agents put probes inside the kernel instead of splitting it into separate launches, and found that the queries and keys first went bad at each GPU's first document boundary: the rotary encoding only covered the first document. With that fixed, the NaNs moved to attention's output on three GPUs. The padding segments on those GPUs were 3,985, 3,811, and 4,419 rows long, so each ended in a partial 64-row tile of 17, 35, and 3 rows, and those were the rows that went bad. Masked attention was still doing arithmetic on value rows past the end of the real data, where the memory held NaNs, so the agents gave the value buffer 64 rows of finite padding. A second fix kept the padding rows out of the loss's softmax, since zero times NaN is still NaN.

If I had a NCCL...

...for every time we use NCCL when training with this megakernel, I'd have 0 NCCLs because we don't use NCCL!NCCL does run exactly once per process, at startup: PyTorch's symmetric-memory allocator, which provides the multicast addresses, needs an initialized process group. Later host-side coordination runs on Gloo over the CPU network. Inside the launch the megakernel moves every training byte itself. Communicating data between GPUs is a perilous endeavor, and most training stacks rely on the excellent collectives NCCL provides. The megakernel cannot: NCCL does its work by launching kernels of its own, and the megakernel occupies every SM for the whole run, so a helper kernel would wait forever for a free multiprocessor. The megakernel has to do all of the communication itself, with loads and stores over NVLink. It uses the multimem instructions, mostly two of them. A multicast store writes one 16-byte word to the same address on all eight GPUs at once. A multicast reduce-load reads the same address on all eight GPUs, and the NVLink switch reduces the eight values to their sum or their minimum on the way back.

Layer L+1 waits on a stream dependency in one stack and on ready words in the other

Two time lines of two layers, L and L+1. Top, a conventional stack: the host launches every kernel; a compute stream runs layer L and then layer L+1, a collective stream runs an NCCL all-gather for layer L+1's weights and then one for layer L+2's, and a stream dependency makes layer L+1 wait for its all-gather. Bottom, inside the megakernel: the host launches nothing during the run. 84 blocks compute layer L and then layer L+1 without a break. The other 48 blocks compute layer L too, stop before the down projection to push layer L+1's weight slices to every GPU with multicast stores, publish a ready word with generation g, and rejoin layer L's tiles; layer L+1 reads its weights once every GPU's ready word reaches g. Block 0 reads the minimum of the eight ready words with a multicast reduce-load, and once it reaches g a grid barrier releases layer L+1. The same happens for layer L+2 during layer L+1.

Widths are schematic. In both, the next layer's weights travel while the current layer computes.

Each rank r owns slice r of every weight matrix, keeping the FP32 master weights, the AdamW moments, and a durable BF16 copy only for that slice. Before layer L runs, every rank copies its BF16 slice of each of L's weights, the four projection matrices and the normalization vectors, into a working slot with multicast stores, so every GPU ends up holding the whole layer.

We use grid barriers to synchronize the blocks on one GPU, but there's no barrier for the full node, so we have to coordinate through the data layer instead. When its stores are visible on every GPU, each rank's block 0 writes that it is ready: it stores a generation number, which goes up every time the slot is refilled, into a ready word with a release store, so no rank can observe the new generation without also observing the weights.Block 0 writes the ready word with a system-scope release store after a system-scope fence, and the consumer's poll is an acquire load, so any thread that sees generation g is guaranteed to see the bytes published before it. The poll is one PTX instruction, multimem.ld_reduce with the min operation, on the multicast address of the ready word. We determine whether every rank has finished publishing by having one thread on block 0 poll the ready words with multicast reduce-loads and take the minimum over the eight ranks. This way we get an effective sync, and a grid barrier then releases the other blocks.

In the backward pass we have the owner read from all eight ranks, so the exchange is a pull rather than a push. Each rank's weight-gradient multiplications write their full FP32 result into a gradient buffer that every GPU holds a copy of, and the owner reads its slice from all eight GPUs with multicast reduce-loads: the NVLink switch computes the eight-way sums as the loads pass through it, so the addition never runs on an SM. The pull is cheap: after a layer's backward the grid publishes its ready words, computes the next layer's backward, and only then collects the previous layer's gradient, so block 0 almost never has to wait.

...without writing training megakernels

All of this code was written by a collective of coding agents that were minimally steered by yours truly.The agents share one workspace, where any of them can read and write any file, on a cluster where they run jobs through Kubernetes. Compiling the megakernel needs only CPUs, and timing it needs a node of eight H100s. Over the whole project, the agents used about 40 billion tokens, almost all of them cached input (the conversation so far, which every turn sends to the model again). In this second part of the article, I'll outline some of the design choices in the multiagent system. In the following part, I'll cover how a multiagent system can produce coherent system optimizations by hill climbing on a reward function.

The messages between agent sessions

A network diagram in three columns labeled Phase 0, Phase 1, and Phase 2, in campaign order and without dates. Each circle is one agent session, filled for a GPT session and open for a Claude session. An arrow is a message relayed from one session to another, and the small dots clustered around a session are the messages it received directly; every mark is colored by the kind of message: execute in blue (dispatching work, relaying another agent's message), review in green (review requests, probes, catches), and plan in red (steering, asking for a plan). Phase 0 holds a few isolated sessions and pairs. Phase 1 is a hub-and-spoke: one session in the center exchanges arrows with a ring of sessions, most of them Claude sessions. Phase 2 is a short chain of GPT sessions with dense message clouds, with a few single sessions above it. Nearly every session's cloud mixes all three colors. With JavaScript and without a reduced-motion preference, the marks appear in message order over eighteen seconds.

When I started this project, I was but a novice to the wild world of megakernels. My prompt for Phase 0 was quite literally “/goal write a training megakernel for qwen3-8b. make no mistakes” (and as you can imagine, the agents absolutely did not build a proper training megakernel! Nothing of the sort, in fact). Phase 0 was basically a single-GPU CUDA graph that contained the full optimizer step. Neat, but not what I asked for. Phase 1 was where we actually got a single-GPU “real” megakernel, and then extended it to multiple GPUs by using NCCL as a stopgap. Phase 2 is where we did the hard work of bridging the single-GPU megakernel into a proper multi-GPU megakernel and got rid of NCCL.

The above figure shows the communication between different agents (circles) in the system over time, in terms of the different kinds of plan, review, and execute messages that were sent to and from agents. This does not include subagents, the helpers that a model starts inside its own session, such as those spun up by GPT-5.6-Ultra. The figure's three columns are the three phases of the project. You can see the hub-and-spoke emerging in Phase 1, the chain of long-lived sessions in Phase 2, and that nearly every session's messages mix all three colors.

KindWhat it doesShare
Execute47%
dispatchGive an agent its next unit of work, typically in the form of a workorder markdown file28%
relayPipe a message from one agent to another with the sender's identity19%
Review34%
review requestReview another unit of work (plan, workorder, completed work)16%
probeAsk a question to an agent that has some particular context to circumvent rediscovering something10%
catchCall out an anomaly in an agent's trajectory, claims, etc. and drive that agent to correct or explain itself8%
Plan19%
steerAdjust the agent's approach, scope, or priorities, typically based on the results of Review or Catch instructions13%
plan requestAsk the agent to assess the work strategically, produce a plan, etc.6%

Agents spawning agents

In Phase 0 I wanted to just instantiate a set of agents and then see how far they got (as it turns out, not very far). In Phase 1 I allowed one agent, which I'll call the master agent (the hub of Phase 1 in the figure), to start spinning up other agents and giving them work. However, it absolutely abused this power and created many Claude Fable agents, and had them do a bunch of work that turned out to mostly be meaningless. The failure mode was that the master agent just came up with a plan, created a Fable agent to execute the plan, and then reviewed the work, but never had any criticism for the work. The Fable agent just executed whatever the master agent had penned, and it had nothing in its context except that plan, so when the master agent reviewed the work against its own plan, nobody in the loop could find fault with the plan itself.

By contrast, the long-lived agents in Phase 2 built the first complete megakernel, took it from 8.7 to 4.1 seconds per step, and got better at understanding how to optimize the system along the way. Phase 1's spokes were mostly Claude sessions and Phase 2 was mostly GPT, but I don't think the model was the difference. The structure of the collective changed and my supervision got a little better, and above all I caught the agents climbing reward functions that measured the wrong thing and made them stop (more on this in Part 3).

So in the final version of the system, apart from clearly defined tool calls, I did not allow open-ended programmatic instantiation of long-lived agents. Of course, if a session wants to spin up its own subagents with concrete tasks, it can.

I was willing to spend a lot of time and tokens on the early phases, letting the agents build versions of the wrong program, because that is how they learned to work together, wrote the skills they needed,A skill is a file of instructions that an agent loads when a task calls for it. Any agent could invoke, create, or modify one. and filled the shared workspace with context about the model, the cluster, and the kernels. I doubt that a collective cold-started at Phase 2 would have succeeded without that shared experience. More than two thirds of the agent time went into the phases before the multi-GPU megakernel existed, and the phase that built it was the shortest.

Time spent on each phase

For each of the three phases, two bars scaled to the largest phase: calendar time and agent time, with what the phase produced. Phase 0 took the most calendar time and built a CUDA graph. Phase 1 used the most agent time and built a single-GPU megakernel and a multi-GPU staged CUDA graph. Phase 2 took half the calendar time of Phase 0 and about as much agent time, and built the multi-GPU megakernel and optimized it from 8.7 to 4.1 seconds per step.

Bars are relative to the largest phase: gray is calendar time, teal is agent time.

Agents without job titles

Identity is context

I've seen a lot of multiagent systems where the agents have specific jobs, but in this system, the agents do not have predetermined “roles”. I think the correct way to determine identity is via the context, since the only differences between agents on the same model are in their context. I believe that context engineering plays an important role in setting up these autoresearch pipelines. I don't constrain any of the agents to “judge” or “executor” or “designer”. There aren't constraints against agents naturally falling into those roles, but generally all agent sessions have a mix of proposing designs, reviewing other designs, executing optimizations, etc. as shown by the distribution of colors in the figure above.

Context is also my guess for why review helps at all, even when the reviewer is the same model as the author. A reviewer that shares the author's context shares its blind spots. That is what happened in Phase 1: the Fable agent's only context was the master agent's plan, and the master agent reviewed the work against that same plan, so neither could see what the plan got wrong. A reviewer that comes to the code from a different task has read different files, run different experiments, and been wrong about different things, so the mistakes it misses are less likely to be the ones the author made. I didn't measure this. The test would be to limit what reviewers can read and count the bugs they catch.

The agents in this system are also probably unusually long-lived relative to other systems that may have task-specific agents: one agent works through more tasks than fit in one context window. I believe that when context is managed properly, agents only grow better with time. A task-specific agent that is spawned will likely not have sufficient context to understand the implications of the task it's working on within the broader context of the project, which is what happened to the Fable agents in Phase 1. I really value the built-up context that defines a long-lived agent, and found that agents who ran for longer were more likely to contribute meaningfully back to the collective in the form of useful analyses of the existing system or high-level meta-instructions for proper execution.

Managing context

Because the agents worked on multiple tasks, and many of these agents were extremely long-running, getting the compaction right is quite important.Compaction is what a coding tool does when a conversation fills the model's context window: it summarizes the conversation and continues from the summary. In this system, agents implement compaction by writing files and pointers to themselves that are included in the next iteration's initial prompt.

Another important abstraction is properly forking the context. A fork starts from a copy of an agent's context, does one job, and hands back only its result. The forks share the KV cache blocks of the context they start from, so that a newly “forked agent” just manifests as a transient sequence of calls that read the context, but write to a separate block of context so that they don't pollute the context of our main agent. I find that imagining the agent as being defined by its context, and thinking about the context as KV cache blocks, is useful for building intuition about how to set up agentic systems. I want agents to fork aggressively to preserve their context as much as possible, as long as each fork does its one job and ends. I actively discouraged persistent forking, where the fork becomes another long-lived agent, as I felt it could lead to many more parallel agents running than I wanted.

Communication between agents

Why is there so much communication between agents? When an agent needs something, like having its code reviewed or getting feedback on a plan or asking a question about some existing piece of code (the review requests and probes in the table above), it needs to answer two questions: (1) should I do this work myself, or should I delegate it? If the answer to (1) is to delegate, then the agent needs to answer a follow-up question (2) who should I delegate it to?

Answering these questions amounts to identifying who is best suited to doing a task. The agents differ in their context, so this means that agents have to figure out whether they have the appropriate context to complete a task, or whether they should try to farm it out.

As humans, we can't read each other's minds, so we rely on titles and roles and historical knowledge of what kinds of things people have worked on, to organize our mental model of how other people in our organizations can help us make progress on complex tasks. It's reasonable to try and coerce multi-agent systems into these kinds of models, so that we have an efficient addressing scheme for work that needs to be done. But I didn't give the agents in this system roles, so they need other ways to know who should do what.

Whenever the agent decides that the work is better done by “someone other than myself”, it will end up communicating with another agent in some manner. There are a few different ways for agents to communicate, and each one is a different answer to the second question. In the agora, nobody has to answer it, because everyone involved in a task reads and writes one file. On the corkboard, the sender describes who it needs and waits for that agent to find the request. With the mailbox, the sender finds the recipient itself.

The shared filesystem is the main way that agents communicate. This is admittedly much clunkier than implementing custom tool calls that allow the agents to directly message each other, but it was easier to implement. The agents used all three of the patterns below, and each one is built on those shared files. Let's go over each one, and the pros and cons.

The agora

The shared file drawn as a log of signed, timestamped lines appended in order, with agents on both sides. A1, A2, and A3 on the left and A4 on the right each append a line with a green arrow: review my plan?, who has read FA4?, timing it now, and A5: rebase on the new parent. A6 tries to append is node 3 free? at the same moment as A2's line; the two writes collide, and A6's line is lost to an I/O error. Below the file, agent A5 reads every line added since its last read, drawn as one blue-gray arrow; only the last line is addressed to it.

Green arrows append and the blue-gray arrow reads. Only the tinted line is meant for A5, and every agent reads the same way.

Consider the agora, a public space where many individuals seem to be shouting over one another at the same time. This can be challenging for humans because we struggle to make out individual speakers when the sound waves overlap. Now suppose that you are always able to perfectly hear what everyone else is saying, even while you are talking. This is what happens when agents all read and write to a single file. They can always timestamp and sign each message, and read all edits made to the file since their last reading, so in principle they can all read and write at the same time.In distributed systems this is a blackboard: a shared store that every process reads and writes, first used in the Hearsay-II speech recognizer (Erman et al., 1980). Recent LLM multiagent systems use the same design (Han and Zhang, 2025; Salemi et al., 2025).

This has a few upsides. For one, once all the agents involved in a task become aware of a file, we don't need to do anything special to continue having the agents read and write to this file. Another is that we can kind of solve the problem of not knowing who should be doing a task because if we're wrong, another agent will probably read our message and realize that it's a perfect fit for their context and pick it up. This communication also won't be blocking.

However, there are downsides. When many agents all try to write to the same file at the same time, the writes run into I/O errors. Analysis of agent transcripts showed that when agents ran into these errors, they would intermittently stop using the filesystem for communication. And because every agent reads every message, the agents waste context by reading many messages that are not pertinent to them. It is very easy for an agent to receive a message mistakenly and just start acting on it instead of realizing that they are not the intended recipient. I suspect a shared Slack channel would have the same problems.

The corkboard

Remember the corkboards at AI conferences that have all sorts of random fliers on them, in many cases so many layers of things pinned over each other that you can't tell where the corkboard ends and the paper begins?

Suppose that an agent is not able to figure out who is best suited to take on the work that it needs done. It can post an open request for help by creating a file detailing what needs to be done and what contextual knowledge would help an agent take on the task. This is akin to pinning a message on the corkboard and hoping that someone reads it eventually. The upside is that the sender doesn't need to know who has the right context: the request says what context it needs, so the right agent can recognize that the request is meant for it.This is close to a tuple space, from Gelernter's Linda (1985): a process posts a record describing work, and whichever process matches it takes it out. The sender never names the receiver.

There are obvious downsides to employing “shouting into the void” as your method of getting someone to do work for you. Analysis of agent transcripts and references to corkboard messages showed that some messages were simply posted and never followed up on.

The mailbox

As humans we find the prospect of shouting into the void or shouting over each other a bit primitive. After all, we have the modern technology of the mailbox. If you know the recipient's address, you can just write a document that only they will read, and give them instructions on how to give the results back to you. Let's go through how we can implement both parts of this, the send and recv.This is message passing between actors, from Hewitt, Bishop and Steiger's actor formalism (1973): each actor has an address and a mailbox, and acts on a message only when it reads it.

To implement send, we must first figure out the recipient's address. When we need to try and identify a specific agent to accomplish a task for us, we should first package our specification and description of what's required to accomplish the task. If we want someone to review our code, that agent should be familiar with the objectives that we set out to accomplish, etc. Now, it's a matter of figuring out what the needed context is based on this task spec, and matching that to the available context based on our database of transcripts. To make sure that this operation itself does not consume a ton of context by requiring our agent to read through everyone else's context, we need to maintain a thin abstraction layer on top of the transcript database. We can implement this by forking to instantiate an agent that has all of our context, that will look through the existing maintained database of agent transcripts, and see what context should be invoked with our task. This gives us the recipient.

Checking messages

There is a problem with the agora, the corkboard, and the mailbox. It's the same problem that I have with communications like my email or Slack: I either check my email and Slack too often, while procrastinating work, or not enough while actually doing work. The natural progression of the lifecycle of an agent is to take on progressively longer tasks, and just as humans don't like to break their flow while working to check their email, agents can work for up to 24 hours before they reach a point where they consider checking to see whether someone else has a message for them.To be overly OS-y, agents poll. I don't want anything to interrupt the agent mid-turn, so messages will wait until their recipients check. The periodic forks act as a timer interrupt. This can lead to miscalibrated expectations when an agent sends off a message that it expects to be completed fairly soon. We can fix this by periodically forking from an active agent to assess incoming messages and see what is pertinent enough to be worked on, or how priorities should be rebalanced.

One way to get around the issue of agents needing to do multiple things is to just fork the agent to do an incoming task. However, I discouraged persistent forking, so these forks are mainly to aid in the send-receive functionality.

Finding a hill to climb

An ink painting of a hill with a path winding up it past five cairns, the last one short of the summit, and a small figure in a coat and hat at the first.

Partway through Phase 2, we have a complete “training megakernel”, but it isn't very good: it takes 8.7 seconds per step, about 1.7 times as long as Megatron. So from there, the focus is on improving the compiler so that the megakernel runs faster. To do this across a collective, we need a fairly rigorous procedure for evaluating candidate improvements to the system and deciding what to keep or reject. Of course, specifying a reward function is easier said than done, and if I want to evaluate the capacity of a multiagent system to autonomously create a training megakernel, I can't just give it a reward function. I need to see what it comes up with!

From 1.74 times Megatron-LM's step to 0.82 times

A step chart of seconds per optimizer step for the five complete eight-GPU megakernel builds in order: 8.685, 7.465, 5.694, 4.652, 4.092. Each is labeled with its ratio to the Megatron-LM median step of 4.98 seconds: 1.74×, 1.50×, 1.14×, 0.93×, 0.82×. Two dashed reference lines mark Megatron's median step and the staged CUDA graph, 4.141 seconds. The fourth build is the first faster than Megatron, and the released build is just under the staged graph. The figure reveals the builds in order.

In this part, I'll go over the final reward function that the system arrived at, why this makes sense, and then go over some of the progression of the reward specification and also some of the reward hacking issues that arose.

The final reward procedure that the agents settled on looks like this: given a parent P and a child C, on the same node, run: P then C, and C then P (so, both orders) and measure the times, and accept C if and only if it is faster than its parent in both orderings. There are a few things to think about here. First is that the timings need to be done on the same node.An agent can reserve a node, isolate its jobs from other work on that node, or just submit jobs to the cluster's scheduler. The agents seemed to realize this after having a spate of false positives where the inter-node timing differences were larger than the effect size they were trying to measure with some initial micro-optimizations. I think this is reasonable. Second is that the candidate needs to be faster than the parent in both orderings. Each of the four runs starts fresh processes on all eight GPUs and takes 4 warmup steps and 8 measured steps. The runtime is the median, over the 8 measured steps, of the slowest GPU's step time.At least 20 candidates won in one order and lost in the other, and the agents kept none of them. Third is this notion of a “parent”. To explain that, you should understand how the agents are able to collaborate on code.

Because the agents in the collective are simultaneously working on many different optimizations, there has to be some kind of ordering or global coherence to enable the agents to compose improvements. The kind of structure they ended up pursuing looks like a DAG, where each agent is frequently cloning their working directory (at no point did the agents ever really care about using Git, as they were all running on the same cluster). So at any given point, an agent will be working on improving a node in the DAG, which is the “parent” with different candidate optimizations, which are the “children”. When a child is kept, it becomes the parent that every later candidate is timed against, so one agent's win means every other agent's candidate has to be rebuilt on the new parent and timed again.

The process may seem a little complex because I've written it all out, with my best attempts at explaining why the agents produced it this way, but it's actually fairly efficient when compared to other ways the agents tried to create reward functions for themselves, like minimizing the number of bytes in the compiled kernel, or running many, many timings of every candidate.

Three of four changes that should have helped made the step slower

A dot chart of four proposed changes. For each, a hollow circle marks the change in step time projected from the operation alone and a filled dot marks the change measured on the complete eight-GPU megakernel, with an arrow from one to the other. A 64-by-128 attention-backward variant projects 0.21 seconds faster and measures 1.32 seconds slower. The same code behind a helper call projects 0.16 seconds faster and measures 31.4 seconds slower, far off the scale. Chunked queue claims remove 93 percent of queue atomics, projected only as fewer scheduler operations, and measure 0.64 seconds slower. A quarter-warp reworking of the Q/K rows projects 0.032 seconds faster and measures 0.017 seconds faster; it is the only one kept.

Projected is the saving expected from the operation alone; measured is the change in the complete megakernel's step time on eight GPUs.

A plague of bureaucracy

OK, we've all seen the many reports of agents creating kernels that try to scam the verifier by doing all manner of weird tricks. Not so the collective! The most persistent recurring failure mode, and what demanded frequent human intervention, was that the agents tried to introduce “gates” that needed to be passed before a candidate could actually be run on GPUs, and these gates led to many many many good ideas never being run. At the peak of this madness, there were 77 gate scripts that needed to be passed before a candidate could actually run! Examples of gates included preregistering results, a hash-and-freeze step, and a check on the number of bytes of the final compiled kernel produced by the compiler. I call this recurring pattern “a plague of bureaucracy”.

An ink painting of 77 gates standing in a line across an open field, each closed by a bar and the nearer ones hung with plaques, and a figure in a long coat and hat waiting at the first one with a folder under one arm.

Why did the agents resort to this sort of “inverse reward hacking”, of adding loads of arbitrary gates to prevent real work from ever actually running? Many gates started as a response to a real incident, like one agent deleting another agent's job in the middle of an experiment, or a claimed win that didn't hold up, and they stayed until I told the agents to drop them. Producing receipts that gates were passed is also safe and straightforward, whereas actually getting a measurement is risky because it can lead to rejection, or it can lead to a successful optimization that changes the parent for every other agent.

Here are a couple of concrete examples of victims of a plague of bureaucracy. During the time that agents had to preregister how the compiler would operate, an agent preregistered its prediction that a certain implementation for the vocab-head would compile to four stages. When the compiler only emitted three stages, the gate forced the agent to axe the candidate. Later, when I intervened and told the agents to get rid of the gates, this same vocab-head implementation ended up shipping successfully because it saved time.It saved 84.6 ms per step. The first improvement in the figure at the start of this part, from 8.7 to 7.5 seconds per step, was built but not timed, because the agents read a rule meant only for the final comparison against the staged graph as a ban on ordinary timing runs. It was measured only after I amended the rule. There was a long stretch where the agents had difficulties getting jobs to actually run on the cluster properly, so they used the size of the compiled kernels as a stand-in for efficiency, and just optimized by making the final compiled megakernel smaller.

While agents have complete freedom to use skills, they don't seem to really need to do this as they can already create arbitrary markdown files or python programs, and refer back to them later. In some cases I had to manually intervene to prune skills that seemed unnecessary. However, 2/3 of agents ended up invoking one skill, mk-throughput-tuner, which I hadn't read until writing this article. It lays out a short development loop (state a hypothesis, change the current parent, run a quick check, time the full step against the parent, then keep or drop the change) and tells the agent not to start with a planner, a receipt system, or a validation campaign.

What comes next

I did most of this work in July and August of 2026 as a side project while working at TogetherAI. Hopefully it's obvious by the, shall we say, “accessible language” of this article, that I knew next to nothing about megakernels at the time. I did most of this work with GPT-5.6 Sol, which is an excellent model but already made obsolete by the time I got around to writing this article.

In the coming years, I expect to see “Compilers 2.0” more and more. Our own compiler isn't there yet. It writes one program whose choices the agents made. It doesn't pick tile shapes or implementations, find fusions, work out the schedule across the eight GPUs, or derive the memory layout. If I were going to redo this project today, I would use systems that look more like classifiers as components of the compiler, and the latest frontier models to conjure optimizations. Similarly, components of the multiagent infra could immediately be improved. For example, an agent-native version of Kubernetes would make it much easier for agents to run jobs and check on them. It also seems that Codex has started rolling out an experimental compaction protocol that promises to do something similar to the notes our agents wrote for themselves. I have seen recent papers that propose multi-agent coordination schemes similar to the agora, and I think that scaling up multi-agent work is just the natural path forward for organizations seeking to accomplish increasingly challenging objectives who have successfully cleared the way for agents to properly coordinate work.

If you would like to cite this article, you can use the following bibtex entry:

@misc{panda2026megakernel,
  author       = {Ashwinee Panda},
  title        = {Writing Training Megakernels without Writing Training
                  Megakernels},
  howpublished = {\url{https://kiddyboots216.github.io/megakernel/}},
  year         = {2026},
  month        = {sep},
  note         = {Blog post}
}