CUDA-Q

Also known as: CUDA Quantum

On this page 7

CUDA-Q is an open-source platform from NVIDIA for writing hybrid quantum-classical programs in Python and C++, in which quantum kernels run on GPU-accelerated simulators or on real quantum processors while the surrounding classical code runs on CPUs and GPUs. Formerly called CUDA Quantum, it belongs to the quantum software layer that sits between algorithms and hardware.

Its central idea is that quantum processors will work as accelerators inside classical supercomputers, much as GPUs do today. CUDA-Q therefore treats a quantum device as one more target in a single heterogeneous programming model, and it emphasizes compilation performance and multi-GPU simulation at scale more than most other quantum SDKs.

How CUDA-Q programs are structured

A CUDA-Q program separates quantum kernels from ordinary host code. In Python, a kernel is a function marked with the @cudaq.kernel decorator; in C++, it is a function or lambda annotated with __qpu__. Inside a kernel, the developer allocates qubits, applies gates, uses classical control flow and measures, and the host code calls the kernel through library functions.

The three most used entry points are cudaq.sample, which returns measurement counts over many shots, cudaq.observe, which computes the expectation value of a spin operator, and cudaq.get_state, which returns the simulated state vector. Kernels can take parameters, so a classical optimizer can update angles in a loop without rebuilding the program.

The table below summarizes the main language constructs and what each one does.

ConstructPurposeTypical use
KernelDefines quantum code to run on a targetAnsatz circuits, state preparation
`cudaq.sample`Executes a kernel and collects bitstringsSampling algorithms, QAOA readout
`cudaq.observe`Computes expectation values of operatorsVariational energy estimation
Spin operatorRepresents a Hamiltonian as Pauli termsChemistry and optimization problems
`cudaq.set_target`Selects the simulator or hardware backendSwitching from simulation to a QPU
Core CUDA-Q programming constructs

Compilation toolchain and intermediate representations

CUDA-Q is built on MLIR, the multi-level compiler infrastructure from the LLVM project. Kernels are lowered into a quantum dialect called Quake, which represents qubits and gates as values that compiler passes can optimize, and then into further dialects that perform decomposition, inlining and gate-set mapping.

For execution, the toolchain can emit QIR, the Quantum Intermediate Representation, or OpenQASM for providers that accept it. C++ programs are compiled ahead of time by the `nvq++` compiler, while Python kernels are compiled just in time. This compiled approach reduces the overhead of rebuilding circuits in tight variational loops, which is a known bottleneck in interpreted SDKs.

Because the compiler sees the whole kernel, it can apply gate cancellation, loop unrolling and decomposition into a native gate set before a job leaves the host. The same representation also supports mid-circuit measurement with classical branching, which matters for error correction experiments and dynamic circuits. Developers can inspect the generated Quake or QIR output to verify what will actually run on a target, which helps when debugging unexpected hardware results.

Simulation and hardware targets

A target in CUDA-Q is the backend that executes kernels, and switching targets usually requires only one line. GPU targets use NVIDIA libraries such as cuStateVec for state vectors and cuTensorNet for tensor networks, which is where the platform gains its speed advantage.

The following table lists representative simulation targets and the workloads they suit.

TargetMethodBest suited for
`nvidia`GPU statevector simulationExact circuits up to roughly 30 qubits per GPU
`nvidia` multi-GPU optionStatevector distributed across GPUsLarger exact simulations on clusters
`nvidia` multi-QPU optionParallel virtual QPUs on several GPUsBatched circuits and parameter sweeps
`tensornet`Tensor network contractionMany qubits with limited entanglement
`density-matrix-cpu`Density matrix with noise channelsSmall noisy simulations
Representative CUDA-Q simulation targets

Hardware access runs through provider targets for vendors of trapped-ion, superconducting and neutral-atom processors, and through cloud services such as Amazon Braket. The same kernel source can be sampled on a simulator and then on a QPU, although results differ because of hardware noise and native gate constraints.

How CUDA-Q compares with other quantum SDKs

CUDA-Q is one of several quantum SDKs, and its differences lie mainly in compilation model, language support and simulation focus. Qiskit and Cirq dominate circuit-level research, while PennyLane specializes in differentiable programming.

SDKLanguagesDistinctive strength
CUDA-QPython and C++Compiled kernels and multi-GPU simulation
QiskitPythonBroad ecosystem and IBM hardware access
CirqPythonFine control over Google-style devices
PennyLanePythonAutomatic differentiation for variational models
Q#Q# with Python hostResource estimation and typed quantum language
CUDA-Q compared with other quantum SDKs

These tools are not mutually exclusive. PennyLane and Qiskit can use NVIDIA GPU libraries through their own simulators, and some teams prototype in Qiskit and port performance-critical loops to CUDA-Q. The choice often depends on whether the bottleneck is algorithm design or simulation throughput.

Strengths, limitations and common pitfalls

CUDA-Q is strongest in large-scale simulation and HPC integration, including MPI-based distribution and coupling with classical GPU workloads such as machine learning. Its weaknesses mostly concern ecosystem breadth and the restrictions that compilation places on kernel code.

  • Kernel language restrictions: Python kernels support only a subset of Python, so arbitrary libraries cannot be called inside a kernel.
  • GPU dependence for speed: CPU targets exist, but the main performance advantage requires NVIDIA GPUs.
  • Memory limits of exact simulation: statevector memory doubles with each added qubit, so a 40-qubit exact simulation needs terabytes across many GPUs.
  • Assuming simulator results transfer: noiseless simulation overstates hardware quality, so noise models should be added before conclusions are drawn.

In plain words

CUDA-Q is a toolkit for writing quantum programs that work hand in hand with ordinary computers. A developer writes the quantum part and the normal part in the same file, in Python or C++.

The same program can run on a powerful graphics card that imitates a quantum computer or on a real quantum machine. This lets researchers test ideas quickly on fast simulators and then try them on actual hardware with very few changes.

A real-world example

A computational chemistry group wants to estimate the ground-state energy of a small molecule with the variational quantum eigensolver. The team writes a parameterized ansatz as a CUDA-Q kernel, expresses the molecular Hamiltonian as a spin operator, and uses cudaq.observe inside a classical optimizer loop.

On a single data-center GPU, the nvidia target evaluates each 24-qubit energy estimate in a fraction of a second, so thousands of optimizer iterations finish within hours rather than days on a CPU simulator. Using the multi-QPU option, the group then evaluates gradient terms in parallel across four GPUs.

Once the method converges in simulation, the team switches the target to a trapped-ion provider and runs a reduced 8-qubit version. The hardware energies deviate because of noise, but the workflow moves to real hardware with one changed line, which makes comparison between simulation and experiment straightforward.