QCircuitEval leverages quantum frameworks—Qiskit, Cirq, PennyLane, CUDA-Q.

A single, stored solution may unfairly penalize correct quantum code, according to researchers behind QCircuitEval, a new benchmark for large language model-generated quantum circuits. While benchmarks like Qiskit HumanEval and QuanBench+ currently rely on comparing outputs to one example, QCircuitEval instead assesses what a program does, not just what it outputs, across frameworks including Qiskit, Cirq, and PennyLane.

“Matching an expected output is not proof that a quantum program performed the requested computation,” the team explains, emphasizing the need to verify both functional behavior and output. QCircuitEval employs both structural and functional graders, ensuring a deterministic verdict based on a contract derived from the task itself, and pinned by a hash to prevent unnoticed changes.

QCircuitEval Benchmarks LLM Quantum Code Across Frameworks

The benchmark comprises 70 tasks, split into 58 core challenges and 12 focused on quantum error correction. This extensive testing suite addresses a critical flaw in existing quantum code evaluations, where a single stored solution can unfairly penalize functionally correct, yet syntactically different, programs. The design of QCircuitEval directly responds to limitations observed in classical code benchmarks like EvalPlus, which demonstrated that improved test suites can significantly alter model rankings.

Quantum code generation compounds this issue because multiple distinct quantum circuits can achieve the same computational result, meaning a grader relying on a single reference solution risks rejecting valid code. The benchmark’s structure ensures a verdict is based on a contract of expected behavior, not a specific implementation.

Unlike benchmarks such as Qiskit HumanEval and QuanBench+, which also featured arithmetic and Boolean tasks evaluated across their full declared input domain, and Shor and Steane encoders utilizing phase-sensitive exact state checks, QCircuitEval evaluates whether a circuit realizes the contracted behavior, irrespective of its similarity to a pre-defined answer. This approach acknowledges that differences undetectable by measurement, like global phase, should not disqualify a program.

The system employs both structural and functional graders, verifying both the program’s output and its internal workings, Qiskit says. Tasks like state preparation require building a five-layer QAOA ansatz, while variational algorithms demand construction of a six-qubit quantum Fourier transform. Arithmetic and Boolean tasks are evaluated across their full declared input domain, and parameterized quantum error correction tasks run every diagnostic case, including scenarios with no error and each permitted single-error location.

Shor and Steane encoders utilize phase-sensitive exact state checks, ensuring programs accurately represent the correct codeword signs. Cross-case invariance tests identify functions that hardcode truth tables instead of computing them, employing adversarial tests to expose such shortcuts. The benchmark’s design also addresses the issue of Kullback-Leibler divergence, a measure of the gap between probability distributions used in QuanBench+. Even circuits performing the same quantum job can register high KL divergence, potentially leading to incorrect grading.

QCircuitEval’s focus on behavioral contracts sidesteps this problem by prioritizing functional equivalence over distributional similarity. The benchmark’s open-source nature encourages community contribution and refinement, fostering a more robust and reliable evaluation landscape for LLM-generated quantum code.

Functional and Structural Graders Verify Quantum Behavior

Evaluations of quantum code increasingly rely on verifying program behavior, not simply matching outputs to a single reference solution, a shift informed by lessons from classical code benchmarking. The EvalPlus benchmark for classical code demonstrated that more rigorous test suites can fundamentally alter rankings of coding models; this principle now applies to quantum systems, complicated by the potential for multiple valid implementations of the same algorithm.

QCircuitEval, an open-source benchmark supporting Qiskit, Cirq, PennyLane, and CUDA-Q, addresses this challenge with a dual-grader system designed to assess both how a quantum program arrives at an answer and the answer itself. A functional grader within QCircuitEval simulates a candidate circuit and compares its behavior to an independently derived target, but this alone is insufficient to guarantee a correct computation.

The system recognizes that a program can produce the expected output without actually performing the intended quantum operations, a loophole addressed by the structural grader. This second component inspects the circuit’s construction, examining registers, gates, measurements, and source code for evidence of the required operations and flagging any prohibited shortcuts. Both graders must independently pass for a program to be considered valid, with structural checks preceding functional evaluations.

The benchmark’s approach to evaluating measurement results accounts for the inherent stochasticity of quantum mechanics. Rather than demanding a single, precise return value, QCircuitEval often compares probability distributions using the Hellinger fidelity, calculated as p(z)q(z)))². This allows for variations in measurement outcomes while still verifying that the program is producing the correct statistical behavior.

Specific tasks, like those involving Shor and Steane encoders, employ phase-sensitive exact state checks to ensure accurate representation of quantum states, rejecting programs that match measurement support but produce incorrect codeword signs. This comprehensive testing regime ensures robustness and reliability. The target behavior is derived independently of any single canonical solution, meaning a circuit passes if it realizes the contracted behavior, not if it merely replicates a specific reference listing.

For example, the system recognizes that S and RZ(π/2) are functionally equivalent, treating them as interchangeable despite differences in their literal representation, because RZ(π/2) = e-iπ/4S. The dual-grader system is designed to prevent functional graders from being misled by code that directly outputs the expected answer without performing the necessary computation. “The functional grader sees the expected output; the structural grader sees that no adder was built,” illustrating the importance of verifying both the result and the process. QCircuitEval’s design, therefore, moves beyond simple output comparison to a thorough assessment of quantum program correctness.

Hellinger Fidelity Quantifies Distributional Similarity in Results

QCircuitEval employs the Hellinger fidelity to assess quantum program outputs, a metric chosen for its robustness against the challenges of probabilistic measurement outcomes. Unlike Kullback-Leibler divergence, a common measure of distributional gap used in benchmarks like QuanBench+, the Hellinger fidelity remains stable even when probability mass is spread across numerous low-probability bitstrings, a scenario where single-reference KL thresholds often falter.

This stability is critical because quantum computations inherently produce measurement statistics, not deterministic values, necessitating a comparison of probability distributions rather than single outputs. The Hellinger fidelity, mathematically defined as F_H(p,q) = p(z)q(z)))², provides a symmetric and bounded score between zero and one, quantifying the overlap between a target distribution, p, and a candidate distribution, q. Where the two distributions coincide, the Hellinger fidelity is high; the greater the divergence, the lower the score.

Visualizations generated by the QCircuitEval team demonstrate this overlap, showing how two circuits realizing the same measurement assign mass to the same bitstrings. Acceptance is then determined by evaluating the Hellinger infidelity, 1 – F_H(p,q), against a target value specified within the task contract. Beyond probabilistic tasks, QCircuitEval’s grading extends to gate and unitary operations, comparing candidate operators to target operators up to global phase.

The acceptance criterion is expressed as U_C ∼ ε U_R ⟺ ϕ ∈ R min d ∥ U_C − e(iϕ) U_R ∥_F ≤ ε, where U_C represents the candidate unitary, U_R the reference unitary, and ε defines the acceptable tolerance. Semantic objects like states, unitaries, channels, and instruments each have tailored comparison methods, ensuring a precise evaluation aligned with their specific properties.

States are compared using trace distance under the contract’s phase and observation policy, unitaries and isometries utilize operator norms restricted to relevant subspaces, and channels are assessed through the normalized Choi representation under the contract’s phase and observation policy. Classical input-output tasks employ full truth tables under the contract’s phase and observation policy, while distribution tasks compare entire probability vectors.

The design philosophy behind QCircuitEval prioritizes verifying what a program does, not how it achieves the result, allowing for functionally equivalent circuits to be graded equally. “Different constructions can still overlap on that contracted distribution,” the team notes, emphasizing that the benchmark focuses on realized behavior rather than adherence to a specific reference implementation.

Contract-Based Verification Prevents Shortcut Solutions

QCircuitEval, a new benchmark for quantum code, employs a dual-grader system to identify programs that achieve correct results through unintended shortcuts, a problem previously exposed in classical code testing. The system operates across four quantum software frameworks, Qiskit, Cirq, PennyLane, and CUDA-Q, and assesses code based on what it accomplishes, not how it achieves the result, according to the company. A candidate program must satisfy both a structural grader and a functional grader, with construction requirements evaluated before functional checks are performed.

No large language model participates in the grading process; every verdict originates from a deterministic verifier linked to a specific contract for each task. This contract, a versioned definition of the task, specifies inputs, the expected result, bit order, parameter domain, output policy, semantic object, metric tolerance, resource limits, and required construction details. Pinning the target result with a hash ensures that any unintended drift in the expected outcome is immediately detectable.

The acceptance test centers on Hellinger infidelity, 1−F_H(p,q), against a target value specified in the contract. Beyond rejecting precomputed results or amplitude injection, contracts can also specify minimum requirements for qubits, operations, measurements, and entangling gates. The system also incorporates checks to identify entangling gates that cancel each other out, ensuring that they contribute to the computation rather than simply satisfying a gate count.</p, the company says.

Stay current

See today’s quantum computing news on Quantum Zeitgeist for the latest breakthroughs in qubits, hardware, algorithms, and industry deals.

Avatar of Ivy Delaney

Ivy Delaney

Ivy Delaney has been working with neural networks and machine learning since the mid-nineties, back when a couple of hidden layers and a long afternoon of training counted as ambitious. She has watched the field go from academic curiosity to the thing quietly running underneath everything, and she brings that long view to quantum computing. For Quantum Zeitgeist she covers the ground where the two fields meet. That means quantum machine learning and the variational algorithms it leans on, and it also means the less glamorous but more interesting story of classical machine learning already doing real work inside quantum machines, decoding error-correcting codes, calibrating noisy hardware and learning the error models that simulators depend on. She writes about the hardware those algorithms have to run on too, and about the post-quantum cryptography scramble that the same hardware has set off. Her stories typically start with the paper, whether that is peer-reviewed work, conference proceedings or an arXiv preprint, with the source linked so you can hold a claim up against the research it came from. She is unimpressed by benchmarks that will not say what they beat, and by demonstrations that only work in the press release.

Latest Posts by Ivy Delaney: