OpenMP-Q: Quantum Task Offloading in OpenMP
摘要
Quantum accelerators hold promise for applications including combinatorial optimization, chemistry simulation, and hybrid ML workloads, etc. To program such applications, most quantum SDKs (e.g., Qiskit, Cirq) expose only Python APIs. This leaves C/C++ codes—many already orchestrating heterogeneous CPU/GPU work with frameworks such as OpenMP—without a clean path to invoke quantum kernels or iterate on their results. This work contributes OpenMP-Q and aims to raise a discussion for inclusion in the OpenMP standard. OpenMP-Q is an extension to the OpenMP 5.x target model that treats a quantum processor as a first-class device and enables bi-directional communication between C++ and Python. OpenMP-Q adds (i) a quantum device type, (ii) a mechanism that bridges OpenMP’s offload API to the Python quantum stack via POSIX pipes, and (iii) an extended offloading framework that communicates variables via map clauses to a Python script, executes the quantum task, and reinserts the results into the same mapped variables. The pipe mechanism also supports reverse-offload-style workflows, e.g., variational algorithms where C++ supplies initial rotation angles, the quantum backend returns qubit statistics, and the host refines those angles for subsequent iterations, without breaking OpenMP’s asynchronous execution model or requiring extra device kernels. Moreover, by combining standard OpenMP parallel regions with per-thread quantum offload, OpenMP-Q scales natively across multiple QPUs, dispatching independent circuit evaluations in parallel.