Scratchpad Patching in Byte-level Modeling
- Scratchpad Patching (SP) is a byte-level mechanism that decouples compute from patch size by inserting transient scratchpads to update stale intra-patch context.
- It uses entropy-triggered binary signals to selectively refresh patch representations, thereby mitigating patch lag and improving prediction accuracy.
- Empirical results show that SP nearly recovers the quality loss of large patches while maintaining a reduced KV-cache footprint and lowering inference FLOPs.
Searching arXiv for the cited papers and closely related terminology. Scratchpad Patching (SP) is a mechanism for tokenizer-free, byte-level, patch-based LLMs that inserts transient scratchpads inside each patch to aggregate the bytes seen so far and refresh patch-level context for subsequent predictions. It was introduced to address the quality degradation caused by large patch sizes in models that group contiguous byte spans into patches for efficiency. In that setting, SP is presented as a way to decouple within-patch compute from the committed patch size, so that inference-time compute can be adjusted post hoc while preserving the reduced KV-cache footprint associated with patch-based processing (Zheng et al., 10 May 2026).
1. Problem setting: byte-level patching and patch lag
In a tokenizer-free model, computation proceeds directly on a UTF-8 byte stream plus a few sentinels. Because is large, patch-based methods group contiguous byte windows into patches, each summarized to a single patch representation before passing through the expensive Transformer trunk . A typical byte-patch model has the pipeline (Zheng et al., 10 May 2026).
This design creates a trade-off. Larger patches imply fewer trunk steps, lower compute, and a smaller KV-cache. However, large patches also introduce “patch lag”: until a patch is fully observed, byte predictions within it must rely on a stale representation from the previous patch in order to preserve causality. In the standard non-SP unpatchifier, for patch covering bytes ,
where 0, 1, and 2. For non-final bytes, the model therefore conditions on 3 rather than an updated summary of the current patch. If each patch is on average 4 bytes, the lag can be as large as 5 steps (Zheng et al., 10 May 2026).
The central motivation for SP is thus not generic scratchpad reasoning, but a specific systems-level problem in byte-level autoregressive modeling: retaining most of the efficiency benefit of patch compression without forcing intra-patch prediction to depend on stale context.
2. Core mechanism: transient scratchpads inside a patch
SP inserts transient “scratchpad” states inside each patch so that non-final bytes can condition on a more current representation of their own patch. For patch 6 spanning 7, binary triggers 8 are defined for 9, and the number of scratchpads is
0
The construction reserves 1, and for each 2, 3, where 4 is the 5-th position with 6. Each 7 is passed through the trunk to produce 8. The unpatchifier then becomes
9
where 0 is the index of the most recent scratchpad before or at 1. Thus every byte except the final byte conditions on some 2 from its own patch, rather than always using 3 (Zheng et al., 10 May 2026).
The scratchpads are transient rather than committed. Only the final patch representation 4 is committed to the cache for future patches. This distinction is structurally important: SP increases within-patch compute adaptively, but does not change the asymptotic cache footprint of the committed patch sequence.
A useful way to characterize the mechanism is that committed patch size controls inter-patch memory, whereas scratchpads control intra-patch refresh. This interpretation follows directly from the fact that scratchpads are recomputed within a patch, used to improve subsequent byte prediction inside that patch, and then dropped from the KV cache at inference time (Zheng et al., 10 May 2026).
3. Triggering, masking, and inference procedure
SP does not recompute at every byte. Instead, it uses an auxiliary next-byte entropy 5 from a lightweight LM head over 6:
7
and sets
8
The threshold 9 is tuned per patchifier. Common defaults are 0 nats for fixed/SpaceByte, 1 for entropy-based patching, and 2 for H-Net in order to avoid redundant near-boundary updates (Zheng et al., 10 May 2026).
Training is parallelized by unrolling all patch and scratchpad states as a single sequence,
3
while masking self-attention so that each scratchpad or patch 4 attends only to 5, and no attention flows between scratchpads of the same patch. This allows gradients to be computed in one pass. At inference, scratchpads are omitted from the KV cache because they are never keys for later patches (Zheng et al., 10 May 2026).
The implementation notes emphasize several constraints. Scratchpad states must share the patch’s positional index and must not be attended to by later patches. Gradients from the entropy head back into 6 are stopped to stabilize representation learning. An entropy head with two extra Transformer layers on top of 7 works well, and additional layers provide little benefit. The threshold 8 is described as critical: values that are too low waste compute, while values that are too high produce too few scratchpads. SP is intended to integrate with any patchifier, provided that 9 on real patch boundaries to avoid double-counting (Zheng et al., 10 May 2026).
A recurring misunderstanding is that a scratchpad mechanism should be dense to be effective. The reported ablations do not support that view. Dense updates, corresponding to 0, yield diminishing returns or even degrade BPB on natural text; the more effective regime is selective triggering at information-dense positions (Zheng et al., 10 May 2026).
4. Compute, memory, and empirical performance
The complexity profile is central to SP. In a non-SP model, 1 patches imply 2 trunk states in cache and memory 3, with compute approximately 4, where 5 is the cost per trunk token. With SP, there are still only 6 committed representations in cache, but patch 7 requires 8 trunk calls instead of one. Total inference trunk FLOPs are therefore proportional to 9 rather than 0. In practice, entropy triggering keeps 1 much smaller than patch size on average, so the reported overhead is only 2–3 extra compute while preserving the 4 cache (Zheng et al., 10 May 2026).
Empirically, SP shifts the BPB–compression Pareto frontier downward across four patchifier families: Fixed-size 5, SpaceByte, Entropy, and H-Net. At 6, SP is reported to recover almost all of the BPB loss of vanilla patching, bringing SP-Fixed 7 within 8 of the byte-level baseline (Zheng et al., 10 May 2026).
The reported downstream results on natural language understanding and code generation are summarized below.
| Model | Key efficiency figure | Reported task result |
|---|---|---|
| Byte-level | SeqRed 9, FLOPsRed 0 | AvgAcc 1 |
| Tokenizer-based | SeqRed 2, FLOPsRed 3 | AvgAcc 4 |
| Fixed 5 | SeqRed 6, FLOPsRed 7 | AvgAcc 8 |
| Fixed 9SP | SeqRed 0, FLOPsRed 1 | AvgAcc 2 |
| Model | MBPP P@1 | HE P@1 |
|---|---|---|
| Byte-level | 3 | 4 |
| Tokenizer-based | 5 | 6 |
| Fixed 7 | 8 | 9 |
| Fixed 0SP | 1 | 2 |
For code generation, the same 3 SP configuration preserves a 4 KV-cache reduction while reducing inference FLOPs by 5 on MBPP and 6 on HumanEval. The improvement over vanilla patching at 7 is reported as approximately 8 percentage points on MBPP, from 9 to 00, and approximately 01 percentage points on HumanEval, from 02 to 03 (Zheng et al., 10 May 2026).
These results are significant in the narrow technical sense established by the paper: they indicate that the quality loss traditionally attributed to large patch sizes is not purely a consequence of compression ratio, but is closely tied to stale within-patch context. SP addresses that specific failure mode without forfeiting the cache savings of patch-level commitment.
5. Related meanings of “scratchpad patching” in reasoning and robotics
The phrase “scratchpad patching” also appears in two distinct but related 2026 contexts: intervention on reasoning traces and update rules for language scratchpads in vision-language-action systems.
In "Do Models Read What They Write? Causal Registers in Scratchpad Reasoning" (Shih et al., 28 Jun 2026), the setting is a controlled state-tracking problem with known transition rule
04
where 05, 06, and 07. There, a model fine-tuned to emit intermediate states writes each 08 explicitly in a visible scratchpad. The intervention protocol edits the internal residual-stream representation of the printed current phase token at a chosen layer while leaving the visible scratchpad text fixed. The resulting “patch” tests whether later computation follows the edited latent state rather than the original visible text. In Qwen2.5-Coder-7B, the running-state model achieves edited-branch agreement 09 on the 10 task and 11 on the 12 task, while pretrained and final-answer-only controls remain near 13, and random or orthogonal patches yield 14 (Shih et al., 28 Jun 2026).
In "Notes-to-Self: Scratchpad Augmented VLAs for Memory Dependent Manipulation Tasks" (Haresh et al., 24 Feb 2026), scratchpad patching refers to updating an external sequence of text tokens 15 that is prepended or interleaved with the current image and language goal at each timestep. The policy outputs an action 16 and a language description 17, and the scratchpad update is governed by a gating bit 18: if 19 includes an update trigger such as 20, then 21; otherwise the scratchpad is left unchanged. In the reported ClevrSkills-Mem experiments, average success across five tasks rises from approximately 22 to approximately 23 for T-VLA with SP, and from approximately 24 to approximately 25 for R-VLA with SP (Haresh et al., 24 Feb 2026).
These usages are not identical to the byte-level SP mechanism. In the byte-level paper, scratchpads are transient internal summaries inside a patch; in the causal-reasoning paper, patching is an activation intervention on a written intermediate state; in the VLA paper, patching is an explicit update rule for an external text memory. What unifies them is the attempt to make intermediate state representations operational rather than merely decorative. This suggests that “scratchpad” functions as a broader design motif across multiple subfields, while “Scratchpad Patching (SP)” in the strict acronymized sense refers specifically to the byte-level patch-based mechanism of (Zheng et al., 10 May 2026).
6. Significance, limitations, and interpretive scope
The principal technical significance of SP in byte-level language modeling is that it reframes the compute-quality trade-off of patch-based models. Larger committed patches no longer imply a single fixed amount of within-patch computation, because scratchpads permit selective refresh at high-entropy positions. The paper therefore describes SP as decoupling compute from patch size, rather than replacing patching itself (Zheng et al., 10 May 2026).
The ablations also identify clear limits. Entropy-based triggers outperform fixed-stride and whitespace heuristics in BPB versus FLOPs for a Fixed 26 base. Dense updates are not uniformly beneficial. Under H-Net, scratchpad triggers often land one byte before H-Net boundaries, causing redundant near-boundary computations, which explains smaller gains under strict FLOPs matching. These findings indicate that SP is not a universal monotonic improvement; its behavior depends on interaction with the chosen patchifier and on threshold calibration (Zheng et al., 10 May 2026).
The related reasoning and robotics papers sharpen a broader conceptual point. In the reasoning study, “causal legibility” is distinguished from “plausible legibility”: it is not enough for a model to write a plausible chain of thought if later computation does not use the written variables (Shih et al., 28 Jun 2026). In the VLA setting, the scratchpad serves as a persistent textual memory for object positions, plans, and progress toward subgoals, and improvements are largest on memory-dependent long-horizon tasks (Haresh et al., 24 Feb 2026). A plausible implication is that contemporary scratchpad research is converging on a shared criterion: intermediate states become scientifically useful when they alter downstream computation in predictable ways.
Within that broader landscape, Scratchpad Patching in the sense of (Zheng et al., 10 May 2026) occupies a specific systems and architecture niche. It is a method for improving byte-level autoregressive modeling under sequence compression by repairing stale intra-patch context, using transient, entropy-triggered summaries that are computationally active but not persistently cached.