QTestBench: A Test Framework for Evaluating LLM-Generated Quantum Code
cs.LG, cs.CL, quant-ph
Submitted: 2026-10-09
Updated: 2026-10-09
Comments: Accepted at the 2026 IEEE 2nd International Conference on Quantum Artificial Intelligence (QAI), 2026
Code: https://github.com/eBrain4Everyone/QTestBench
License: http://creativecommons.org/licenses/by/4.0/
The gist: 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.
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.
Sources
- Evaluating Large Language Models Trained on Code
- Program Synthesis with Large Language Models
- Qiskit HumanEval: An Evaluation Benchmark For Quantum Code Generative Models
- QuanBench: Benchmarking Quantum Code Generation with Large Language Models
- StarCoder: may the source be with you!
- CodeBLEU: a Method for Automatic Evaluation of Code Synthesis
- Benchmarks and Metrics for Evaluations of Code Generation: A Critical Review
- Qiskit Code Assistant: Training LLMs for generating Quantum Computing Code
- PennyLane: Automatic differentiation of hybrid quantum-classical computations
- A PennyLane-Centric Dataset to Enhance LLM-based Quantum Code Generation using RAG
- PennySynth: RAG-Driven Data Synthesis for Automated Quantum Code Generation
- QCoder Benchmark: Bridging Language Generation and Quantum Hardware through Simulator-Based Feedback
- QHackBench: Benchmarking Large Language Models for Quantum Code Generation Using PennyLane Hackathon Challenges
- Semi-Supervised Fine-Tuning of Vision Foundation Models with Content-Style Decomposition
- WaitGPT: Monitoring and Steering Conversational LLM Agent in Data Analysis with On-the-Fly Code Visualization
Related papers
- Polynomial-Augmented Neural Networks (PANNs) with Weak Orthogonality Constraints for Enhanced Function and PDE Approximation
- AIRL-S: Unifying Reinforcement Learning and Search-Based Test-Time Scaling via Adversarial Inverse Reinforcement Learning
- Transformers as Bayesian In-Context Experimenters: Smoothness-Adaptive Efficient ATE Estimation
- Convergence issues in Relational Concept Analysis based on AOC-posets
- Beliefs Beyond Posteriors: The Predictive Cost of ELBO Binding
- Understanding Diffusion Models via Ratio-Based Function Approximation with SignReLU Networks