Python objects & constants



See custatevecPauli_t.


See custatevecMatrixLayout_t.


See custatevecMatrixType_t.


See custatevecCollapseOp_t.


See custatevecSamplerOutput_t.


See custatevecDeviceNetworkType_t.

Python functions

Library Management

Handle Management API


Initialize the cuStateVec library and create a handle.

destroy(intptr_t handle)

Destroy the cuStateVec library handle.

get_default_workspace_size(intptr_t handle)

Get the default workspace size defined by cuStateVec.

set_workspace(intptr_t handle, ...)

Set the workspace to be used by cuStateVec.

CUDA Stream Management API

set_stream(intptr_t handle, intptr_t stream)

Set the stream to be used by cuStateVec.

get_stream(intptr_t handle)

Get the stream used by cuStateVec.

Logger API

logger_set_callback_data(callback, *args, ...)

Set the logger callback along with arguments.


Set the filename for the logger to write to.

logger_set_level(int level)

Set the logging level.

logger_set_mask(int mask)

Set the logging mask.


Disable the logger.

Memory Management API

set_device_mem_handler(intptr_t handle, handler)

Set the device memory handler for cuTensorNet.

get_device_mem_handler(intptr_t handle)

Get the device memory handler for cuTensorNet.

Versioning API

get_property(int lib_prop_type)

Get the version information of cuStateVec.


Get the version of cuStateVec.

Gate Application

General Matrices


Computes the required workspace size for apply_matrix().

apply_matrix(intptr_t handle, intptr_t sv, ...)

Apply the specified gate matrix.

Pauli Matrices

apply_pauli_rotation(intptr_t handle, ...)

Apply the exponential of a multi-qubit Pauli operator.

Generalized Permutation Matrices


Computes the required workspace size for apply_generalized_permutation_matrix().


Apply a generalized permutation matrix.


Measurement on Z-bases

abs2sum_on_z_basis(intptr_t handle, ...)

Calculates the sum of squared absolute values on a given Z product basis.

collapse_on_z_basis(intptr_t handle, ...)

Collapse the statevector on the given Z product basis.

measure_on_z_basis(intptr_t handle, ...)

Performs measurement on the given Z-product basis.

Batched Single Qubit Measurement

abs2sum_array(intptr_t handle, intptr_t sv, ...)

Calculates the sum of squared absolute values for a given set of index bits.

collapse_by_bitstring(intptr_t handle, ...)

Collapse the statevector to the state specified by the given bit string.

batch_measure(intptr_t handle, intptr_t sv, ...)

Performs measurement of arbitrary number of single qubits.

batch_measure_with_offset(intptr_t handle, ...)

Performs measurement (on a partial statevector) of arbitrary number of single qubits.


Expectation via a Matrix


Computes the required workspace size for compute_expectation().

compute_expectation(intptr_t handle, ...)

Compute the expectation value of the given matrix with respect to the statevector.

Expectation on Pauli Basis


Compute expectation values for multiple multi-qubit Pauli strings.


sampler_create(intptr_t handle, intptr_t sv, ...)

Create a sampler descriptor.

sampler_destroy(intptr_t sampler)

Destroy the sampler descriptor.

sampler_preprocess(intptr_t handle, ...)

Preprocess the statevector to prepare for sampling.

sampler_sample(intptr_t handle, ...)

Sample bit strings from the statevector.

sampler_get_squared_norm(intptr_t handle, ...)

Get the squared norm of the statevetor.

sampler_apply_sub_sv_offset(intptr_t handle, ...)

Apply the partial norm and norm to the statevector.


accessor_create(intptr_t handle, ...)

Create accessor to copy elements between the statevector and external buffers.

accessor_create_view(intptr_t handle, ...)

Create accessor to copy elements from the statevector to external buffers.

accessor_destroy(intptr_t accessor)

Destroy the accessor descriptor.


Set the external workspace to the accessor.

accessor_get(intptr_t handle, ...)

Copy elements from the statevector to an external buffer.

accessor_set(intptr_t handle, ...)

Copy elements from an external buffer to the statevector.

Qubit reordering

swap_index_bits(intptr_t handle, ...)

Swap index bits and reorder statevector elements on the device.

multi_device_swap_index_bits(handles, ...)

Swap index bits and reorder statevector elements on multiple devices.

Test gate matrix type


Computes the required workspace size for test_matrix_type().

test_matrix_type(intptr_t handle, ...)

Test the deviation of a given matrix from a certain matrix type (Hermitian or unitary).