cuquantum.cutensornet.experimental.NetworkOperator¶
- class cuquantum.cutensornet.experimental.NetworkOperator(state_mode_extents, dtype='complex128', options=None)[source]¶
Create a tensor network operator object.
- Parameters
state_mode_extents – A sequence of integers specifying the dimension for all state modes.
dtype –
A string specifying the datatype for the tensor network operator, currently supports the following data types:
'float32'
'float64'
'complex64'
'complex128'
(default)
options – Specify options for the state computation as a
NetworkOptions
object. Alternatively, adict
containing the parameters for theNetworkOptions
constructor can also be provided. If not specified, the value will be set to the default-constructedNetworkOptions
object.
Methods
- append_mpo(coefficient, modes, mpo_tensors, stream=None)[source]¶
Append a matrix product operator (MPO) component to the tensor network operator.
- Parameters
coefficient – A scalar for the cofficient of the full tensor product.
modes – A sequence of integers specifying each mode where the MPO acts on.
mpo_tensors – A sequence of tensors (ndarray-like objects) for each MPO operand. The currently supported types are
numpy.ndarray
,cupy.ndarray
, andtorch.Tensor
. The mode of each operand is expected to follow the order ofpknb
wherep
denotes the mode connecting to the previous MPO tensor,n
denotes the mode connecting to the next MPO tensor,k
denotes the ket mode andb
denotes the bra mode. Note that currently only MPO with open boundary condition is supported, thereforep
andn
mode should not be present in the first and last MPO tensor respectively. Note that the relative order of bra and ket modes here differs from that ofoperand
inappend_product()
.stream – Provide the CUDA stream to use for appending tensor product (this is used to copy the operands to the GPU if they are provided on the CPU). Acceptable inputs include
cudaStream_t
(as Pythonint
),cupy.cuda.Stream
, andtorch.cuda.Stream
. If a stream is not provided, the current stream will be used.
- append_product(coefficient, modes, tensors, stream=None)[source]¶
Append a tensor product component to the tensor network operator.
- Parameters
coefficient – A scalar for the cofficient of the full tensor product.
modes – A nested sequence of integers denoting the modes where each operand in
tensors
acts on.tensors – A sequence of tensors (ndarray-like objects) for each tensor operand. The currently supported types are
numpy.ndarray
,cupy.ndarray
, andtorch.Tensor
. The modes of each operand are expected to be ordered asABC...abc...
, whereABC...
denotes output bra modes andabc...
denotes input ket modes corresponding tomodes
.stream – Provide the CUDA stream to use for appending tensor product (this is used to copy the operands to the GPU if they are provided on the CPU). Acceptable inputs include
cudaStream_t
(as Pythonint
),cupy.cuda.Stream
, andtorch.cuda.Stream
. If a stream is not provided, the current stream will be used.
- classmethod from_pauli_strings(pauli_strings, dtype='complex128', backend='cupy', options=None, stream=None)[source]¶
Generate a tensor network operator object from given pauli strings.
- Parameters
pauli_strings – A dictionary that maps pauli strings to corresponding coefficients. Alternative can be a single pauli string.
dtype –
A string specifying the datatype for the tensor network operator, currently supports the following data types:
'complex64'
'complex128'
(default)
backend – A string specifying the ndarray backend for the device tensor operands. Currently supports
'cupy'
(default) and'torch'
.options – Specify options for the state computation as a
NetworkOptions
object. Alternatively, adict
containing the parameters for theNetworkOptions
constructor can also be provided. If not specified, the value will be set to the default-constructedNetworkOptions
object.stream – Provide the CUDA stream to use for tensor network operator construction, which is needed for stream-ordered operations such as allocating memory. Acceptable inputs include
cudaStream_t
(as Pythonint
),cupy.cuda.Stream
, andtorch.cuda.Stream
. If a stream is not provided, the current stream will be used.