微调还是提示词更好?一项面向 Qiskit 到 CUDA-Q 代码翻译的执行验证研究
When Does Fine-Tuning Beat Prompting for Qiskit-to-CUDA-Q Translation? An Execution-Verified Study
做量子计算迁移的工程师值得看看这篇:它不用 LLM 打分,而是直接跑代码比对状态向量,结论很实在——Qwen2.5-Coder 7B 上微调明显赢过提示词,Nemotron 3 Nano 4B 上却打平还伤旧能力,另外所有模型在真实 QED-C kernel 上全军覆没,说明这条自动化路还早。
arXiv 论文(arXiv:2611.29793)研究了语言模型能否自动把 Qiskit 量子代码翻译成 NVIDIA CUDA-Q,并给出了一套以执行结果为准的评测方法:只有当生成的 kernel 状态向量与 Qiskit 参考实现的保真度 ≥ 0.999 才算正确,完全不用文本匹配或 LLM 当裁判。
作者构建了 640 个任务的基准,包含三个测试集(更大电路、未见过的电路家族、未见过的 Qiskit 编码风格)和一个 QuantumKatas 回归探针。实测发现:没有一个基础模型能零样本产出合法 CUDA-Q kernel;规则转换器靠执行输入并映射电路就能解决全部 640 题,说明该基准衡量的是源码级翻译能力。
微调收益取决于基础模型:在 Nemotron 3 Nano 4B 上 LoRA 达到 83.9%,与 4-shot 提示词(83.1%)打平,但未见风格泛化更差(48.5% 对 65.5%),且把 QuantumKatas 成绩从 23.8% 拉低到 8.9%;在 Qwen2.5-Coder 7B 上 LoRA 整体胜出(92.0% 对 82.8%)。真实程序仍是短板:27 个真实 QED-C kernel 上所有模型都是 0%。
When Does Fine-Tuning Beat Prompting for Qiskit-to-CUDA-Q Translation? An Execution-Verified Study
Moving quantum code from Qiskit to NVIDIA CUDA-Q is a practical adoption cost that language models are starting to automate. We ask whether a small open model can learn this translation, and how to measure it so that the result can be trusted. Both programs can be executed and their state vectors compared, so a kernel counts as correct only if it prepares the same state as the Qiskit reference (fidelity >= 0.999), with no text matching and no LLM judge. We build a 640-task benchmark with three test sets (larger circuits, an unseen circuit family, an unseen Qiskit coding style) and a QuantumKatas regression probe, and we test the evaluator before training. Measurement counts miss every phase-only error; a surface rule-based translator solves two of three original splits (text substitution); a converter that executes the Qiskit input and maps the circuit solves all 640 tasks -- so the benchmark measures source-level translation, not whether a circuit can be ported after running it. No base model emits a valid CUDA-Q kernel zero-shot. On Nemotron 3 Nano 4B, LoRA reaches 83.9%, tying a 4-shot prompt (83.1%), but generalizes worse to unseen style (48.5% vs. 65.5%) and cuts QuantumKatas from 23.8% to 8.9%; on Qwen2.5-Coder 7B, LoRA beats the prompt overall (92.0% vs. 82.8%) and on unseen style (78.5% vs. 65.0%), and on the 1.5B model as well, so whether fine-tuning pays off depends on the base model, while the Qiskit regression appears in all three. Mixing two replay formats is the best mitigation trade-off (84.4% translation, Katas 21.5%). On 48 parametric functions that must become kernels with arguments -- where executing the input cannot yield a parametric kernel -- models reach up to 83%; on 27 real QED-C kernels, every model scores 0%. Language models can do source-level translation of simple parametric code, but not yet of real programs.
This report is categorized under AITOP's "Papers" desk, focusing on US frontier AI labs and Silicon Valley technology leaders. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows. Key entities and technical topics under continuous tracking include CUDA-Q, Qiskit, Qwen2.5-Coder, Nemotron.
Source attribution: curated from arXiv cs.AI (@Ana Paula Appel). Cross-source corroboration: 7 independent sources have covered this development (including rohanpaul_ai, Lxfater, Decoder), confirming industry-wide signal strength.