Skip to content

Instantly share code, notes, and snippets.

@mtjrider
mtjrider / cusv_batched_apply_matrix.py
Last active September 24, 2023 04:30
Select and apply gate matrices to a batch of states using cuSV and PyTorch
import typing
import numpy as np
import cupy as cp
import torch
from cuquantum import custatevec as cusv
from cuquantum import cudaDataType, ComputeType
nSVs = 1
@mtjrider
mtjrider / cusv_initialize_state.py
Created August 23, 2023 04:45
Pipelining custatevec state vector initialization with streams
import torch
import numpy as np
import cuquantum
from cuquantum import custatevec as cusv
num_qubits = 24
device = "cuda:0"
dtype = torch.complex64
cusv_state_dtype = cuquantum.cudaDataType.CUDA_C_32F
@mtjrider
mtjrider / nsight.sh
Created February 10, 2023 03:35 — forked from mcarilli/nsight.sh
Favorite nsight systems profiling commands for Pytorch scripts
# This isn't supposed to run as a bash script, i named it with ".sh" for syntax highlighting.
# https://developer.nvidia.com/nsight-systems
# https://docs.nvidia.com/nsight-systems/profiling/index.html
# My preferred nsys (command line executable used to create profiles) commands
#
# In your script, write
# torch.cuda.nvtx.range_push("region name")
# ...