cuPauliProp functions#
Library Initialization and Management API#
cupaulipropGetVersion#
-
size_t cupaulipropGetVersion()#
Returns the semantic version number of the cuPauliProp library.
cupaulipropGetErrorString#
-
const char *cupaulipropGetErrorString(cupaulipropStatus_t error)#
Returns the description string for an error code.
Remark
non-blocking, no reentrant, and thread-safe.
- Parameters:
error – [in] Error code to get the description string for.
- Returns:
the error description string.
cupaulipropGetNumPackedIntegers#
- cupaulipropStatus_t cupaulipropGetNumPackedIntegers(
- int32_t numQubits,
- int32_t *numPackedIntegers
Returns the number of packed integers of cupaulipropPackedIntegerType_t needed to represent the X bits (or equivalently, the Z bits) of a single Pauli string.
Each Pauli string is represented by storing X bits and Z bits separately in packed integers. This function returns the number of packed integers needed for ONE set of bits (either X or Z). The total storage for a complete Pauli string is twice this value (one set for X bits, one set for Z bits). For example, for 64 qubits, this returns 1, and the total storage is 2 uint64 integers (1 for X bits + 1 for Z bits). For 65 qubits, this returns 2, and the total storage is 4 uint64 integers (2 for X bits + 2 for Z bits). Note that the integers are required to be zero padded for the most significant bits if the number of qubits is not a multiple of 64.
- Parameters:
numQubits – [in] Number of qubits.
numPackedIntegers – [out] Number of uint64 integers needed to store X bits (or Z bits) for one Pauli string. To get the total storage requirement, multiply this value by 2.
- Returns:
cupaulipropStatus_t
cupaulipropCreate#
-
cupaulipropStatus_t cupaulipropCreate(cupaulipropHandle_t *handle)#
Creates and initializes the library context.
- Parameters:
handle – [out] Library handle.
- Returns:
cupaulipropStatus_t
cupaulipropDestroy#
-
cupaulipropStatus_t cupaulipropDestroy(cupaulipropHandle_t handle)#
Destroys the library context.
- Parameters:
handle – [in] Library handle.
- Returns:
cupaulipropStatus_t
cupaulipropSetStream#
- cupaulipropStatus_t cupaulipropSetStream(
- cupaulipropHandle_t handle,
- cudaStream_t stream
Sets the CUDA stream to be used for library operations.
- Parameters:
handle – [in] Library handle.
stream – [in] CUDA stream to be used for library operations.
- Returns:
cupaulipropStatus_t
Workspace Management API#
cupaulipropCreateWorkspaceDescriptor#
- cupaulipropStatus_t cupaulipropCreateWorkspaceDescriptor(
- cupaulipropHandle_t handle,
- cupaulipropWorkspaceDescriptor_t *workspaceDesc
Creates a workspace descriptor.
- Parameters:
handle – [in] Library handle.
workspaceDesc – [out] Workspace descriptor.
- Returns:
cupaulipropStatus_t
cupaulipropDestroyWorkspaceDescriptor#
- cupaulipropStatus_t cupaulipropDestroyWorkspaceDescriptor(
- cupaulipropWorkspaceDescriptor_t workspaceDesc
Destroys a workspace descriptor.
- Parameters:
workspaceDesc – [inout] Workspace descriptor.
- Returns:
cupaulipropStatus_t
cupaulipropWorkspaceGetMemorySize#
- cupaulipropStatus_t cupaulipropWorkspaceGetMemorySize(
- const cupaulipropHandle_t handle,
- const cupaulipropWorkspaceDescriptor_t workspaceDesc,
- cupaulipropMemspace_t memSpace,
- cupaulipropWorkspaceKind_t workspaceKind,
- int64_t *memoryBufferSize
Queries the required workspace buffer size.
- Parameters:
handle – [in] Library handle.
workspaceDesc – [in] Workspace descriptor.
memSpace – [in] Memory space.
workspaceKind – [in] Workspace kind.
memoryBufferSize – [out] Required workspace buffer size in bytes.
- Returns:
cupaulipropStatus_t
cupaulipropWorkspaceSetMemory#
- cupaulipropStatus_t cupaulipropWorkspaceSetMemory(
- const cupaulipropHandle_t handle,
- cupaulipropWorkspaceDescriptor_t workspaceDesc,
- cupaulipropMemspace_t memSpace,
- cupaulipropWorkspaceKind_t workspaceKind,
- void *memoryBuffer,
- int64_t memoryBufferSize
Attaches memory to a workspace buffer.
- Parameters:
handle – [in] Library handle.
workspaceDesc – [inout] Workspace descriptor.
memSpace – [in] Memory space.
workspaceKind – [in] Workspace kind.
memoryBuffer – [in] Pointer to a user-owned memory buffer to be used by the specified workspace.
memoryBufferSize – [in] Size of the provided memory buffer in bytes.
- Returns:
cupaulipropStatus_t
cupaulipropWorkspaceGetMemory#
- cupaulipropStatus_t cupaulipropWorkspaceGetMemory(
- const cupaulipropHandle_t handle,
- const cupaulipropWorkspaceDescriptor_t workspaceDescr,
- cupaulipropMemspace_t memSpace,
- cupaulipropWorkspaceKind_t workspaceKind,
- void **memoryBuffer,
- int64_t *memoryBufferSize
Retrieves a workspace buffer.
- Parameters:
handle – [in] Library handle.
workspaceDescr – [in] Workspace descriptor.
memSpace – [in] Memory space.
workspaceKind – [in] Workspace kind.
memoryBuffer – [out] Pointer to a user-owned memory buffer used by the specified workspace.
memoryBufferSize – [out] Size of the memory buffer in bytes.
- Returns:
cupaulipropStatus_t
Pauli Expansion API#
Pauli Expansion Creation and Management#
cupaulipropCreatePauliExpansion#
- cupaulipropStatus_t cupaulipropCreatePauliExpansion(
- const cupaulipropHandle_t handle,
- int32_t numQubits,
- void *xzBitsBuffer,
- int64_t xzBitsBufferSize,
- void *coefBuffer,
- int64_t coefBufferSize,
- cudaDataType_t dataType,
- int64_t numTerms,
- int32_t isSorted,
- int32_t hasDuplicates,
- cupaulipropPauliExpansion_t *pauliExpansion
Creates a Pauli operator expansion.
Note
The
xzBitsBufferandcoefBuffermust both be either GPU-accessible memory or CPU-accessible memory. Mixing memory types between these two buffers is not supported.- Parameters:
handle – [in] Library handle.
numQubits – [in] Number of qubits.
xzBitsBuffer – [in] Pointer to a user-owned memory buffer to be used by the created Pauli operator expansion for storing the X and Z bits for each Pauli operator term. The first
numTermsPauli operator terms will define the current Pauli operator expansion.xzBitsBufferSize – [in] Size (in bytes) of the provided memory buffer for storing the X and Z bits.
coefBuffer – [in] Pointer to a user-owned memory buffer to be used by the created Pauli operator expansion for storing the coefficients for all Pauli operator terms. The first
numTermsPauli operator terms will define the current Pauli operator expansion.coefBufferSize – [in] Size (in bytes) of the provided memory buffer for storing the coefficients.
dataType – [in] Data type of the coefficients in the Pauli operator expansion.
numTerms – [in] Number of the Pauli operator terms stored in the provided memory buffer (the first
numTermscomponents define the current Pauli operator expansion).isSorted – [in] Whether or not the Pauli expansion is sorted. A sorted expansion has its Pauli operator terms sorted by the X and Z bits in ascending order (interpreted as big integers in little-endian representation).
hasDuplicates – [in] Whether or not there are duplicates in the expansion, i.e. several terms with identical X and Z bits.
pauliExpansion – [out] Pauli operator expansion.
- Returns:
cupaulipropStatus_t
cupaulipropDestroyPauliExpansion#
- cupaulipropStatus_t cupaulipropDestroyPauliExpansion(
- cupaulipropPauliExpansion_t pauliExpansion
Destroys a Pauli operator expansion.
- Parameters:
pauliExpansion – [inout] Pauli operator expansion.
- Returns:
cupaulipropStatus_t
Pauli Expansion Storage and Properties#
cupaulipropPauliExpansionGetStorageBuffer#
- cupaulipropStatus_t cupaulipropPauliExpansionGetStorageBuffer(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansion_t pauliExpansion,
- void **xzBitsBuffer,
- int64_t *xzBitsBufferSize,
- void **coefBuffer,
- int64_t *coefBufferSize,
- int64_t *numTerms,
- cupaulipropMemspace_t *location
Gets access to the storage of a Pauli operator expansion.
- Parameters:
handle – [in] Library handle.
pauliExpansion – [in] Pauli operator expansion.
xzBitsBuffer – [out] Pointer to a user-owned memory buffer used by the Pauli operator expansion for storing the X and Z bits for each Pauli operator term.
xzBitsBufferSize – [out] Size (in bytes) of the memory buffer for X and Z bits.
coefBuffer – [out] Pointer to a user-owned memory buffer used by the Pauli operator expansion for storing the coefficients for each Pauli operator term.
coefBufferSize – [out] Size (in bytes) of the memory buffer for storing the coefficients.
numTerms – [out] Current number of Pauli operator terms in the Pauli operator expansion (first
numTermsterms define the current Pauli operator expansion).location – [out] Storage location of the Pauli operator expansion (whether it is on the host or device).
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionGetNumQubits#
- cupaulipropStatus_t cupaulipropPauliExpansionGetNumQubits(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansion_t pauliExpansion,
- int32_t *numQubits
Gets the number of qubits of a Pauli operator expansion.
- Parameters:
handle – [in] Library handle.
pauliExpansion – [in] Pauli operator expansion.
numQubits – [out] Number of qubits.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionGetNumTerms#
- cupaulipropStatus_t cupaulipropPauliExpansionGetNumTerms(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansion_t pauliExpansion,
- int64_t *numTerms
Gets the number of terms in the Pauli operator expansion.
- Parameters:
handle – [in] Library handle.
pauliExpansion – [in] Pauli operator expansion.
numTerms – [out] Number of terms.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionGetDataType#
- cupaulipropStatus_t cupaulipropPauliExpansionGetDataType(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansion_t pauliExpansion,
- cudaDataType_t *dataType
Gets the data type of the coefficients in a Pauli operator expansion.
- Parameters:
handle – [in] Library handle.
pauliExpansion – [in] Pauli operator expansion.
dataType – [out] Data type.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionIsSorted#
- cupaulipropStatus_t cupaulipropPauliExpansionIsSorted(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansion_t pauliExpansion,
- int32_t *isSorted
Queries whether a Pauli operator expansion is sorted or not.
- Parameters:
handle – [in] Library handle.
pauliExpansion – [in] Pauli operator expansion.
isSorted – [out] Indicating whether the Pauli operator expansion is sorted. Sortedness is defined as the Pauli strings being sorted in ascending order according to the little-endian representation of the big integers formed by the X and Z bits. True (!= 0) if the Pauli operator expansion is sorted, false (0) otherwise.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionIsDeduplicated#
- cupaulipropStatus_t cupaulipropPauliExpansionIsDeduplicated(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansion_t pauliExpansion,
- int32_t *isDeduplicated
Queries whether a Pauli operator expansion is deduplicated. i.e. guaranteed to not contain duplicate Pauli strings or may otherwise potentially contain duplicates Pauli strings.
- Parameters:
handle – [in] Library handle.
pauliExpansion – [in] Pauli operator expansion.
isDeduplicated – [out] Indicating whether the Pauli operator expansion is deduplicated. True (!= 0) if the Pauli operator expansion is guaranteed to not contain duplicate Pauli strings, false (0) if no such guarantee can be made (though it may be incidentally the case).
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionGetTerm#
- cupaulipropStatus_t cupaulipropPauliExpansionGetTerm(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansion_t pauliExpansion,
- int64_t termIndex,
- cupaulipropPauliTerm_t *term
Gets access to a specific term of a Pauli operator expansion.
- Parameters:
handle – [in] Library handle.
pauliExpansion – [in] Pauli operator expansion.
termIndex – [in] Index of the term.
term – [out] Pauli operator term.
- Returns:
cupaulipropStatus_t
Pauli Expansion Views#
cupaulipropPauliExpansionGetContiguousRange#
- cupaulipropStatus_t cupaulipropPauliExpansionGetContiguousRange(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansion_t pauliExpansion,
- int64_t startIndex,
- int64_t endIndex,
- cupaulipropPauliExpansionView_t *view
Creates a non-owning view of a contiguous range of Pauli operator terms inside a Pauli operator expansion.
- Parameters:
handle – [in] Library handle.
pauliExpansion – [in] Pauli operator expansion.
startIndex – [in] Start index of the range (inclusive, first element in the range).
endIndex – [in] End index of the range (exclusive, one past the last element).
view – [out] View to a range of Pauli terms inside the Pauli operator expansion.
- Returns:
cupaulipropStatus_t
cupaulipropDestroyPauliExpansionView#
- cupaulipropStatus_t cupaulipropDestroyPauliExpansionView( )#
Destroys a Pauli expansion view.
- Parameters:
view – [inout] Pauli expansion view.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionViewGetNumTerms#
- cupaulipropStatus_t cupaulipropPauliExpansionViewGetNumTerms(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t view,
- int64_t *numTerms
Returns the number of Pauli terms in a Pauli expansion view.
- Parameters:
handle – [in] Library handle.
view – [in] Pauli expansion view.
numTerms – [out] Number of terms.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionViewGetLocation#
- cupaulipropStatus_t cupaulipropPauliExpansionViewGetLocation(
- const cupaulipropPauliExpansionView_t view,
- cupaulipropMemspace_t *location
Gets the storage location of a Pauli expansion view (whether its elements are stored on the host or device).
- Parameters:
view – [in] Pauli expansion view.
location – [out] Location.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionViewGetTerm#
- cupaulipropStatus_t cupaulipropPauliExpansionViewGetTerm(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t view,
- int64_t termIndex,
- cupaulipropPauliTerm_t *term
Gets a specific term of a Pauli expansion view.
- Parameters:
handle – [in] Library handle.
view – [in] Pauli expansion view.
termIndex – [in] Index of the term in the Pauli expansion view.
term – [out] Pauli operator term.
- Returns:
cupaulipropStatus_t
Deduplication Operations#
cupaulipropPauliExpansionViewPrepareDeduplication#
- cupaulipropStatus_t cupaulipropPauliExpansionViewPrepareDeduplication(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t viewIn,
- int32_t makeSorted,
- int64_t maxWorkspaceSize,
- cupaulipropWorkspaceDescriptor_t workspace
Prepares a Pauli expansion view for deduplication.
This function queries the workspace requirements for deduplicating a Pauli expansion view (removing duplicate Pauli strings and summing their coefficients).
- Parameters:
handle – [in] Library handle.
viewIn – [in] Pauli expansion view to be deduplicated.
makeSorted – [in] Whether or not the output expansion is required to be sorted.
maxWorkspaceSize – [in] Maximum workspace size limit in bytes.
workspace – [out] Workspace descriptor with the required workspace buffer size.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionViewExecuteDeduplication#
- cupaulipropStatus_t cupaulipropPauliExpansionViewExecuteDeduplication(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t viewIn,
- cupaulipropPauliExpansion_t expansionOut,
- int32_t makeSorted,
- cupaulipropWorkspaceDescriptor_t workspace
Deduplicates a Pauli expansion view.
This function removes duplicate Pauli strings from a sorted Pauli expansion view and sums their coefficients, populating the output expansion with the deduplicated view.
Note
This method is blocking, i.e. it will wait for the operation to complete before returning to the caller.
Note
The storage location of both the input view and the output expansion must be GPU-accessible (i.e.
CUPAULIPROP_MEMSPACE_DEVICE).- Parameters:
handle – [in] Library handle.
viewIn – [in] Pauli expansion view to be deduplicated.
expansionOut – [out] Pauli expansion to be populated with the deduplicated view.
makeSorted – [in] Whether or not the output expansion is required to be sorted.
workspace – [in] Allocated workspace descriptor.
- Returns:
cupaulipropStatus_t
Sorting Operations#
cupaulipropPauliExpansionViewPrepareCanonicalSort#
- cupaulipropStatus_t cupaulipropPauliExpansionViewPrepareCanonicalSort(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t viewIn,
- int64_t maxWorkspaceSize,
- cupaulipropWorkspaceDescriptor_t workspace
Prepares a Pauli expansion view for canonical sorting.
This function queries the workspace requirements for canonically sorting a Pauli expansion view (by Pauli strings viewed as big integers in little-endian order).
- Parameters:
handle – [in] Library handle.
viewIn – [in] Pauli expansion view to be sorted.
maxWorkspaceSize – [in] Maximum workspace size limit in bytes.
workspace – [out] Workspace descriptor with the required workspace buffer size.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionViewExecuteCanonicalSort#
- cupaulipropStatus_t cupaulipropPauliExpansionViewExecuteCanonicalSort(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t viewIn,
- cupaulipropPauliExpansion_t expansionOut,
- cupaulipropWorkspaceDescriptor_t workspace
Sorts a Pauli expansion view canonically.
This function sorts a Pauli expansion view by Pauli strings (viewed as big integers in little-endian order), writing the result to the output expansion.
Note
This function is non-blocking if a stream is set on the library handle (via
cupaulipropSetStream), i.e. it will return immediately and the sorting will be performed asynchronously on the stream.Note
The storage location of both the input view and the output expansion must be GPU-accessible (i.e.
CUPAULIPROP_MEMSPACE_DEVICE).- Parameters:
handle – [in] Library handle.
viewIn – [in] Pauli expansion view to be sorted.
expansionOut – [out] Pauli expansion to be populated with the sorted view.
workspace – [in] Allocated workspace descriptor.
- Returns:
cupaulipropStatus_t
Population Operations#
cupaulipropPauliExpansionPopulateFromView#
- cupaulipropStatus_t cupaulipropPauliExpansionPopulateFromView(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t viewIn,
- cupaulipropPauliExpansion_t expansionOut
Populates a Pauli operator expansion from a Pauli expansion view.
Note
This function is non-blocking if a stream is set on the library handle (via
cupaulipropSetStream), i.e. it will return immediately and the population will be performed asynchronously on the stream.Note
The Pauli expansion view must not belong to the same Pauli operator expansion.
- Parameters:
handle – [in] Library handle.
viewIn – [in] Input Pauli expansion view.
expansionOut – [out] Populated Pauli operator expansion.
- Returns:
cupaulipropStatus_t
Trace Operations#
cupaulipropPauliExpansionViewPrepareTraceWithExpansionView#
- cupaulipropStatus_t cupaulipropPauliExpansionViewPrepareTraceWithExpansionView(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t view1,
- const cupaulipropPauliExpansionView_t view2,
- int64_t maxWorkspaceSize,
- cupaulipropWorkspaceDescriptor_t workspace
Prepares a Pauli expansion view for computing the product trace of two Pauli expansion views.
- Parameters:
handle – [in] Library handle.
view1 – [in] First Pauli expansion view to be traced.
view2 – [in] Second Pauli expansion view to be traced.
maxWorkspaceSize – [in] Maximum workspace size limit in bytes.
workspace – [out] Workspace descriptor with the required workspace buffer size.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionViewComputeTraceWithExpansionView#
- cupaulipropStatus_t cupaulipropPauliExpansionViewComputeTraceWithExpansionView(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t view1,
- const cupaulipropPauliExpansionView_t view2,
- int32_t takeAdjoint1,
- void *trace,
- cupaulipropWorkspaceDescriptor_t workspace
Computes the trace of two Pauli expansion views.
This function computes the trace
tr(view1 view2)of the composition (i.e. product) of two Pauli expansion views. Optionally, the adjoint of the first viewview1can be taken when computing the trace. Currently, both input views must not contain duplicates.Note
This function is non-blocking if a stream is set on the library handle (via
cupaulipropSetStream), i.e. it will return immediately and the tracing will be performed asynchronously on the stream.Note
The storage location of both input views must be GPU-accessible (i.e.
CUPAULIPROP_MEMSPACE_DEVICE).- Parameters:
handle – [in] Library handle.
view1 – [in] First Pauli expansion view.
view2 – [in] Second Pauli expansion view.
takeAdjoint1 – [in] Whether or not the adjoint of the first view is taken. True
(!= 0)if the adjoint is taken, false(0)otherwise.trace – [out] Pointer to CPU-accessible memory where the trace value will be written. The numerical type must match the data type of the views’ coefficients.
workspace – [in] Allocated workspace descriptor.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionViewPrepareTraceWithZeroState#
- cupaulipropStatus_t cupaulipropPauliExpansionViewPrepareTraceWithZeroState(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t view,
- int64_t maxWorkspaceSize,
- cupaulipropWorkspaceDescriptor_t workspace
Prepares a Pauli expansion view for tracing with the zero state, i.e. computing
Tr(view * |0...0⟩).- Parameters:
handle – [in] Library handle.
view – [in] Pauli expansion view to be traced.
maxWorkspaceSize – [in] Maximum workspace size limit in bytes.
workspace – [out] Workspace descriptor with the required workspace buffer size.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionViewComputeTraceWithZeroState#
- cupaulipropStatus_t cupaulipropPauliExpansionViewComputeTraceWithZeroState(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t view,
- void *trace,
- cupaulipropWorkspaceDescriptor_t workspace
Traces a Pauli expansion view with the zero state, i.e. computes
Tr(view * |0...0⟩).Note
This function is non-blocking if a stream is set on the library handle (via
cupaulipropSetStream), i.e. it will return immediately and the tracing will be performed asynchronously on the stream.Note
The storage location of the input view must be GPU-accessible (i.e.
CUPAULIPROP_MEMSPACE_DEVICE).- Parameters:
handle – [in] Library handle.
view – [in] Pauli expansion view to be traced.
trace – [out] Pointer to CPU-accessible memory where the trace value will be written. The numerical type must match the data type of the views’ coefficients.
workspace – [in] Allocated workspace descriptor.
- Returns:
cupaulipropStatus_t
Operator Application#
cupaulipropPauliExpansionViewPrepareOperatorApplication#
- cupaulipropStatus_t cupaulipropPauliExpansionViewPrepareOperatorApplication(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t viewIn,
- const cupaulipropQuantumOperator_t quantumOperator,
- int32_t makeSorted,
- int32_t keepDuplicates,
- int32_t numTruncationStrategies,
- const cupaulipropTruncationStrategy_t truncationStrategies[],
- int64_t maxWorkspaceSize,
- int64_t *requiredXZBitsBufferSize,
- int64_t *requiredCoefBufferSize,
- cupaulipropWorkspaceDescriptor_t workspace
Prepares a Pauli expansion view for quantum operator application.
- Parameters:
handle – [in] Library handle.
viewIn – [in] Pauli expansion view to apply a quantum operator to.
quantumOperator – [in] Quantum operator to be applied.
makeSorted – [in] Whether or not the output expansion is required to be sorted.
keepDuplicates – [in] Whether or not the output expansion is allowed to contain duplicates.
numTruncationStrategies – [in] Number of Pauli expansion truncation strategies.
truncationStrategies – [in] Pauli expansion truncation strategies.
maxWorkspaceSize – [in] Maximum workspace size limit in bytes.
requiredXZBitsBufferSize – [out] Required size (in bytes) of the X and Z bits output buffer.
requiredCoefBufferSize – [out] Required size (in bytes) of the coefficients output buffer.
workspace – [in] Workspace descriptor with the required workspace buffer size.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionViewComputeOperatorApplication#
- cupaulipropStatus_t cupaulipropPauliExpansionViewComputeOperatorApplication(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t viewIn,
- cupaulipropPauliExpansion_t expansionOut,
- const cupaulipropQuantumOperator_t quantumOperator,
- int32_t adjoint,
- int32_t makeSorted,
- int32_t keepDuplicates,
- int32_t numTruncationStrategies,
- const cupaulipropTruncationStrategy_t truncationStrategies[],
- cupaulipropWorkspaceDescriptor_t workspace
Computes the application of a quantum operator to a Pauli expansion view.
This function computes the application of a quantum operator to a Pauli expansion view. Optionally, the adjoint of the quantum operator can be applied when computing the application. Optionally, truncations can be applied to the output expansion to reduce the number of terms.
Note
This function is blocking on exit, i.e. it will wait for the operation to complete before returning to the caller.
Note
The storage location of the input view and the output expansion must be GPU-accessible (i.e.
CUPAULIPROP_MEMSPACE_DEVICE).- Parameters:
handle – [in] Library handle.
viewIn – [in] Pauli expansion view to apply a quantum operator to.
expansionOut – [inout] Pauli expansion to be overwritten with the result. The output expansion will satisfy sortedness and uniqueness respectively if these flags have been set to true when creating or resetting the output expansion. Otherwise they may or may not be satisfied. Their state is queryable on the output expansion after this function call via
cupaulipropPauliExpansionGetSortedness()andcupaulipropPauliExpansionGetUniqueness().quantumOperator – [in] Quantum operator to be applied.
adjoint – [in] Whether or not the adjoint of the quantum operator is applied. True (!= 0) if the adjoint is applied, false (0) otherwise.
makeSorted – [in] Whether or not the output expansion is required to be sorted.
keepDuplicates – [in] Whether or not the output expansion is allowed to contain duplicates.
numTruncationStrategies – [in] Number of Pauli expansion truncation strategies.
truncationStrategies – [in] Pauli expansion truncation strategies.
workspace – [in] Allocated workspace descriptor.
- Returns:
cupaulipropStatus_t
Truncation Operations#
cupaulipropPauliExpansionViewPrepareTruncation#
- cupaulipropStatus_t cupaulipropPauliExpansionViewPrepareTruncation(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t viewIn,
- int32_t numTruncationStrategies,
- const cupaulipropTruncationStrategy_t truncationStrategies[],
- int64_t maxWorkspaceSize,
- cupaulipropWorkspaceDescriptor_t workspace
Prepares a Pauli expansion view for truncation.
This function queries the workspace requirements for truncating a Pauli expansion view based on the given truncation strategies.
- Parameters:
handle – [in] Library handle.
viewIn – [in] Pauli expansion view to be truncated.
numTruncationStrategies – [in] Number of Pauli expansion truncation strategies.
truncationStrategies – [in] Pauli expansion truncation strategies.
maxWorkspaceSize – [in] Maximum workspace size limit in bytes.
workspace – [out] Workspace descriptor with the required workspace buffer size.
- Returns:
cupaulipropStatus_t
cupaulipropPauliExpansionViewExecuteTruncation#
- cupaulipropStatus_t cupaulipropPauliExpansionViewExecuteTruncation(
- const cupaulipropHandle_t handle,
- const cupaulipropPauliExpansionView_t viewIn,
- cupaulipropPauliExpansion_t expansionOut,
- int32_t numTruncationStrategies,
- const cupaulipropTruncationStrategy_t truncationStrategies[],
- cupaulipropWorkspaceDescriptor_t workspace
Truncates a Pauli expansion view.
This function applies truncation strategies to a Pauli expansion view, removing terms that do not satisfy the truncation criteria, and writes the result to the output expansion.
Note
This function is blocking on exit, i.e. it will wait for the operation to complete before returning to the caller.
Note
The storage location of the input view and the output expansion must be GPU-accessible (i.e.
CUPAULIPROP_MEMSPACE_DEVICE).- Parameters:
handle – [in] Library handle.
viewIn – [in] Input Pauli expansion view to be truncated.
expansionOut – [inout] Output Pauli operator expansion.
numTruncationStrategies – [in] Number of Pauli expansion truncation strategies.
truncationStrategies – [in] Pauli expansion truncation strategies.
workspace – [in] Allocated workspace descriptor.
- Returns:
cupaulipropStatus_t
Quantum Operators#
Clifford Gates#
cupaulipropCreateCliffordGateOperator#
- cupaulipropStatus_t cupaulipropCreateCliffordGateOperator(
- const cupaulipropHandle_t handle,
- cupaulipropCliffordGateKind_t cliffordGateKind,
- const int32_t qubitIndices[],
- cupaulipropQuantumOperator_t *oper
Creates a Clifford gate.
- Parameters:
handle – [in] Library handle.
cliffordGateKind – [in] Clifford gate kind.
qubitIndices – [in] Qubit indices.
oper – [out] Quantum operator associated with the Clifford gate.
- Returns:
cupaulipropStatus_t
Pauli Rotation Gates#
cupaulipropCreatePauliRotationGateOperator#
- cupaulipropStatus_t cupaulipropCreatePauliRotationGateOperator(
- const cupaulipropHandle_t handle,
- double angle,
- int32_t numQubits,
- const int32_t qubitIndices[],
- const cupaulipropPauliKind_t paulis[],
- cupaulipropQuantumOperator_t *oper
Creates a Pauli rotation gate,
exp(-i * angle/2 * P), for a rotation ofanglearound the Pauli stringP.- Parameters:
handle – [in] Library handle.
angle – [in] Rotation angle in radians.
numQubits – [in] Number of qubits.
qubitIndices – [in] Qubit indices. If NULL, the qubit indices are assumed to be [0, 1, 2, …, numQubits-1].
paulis – [in] Pauli operators for each qubit index.
oper – [out] Quantum operator associated with the Pauli rotation gate.
- Returns:
cupaulipropStatus_t
Pauli Noise Channels#
cupaulipropCreatePauliNoiseChannelOperator#
- cupaulipropStatus_t cupaulipropCreatePauliNoiseChannelOperator(
- const cupaulipropHandle_t handle,
- int32_t numQubits,
- const int32_t qubitIndices[],
- const double probabilities[],
- cupaulipropQuantumOperator_t *oper
Creates a Pauli noise channel.
- Parameters:
handle – [in] Library handle.
numQubits – [in] Number of qubits. Only 1 and 2 qubits are supported.
qubitIndices – [in] Qubit indices.
probabilities – [in] Probabilities for each Pauli channel. For a single qubit Pauli Channel, the probabilities are an array of length 4:
PauliKind((i)%4)(i.e.[p_I, p_X, p_Y, p_Z]). For a two qubit Pauli Channel, probabibilities is an array of length 16. The i-th element of the probabilities is associated with the i-th element of the 2-qubit Pauli strings in lexographic order. E.g. prob[i] corresponds to the Pauli stringPauliKind((i)%4), PauliKind_t((i)/4).oper – [out] Quantum operator associated with the Pauli channel.
- Returns:
cupaulipropStatus_t
Operator Queries and Management#
cupaulipropQuantumOperatorGetKind#
- cupaulipropStatus_t cupaulipropQuantumOperatorGetKind(
- const cupaulipropHandle_t handle,
- const cupaulipropQuantumOperator_t oper,
- cupaulipropQuantumOperatorKind_t *kind
Queries what kind of gate or channel a quantum operator represents.
- Parameters:
handle – [in] Library handle.
oper – [in] Quantum operator.
kind – [out] Kind of the quantum operator.
- Returns:
cupaulipropStatus_t
cupaulipropDestroyOperator#
- cupaulipropStatus_t cupaulipropDestroyOperator( )#
Destroys a quantum operator.
- Parameters:
oper – [in] Quantum operator.
- Returns:
cupaulipropStatus_t