TRANSMISSION // 2612.04403v1

When AI Ports Quantum Code, Verification Matters

Source published

An execution-and-checking loop helped some models translate Qiskit programs into CUDA-Q, but fine-tuning was cheaper on familiar tasks. A verifier-gated combination performed best in this benchmark.

AI-generated conceptual illustration for When AI Ports Quantum Code, Verification Matters
AI-generated conceptual illustration; not documentary evidence.

Moving quantum programs between software frameworks is more than a syntax exercise: the translated code must produce the right quantum state. A preprint compares one-shot, fine-tuned models with agents that can run and check their code. Its results suggest the better choice depends on a model’s ability to use tools and how closely the input resembles its training data.

Porting a quantum program from Qiskit to NVIDIA’s CUDA-Q involves more than replacing one set of commands with another. The translated program must prepare the same quantum state as the original. That makes this task a useful test of whether an AI-generated translation is actually correct—not just plausible-looking code.

Ana Paula Appel’s study asks whether a model should be fine-tuned for the translation or given an “agent harness”: a setup that lets it run code, receive feedback and revise its answer. The researchers also test which parts of the harness matter, whether it helps on real benchmark programs, and whether combining fine-tuning with a harness can balance accuracy and computing cost.

Checking the result, not just the code

The study evaluates 640 translation tasks divided into three kinds of challenge: larger circuits, an unseen circuit family, and familiar circuits rewritten with different Qiskit coding styles. It also examines 48 parameterized functions and 27 real kernels from the QED-C benchmark.

For each candidate translation, a verifier runs the CUDA-Q code and compares the resulting quantum state with the state produced by the Qiskit reference. A translation counts as correct only if its state fidelity reaches at least 0.999. This checks behavior rather than whether the program merely compiles. The verifier runs separately from the model, in an isolated process with memory limits.

In the harness, the model can use a short CUDA-Q API guide, execute code, and request a correctness check. The researchers switched individual components off in tests on 60 tasks, using the same tasks across configurations. They also compared models with different sizes and training histories, estimated inference compute, and tested a cascade in which a fine-tuned model’s answer is checked before a harness is called.

The loop helps only when the model can use it

On the 60-task sample, Nemotron Cascade 2, a model with 3 billion active parameters, reached 97% accuracy with the full harness, compared with 0% in a single attempt without the API reference. Across all 640 tasks, it reached 93.8%. A separate model, GLM-5.3 Flash, reached 99.8% with the harness across all 640 tasks, but used substantially more estimated compute.

The component tests point to two practical ingredients: knowledge of the target framework’s API and useful feedback. Without the API guide, Cascade 2 solved none of the 60 tasks. Removing verification reduced its accuracy from 97% to 77%. A weaker check that only confirmed code compiled and ran still produced 93% on this sample, though that does not make it an adequate final correctness test. Simply giving the model an execution tool without verification performed worse than providing the API guide alone: the model sometimes explored the environment instead of using it to confirm an answer.

The loop was not a universal fix. Several models—including dense 4B and 7B models and Llama 4 Scout—did not gain from it in the tested configurations. The researchers’ traces suggest that calling a tool is not enough: a model must interpret the feedback and change its approach. Model size alone did not predict whether the harness helped, though the authors caution that differences in serving setups and output budgets make these model comparisons imperfect.

Fine-tuning, a harness, or both?

A fine-tuned Qwen2.5-Coder 7B model achieved 93.6% across the 640 tasks in a single attempt. It was substantially cheaper per task than running the harness, but its accuracy fell to 80% on the test set with unfamiliar coding styles. Cascade 2 with the harness scored 90.5% on that set. On the real QED-C kernels, the harness-equipped models reached 63% and 100%; the earlier study reported that its tested models had not translated any of those kernels. These results suggest fine-tuning can be economical when inputs resemble training examples, while a useful harness may help when they differ.

The researchers also tested a verifier-gated cascade: try the fine-tuned 7B model first, then call the harness only if the verifier rejects its answer. On all 640 tasks, this system reached 98.9% accuracy—about five percentage points above either system alone in this comparison—and used about one-third of the harness’s estimated compute. This is a benchmark result, not a guarantee that the same combination will work as well for other models or software tasks.

What the evidence can—and cannot—show

The study’s evidence concerns a specific translation task, one harness design and CUDA-Q version 0.16 running on CPU. The component ablations used only 60 of 640 tasks, so small differences are uncertain. The authors also note that results may depend on the API reference they wrote, model-serving changes and how tool calls were handled. Estimated inference compute does not capture every practical cost, including memory and subprocess time.

The verifier assumes that the Qiskit source is correct: matching a faulty source would carry its mistake into the translation. Exact state checks also become impractical for large circuits. Finally, this is a preprint, and the evidence described here comes from the authors’ reported experiments rather than independent replication. The paper says code, evaluation scripts and analysis are publicly available; detailed run traces are available on request.

Reviewed cross-references

These connections were reviewed by a model, not independently fact-checked by a human. Similarity does not imply agreement; consult the original papers and the evidence below.

  • When AI Translates Quantum Code, Correctness Is More Than Syntax

    Shared method: Both studies evaluate Qiskit-to-CUDA-Q translations by executing the source and candidate and comparing quantum states, rather than relying on text matching or an LLM judge. The earlier study specifies a fidelity threshold of 0.999; the later study says it reuses that evaluator. These are related studies, not independent corroboration, and the later study adds an agent harness.

    Model review: · openai-codex/gpt-6-luna

    Evidence and provenance

    Selected excerpts, not complete papers. PDF extraction can omit figures or damage equations, tables and reading order; sources may be preprints.

    • 2612.04403v1 — Original paper

      Excerpt reference: static/papers/2612.04403v1.md:46-97
      Basis: Paper text
      Source file SHA-256: dc3f30ac896a926d73e9f287a2f5c47a0cf0d90e2a24ac5723db3103dd018928

    • 2611.29793v1 — Original paper

      Excerpt reference: static/papers/2611.29793v1.md:13-50
      Basis: Paper text
      Source file SHA-256: dac0afc8690cee46b40cd12cd7cb13040fee8785c753c26dddaa527926b00750

  • Targeted AI repairs improve scientific code translation—but simple tests miss errors

    Shared method: Both papers use execution feedback within an iterative code-translation workflow: the quantum study lets a model run and verify a translation, while the HPC study routes diagnosed compilation or execution failures to targeted repairs. The systems, benchmarks, and correctness criteria differ, so this connection does not establish comparable performance.

    Model review: · openai-codex/gpt-6-luna

    Evidence and provenance

    Selected excerpts, not complete papers. PDF extraction can omit figures or damage equations, tables and reading order; sources may be preprints.

    • 2612.04403v1 — Original paper

      Excerpt reference: static/papers/2612.04403v1.md:46-97
      Basis: Paper text
      Source file SHA-256: dc3f30ac896a926d73e9f287a2f5c47a0cf0d90e2a24ac5723db3103dd018928

    • 2611.08947v1 — Original paper

      Excerpt reference: static/papers/2611.08947v1.md:132-203
      Basis: Paper text
      Source file SHA-256: de224fcf2c0a62b65d7dbfea1b6fe755c2583bb2bfc1afd7d402fdb2ab2c5d23

Automatically matched by shared topic keywords. These links do not imply that the sources agree or establish a consensus.