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, a dict containing the parameters for the NetworkOptions constructor can also be provided. If not specified, the value will be set to the default-constructed NetworkOptions object.

Methods

__init__(state_mode_extents, dtype='complex128', options=None)[source]
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, and torch.Tensor. The mode of each operand is expected to follow the order of pknb where p denotes the mode connecting to the previous MPO tensor, n denotes the mode connecting to the next MPO tensor, k denotes the ket mode and b denotes the bra mode. Note that currently only MPO with open boundary condition is supported, therefore p and n 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 of operand in append_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 Python int), cupy.cuda.Stream, and torch.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, and torch.Tensor. The modes of each operand are expected to be ordered as ABC...abc..., where ABC... denotes output bra modes and abc... denotes input ket modes corresponding to modes.

  • 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 Python int), cupy.cuda.Stream, and torch.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, a dict containing the parameters for the NetworkOptions constructor can also be provided. If not specified, the value will be set to the default-constructed NetworkOptions 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 Python int), cupy.cuda.Stream, and torch.cuda.Stream. If a stream is not provided, the current stream will be used.