Saved in:
Bibliographic Details
Main Authors: Du, Alexander, Ou, Jianjun, Zhuo, Danyang, Lentz, Matthew
Format: Preprint
Published: 2026
Subjects:
Online Access:https://arxiv.org/abs/2605.15238
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866914567836139520
author Du, Alexander
Ou, Jianjun
Zhuo, Danyang
Lentz, Matthew
author_facet Du, Alexander
Ou, Jianjun
Zhuo, Danyang
Lentz, Matthew
contents Large language models are increasingly used for code generation, but many generated programs fail to compile, a prerequisite for further correctness checks such as unit tests. Existing solutions for repairing static errors are costly in both latency and token consumption. Post-hoc repair delays error detection until generation completes and commonly regenerates large regions of previously valid code. Constrained semantic decoding checks after each token, incurring per-token overhead while limiting repair to the current token even when the root cause lies earlier. We present Hydra, a system for efficient recovery from static errors during code generation. Hydra allows checking to proceed asynchronously with generation, avoiding checker overhead when the generated code is semantically correct. In addition, it provides checkpoint-and-rollback support for targeted repair, avoiding regeneration and rechecking of valid prefixes. We retrofit the Clang C/C++ compiler to support Hydra with modest modifications. Paired with a token-efficient repair strategy, Hydra reduces latency by up to 71% and token consumption by up to 70% relative to post-hoc repair on C/C++ code generation tasks that encounter static errors.
format Preprint
id arxiv_https___arxiv_org_abs_2605_15238
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Hydra: Efficient, Correct Code Generation via Checkpoint-and-Rollback Support
Du, Alexander
Ou, Jianjun
Zhuo, Danyang
Lentz, Matthew
Software Engineering
Artificial Intelligence
Programming Languages
Large language models are increasingly used for code generation, but many generated programs fail to compile, a prerequisite for further correctness checks such as unit tests. Existing solutions for repairing static errors are costly in both latency and token consumption. Post-hoc repair delays error detection until generation completes and commonly regenerates large regions of previously valid code. Constrained semantic decoding checks after each token, incurring per-token overhead while limiting repair to the current token even when the root cause lies earlier. We present Hydra, a system for efficient recovery from static errors during code generation. Hydra allows checking to proceed asynchronously with generation, avoiding checker overhead when the generated code is semantically correct. In addition, it provides checkpoint-and-rollback support for targeted repair, avoiding regeneration and rechecking of valid prefixes. We retrofit the Clang C/C++ compiler to support Hydra with modest modifications. Paired with a token-efficient repair strategy, Hydra reduces latency by up to 71% and token consumption by up to 70% relative to post-hoc repair on C/C++ code generation tasks that encounter static errors.
title Hydra: Efficient, Correct Code Generation via Checkpoint-and-Rollback Support
topic Software Engineering
Artificial Intelligence
Programming Languages
url https://arxiv.org/abs/2605.15238