Manuscript Offprint
arXiv:2610.13811QTestBench: A Test Framework for Evaluating LLM-Generated Quantum Code
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Meriem Terki, Nouhaila Innan, Minghao Shao, Muhammad Kashif, Alberto Marchisio, Muhammad Shafique
École Supérieure en Informatique de Sidi Bel Abbès, Algeria
eBRAIN Lab, Division of Engineering, New York University Abu Dhabi (NYUAD), Abu Dhabi, UAE
Center for Quantum and Topological Systems (CQTS), NYUAD Research Institute, NYUAD, Abu Dhabi, UAE
SDU Microelectronics, Institute of Mechanical and Electrical Engineering, University of Southern Denmark, Odense, Denmark
m.terki@esi-sba.dz, {nouhaila.innan, shao.minghao, muhammadkashif, muhammad.shafique}@nyu.edu, chisio@sdu.dk
Abstract—Large language models (LLMs) have shown strong results in classical code generation and are increasingly used to write the unit tests that safeguard that code. Whether they can do the same for quantum software is less clear, because quantum programs are probabilistic, depend on numerical tolerances, and are judged by domain-specific checkers, so a well-formed test can still disagree with the benchmark's verdict. Existing quantum benchmarks measure whether a model produces a correct solution, but not whether its tests can distinguish correct implementations from faulty ones. We introduce QTestBench, a framework that evaluates LLM-generated quantum test suites against independent benchmark checkers, never treating the tests themselves as ground truth. For each task, QTestBench prompts models to produce syntactic, semantic, and behavioral tests, injects candidate solutions at runtime, and compares each test verdict with the checker's label under three validation cohorts, each answering a distinct diagnostic question. We benchmark five LLMs on eight PennyLane QHack challenges and ten Qiskit HumanEval tasks. Generated suites almost always execute, but discrimination lags behind: the best generator reaches a test quality of 0.71 on QHack and 0.34 on Qiskit HumanEval, so executability alone overstates test quality. Oracle-verified synthetic mutants stabilize bug-detection estimates when natural faulty solutions are scarce, as on three of ten Qiskit tasks that yield none. QTestBench offers a reproducible, cross-framework benchmark for the trustworthiness of LLM-generated quantum tests.
Index Terms—Quantum computing, large language models, software testing, code generation, benchmarking, Qiskit, PennyLane.
I. INTRODUCTION
Large language models (LLMs) now turn natural-language prompts into executable code, performing strongly on classical benchmarks such as HumanEval [1] and MBPP [2]. Developers increasingly ask the same models to write the unit tests that guard this code, yet a passing generated test is not necessarily trustworthy: a suite that accepts incorrect code is worse than no test at all [3]. The risk intensifies in quantum computing, where outputs are probabilistic, tolerances matter, and correctness is often defined only through domain-specific checkers [4], [5]. Benchmarks such as Qiskit HumanEval [6], QHackBench [7], and QuanBench [8] evaluate whether LLMs write correct quantum solutions; none measures whether they write tests that separate correct from incorrect quantum code. We close this gap with QTestBench.
TABLE I: Two failure modes when generated tests are scored against the benchmark checker (Coffee Conundrum challenge).
| Mode | Test checks | Probe scenario | Test | Checker |
|---|---|---|---|---|
| Too weakDeepSeekV3.2 [9]syntactic | Entry-point checks only; no execution on official input | Oracle-wrong LLM output | Pass | Wrong |
| Too strictGPT-5.4 [10]semantic | Numerical tolerance at | Human reference output | Fail | Correct |
Legend: Red cells mark test verdicts that disagree with the checker; blue cells show oracle labels.
To be useful, a generated test must (i) execute without infrastructure failure, (ii) accept oracle-correct candidates, and (iii) reject oracle-wrong ones. QTestBench scores LLM-generated pytest suites on all three counts against an independent benchmark oracle, never against the tests themselves, spanning PennyLane QHack [7] and Qiskit HumanEval [6].
In the first row, the syntactic suite never executes the candidate on official inputs, so oracle-wrong LLM solutions pass every sub-test even though their circuits return incorrect values. In the second row, the human reference passes the task acceptance routine, yet the generated semantic suite rejects it: two numerically close outputs land just outside the test's tolerance. Fig. 1 lists the assertions behind each row; harness boilerplate is omitted. Neither mismatch is visible when grading
This work has been carried out while at NYUAD.
Assertions behind Table I
Task. Coffee Conundrum: candidates are loaded at runtime; official pairs are embedded in the generated suite; the benchmark checker is the task acceptance routine.
(A) Too weak: DeepSeek V3.2 syntactic (row 1)
Structure checks only; oracle-wrong output still yields Test=Pass, Checker=Wrong.
1 exec(sol, ns) 2 assert "run" in ns and callable(ns["run"]) 3 assert "check" in ns and callable(ns["check"]) 4 # no run('5') -> Pass despite wrong circuit
(B) Too strict: GPT-5.4 semantic (row 2)
Human reference passes the acceptance routine; strict allclose rejects numerically close outputs (Test=Fail, Checker=Correct).
1 out = ns"run" # '0.6725000000000004' 2 exp = '0.6735' 3 assert np.allclose(float(out), float(exp), atol=1e-4)
Fig. 1: Illustrative generated-test assertions for the Coffee Conundrum challenge (Table I). Each snippet shows the discriminating checks; harness boilerplate is omitted.
only the generated code; both surface only when grading the generated tests against the checker, and exposing exactly such mismatches is what QTestBench is built for.
B. Research Challenges
Evaluating LLM-generated quantum tests raises four challenges: (i) existing benchmarks grade solutions, not tests; (ii) ground truth must come from an oracle independent of the generated suite; (iii) naturally occurring wrong solutions are too sparse for stable bug-detection estimates; and (iv) scores must transfer across SDKs with different task formats and execution models.
C. Our Contributions
We introduce QTestBench, a framework for measuring LLM-written quantum test quality. Our contributions are:
• Oracle-grounded test evaluation. QTestBench generates syntactic, semantic, and behavioral pytest modules per task and scores them against benchmark checkers that label each candidate correct, wrong, or unknown.
• Discrimination metrics. We define executability, correctness acceptance, bug-detection rejection, test quality, checker-input coverage, and composite quality for quantum test suites (Section III-C).
• Three validation cohorts. Configurations A–C (Section III-D) isolate executability and acceptance on trusted references, discrimination against oracle-labeled LLM solutions, and calibrated rejection via synthetic mutants.
• Cross-SDK evaluation. We benchmark Claude Opus 4.6 [11], DeepSeek V3.2 [9], Gemini 3 Pro [12], GPT-5.4 [10], and Qwen3-Coder [13] on eight QHack challenges and a fixed ten-task Qiskit HumanEval scope, using the same metrics on PennyLane and Qiskit.
Section II reviews related work; Section III describes the pipeline and evaluation protocol; Section IV reports QHack and Qiskit HumanEval results; Section V concludes.
II. BACKGROUND AND RELATED WORK
A. LLM Code Generation and Evaluation
LLMs such as Codex [1] and StarCoder [14] turn natural-language prompts into executable code and are benchmarked on HumanEval [1] and MBPP [2]. Because judging code automatically is itself difficult, a parallel line of work studies how generated code should be scored. Text-similarity metrics such as CodeBLEU [15] compare program text, while execution-aware methods such as CodeScore [16] predict run-time success, and FormalEval [17] checks correctness without hand-written tests. Recent reviews note that these benchmarks are fragile and often disagree [18]. Separately, LLMs are increasingly used to author unit tests for the code they generate [3], but classical benchmarks do not score whether those tests reliably discriminate correct from incorrect implementations.
B. LLM Quantum Code Generation
Quantum programming introduces additional difficulty: outputs are probabilistic, domain-specific checkers define correctness, and tasks cover circuit construction, simulation, and hardware-oriented APIs. For IBM Qiskit, the Qiskit Code Assistant fine-tunes models for quantum programming [19], while Qiskit HumanEval provides curated tasks with reference solutions and simulator-based checks [6]. For PennyLane, QHackBench evaluates models on real QHack coding challenges drawn from hackathon-style problem sets [7] and implemented using the PennyLane framework [20]. PennyLang introduces a PennyLane-centric dataset and studies retrieval-augmented quantum code generation [21], while PennyCoder develops lightweight domain-specific models fine-tuned for PennyLane code generation [22]. PennySynth further uses retrieval-driven data synthesis and code-aware retrieval to improve generation on QHack challenges [23]. Beyond SDK-specific studies, QuanBench covers broader quantum programming tasks and reports low accuracy for current models [8]; QCoder incorporates simulator feedback [24], and multi-agent pipelines iteratively repair incorrect solutions [25]. These studies share a common evaluation target: whether a model can generate correct quantum code. However, none evaluates whether generated test suites can reliably distinguish correct from incorrect quantum programs across multiple SDKs.
C. Trusting LLM-Generated Artifacts
Studies that inspect LLM-generated code find that high benchmark accuracy can still hide defects, so accuracy alone is not a reliable quality signal [26], [27]. Generated artifacts should be checked against an independent source of truth. This caution applies equally to generated tests: a suite that passes broken code is actively misleading. QTestBench therefore never uses generated tests as ground truth; benchmark checkers label every candidate solution.
D. Test Oracles and Mutation Testing
Two classical software-testing ideas underpin QTestBench. A test oracle decides whether an output is correct; oracle selection is a long-standing challenge [28], especially for quantum code with probabilistic outputs and numerical tolerances. Mutation testing inserts faults into correct programs and scores suites by mutant detection [29]. QTestBench uses each benchmark's official checker as an independent oracle and oracle-verified synthetic mutants when natural wrong solutions are too sparse for stable bug-detection estimates.
III. METHODOLOGY
QTestBench evaluates LLM performance in quantum test generation through an automated benchmarking framework for PennyLane QHack challenges [7] and Qiskit HumanEval tasks [6]. Our methodology separates test generation (Stage 1) from oracle-grounded validation (Stage 2): an LLM first writes pytest modules; the framework then injects candidate solutions, runs those modules, and compares outcomes against independent benchmark checkers. Section III-C defines discrimination metrics; Section III-D specifies three validation cohorts; Stage 2 applies both within the pipeline in Fig. 2 and Algorithm 1. The same workflow applies to both SDKs; only task materialization and oracle execution differ.
A. Benchmark Tasks and Inputs
To ensure consistency across SDKs, every evaluable task is materialized into the same three inputs (Fig. 2):
-
Task description: problem statement and entry-point stub that define the callable interface a solution must implement.
-
Official test cases: published input/output pairs that ground semantic and behavioral assertions. Stage 1 embeds these pairs in generated suites; the reference solution is withheld from test-generation prompts.
-
Official checker (oracle): benchmark logic that labels any candidate correct, wrong, or unknown. Stage 2 uses the checker only to label the solution cohort; generated tests never serve as ground truth.
QHack (PennyLane). We use eight challenges from the QHack framework bundle, each with a template notebook, human reference submissions, and a task-specific acceptance routine. The framework extracts prompts, stubs, and official I/O pairs into a uniform layout shared with Stage 1 prompts and Stage 2 oracle execution.
Qiskit HumanEval. Curated task records are converted into executable benchmark units (prompt, stub, reference solution, and published checker). Oracle execution invokes the required entry-point function and applies the benchmark acceptance logic. All reported Qiskit results use a fixed ten-task evaluation scope chosen before any test generation, so every model and configuration is compared on the same tasks.
B. Automated Test Generation (Stage 1)
To ensure reproducibility, Stage 1 follows the same four-step sequence for each test type; only the type-specific instructions in step 2 change (Fig. 2):
TABLE II: Generated test types in Stage 1: scope and oracle interaction.
| Type | Question | What runs | Ground truth used |
|---|---|---|---|
| Syntactic | Valid structure? | Parse/load candidate; no circuit execution | Required entry points only |
| Semantic | Correct outputs? | Candidate execution on official cases | Embedded official I/O values |
| Behavioral | Passes harness rules? | run() then candidate check() | Candidate's embedded check() |
Legend: Row shading groups the three Stage 1 test types (see Fig. 3). Behavioral suites call the candidate's template-local check() helper (not the benchmark's official Stage 2 oracle).
-
Prepare task. Assemble the problem statement, entry-point stub, and official input/output pairs. The reference solution is excluded from the prompt so the model cannot copy correct answers into assertions.
-
Build prompt. Combine task context with harness rules (tests must load injected candidate code at runtime) and instructions for syntactic, semantic, or behavioral checking.
-
Query the LLM. Issue one request per test type at temperature 0.8 with no repair or re-prompt loop.
-
Normalize and ground. Strip markdown fences, validate Python syntax, prepend a file header, and embed official input/output pairs so semantic and behavioral suites compare against benchmark values.
Three modules are saved per (task, test-generator model):
-
Syntactic: valid Python, harness load, required callable entry points; no circuit execution.
-
Semantic: candidate execution on official cases with numerical comparison at atol = .
-
Behavioral: on QHack, call the candidate's template-local run() / check() helpers (harness acceptance, not the official checker); on Qiskit, invoke the injected entry point end-to-end.
Table II and Fig. 3 summarize how each type interacts with the oracle on the Rainy Days forest-parity challenge.
C. Discrimination Metrics
Let be a generated test suite and let a validation cohort denote the set of candidate solutions evaluated under one configuration (Section III-D). For that cohort, is the set of oracle-correct candidates (the trusted baseline plus any probe the oracle labels correct) and is the set of oracle-wrong candidates. Candidates labeled unknown are excluded from both pools. A suite accepts a candidate when all test functions pass; it rejects when any function fails or errors.
The executability score (ES) is a binary indicator of whether the suite runs without infrastructure failure on the trusted-correct baseline:

Fig. 2: QTestBench pipeline. Inputs: task description, official cases, and benchmark checker (oracle). Stage 1 generates syntactic, semantic, and behavioral pytest modules (one LLM call per type, temperature 0.8, no repair loop). Stage 2 builds a solution cohort, labels probes with the oracle, executes generated tests via runtime solution injection, and reports the metrics in Section III-C under Configuration A (trusted correct only), Configuration B (checker-labeled LLM cohort), and Configuration C (synthetic incorrect calibration; Section III-D).
The correctness score (CS) is the fraction of oracle-correct candidates accepted by the generated tests:
The bug-detection score (BDS) is the fraction of oracle-wrong candidates rejected by the generated tests, defined only when ; otherwise BDS is :
The test quality score (TQS) combines discrimination components:
Under Configuration A, BDS is and TQS = ES × CS. Under Configurations B and C, reporting BDS or TQS as zero when would incorrectly penalize suites that accept all available correct probes but have no wrong probes to reject; BDS, TQS, and CQ are therefore whenever the cohort contains no oracle-wrong candidate. We also report checker-input coverage ( ), the fraction of official checker literals present in the generated test body, and composite quality (CQ), when TQS is defined.
D. Validation Configurations
Stage 2 is repeated under three cohort compositions (Fig. 2). We refer to them as Configuration A, Configuration B, and Configuration C (Config A–C in tables). Each configuration answers a distinct diagnostic question while applying the metrics in Section III-C:
• Configuration A (trusted-reference cohort). Only the canonical reference solution is probed. This isolates executability and acceptance of known-correct code; BDS is undefined and TQS = ES × CS.
• Configuration B (natural LLM solution cohort). The reference plus oracle-labeled solutions from LLM code generators run independently of test generation. This measures discrimination against naturally occurring wrong implementations; TQS = ES × CS × BDS when wrong probes exist. When , BDS, TQS, and CQ are n/a.
• Configuration C (synthetic mutant cohort). The reference plus oracle-verified mutants of the reference, retained only when the oracle confirms they are wrong (synthetic incorrect calibration in Fig. 2). This supplies calibrated negatives when Configuration B lacks wrong probes per task.
Stage 1 assertion patterns (Rainy Days challenge)
Task. Claude Opus 4.6 [11] generator; parity of forest runs on eight-qubit inputs. Only discriminating assertion bodies are shown.
Syntactic: valid structure and entry points
1 tree = ast.parse(sol) 2 assert "run" in funcs and "check" in funcs 3 exec(sol, ns) 4 assert callable(ns["run"]) and callable(ns["check"])
Semantic: correct outputs on official inputs
1 exec(sol, ns) 2 for inp, exp in TEST_CASES: 3 out = json.loads(ns["run"] (inp)) 4 assert np.allclose(out, json.loads(exp), atol=1e-4)
Behavioral: candidate harness check() (not the oracle)
1 exec(sol, ns) 2 for inp, exp in TEST_CASES: 3 out = ns["run"] (inp) 4 ns["check"] (out, exp) # solution-local helper, not Stage-2 oracle
Fig. 3: Core assertion patterns for the three generated test types (Table II), exemplified on the Rainy Days challenge.
E. Validation and Scoring (Stage 2)
Stage 2 applies Section III-D under the metrics in Section III-C (Algorithm 1). For each configuration the pipeline (i) assembles a solution cohort, (ii) labels non-baseline probes with the benchmark checker, (iii) executes generated tests with runtime candidate injection, and (iv) aggregates scores by test type, task, and test-generator model.
Every cohort includes a trusted baseline . On QHack, we select before oracle-based scoring: for each challenge, every human submission file is executed against the three Stage 1 test modules (syntactic, semantic, behavioral); we sum the pytest sub-tests each file passes and assign to the submission with the highest total (ties broken by file order). This chooses a human reference that is compatible with the generated suites; it does not define ground truth. Stage 2 then applies the benchmark's official checker to every probe, including , labeling each correct, wrong, or unknown (excluded from and ). For each probe, the framework injects candidate source into the pytest harness and records pass/fail outcomes. The trusted baseline is always executed first: infrastructure failure on the baseline (import error, timeout, or pytest crash) sets ES = 0 and zeros ES/CS for that suite (BDS/TQS remain when ).
F. Experimental Design
Task selection and models. We evaluate eight QHack challenges and ten Qiskit HumanEval tasks (0000–0003, 0019, 0020, 0024, 0034, 0035, 0063), fixed before generation as a stratified easy/intermediate/hard mix so that every model and configuration uses the same tasks. Five LLMs (Claude Opus 4.6 [11], DeepSeek V3.2 [9], Gemini 3 Pro [12], GPT-5.4 [10], Qwen3-Coder [13]) generate tests at temperature
Algorithm 1 Unit Test Execution Harness (score aggregation follows Section III-C).
Require: Generated test file F, candidate pool , trusted baseline
Ensure: Per-candidate run records
1:
2: Inject into harness namespace; run pytest on F with timeout
3: if run fails with infrastructure error then
4: Mark F as non-executable; set
5: return
6: end if
7: Set
8: for each candidate do
9: Write s to a temporary module; inject candidate source and entry point into the harness namespace
10: Execute pytest on F with timeout
11: Parse passed / failed / error counts from pytest output
12: Classify outcome: ACCEPT if all tests pass, REJECT otherwise
13:
14: end for
15: Aggregate by test type, task, and model
16: return
0.8 (one call per type; no repair). Configuration B uses their separately generated solutions as probes.
Prompts. A fixed system prompt and type-specific user prompts request self-contained pytest modules with at least three unit tests, runtime loading of the candidate (never the reference solution), and . Qiskit prompts also name the required entry point. Syntactic prompts request structure checks; semantic prompts request execution on official or specification-implied cases; behavioral prompts request end-to-end harness checks (QHack: run() / check(); Qiskit: entry-point call). Mentions of edge cases or fixed seeds in prompts are soft guidance for stochastic tasks, not hard scoring requirements, and are not enforced by the harness.
Mutants and sandbox. Configuration C applies deterministic mutations to the trusted reference and keeps only mutants the official checker labels wrong: return None; flip == to !=; remove measure_all(); replace the first CX or Hadamard with an X gate; perturb numeric literals ; and, on QHack only, force a local check() failure. Up to twelve candidates are tried; the first three wrong probes are kept. Probes run in isolated temporary directories with runtime candidate injection. On QHack, pytest limits are 180s per file and 60s per test, with 90s oracle labeling per candidate; on Qiskit HumanEval the corresponding limits are 240s, 120s, and 120s.
Table aggregation. Cells average bottom-up over suite types, then generators, then tasks (Tables IV–VII). When , BDS, TQS, and CQ are (never zero); model-level BDS/CQ use only tasks with . Qiskit Configuration B omits TQS because TQS requires BDS and three scoped tasks have (Case C, Fig. 4).
Table III walks through ledger-to-score aggregation for one Configuration B run; Section IV then reports benchmark means.
IV. RESULTS AND DISCUSSION
This section asks whether each suite runs and accepts correct code (A), catches bugs models actually make (B), and catches injected faults (C). Metrics follow Sections III-C and III-D.
TABLE III: Scoring ledger: Chalet Random Gate, Configuration B, Claude Opus 4.6 (test generator). Probe counts then CS, BDS, and TQS (avg. row over test types).
| Suite | ES | CS | BDS | TQS | ||
|---|---|---|---|---|---|---|
| Syntactic | 1 | 6/6 | 1.00 | 2/3 | 0.67 | 0.67 |
| Semantic | 1 | 6/6 | 1.00 | 3/3 | 1.00 | 1.00 |
| Behavioral | 1 | 6/6 | 1.00 | 3/3 | 1.00 | 1.00 |
| Avg. | - | - | 1.00 | - | 0.89 | 0.89 |
Legend: : oracle-labeled probe pass/tot and fail/tot counts; TQS = ES × CS × BDS. Row colors match Table II; TQS shading matches result tables.
Across both benchmarks, models write tests that run, but are better at accepting correct code than at rejecting incorrect code.
A. QHack Results
Table IV reports per-challenge means averaged over the five test generators; Table V aggregates the same run by model.
Tests run reliably, but acceptance already separates models. Under Configuration A, executability is at least 0.79 for every model and reaches 1.00 for Claude Opus 4.6, Gemini 3 Pro, and GPT-5.4, so runtime injection is reliable. Acceptance already spreads the field: Gemini 3 Pro accepts almost all correct code (CS = TQS = 0.96), ahead of Claude Opus 4.6 (0.88) and GPT-5.4 (0.83), whereas DeepSeek V3.2 (0.42) and Qwen3-Coder (0.37) write tests so strict that they reject much of the trusted reference before any bug is considered. The Coffee Conundrum row (CS = 0.47; Table I, Fig. 1) shows that high executability alone is insufficient when semantic checks disagree with the benchmark checker.
Bug detection, not acceptance, decides overall quality. Configurations B and C add oracle-wrong probes, so BDS contributes to TQS and reorders the ranking. Claude Opus 4.6 attains the highest test quality (TQS = 0.69 and 0.71) by pairing strong acceptance with the best bug detection (BDS = 0.80 and 0.83). Gemini 3 Pro keeps the highest acceptance (CS = 0.96) but detects fewer bugs (BDS = 0.67), so its Configuration A lead does not survive once rejection matters. Configurations B and C agree closely for every model, indicating that synthetic mutants reproduce the discrimination signal of naturally occurring wrong solutions on QHack.
High coverage does not imply good tests. Coffee embeds almost all checker inputs ( ) yet reaches only TQS = 0.13, so coverage without discrimination is not enough.
Table V aggregates the same run by test-generator model.
B. Qiskit HumanEval Results
Tables VI–VII report the fixed ten-task scope, organized around the same three questions.
The protocol transfers, but tasks vary widely. Under Configuration A, harness injection carries over unchanged (four models reach ES = 1.00; Qwen3-Coder averages 0.93), and Claude Opus 4.6 again leads on acceptance (CS = TQS = 0.77). What changes is the spread across tasks: the Bell-state simulator reaches TQS = 0.87 ( ) while GHZ-state construction collapses to TQS = 0.13 at comparable coverage ( ), because semantic suites sometimes echo checker literals without accepting the reference.
Realistic bugs are caught only moderately, and sometimes cannot be measured. Configuration B enriches the pool with LLM solutions (199 probes per run: 119 correct, 80 wrong). Bug detection is middling (BDS = 0.45–0.60): Qwen3-Coder rejects the most wrong code (0.60) while Claude Opus 4.6 accepts the most correct code (CS = 0.84), again the acceptance–rejection trade-off. Three of the ten tasks attract no wrong solutions and report n/a for BDS, TQS, and CQ, so the cohort, not the suite, is limiting (Case C). Because TQS is defined as ES × CS × BDS only when , Table VI omits the TQS column for Configuration B rather than reporting zeros.
Synthetic faults restore measurability but expose low ceilings. Configuration C injects verified mutants into every task, so BDS is always defined: Gemini 3 Pro then leads (TQS = 0.34), with Claude Opus 4.6 at 0.29. These ceilings sit well below QHack because many Qiskit checkers contain few extractable literals (Deutsch–Jozsa has ), pushing CQ toward zero even when acceptance is moderate.
Illustrative case studies: metrics in practice
Each panel reports probe verdicts (Test vs. benchmark Checker) and the resulting ES/CS/BDS/TQS scores under the stated configuration.
Case A: Too weak (missed bugs; Configuration B)
| Challenge Mach-Zehnder Cabin | Generator GPT-5.4 syntactic | ||
|---|---|---|
| Candidate probe | Test | Checker |
| Oracle-wrong LLM solution | Pass | Wrong |
| Human baseline | Pass | Correct |
| Metrics: ES=1 CS=1 BDS=0 TQS=0Note: ES × CS = 1 masks zero bug detection; BDS is required. | ||
Case B: Too strict (false reject; Configuration B)
| Challenge Contextuality Dunes | Generator DeepSeek V3.2 semantic | ||
|---|---|---|
| Candidate probe | Test | Checker |
| Human reference | Fail | Correct |
| Oracle-wrong LLM solutions | Fail | Wrong |
| Metrics: ES=1 CS=0 BDS=1 TQS=0Note: High BDS alone is insufficient when CS rejects trusted code. | ||
Case C: Cohort design (GHZ construction; Config. B vs. C)
| Generator Claude Opus 4.6 | same suites, different probe pools (Table VI). | |||||
|---|---|---|---|---|---|
| Config. | Wrong probes | ES | CS | BDS | TQS |
| B (LLM cohort) | 0 () | 0.93 | 0.80 | n/a | n/a |
| C (synthetic) | oracle-wrong mutants | 0.93 | 0.13 | 0.83 | 0.03 |
Note: With , BDS/TQS are n/a; Configuration C restores measurable rejection, but low CS caps TQS at 0.03.
Fig. 4: Three case studies on challenges other than the motivational example, connecting QTestBench metrics to concrete oracle vs. test outcomes.
C. Metric Case Studies
The aggregate tables show that discrimination is the bottleneck; Fig. 4 illustrates why on challenges other than Section I.
Case A: a perfect-looking suite can be worthless. On Mach-Zehnder Cabin, a GPT-5.4 [10] syntactic suite accepts every correct probe (ES = CS = 1) but also passes oracle-wrong
TABLE IV: QHack benchmark: mean per-challenge scores (averaged over five test generators). Configs A–C appear as column groups; see legend below for TQS/CQ shading.
| Challenge | Config A | Config B | Config C | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ES | CS | TQS | CQ | ES | CS | BDS | TQS | CQ | ES | CS | BDS | TQS | CQ | ||||
| QSP swamp | 0.93 | 0.73 | 0.73 | 0.50 | 0.47 | 0.93 | 0.73 | 0.73 | 0.53 | 0.50 | 0.47 | 0.93 | 0.73 | 0.73 | 0.53 | 0.50 | 0.47 |
| Chalet gate | 0.87 | 0.80 | 0.60 | 0.87 | 0.80 | 0.64 | 0.58 | 0.60 | 0.53 | 0.87 | 0.80 | 0.67 | 0.60 | 0.60 | 0.53 | ||
| Coffee | 1.00 | 0.47 | 0.47 | 0.97 | 0.45 | 1.00 | 0.47 | 0.67 | 0.13 | 0.97 | 0.13 | 1.00 | 0.47 | 0.67 | 0.13 | 0.97 | 0.13 |
| Contextuality | 0.93 | 0.80 | 0.47 | 0.93 | 0.80 | 0.60 | 0.47 | 0.47 | 0.40 | 0.93 | 0.80 | 0.60 | 0.47 | 0.47 | 0.40 | ||
| Mach-Zehnder | 0.93 | 0.80 | 0.53 | 0.93 | 0.80 | 0.60 | 0.47 | 0.53 | 0.47 | 0.93 | 0.80 | 0.60 | 0.47 | 0.53 | 0.47 | ||
| Rainy days | 1.00 | 0.40 | 0.40 | 0.50 | 0.31 | 1.00 | 0.44 | 0.93 | 0.37 | 0.50 | 0.40 | 1.00 | 0.40 | 0.93 | 0.33 | 0.50 | 0.31 |
| Eigentracks | 1.00 | 0.87 | 0.53 | 1.00 | 0.87 | 0.71 | 0.57 | 0.53 | 0.53 | 1.00 | 0.87 | 0.73 | 0.60 | 0.53 | 0.53 | ||
| Triple-H | 0.93 | 0.67 | 0.67 | 0.53 | 0.40 | 0.93 | 0.73 | 0.60 | 0.40 | 0.53 | 0.40 | 0.93 | 0.67 | 0.60 | 0.40 | 0.53 | 0.40 |
Legend: TQS and CQ cell shading (higher is better): ≥0.75; ≥0.50; ≥0.25; <0.25; n/a = BDS/TQS/CQ undefined (|| = 0).
TABLE V: QHack benchmark: mean scores per test-generator model (Configs A–C as column groups; best TQS per configuration in bold). Layout matches Table IV.
| Model | Config A | Config B | Config C | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ES | CS | TQS | CQ | ES | CS | BDS | TQS | CQ | ES | CS | BDS | TQS | CQ | ||||
| Claude Opus 4.6 | 1.00 | 0.88 | 0.88 | 0.69 | 0.57 | 1.00 | 0.88 | 0.80 | 0.69 | 1.00 | 0.88 | 0.83 | 0.69 | ||||
| DeepSeek V3.2 | 0.96 | 0.42 | 0.42 | 0.35 | 0.28 | 0.96 | 0.47 | 0.75 | 0.26 | 0.35 | 0.27 | 0.96 | 0.42 | 0.75 | 0.25 | 0.35 | 0.25 |
| Gemini 3 Pro | 1.00 | 0.96 | 0.71 | 1.00 | 0.96 | 0.67 | 0.63 | 0.71 | 0.63 | 1.00 | 0.96 | 0.67 | 0.63 | 0.71 | 0.63 | ||
| GPT-5.4 | 1.00 | 0.83 | 0.83 | 0.71 | 0.58 | 1.00 | 0.84 | 0.71 | 0.55 | 0.71 | 0.56 | 1.00 | 0.83 | 0.71 | 0.54 | 0.71 | 0.54 |
| Qwen3-Coder | 0.79 | 0.37 | 0.37 | 0.44 | 0.12 | 0.79 | 0.37 | 0.50 | 0.08 | 0.44 | 0.08 | 0.79 | 0.37 | 0.50 | 0.08 | 0.44 | 0.08 |
Legend: TQS and CQ cell shading (higher is better): ≥0.75; ≥0.50; ≥0.25; <0.25; n/a = BDS/TQS/CQ undefined (|| = 0).
TABLE VI: Qiskit HumanEval: mean per-task scores (ten-task scope; averaged over five test generators). Configuration A: ES, CS, TQS (TQS = ES × CS), , CQ. Configuration B: ES, CS, BDS (n/a if no oracle-wrong probes), , CQ. Configuration C: full metric set. Rows list short HumanEval task identifiers.
| Task | Config A | Config B | Config C | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ES | CS | TQS | CQ | ES | CS | BDS | CQ | ES | CS | BDS | TQS | CQ | ||||
| create_quantum_circuit | 1.00 | 0.73 | 0.73 | 0.00 | 0.00 | 1.00 | 0.70 | n/a | 0.00 | n/a | 1.00 | 0.73 | 1.00 | 0.73 | 0.00 | 0.00 |
| run_bell_state_simulator | 1.00 | 0.87 | 0.93 | 1.00 | 0.87 | 0.73 | 0.93 | 0.60 | 1.00 | 0.93 | 0.62 | 0.56 | 0.93 | 0.59 | ||
| create_bell_statevector | 1.00 | 0.73 | 0.73 | 0.93 | 0.71 | 1.00 | 0.73 | 0.73 | 0.93 | 0.47 | 1.00 | 0.73 | 0.00 | 0.00 | 0.93 | 0.00 |
| create_ghz | 0.93 | 0.13 | 0.13 | 0.78 | 0.11 | 0.93 | 0.80 | n/a | 0.78 | n/a | 0.93 | 0.13 | 0.83 | 0.03 | 0.78 | 0.04 |
| transpile_circuit_maxopt | 1.00 | 0.40 | 0.40 | 0.00 | 0.00 | 1.00 | 0.45 | n/a | 0.00 | n/a | 1.00 | 0.40 | 0.00 | 0.00 | 0.00 | 0.00 |
| transpile_ghz_customlayout | 1.00 | 0.27 | 0.27 | 0.00 | 0.00 | 1.00 | 0.27 | 0.87 | 0.00 | 0.00 | 1.00 | 0.27 | 0.00 | 0.00 | 0.00 | 0.00 |
| dj_algorithm | 1.00 | 0.47 | 0.47 | 0.00 | 0.00 | 1.00 | 0.79 | 0.88 | 0.00 | 0.00 | 1.00 | 0.47 | 0.77 | 0.23 | 0.00 | 0.00 |
| run_jobs_on_batch | 1.00 | 0.47 | 0.47 | 0.65 | 0.30 | 1.00 | 0.47 | 0.60 | 0.65 | 0.13 | 1.00 | 0.47 | 0.53 | 0.00 | 0.65 | 0.00 |
| run_circuit_with_dd_trex | 0.93 | 0.47 | 0.47 | 0.00 | 0.00 | 0.93 | 0.47 | 0.66 | 0.00 | 0.00 | 0.93 | 0.47 | 0.67 | 0.20 | 0.00 | 0.00 |
| bb84_circuit_generate_key | 1.00 | 0.53 | 0.53 | 0.00 | 0.00 | 1.00 | 0.51 | 0.70 | 0.00 | 0.00 | 1.00 | 0.53 | 0.70 | 0.23 | 0.00 | 0.00 |
Legend: TQS and CQ cell shading (higher is better): ≥0.75; ≥0.50; ≥0.25; <0.25; n/a = metric undefined (|| = 0); Config B has no TQS column because TQS requires BDS and three tasks have || = 0.
TABLE VII: Qiskit HumanEval: mean scores per test-generator model over the scoped ten-task runs. Same column layout as Table VI; best TQS per configuration in bold (Config A and Config C).
| Model | Config A | Config B | Config C | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ES | CS | TQS | CQ | ES | CS | BDS | CQ | ES | CS | BDS | TQS | CQ | ||||
| Claude Opus 4.6 | 1.00 | 0.77 | 0.36 | 1.00 | 0.84 | 0.65 | 0.36 | 0.27 | 1.00 | 0.77 | 0.46 | 0.29 | 0.36 | 0.07 | ||
| DeepSeek V3.2 | 1.00 | 0.30 | 0.30 | 0.37 | 0.13 | 1.00 | 0.42 | 0.73 | 0.37 | 0.07 | 1.00 | 0.33 | 0.52 | 0.06 | 0.37 | 0.03 |
| Gemini 3 Pro | 1.00 | 0.70 | 0.70 | 0.33 | 0.24 | 1.00 | 0.82 | 0.75 | 0.33 | 0.19 | 1.00 | 0.70 | 0.54 | 0.33 | ||
| GPT-5.4 | 1.00 | 0.47 | 0.47 | 0.33 | 0.16 | 1.00 | 0.57 | 0.72 | 0.33 | 0.14 | 1.00 | 0.47 | 0.48 | 0.14 | 0.33 | 0.05 |
| Qwen3-Coder | 0.93 | 0.30 | 0.30 | 0.26 | 0.16 | 0.93 | 0.37 | 0.85 | 0.26 | 0.18 | 0.93 | 0.30 | 0.56 | 0.16 | 0.26 | 0.08 |
Legend: TQS and CQ cell shading (higher is better): ≥0.75; ≥0.50; ≥0.25; <0.25; n/a = metric undefined (|| = 0); Config B has no TQS column because TQS requires BDS and three tasks have || = 0.
solutions never run on official inputs (BDS = 0), so TQS collapses to zero.
Case B: the opposite failure is just as damaging. On Contextuality Dunes, a DeepSeek V3.2 [9] suite rejects even the correct human reference (BDS = 1, CS = 0, TQS = 0). Cases A and B are mirror images, so acceptance and rejection must be reported separately.
Case C: sometimes the cohort, not the suite, sets the score. On create_ghz, the same Claude Opus 4.6 suites give BDS/TQS n/a under Configuration B ( ) but BDS = 0.83 under Configuration C; low CS (0.13) caps TQS at 0.03, which is why Qiskit Configuration B omits a pooled TQS column.
D. Cross-Framework Synthesis
The same metric definitions transfer across PennyLane and Qiskit without changing the protocol. Executability rarely limits (ES ≥ 0.93 for most pairs), while CS and BDS separate generators. Claude Opus 4.6 and Gemini 3 Pro lead on QHack (TQS = 0.71 and 0.63 under Configuration C); Qiskit peaks lower (0.34, Gemini), reflecting sparser wrong probes and fewer extractable checker literals. Absolute TQS depends on probe composition, so BDS should be read with probe counts and as n/a when .
On QHack, Configurations B and C agree closely, so synthetic mutants reproduce the natural cohort signal. On Qiskit, Configuration B leaves three tasks with (no pooled TQS), and Configuration C restores defined BDS with only moderate TQS. High alone is insufficient: Coffee reaches with TQS = 0.13, the same too-weak pattern illustrated by Case A on Mach-Zehnder Cabin (high acceptance without bug detection). Even under Configuration C, single-pass generation remains limited; refinement with execution feedback [7] is a natural next step. Limitations. The evaluation is limited to a fixed temperature of 0.8, a single generation pass without repair, ten selected Qiskit tasks, and benchmark-specific checker oracles.
V. CONCLUSION
We introduce QTestBench, a framework for evaluating LLM-generated quantum test suites against independent benchmark oracles. It unifies PennyLane QHack and Qiskit HumanEval through a two-stage pipeline (single-pass generation of syntactic, semantic, and behavioral pytest modules, followed by validation under three cohort configurations) and reports executability, correctness acceptance, bug-detection rejection, test quality, checker-input coverage, and composite quality with consistent definitions across SDKs.
Experiments with Claude Opus 4.6, DeepSeek V3.2, Gemini 3 Pro, GPT-5.4, and Qwen3-Coder show that runnable quantum tests are achievable (ES ≈ 1.00 on QHack for four models), but discrimination remains the primary bottleneck: leading generators reach only moderate bug detection (Claude Opus 4.6, TQS = 0.71 on QHack), and Qiskit scores are lower and more task-heterogeneous. By scoring tests against benchmark oracles, QTestBench addresses a dimension of quantum LLM evaluation not covered by solution-centric benchmarks.
ACKNOWLEDGMENT
This work was supported in part by the NYUAD Center for Quantum and Topological Systems (CQTS), funded by Tamkeen under the NYUAD Research Institute grant CG008, and the Center for Cyber Security (CCS), funded by Tamkeen under the NYUAD Research Institute Award G1104.
CODE AVAILABILITY
The source code and experiment configurations are available at https://github.com/eBrain4Everyone/QTestBench.
REFERENCES
[1] M. Chen et al., “Evaluating large language models trained on code,” arXiv preprint arXiv:2107.03374, 2021.
[2] J. Austin et al., “Program synthesis with large language models,” arXiv preprint arXiv:2108.07732, 2021.
[3] J. Wang et al., “Software testing with large language models: Survey, landscape, and vision,” IEEE Transactions on Software Engineering, vol. 50, no. 4, pp. 911–936, 2024.
[4] A. Miranskyy and L. Zhang, “On testing quantum programs,” in IEEE/ACM 41st International Conference on Software Engineering: New Ideas and Emerging Results (ICSE-NIER), 2019, pp. 57–60.
[5] A. García de la Barrera et al., “Quantum software testing: State of the art,” Journal of Software: Evolution and Process, vol. 35, no. 4, p. e2419, 2023.
[6] S. Vishwakarma et al., “Qiskit humaneval: An evaluation benchmark for quantum code generative models,” arXiv preprint arXiv:2406.14712, 2024.
[7] A. Basit et al., “Qhackbench: Benchmarking large language models for quantum code generation using pennylane hackathon challenges,” in IEEE International Conference on Quantum Artificial Intelligence (QAI), 2025.
[8] X. Guo, M. Wang, and J. Zhao, “Quanbench: Benchmarking quantum code generation with large language models,” arXiv preprint arXiv:2510.16779, 2025.
[9] DeepSeek-AI, “Deepseek-v3.2: A strong mixture-of-experts language model,” https://github.com/deepseek-ai/DeepSeek-V3, 2025, accessed June 2026.
[10] OpenAI, "Gpt-5.4," https://openai.com/, 2026, accessed June 2026.
[11] Anthropic, “Claude opus 4.6,” https://www.anthropic.com/claude/opus, 2026, accessed June 2026.
[12] Google DeepMind, “Gemini 3 pro,” https://deepmind.google/models/gemini/pro/, 2026, accessed June 2026.
[13] Alibaba Cloud, “Qwen3-coder: Agentic coding in the world,” https://github.com/QwenLM/Qwen3-Coder, 2025, accessed June 2026.
[14] R. Li et al., “Starcoder: May the source be with you!” arXiv preprint arXiv:2305.06161, 2023.
[15] S. Ren et al., “Codebleu: A method for automatic evaluation of code synthesis,” arXiv preprint arXiv:2009.10297, 2020.
[16] Y. Dong et al., “Codescore: Evaluating code generation by learning code execution,” ACM Transactions on Software Engineering and Methodology, 2025.
[17] S. Yang and Y. Yang, “Formaleval: A method for automatic evaluation of code generation via large language models,” in 2024 International Symposium on Electronic Design Automation (ISEDA), 2024, pp. 1–6.
[18] D. G. Paul, H. Zhu, and I. Bayley, “Benchmarks and metrics for evaluations of code generation: A critical review,” arXiv preprint arXiv:2406.12655, 2024.
[19] N. Dupuis et al., “Qiskit code assistant: Training llms for generating quantum computing code,” arXiv preprint arXiv:2405.19495, 2024.
[20] V. Bergholm et al., “Pennylane: Automatic differentiation of hybrid quantum-classical computations,” arXiv preprint arXiv:1811.04968, 2018.
[21] A. Basit et al., “A pennylane-centric dataset to enhance llm-based quantum code generation using rag,” arXiv preprint arXiv:2503.02497, 2025.
[22] —, “Pennycoder: Efficient domain-specific llms for pennylane-based quantum code generation,” in 2025 IEEE International Conference on Quantum Computing and Engineering (QCE), vol. 2. IEEE, 2025, pp. 229–234.
[23] M. Shao et al., “Pennysynth: Rag-driven data synthesis for automated quantum code generation,” arXiv preprint arXiv:2605.25572, 2026.
[24] T. Mikuriya et al., “Qcoder benchmark: Bridging language generation and quantum hardware through simulator-based feedback,” in Proceedings of the 18th International Natural Language Generation Conference (INLG), 2025, pp. 43–55, arXiv:2510.26101.
[25] C. Campbell et al., “Enhancing llm-based quantum code generation with multi-agent optimization and quantum error correction,” arXiv preprint arXiv:2506.20008, 2025.
[26] A. Sabra, O. Schmitt, and J. Tyler, “Assessing the quality and security of ai-generated code: A quantitative analysis,” arXiv preprint arXiv:2410.02069, 2024.
[27] E. L. Melin et al., “Precision or peril: Evaluating code quality from quantized large language models,” arXiv preprint arXiv:2408.01703, 2024.
[28] E. T. Barr et al., “The oracle problem in software testing: A survey,” IEEE Transactions on Software Engineering, vol. 41, no. 5, pp. 507–525, 2015.
[29] Y. Jia and M. Harman, “An analysis and survey of the development of mutation testing,” IEEE Transactions on Software Engineering, vol. 37, no. 5, pp. 649–678, 2011.