Verifier-Guided Code Translation via Meta-Step Decoding

Tianyang Zhou, Somesh Jha, Mihai Christodorescu, Kirill Levchenko, Varun ChandrasekaranarXiv 2026

TL;DR

This paper introduces Decoding Time Verification (DTV), a framework that integrates deterministic code verifiers (like compilers and type checkers) directly into the LLM generation loop. By pausing at structural boundaries (like statements or blocks) to validate code prefixes and rolling back when errors are detected, DTV prevents early mistakes from corrupting the model's context, significantly boosting translation success rates while using fewer tokens.

What Problem Does This Paper Address?

When using Large Language Models (LLMs) for code translation (e.g., converting C to Rust), a single early mistake can ruin the entire output. Because LLMs generate text autoregressively—token by token, conditioning on everything they've written so far—an early syntax or type error corrupts the generation context. The model then tries to build on top of this broken foundation, leading to a cascade of errors.

Traditional test-time scaling methods try to fix this post-hoc by running compilers or tests after the entire program is generated and asking the model to self-debug. However, this is highly inefficient because the model rarely recovers from deeply entrenched early errors. The authors address this gap by bringing verification inside the decoding loop, catching errors before they propagate.

Methods

The authors propose Decoding Time Verification (DTV), a state-machine-driven decoding framework that interleaves code generation with deterministic verifier calls.

Instead of checking the code token-by-token (which is impossible for compilers that need complete code structures), DTV operates at meta steps defined by structural boundaries (statements, blocks, functions).

DTV State Machine Flow

The core framework relies on three key mechanisms:

  1. Structural-Boundary Verification: Generation pauses at logical code boundaries. The partial prefix is rendered into a verifier-consumable artifact and checked by tools like compilers or linters. If it passes, the prefix is committed as a safe checkpoint.
  2. Structure-Aware Rollback with Escalation: If verification fails, the controller rolls back the generation to the smallest scope implicated by the compiler's error message (e.g., deleting just the faulty statement). If retries fail repeatedly, it escalates to wider scopes (e.g., rolling back the entire block).
  3. Feedback via Prompt Augmentation: When a rollback occurs, the compiler's error diagnostics are injected back into the prompt context. Retries proceed in either inline continuation mode (adding errors as comments) or patch-based repair mode (requesting a diff).

Datasets

The framework was evaluated on two distinct code translation tasks:

  • C to Rust (Unsafe-to-Safe Translation): 300 C programs sampled from Project CodeNet. Test inputs were generated using a hybrid LLM-seeded AFL++ fuzzing pipeline to ensure high branch coverage. The in-loop verifier was rustc.
  • JavaScript to TypeScript (Dynamic-to-Static Typing): 150 programs from TypeWeaver that fail standard type-checking. The verifiers used were tsc (TypeScript compiler) and ESLint.

Key Insights and Ideas

  • The Early-Rise Effect: DTV exhibits a distinct advantage in token efficiency. Because it catches and fixes errors early, it achieves high pass rates at much lower token budgets compared to naive self-refinement, which must regenerate entire programs from scratch.
  • Locality Matters: DTV's rescue rate is highly dependent on the "shape" of the fix. It excels at resolving local errors (where the fix is on the exact line the compiler flagged) but its performance drops when dealing with non-local errors (e.g., an error flagged on line 50 that actually requires changing a variable definition on line 5).
  • Compositionality: DTV acts as an inner-loop decoding wrapper. The authors found that it successfully composes with, rather than replaces, outer-loop test-time scaling methods like multi-round self-refinement.

Key Results

Using Qwen3-4B as the primary generation model under matched token budgets, DTV achieved substantial performance gains:

  • C to Rust: DTV improved the compilation pass rate from 72.3% to 82.0% relative to a cost-matched self-refinement baseline, while actually using fewer tokens per case.
  • JavaScript to TypeScript: The pass rate increased from 33.3% to 46.0%.
DTV Pareto-dominates baselines

The authors also verified that these gains did not come at the expense of behavioral correctness; differential testing confirmed that DTV maintained semantic equivalence to the source programs. The performance gains also successfully transferred to another model family, Gemma-4-E4B.

Limitations and Future Work

  • Oracle Requirements: DTV relies heavily on verifiers that provide localized, actionable diagnostics with source-line attribution. It cannot be easily driven by global pass/fail signals (like pure differential testing) during the inner loop.
  • Non-Local Semantic Errors: Errors requiring global architectural redesigns or cross-module consistency checks fall outside the capabilities of DTV's localized rollback ladder.
  • Wall-Clock Overhead: While DTV is highly token-efficient (saving LLM compute), it requires invoking compilers and linters frequently during generation. In environments where toolchain startup or compilation latency is high, this can increase overall wall-clock time.

Future work includes scaling DTV to larger models, extending it to non-translation domains (like theorem proving or formal modeling), and combining it with token-level constrained decoding.

Summary updated

Abstract

Test-time scaling is an important mechanism for improving large language models, especially on tasks with deterministic verifiers. Code translation is a canonical example: the source program constrains valid outputs, while compilers, type check- ers, and behavioral checks provide exact pass/fail feedback. Existing approaches typically apply these verifiers only after generation, which is inefficient because early errors corrupt the autoregressive context and are rarely corrected later. We introduce Decoding Time Verification (DTV), a framework that treats structural boundaries as meta steps for verifier-guided decoding. DTV interleaves generation with verifier calls under a state-machine controller that enforces valid prefixes, using structural-boundary checks and structure-aware rollback to prevent error propagation while reducing wasted tokens. We evaluate DTV on C-to-Rust and JavaScript-to-TypeScript translation. Using Qwen3-4B as the primary generator under matched token budgets, DTV improves pass rates from 72.3% to 82.0% on C-to-Rust and from 33.3% to 46.0% on JavaScript-to-TypeScript relative to matched self-refinement baselines, while using fewer tokens per case; the same trend largely transfers to Gemma-4-E4B. In the evaluated cost-matched grid, DTV achieves a more favorable pass-rate-cost tradeoff than post-hoc verification or sampling-based scaling. These results show that verifier-guided decoding is an effective use of inference-time compute for code translation.
BibTeX
@misc{zhou2026verifier,
  author = {Tianyang Zhou and Somesh Jha and Mihai Christodorescu and Kirill Levchenko and Varun Chandrasekaran},
  title = {{Verifier-Guided Code Translation via Meta-Step Decoding}},
  year = {2026},
  eprint = {2605.17626},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.17626},
}

Loading related content...

Figure