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

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

TL;DR

Byte-level language models eliminate the need for tokenizers but suffer from a harsh trade-off between sequence length efficiency and model quality when grouping bytes into patches. This paper introduces Scratchpad Patching (SP), a technique that dynamically inserts transient context refreshes inside patches based on next-byte prediction entropy. This decouples inference compute from the persistent KV-cache footprint, allowing models with large patch sizes to match byte-level accuracy while using a $16\times$ smaller KV cache.

What Problem Does This Paper Address?

Subword tokenizers are a staple of modern LLMs, but they introduce distinct vulnerabilities: sensitivity to prompt formatting, vulnerability to "glitch tokens," and a rigid segmentation scheme that is difficult to scale. While tokenizer-free, byte-level models eliminate these issues, operating directly on raw bytes results in prohibitively long sequences.

To fix this, researchers use patch-based models that aggregate contiguous bytes into higher-level patches. However, this introduces a structural flaw the authors term patch lag. To preserve causality during autoregressive generation, bytes within a patch cannot look ahead; they must rely on a stale representation from the previous patch until the current patch boundary is fully reached. As patch sizes grow to save compute and KV-cache space, patch lag widens, severely degrading model quality.

Figure 1: Scratchpad Patching (SP). Left: a standard patch-based byte-level model runs the trunk M once per patch (see Fig. 2 for the full architecture), leaving most byte predictions to rely on a stale representation from the previous patch. Right: SP inserts transient scratchpads at selected byte positions, each aggregating the bytes seen so far within the patch and refreshing the trunk representation for subsequent predictions. This reduces patch lag while leaving the number of committed patch states unchanged. Other architectural components are omitted for clarity.

Methods

The authors propose Scratchpad Patching (SP) to break the rigid link between patch size and compute frequency. Instead of committing a single representation only at patch boundaries, SP inserts transient "scratchpads" at selected internal byte positions. Each scratchpad aggregates the bytes observed so far within the patch, refreshing the context for subsequent intra-patch predictions.

Key implementation details include:

  • Entropy-Based Triggering: To avoid doing heavy compute at every single byte, an auxiliary language modeling head on the encoder calculates next-byte prediction entropy. A scratchpad is only triggered when the entropy exceeds a threshold ($\tau_{SP}$), selectively allocating compute to information-dense or unpredictable text regions.
  • Specialized Attention Masking: During training, scratchpads are unrolled in parallel. A specialized causal mask ensures that scratchpads can attend to past committed patches and themselves, but are never attended to by other elements.
  • Scratchpad Overriding at Inference: Because scratchpads are transient, they are computed on the fly and immediately overwritten. They are completely excluded from the persistent KV cache, keeping the inference memory footprint identical to the baseline patch size.

Datasets

Models were pretrained on a 400-billion raw byte mixture of three major open-source datasets:

  • DCLM (Natural Language)
  • Stack v2 (Code)
  • OpenWebMath (Mathematics)

For downstream evaluation, the authors utilized:

  • Code Generation: MBPP and HumanEval.
  • Natural Language Understanding (NLU): A suite of 8 benchmarks including MMLU, HellaSwag, ARC-Challenge, ARC-Easy, BoolQ, OpenBookQA, PIQA, and WinoGrande.
  • Multilingual Robustness: FLORES-200 validation set.

Key Insights and Ideas

  • Compute Allocation Matters More Than Boundaries: Historically, researchers have designed complex, learned routing mechanisms to find optimal patch boundaries (e.g., H-Net, SpaceByte). The authors discover that when SP is applied, the performance gap between these families narrows substantially. Simple fixed-size patching becomes highly competitive, proving that the primary bottleneck was insufficient compute frequency (patch lag) rather than suboptimal boundary placement.
  • Post-Hoc Inference Flexibility: Because the scratchpad mechanism is governed by an entropy threshold, users can dynamically adjust inference-time compute without retraining the model. Raising or lowering the threshold exposes a smooth, single-knob control over the quality-efficiency trade-off.

Key Results

  • Byte-Level Quality with Patch-Level Efficiency: On NLU benchmarks, a fixed patch model of 16 bytes augmented with SP (Fixed (p=16) + SP) improved average accuracy from 48.0% to 54.2%, matching the pure byte-level baseline (54.1%) while utilizing a $16\times$ smaller KV cache and 3–4$\times$ less inference compute.
  • Code Generation Gains: On HumanEval, Fixed (p=8) + SP achieved a pass@1 rate of 15.9%, outperforming the non-SP baseline (13.0%) and the tokenizer-based baseline (13.3%).
  • Multilingual Superiority: On the FLORES-200 dataset, adding SP consistently boosted the average bits-per-byte (BPB) rank across 200 languages, narrowing the gap to the pure byte baseline and vastly outperforming tokenizer-based models which suffer from script-specific biases.

Limitations and Future Work

  • Single-Stage Focus: This work primarily evaluates single-stage patching. The authors note that systematically extending SP to hierarchical or multi-stage patching architectures remains an open area for research.
  • Simple State Recomputation: The current scratchpad formulation completely recomputes intermediate representations. Integrating richer, recurrent update rules could yield superior efficiency and expressivity.
  • Training Compute Overhead: While SP significantly optimizes inference-time KV cache and compute, it increases training-time compute due to processing the transient states. Designing formulations that offer explicit training-time savings is left to future work.

Summary updated

BibTeX
@inproceedings{zheng2026scratchpad,
  author = {Lin Zheng and Vasilisa Bashlovkina and Timothy Dozat and Dan Garrette and Laura Rimell and Joshua Maynez},
  title = {{Scratchpad Patching: Decoupling Compute from Patch Size in Byte-Level Language Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=L1cO6MnwfR},
}
Figure