Summary
Programs that generate scientific code can produce correct syntax but fail to perform the right calculations. This paper studies how language models build quantum circuits used in quantum error correction, focusing on a subgroup called Clifford circuits that can be precisely checked classically. The authors show that guiding these models with detailed algorithmic reasoning steps, called Aaronson-Gottesman chain-of-thought traces, and continuing training on verified correct outputs boosts accuracy severalfold compared to training only on code. They also find that just passing syntax and physical validity checks is not enough to guarantee correct quantum states, highlighting the need for exact verification.
What this means in practice
- •For quantum software developers: Generate verified Clifford circuit code more accurately by training language models with algorithmic trace supervision and verifier-filtered data.
- •For quantum hardware engineers: Use improved language model outputs to test and validate quantum states in hardware experiments with higher confidence in correctness.
Authors
Lu Wei, Yufeng Wang, Chenfeng Cao, Lu Pang, Haibin Ling
Abstract
Scientific code generation can produce executable programs that fail to compute the intended scientific object. We study this problem in language-model synthesis of Clifford circuits, which prepare the stabilizer states used in quantum error correction and admit exact classical verification. In our target-conditioned framework, each target is given as compact signed stabilizer generators, and an exact verifier checks the generated OpenQASM circuits. We supervise models with Aaronson-Gottesman chain-of-thought (AG-CoT) traces checked by the verifier, and continue training on model generations that the verifier accepts. Across two independently trained model families (3B and 7B), AG-CoT supervision multiplies greedy-decode state-equivalence accuracy by four to six times over circuit-only baselines, and verifier-filtered continuation training adds a further consistent gain atop both. A complementary 32B study shows that supervised models achieve near-perfect syntax and Clifford validity while the strongest direct model reaches 6.14% state equivalence per target, rising to over 10% under verifier-guided selection with multiple candidates. These results show that algorithmic trace supervision gives a large, statistically significant gain in both model families and that verifier-filtered continuation adds a further repeated gain. The persistent gap between Clifford validity and state equivalence confirms that exact verification is necessary: a circuit can be syntactically and physically valid yet prepare the wrong quantum state.