arXiv:2608.28276cs.LGAug 2026

Manuscript Offprint

arXiv:2608.28276

Parser States Already Know: Structure-Conditioned KV Persistence for Structured Generation

Linze Wu, Xinrui Chen

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Structured generation underpins large language model (LLM) agents that produce JSON, SQL, and function calls, where a single wrong field can cause the downstream action to fail. Constrained decoding already tracks parser transitions to enforce formal validity, and these transitions expose how generated tokens participate in schema-critical decisions such as required fields, arguments, and structural boundaries under the active grammar. Existing KV compression largely leaves this task-relevant structural signal unused. We introduce PASK (Parser-Aware Structural KV Persistence), which turns parser-derived structure into layer-group-specific KV persistence decisions. PASK addresses the mismatch between model-side KV sensitivity and task-level structured risk by using task-error sensitivity to set minimum protection floors and attention-output distortion to allocate residual KV capacity. An offline calibration stage compiles these signals into a persistence policy, leaving only lightweight structure-conditioned lookup online. At a target total KV budget of 0.33, PASK outperforms the strongest compressed baseline by 17.39 percentage points on average across eight BFCL non-live and Live subcategories on Qwen3-4B. In end-to-end serving, PASK achieves up to 2.2×2.2\times higher throughput and 3.3×3.3\times lower TPOT, while using 0.53×0.53\times the peak GPU memory of Full KV.

1 Introduction

Structured generation is central to LLM-based agents that produce JSON, SQL, function calls, and other machine-executable outputs, where a single incorrect field, argument, or function choice can invalidate the downstream action (Geng et al., 2025; Patil et al., 2025). Constrained decoding (Zheng et al., 2024; Dong et al., 2025; Li et al., 2026b) enforces formal validity by maintaining parser state

Figure

Figure 1: Motivation for PASK. Parser transitions expose structural responsibility that model-side KV importance may fail to capture.

and masking illegal tokens under a schema, grammar, or function signature. Yet each accepted parser transition reveals more than token legality: under the active grammar, it exposes the generated token's structural role, such as a required key, enum value, argument, boundary, or scaffold token. This information is already available during decoding, but is typically discarded once the legal token set is determined.

KV compression decides which generated history remains available to future decoding. Existing policies rely on attention saliency, quantization error, recency, or generic token importance (Liu et al., 2024b; Zhang et al., 2023; Li et al., 2024; Zhou et al., 2025; Jiang and Jin, 2026). Recent work also introduces coarse structural roles for retention in schema-dense input contexts (Mandal, 2026). These signals capture model-side KV importance, but do not directly encode the structural responsibility of generated tokens. To our knowledge, no prior KV policy uses token-level parser transitions from constrained decoding to control generated-KV persistence across Transformer layers.

This gap creates a distinctive failure mode in structured generation. Model-side KV sensitivity need not reflect task-level structured risk: his-

∗^{*}Corresponding author.

tory with modest numerical influence can still alter a later legal function, argument, or field value and change the task outcome. Figure 1 illustrates this mismatch. Model-side importance alone can thus under-protect structurally consequential history. This leads to a simple principle: task-level failure risk determines what must be protected, while model-side distortion determines how the remaining memory is allocated.

We introduce PASK (Parser-Aware Structural KV Persistence), which turns parser-derived structure into a control signal for generated-KV persistence. PASK combines each structural tag with a Transformer layer group and assigns DROP, RETAIN-LOW, or RETAIN-HIGH. Offline, task-error sensitivity sets protection floors, attention-output distortion ranks residual upgrades, and development data select the lowest-cost policy within a reliability tolerance. The calibrated policy is compiled into a frozen lookup table, leaving only lightweight structure-conditioned decisions and constant-size budget state online. A prompt-side companion extends the same principle to prefill compression.

Experiments on BFCL show that PASK substantially improves the reliability–efficiency trade-off under compressed inference. At a target total KV budget of 0.33, PASK improves accuracy over the strongest compressed baseline by 17.39 percentage points on average across eight BFCL subcategories on Qwen3-4B. PASK also achieves the highest overall accuracy among compressed methods on both BFCL non-live and Live with Qwen3-14B. Removing the task-error floor increases the decode budget required to satisfy the same development reliability gate from 50.08% to 98.49%. End-to-end serving further reduces peak memory by about 47.5% relative to Full KV.

Our contributions are:

• We formulate parser-aware KV persistence for structured generation and, to our knowledge, first use token-level parser transitions to control layer-group-specific generated-KV retention.

• We identify a mismatch between model-side KV sensitivity and task-level structured risk, using task-error sensitivity for protection and attention-output distortion for residual KV allocation.

• We develop an offline-calibrated, online-lookup mechanism that compiles parser-derived structure, task-level risk, and model-side distortion into a layer-group-specific persistence policy.

• Extensive experiments show that PASK consistently improves the reliability–efficiency trade-off for compressed structured generation, while ablations validate its key components.

References (14)