Manuscript Offprint

arXiv:2610.13811

QTestBench: A Test Framework for Evaluating LLM-Generated Quantum Code

Meriem Terki, Nouhaila Innan, Minghao Shao, Muhammad Kashif, Alberto Marchisio, Muhammad Shafique

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Meriem Terki1^{1}, Nouhaila Innan2,3^{2,3}, Minghao Shao2^{2}, Muhammad Kashif2,3^{2,3}, Alberto Marchisio2,3,4∗^{2,3,4*}, Muhammad Shafique2,3^{2,3}

1^{1} École Supérieure en Informatique de Sidi Bel Abbès, Algeria

2^{2}eBRAIN Lab, Division of Engineering, New York University Abu Dhabi (NYUAD), Abu Dhabi, UAE

3^{3}Center for Quantum and Topological Systems (CQTS), NYUAD Research Institute, NYUAD, Abu Dhabi, UAE

4^{4}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).

ModeTest checksProbe scenarioTestChecker
Too weakDeepSeekV3.2 [9]syntacticEntry-point checks only; no execution on official inputOracle-wrong LLM outputPassWrong
Too strictGPT-5.4 [10]semanticNumerical tolerance at 10−410^{-4}Human reference outputFailCorrect

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].

References (28)