portc

GPU execution

Run the sweep on NVIDIA or AMD GPUs through CuPy.

portc runs on CPU (NumPy) by default and can be accelerated on GPUs through CuPy. Both NVIDIA (CUDA) and AMD (ROCm) GPUs are supported through optional extras:

uv pip install "portc[gpu-nvidia]"   # CUDA 13.x, driver >= 580
uv pip install "portc[gpu-rocm]"     # ROCm

On data-center GPUs behind an older driver, as on many clusters, NVIDIA's forward-compatibility package runs CUDA 13 without root: unpack cuda-compat-13-x and put its compat/ folder first on LD_LIBRARY_PATH. The Leonardo page does this on driver 535.

When adding portc to another project's pyproject.toml:

dependencies = ["portc[gpu-nvidia]"]

At runtime, pass device="gpu":

result = apply(H, psi, chi_out=256, device="gpu")

The inputs can be NumPy or CuPy arrays; they are moved to the device for the sweep, and the result always comes back as NumPy arrays on the host. Without CuPy installed, device="gpu" raises an ImportError.

To split one sweep among several GPUs of a node, pass resources=Resources(devices=n); see Large problems.