arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2610.13811cs.LGcs.CLquant-ph
收藏

QTestBench:用于评估大语言模型生成量子代码的测试框架

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

École Supérieure en Informatique de Sidi Bel Abbès(西迪贝勒阿巴斯高等计算机学院);New York University Abu Dhabi (NYUAD)(纽约大学阿布扎比分校);NYUAD Research Institute(纽约大学阿布扎比分校研究院);University of Southern Denmark(南丹麦大学)

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

AI总结:

QTestBench是评估LLM生成量子测试可信度的可复现跨框架基准,通过在QHack、Qiskit任务上测试5个LLM,发现其测试可执行性高但区分能力不足,合成突变体可稳定故障检测估计。

摘要:

大语言模型(LLM)在经典代码生成方面已展现出强大性能,且越来越多地被用于编写保障代码质量的单元测试。然而它们能否在量子软件领域做到同样的事尚不明确,因为量子程序具有概率性、依赖数值容差,且需通过领域专用检查器判定,因此格式合规的测试仍可能与基准的判定结果不一致。现有量子基准仅衡量模型是否生成了正确的解决方案,却未评估其测试能否区分正确实现与故障实现。我们提出QTestBench,这一框架会基于独立基准检查器评估LLM生成的量子测试套件,绝不将测试本身视为真值。针对每个任务,QTestBench会提示模型生成语法、语义和行为测试,在运行时注入候选解决方案,并在三个验证队列中对比每个测试的判定结果与检查器的标签,每个队列对应一个不同的诊断问题。我们在8个PennyLane QHack挑战任务和10个Qiskit HumanEval任务上对5个LLM进行了基准测试。生成的测试套件几乎总能执行,但区分能力滞后:表现最佳的生成器在QHack上达到0.71的测试质量,在Qiskit HumanEval上达到0.34,因此仅可执行性会高估测试质量。当自然故障解决方案稀缺时,经预言机验证的合成突变体可稳定故障检测估计值,如10个Qiskit任务中有3个未产生自然故障解决方案的情况。QTestBench为评估LLM生成量子测试的可信度提供了一个可复现、跨框架的基准。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑