AboutWorkProjectsNotes
PT

say hi

 © 2026

  • Embed less, find moreRetrieval
  • The teacher was confidently wrongFine-tuning
  • Every agent write needs a name on itAgents
  • Too long to train onTraining
0/ 500 tokens

Training · Draft · ~2 min

Too long to train on

Agent runs were 50K–100K+ tokens. Two levers got them under budget: compaction and sequence parallelism.

We were fine-tuning Gemma-4-12B on real software-engineering agent runs. The runs were 50K–100K+ tokens long, and the proof of concept trained at 16K. The question for the whole project was simple: how do we fit them under our budget?

There are two levers. You can make the run smaller, or make the window bigger. We pulled both.

Lever one: compaction

Cut the run into windows, and when the history no longer fits, have a teacher model summarize what came before. The next sample starts from that summary. One rule mattered more than any other: never split a tool call from its result. A call without its output teaches the model nothing.

this run → 9 samples, 8 compactions

one agent run · 103K tokens

  1. sample 115.8K/16K
  2. sample 214.6K/16K
  3. sample 314.6K/16K
  4. sample 413.1K/16K
  5. sample 516.0K/16K
  6. sample 614.2K/16K
  7. sample 712.7K/16K
  8. sample 814.8K/16K
  9. sample 913.4K/16K
system Kimi summary call + tool result, never split
16K dataset
1,908 samples
1,630 compactions
32K dataset
660 samples
381 compactions
64K dataset
361 samples
82 compactions

The run above is illustrative. The dataset totals are real, from 279 trajectories.

Pick a window size. Smaller windows mean more samples and more compactions to learn from.

From 279 trajectories that gave 1,908 samples at 16K, 660 at 32K and 361 at 64K, with no sample over its limit. The catch: Kimi, the summarizer, didn't reliably respect the requested length. A five-attempt loop that shrinks the budget by how far it overshot took summary failures to zero.

Lever two: sequence parallelism

Compaction throws detail away. For the longest samples we wanted the model to see more of the run as it actually happened. Sequence parallelism splits one sample across GPUs, and they exchange what attention needs, so every token still sees the whole context.

one sample · 63,263 tokens

  • GPU 07.9K tok
  • GPU 17.9K tok
  • GPU 27.9K tok
  • GPU 37.9K tok
  • GPU 47.9K tok
  • GPU 57.9K tok
  • GPU 67.9K tok
  • GPU 77.9K tok

Each GPU holds one eighth of the sequence. They exchange what attention needs, so every token still sees the whole run.

ml.p6-b200.48xlarge · 8× B200 · SP=8, DP=1 · the proof of concept was 16K. Memory fills are illustrative.

One 63K-token sample on one GPU versus split eight ways.

We trained on ml.p6-b200.48xlarge: eight B200s, sequence parallelism 8, data parallelism 1. The longest sample was 63,263 tokens, up from the 16K proof of concept.

Which one, when

They aren't rivals. Compaction teaches the model to work from summaries, which is what an agent with a condenser does at inference anyway. Sequence parallelism keeps raw context but costs hardware: with data parallelism at 1, all eight GPUs work on one sample at a time. Compaction sets the window, sequence parallelism makes the window big.

This is a draft. If you've hit the same problem, I'd love to compare notes.