Copy-as-Decode: Grammar-Constrained Parallel Prefill for LLM Editing
Abstract
LLMs edit text and code by autoregressively regenerating the full output, even when most tokens appear verbatim in the input. We study Copy-as-Decode, a decoding-layer mechanism that recasts edit generation as structured decoding over a two-primitive grammar: <copy lines="i-j"/> references an input line range, <gen>...</gen> emits new content. A token-level FSM guarantees syntactic validity, and a serving-layer primitive updates the KV cache for each copy span via a single parallel-prefill forward rather than autoregressive steps -- sharing the parallel-forward kernel of speculative decoding but with input tokens as the draft and program-enforced acceptance replacing probabilistic verification. We report an upper-bound analysis that requires no end-to-end training. (i) Kernel speedup: on Qwen2.5-{1.5B, 7B}, copying tokens via parallel prefill is -- faster than autoregressive (, A100 80GB bf16). (ii) Copy ceiling: on ProbeEdit and HumanEvalPack-Fix (Py/JS), -- of gold tokens are reachable under the line-level primitive; composed with the empirical kernel over each corpus's span histogram this yields a closed-form wall-clock bound of ( pooled). A token-level extension reaches -- coverage with -- floors. (iii) Pipeline losslessness: oracle programs round-trip through the deterministic resolver on all cases, localizing any downstream failure to span selection rather than the mechanism. A perturbation study shows pooled EM drops from to under off-by-one noise. A fine-tuning pilot on Qwen2.5-Coder-1.5B lifts HEvalFix-Py EM from (untrained) to --, a learnability signal, not a production selector. Batched-serving integration and multi-file coverage are scoped as follow-up.
Cite
@article{arxiv.2604.18170,
title = {Copy-as-Decode: Grammar-Constrained Parallel Prefill for LLM Editing},
author = {Ziyang Liu},
journal= {arXiv preprint arXiv:2604.18170},
year = {2026}
}
Comments
The authors have decided to withdraw this version following internal review regarding authorship and contribution agreements