Metadata-Version: 2.4
Name: qrisp-cudaq
Version: 0.1.0
Summary: CUDA-Q backend for Eclipse Qrisp
Author: The Qrisp authors
License: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
Project-URL: Homepage, https://github.com/eclipse-qrisp/qrisp-cudaq
Project-URL: Bug Tracker, https://github.com/eclipse-qrisp/qrisp-cudaq/issues
Project-URL: Documentation, https://www.qrisp.eu
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Eclipse Public License 2.0 (EPL-2.0)
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Scientific/Engineering :: Quantum Computing
Classifier: Topic :: Software Development :: Compilers
Requires-Python: <3.14,>=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: qrisp[xdsl]>=0.9.10
Requires-Dist: cudaq>=0.16.0
Provides-Extra: dev-code-style
Requires-Dist: ruff==0.16.5; extra == "dev-code-style"
Provides-Extra: dev-testing
Requires-Dist: pytest==9.1.1; extra == "dev-testing"
Requires-Dist: pytest-timeout==2.4.0; extra == "dev-testing"
Provides-Extra: dev
Requires-Dist: qrisp-cudaq[dev-code-style,dev-testing]; extra == "dev"
Dynamic: license-file

# qrisp-cudaq

CUDA-Q backend for [Eclipse Qrisp](https://github.com/eclipse-qrisp/Qrisp). It compiles
Qrisp programs to the Quake MLIR dialect of [CUDA-Q](https://nvidia.github.io/cuda-quantum/)
and runs them as native CUDA-Q kernels.

## Installation

```bash
pip install qrisp[cudaq]
```

This installs Qrisp together with `qrisp-cudaq`. CUDA-Q supports Linux (x86_64 and
aarch64) and macOS on Apple silicon (CPU simulation only), with Python 3.11 or later.
Windows is not supported.

## Simulation targets

CUDA-Q is built for GPU-accelerated simulation and for quantum hardware. On a
machine with an NVIDIA GPU, CUDA-Q uses its
[GPU state-vector simulator](https://nvidia.github.io/cuda-quantum/latest/using/backends/sims/svsims.html#cuquantum-single-gpu)
by default. The [CUDA-Q backends](https://nvidia.github.io/cuda-quantum/latest/using/backends/backends.html)
page lists all simulators and
[hardware backends](https://nvidia.github.io/cuda-quantum/latest/using/backends/hardware.html).

Without an NVIDIA GPU, for example on macOS, CUDA-Q falls back to its CPU simulator
[`qpp-cpu`](https://nvidia.github.io/cuda-quantum/latest/using/backends/sims/svsims.html#qpp-cpu-backend),
which the CUDA-Q documentation describes as good "for basic testing and
experimentation with just a few qubits". Expect it to become slow from around 20
qubits, in particular with `cudaq.run`, which simulates the kernel again for every
shot.

If a kernel does not use any measurement result inside the kernel,
`@cudaq_kernel(execution_mode="sample")` together with `cudaq.sample` simulates it
once and returns the counts of the measured bitstrings for all shots. Kernels that
use measurement results inside the kernel need the default `execution_mode="run"`.
This includes much of Qrisp's arithmetic, which uncomputes auxiliary qubits with
mid-circuit measurements.

## Example

```python
import cudaq
from qrisp import QuantumFloat, h, measure
from qrisp_cudaq import cudaq_kernel


@cudaq_kernel
def main(k: int):
    a = QuantumFloat(3)
    h(a)  # a is in superposition of 0, 1, ..., 7
    b = QuantumFloat(4)
    b[:] = k
    b += a  # adds all eight values of a to k at once
    return measure(a), measure(b)


print(cudaq.run(main, 5, shots_count=5))
# [(1.0, 6.0), (3.0, 8.0), (0.0, 5.0), (4.0, 9.0), (1.0, 6.0)]
```

## Documentation

The CUDA-Q tutorial and API reference are part of the Qrisp documentation at
[qrisp.eu](https://www.qrisp.eu).

## License

[EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0](LICENSE)
