Learn / Streamed lesson retrieval
Google trains 14M-token contexts by streaming, not storing. ThumbGate now retrieves old lessons the same way
4 min read · For developers running Claude Code and other coding agents
TL;DR: Google added context parallelism to MaxText, its open-source JAX training framework, and reports training at up to 14 million tokens on Cloud TPUs. The trick is to stream keys and values between chips instead of holding the whole sequence on each one. ThumbGate had the same kind of wall in a smaller place: its lesson retrieval only looked at the newest slice of memory. With THUMBGATE_RETRIEVAL_SCAN=auto, ThumbGate now streams the whole memory log in blocks and keeps old, strongly matching lessons reachable. It reads 1 MB blocks and keeps only a bounded pool of matches next to the newest slice, never the whole log.
What Google shipped
These points come from InfoQ's report and Google's announcement, linked below.
- Memory is the first wall. Attention grows quadratically with sequence length, and activations and KV caches grow linearly. Google's Nathan Beach put it this way: "attention memory -- not compute -- is usually the first wall you hit."
- Four strategies, picked by size. All-Gather, All-to-All (Ulysses), P2P (Ring Attention) and a USP hybrid. Per the report, All-Gather is the baseline "where the KV can fit", and Ring Attention is "the primary workhorse for very long-context training."
- Reported numbers. Up to 14M tokens on TPU 5p and TPU 7, and 70% model FLOPs utilization up to 4M tokens on TPU 5p for Llama 3.1 8B. These are Google's own figures; the report gives no batch sizes or run details.
The same wall, in an agent firewall
ThumbGate turns thumbs-down feedback into lessons and checks them before your agent acts. To stay fast, retrieval read only the newest 5,000 lines or 4 MB of the memory log. That bounds memory, but on a long-lived project the oldest lessons fell outside the window. Those are often the expensive ones, like the force-push that wiped shared history.
What ThumbGate does now
- Stream, don't store. With streaming on, ThumbGate reads the memory log in 1 MB blocks. Each lesson is scored as it passes, and only a bounded pool of the 200 best older matches is kept, much like a ring step keeps a running result instead of the whole sequence.
- Skip what can't match. Before a line is parsed, ThumbGate checks it for anything the scorer uses: the tool name, a word or path from the action, or a structured rule. A line with none of these can't score, so it is skipped. On a 39.5 MB log with 100,000 lessons, that took the streamed read from 847 ms to about 130 ms on our test machine.
- Pick the strategy by size.
auto keeps the plain newest-slice read when the log fits, the way All-Gather is used when the data fits, and streams only past that point. streamed always streams.
- Adds results, never removes them. The streamed result is the newest slice plus the older matches. Any error falls back to the newest-slice read.
What it does not do
- It is off by default. Set
THUMBGATE_RETRIEVAL_SCAN=auto to try it.
- It does not change how gates block. It only changes which lessons retrieval can see.
- The older-match pool holds 200 lessons. If more than 200 old lessons match, only the 200 best come back. Lessons in the newest slice are never affected.
- ThumbGate does not use TPUs, MaxText or attention kernels. We borrowed the idea, not the code.
Try it
- Install or update ThumbGate:
npx thumbgate init.
- Set
THUMBGATE_RETRIEVAL_SCAN=auto in your shell or agent environment.
- Thumbs-down a mistake once. Months and thousands of lessons later, ThumbGate can still find it.
Sources
ThumbGate is an independent project and is not affiliated with or endorsed by Google.
Never forget the lesson that hurt
Pre-action gates built from your own thumbs-down, with bounded memory.
npx thumbgate init