← Latest papers
🤖 machine learning

Scratchpad Patching: Decoupling Compute from Patch Size in Byte-Level Language Models

This paper introduces Scratchpad Patching (SP), a technique that decouples compute from patch size in byte-level language models by dynamically inserting transient scratchpads to mitigate patch lag, thereby enabling larger patches for reduced KV-cache and compute costs without sacrificing modeling quality.

Original authors: Lin Zheng, Vasilisa Bashlovkina, Timothy Dozat, Dan Garrette, Laura Rimell, Joshua Maynez

Published 2026-05-12
📖 4 min read☕ Coffee break read

Original authors: Lin Zheng, Vasilisa Bashlovkina, Timothy Dozat, Dan Garrette, Laura Rimell, Joshua Maynez

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are trying to read a very long book, but you have a strict rule: you can only look at the text in big chunks, like grabbing a handful of pages at a time. This is how modern "patch-based" AI models work. Instead of reading word-by-word (tokens), they read byte-by-byte (the raw computer code for letters) in groups called patches.

The problem with this "grab a handful" approach is a phenomenon the authors call Patch Lag.

The Problem: The "Stale" Handful

Imagine you are reading a paragraph. You grab a chunk of text (a patch) to process.

  • The Last Page: When you get to the very last page of that chunk, you have the full picture of what you just read. You can make a perfect guess about what comes next.
  • The First Page: But when you are on the first page of that same chunk, you haven't actually seen the rest of the chunk yet! You are forced to guess based on the previous chunk you read.

If your chunks are huge (say, 16 bytes long), the first 15 bytes are guessing based on "stale" information from the past. The bigger the chunk, the longer this "lag" lasts, and the worse the AI gets at predicting the next letter.

Usually, you have to choose:

  1. Small Chunks: Great accuracy, but the AI has to do a lot of work (slow and expensive).
  2. Big Chunks: Fast and cheap, but the AI makes more mistakes because it's guessing too far ahead.

The Solution: The "Scratchpad"

The authors introduce a clever trick called Scratchpad Patching (SP).

Think of it like this: You are still grabbing those big handfuls of pages (patches) to keep things efficient. But, inside your hand, you have a transient scratchpad.

As you look at the first few pages of the chunk, you quickly jot down notes on your scratchpad.

  • The Magic: These notes are temporary. You use them to update your understanding immediately so you can make better guesses for the next few pages.
  • The Catch: Once you finish the chunk and move to the next one, you throw the scratchpad away. You don't keep it in your long-term memory (the "KV cache").

This allows the AI to have the speed of big chunks (because it only saves the final result of the chunk) but the intelligence of small chunks (because it refreshed its knowledge mid-chunk).

How Does It Know When to Use the Scratchpad?

The AI doesn't use the scratchpad for every single letter; that would be too slow. Instead, it uses a "traffic light" system based on Entropy (a fancy word for "surprise" or "uncertainty").

  • Low Surprise: If the text is boring and predictable (like "the cat sat on the..."), the AI skips the scratchpad. It knows what's coming.
  • High Surprise: If the text gets complex or unpredictable (like a sudden code variable name or a weird symbol), the AI triggers the scratchpad. It says, "Wait, this is important! Let me pause and re-evaluate everything I've seen so far in this chunk before I guess the next letter."

The Results: The Best of Both Worlds

The paper shows that this method works like a magic switch:

  1. Quality without the Cost: Even when using very large chunks (16 bytes), the AI with Scratchpads performs almost as well as if it were reading byte-by-byte.
  2. Memory Savings: Because the scratchpad is thrown away immediately, the AI doesn't need to store extra memory. It keeps the "KV cache" (the AI's short-term memory) 16 times smaller than a standard byte-by-byte model.
  3. Flexible Speed: You can turn the "scratchpad switch" up or down after the model is trained. If you need it to be super fast, you turn off the scratchpads. If you need it to be smarter, you turn them on. You don't need to retrain the model to do this.

Summary Analogy

Imagine you are a chef cooking a massive stew.

  • Old Way (Standard Patching): You taste the stew only once every 10 minutes. If you add a spicy ingredient at minute 1, you don't taste it again until minute 10. By then, the flavor might be off.
  • New Way (Scratchpad Patching): You still only take a full "official" taste every 10 minutes to log the recipe. But, in between, you dip a spoon in whenever the smell changes drastically (high entropy) to adjust your seasoning immediately. You throw the spoon away after tasting, so you don't have to wash a million spoons (memory), but your stew tastes perfect.

The paper proves that by adding these temporary "taste tests" (scratchpads), you can cook a huge pot of stew (process long text) quickly, cheaply, and with perfect flavor.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →