Skip to content

CUDA-Q

The in-app starter (Bell state — runnable as-is):

import cudaq
# Create a Bell State
@cudaq.kernel
def bell():
q = cudaq.qvector(2)
h(q[0])
cx(q[0], q[1])
mz(q)
StageBehavior
DiscoveryThe namespace is scanned newest-first for @cudaq.kernel-decorated callables (with a looser type-name fallback).
Kernel argumentsPositional parameters are resolved by name from the namespace (a kernel def sweep(theta: float) picks up a global theta), falling back to defaults. A kernel with an unresolvable required parameter is skipped — if no other kernel matches, execute returns no_circuit.
SnapshotBest-effort text parsing of str(kernel) — the kernel’s printed representation is scanned line-by-line for gate calls with literal qubit indices. On any failure it degrades to an empty snapshot (0 qubits, no gates) rather than erroring.
LayeringGreedy, like Qiskit/Q#. classical_bit_count counts parsed mz lines.

Gate coverage (string-parser keys → canonical): h x y z s t rx ry rz → themselves; cx/cnotCNOT, czCZ, swapSWAP, ccxToffoli, mzMeasure. Rotations keep their first float argument as the angle.

  1. Countscudaq.sample(kernel, *args, shots_count=shots) fills measurements.
  2. Probabilities are sampled frequencies (count / total), not exact amplitudes — even when the statevector is available.
  3. Statevector + Bloch are best-effortcudaq.get_state(kernel, *args) with partial-trace Bloch coordinates; any failure silently leaves state_vector and bloch_coords empty.

In-editor simulation runs on whatever target CUDA-Q selects by default — CPU (qpp-cpu) on machines without a CUDA GPU. GPU-accelerated runs go through the NVIDIA provider in the hardware panel, which exposes the nvidia, nvidia-fp64, nvidia-mgpu, and qpp-cpu targets as submission backends and needs no credentials — see the hardware overview.

  • The circuit diagram is a best-effort reconstruction. Gates addressed with runtime indices (loops, computed indices, qvector slices) don’t parse out of the kernel’s string form — the simulation is still correct, but the diagram may be empty or partial. Qiskit/Cirq/Q# extraction is exact; CUDA-Q’s is not.
  • Kernel-argument capture is name-based. Rename the global without renaming the kernel parameter and discovery silently skips that kernel.
  • No exact probabilities. Expect shot noise in the histogram even for deterministic circuits; raise shots to tighten it.
  • Heaviest install (~500 MB, see the catalog), and not available in the web build.