quri_parts.tensornetwork.state package

class MultiMappedNode(node, input_qubit_edge_mapping=None, output_qubit_edge_mapping=None, name=None)

Bases: AbstractNode

This is a convenience class for tensors representing multiple qubits.

This node must be initialized with an existing node, it then facilitates functionality needed for certain MPS or MPO based algorithms.

Parameters:
  • node (Node)

  • input_qubit_edge_mapping (Optional[Mapping[int, Edge]])

  • output_qubit_edge_mapping (Optional[Mapping[int, Edge]])

  • name (Optional[Text])

property input_qubit_edge_mapping: dict[int, Edge] | None
property output_qubit_edge_mapping: dict[int, Edge] | None
property dtype: Tensor
property left_edge: Edge | None

Assuming the tensor is in MPO form, returns the left edge.

This method throws an error if there are multiple left edges, such as after a contraction of two MPO layers.

property right_edge: Edge | None

Assuming the tensor is in MPO form, returns the right edge.

This method throws an error if there are multiple right edges, such as after a contraction of two MPO layers.

property left_edges: Sequence[Edge]
property right_edges: Sequence[Edge]
property bond_dimension: int | None

Gives the highest bond dimension of this tensor.

flatten_edges()
Return type:

None

copy(conjugate=False)

Returns a copy of itself.

Parameters:

conjugate (bool)

Return type:

MultiMappedNode

property edges: Any
property name: Any
property axis_names: Any
disable()
Return type:

None

get_tensor()
Return type:

Tensor

set_tensor(tensor)
Parameters:

tensor (Tensor)

Return type:

None

property shape: Any
property tensor: Tensor
to_serial_dict()

Return a serializable dict representing the node.

Returns: A dict object.

Return type:

None

classmethod from_serial_dict(_)

Return a node given a serialized dict representing it.

Parameters:
  • serial_dict – A python dict representing a serialized node.

  • _ (Any)

Returns:

A node.

Return type:

None

class MappedNode(node, qubit_index, input_edge_index=None, output_edge_index=None, name=None)

Bases: MultiMappedNode

This is a convenience class for single tensors in an MPS or MPO.

This node must be initialized with an existing node, it then facilitates functionality needed for certain MPS or MPO based algorithms.

Parameters:
  • node (Node)

  • qubit_index (int)

  • input_edge_index (Optional[int])

  • output_edge_index (Optional[int])

  • name (Optional[Text])

property input_edge: Edge
property output_edge: Edge
copy(conjugate=False)

Returns a copy of itself.

Parameters:

conjugate (bool)

Return type:

MappedNode

class TensorNetworkState(edges, container, layer_tensor_map)

Bases: NodeCollection

Tensor network representation of a quantum state.

This class subclasses NodeCollection and provides output edges for the state, each of which represents a qubit

Parameters:
  • edges (Sequence[Edge])

  • container (Union[set[AbstractNode], list[AbstractNode]])

  • layer_tensor_map (Sequence[Mapping[int, Union[AbstractNode]]])

with_gates_applied(circuit)

Returns a new TensorNetworkState with the given TensorNetworkCircuit applied.

Parameters:

circuit (TensorNetworkLayer)

Return type:

TensorNetworkState

copy(conjugate=False)

Returns a copy of itself.

Parameters:

conjugate (bool)

Return type:

TensorNetworkState

conjugate()

Returns a conjugated copy of itself.

Return type:

TensorNetworkState

contract(method='greedy')

Returns a copy of self after contracting internal tensor network.

Parameters:

method (str)

Return type:

TensorNetworkState

inner_product(other, conjugate=True)
Parameters:
Return type:

complex

get_zero_state(qubit_count, backend='numpy')

Returns the zero state for the given number of qubits.

Parameters:
  • qubit_count (int)

  • backend (str)

Return type:

TensorNetworkState

convert_state(state, transpiler=<quri_parts.circuit.transpile.transpiler.SequentialTranspiler object>, backend='numpy')
Parameters:
  • state (CircuitQuantumState)

  • transpiler (circuit.transpile.transpiler.CircuitTranspiler | None)

  • backend (str)

Return type:

TensorNetworkState

quantum_state_vector_from_tensor_network_state(state)

Convert TensorNetworkState to QuantumStateVector that only contains the state vector and no quantum circuit.

Parameters:

state (TensorNetworkState)

Return type:

QuantumStateVector