Module constructing_tns

Module constructing_tns 

Source
Expand description

§Constructing tensor networks

There are multiple ways to construct tensors and tensor networks.

§Quantum

§OpenQASM2 code

If the goal is to clasically simulate quantum circuits, one can directly load OpenQASM2 code and construct a Circuit out of it using import_qasm.

This library implements many standard gates and when it encounters one in the QASM code, it will not look for a gate definition; only when it doesn't know the gate, it will decompose the gate using an earlier gate definition in the QASM code.

From the circuit, we can then construct different tensor networks, depending on what we want to compute:

§Circuit builder

Similar to importing QASM2 code, the Circuit struct can also directly be used to construct tensor networks that simulate quantum circuits.

§Sycamore circuit

There are special methods to construct tensor networks corresponding to the quantum circuits of the Sycamore experiment (Quantum supremacy using a programmable superconducting processor (Arute et al.)). See the sycamore_circuit method.

§HDF5 files

Tensors and tensor networks can also be saved and loaded from HDF5 files, see the functions in hdf5. The structure of the files is:

[Group name="tensors"]
    [Dataset name="tensorA" datatype=double complex tensor]
        [Attribute name="bids" datatype=int list]
    [Dataset name="tensorB" datatype=double complex tensor]
        [Attribute name="bids" datatype=int list]
    ...

where bids are the leg IDs.

§General tensor networks

The Tensor struct can be used to directly construct arbitrary tensors and tensor networks. Tensors are created from a list of leg IDs and the corresponding dimensions of these legs. Connected tensors are identified by having at least one leg ID in common. The corresponding bond dimensions have to match.

Tensors without data can already be used for e.g. finding a contraction path, but if you want to actually contract a tensor network, the tensors need data. For this, there is the set_tensor_data method which takes a variant of TensorData.

A normal tensor network is a list of tensors. However, this library also supports hierarchical tensor network structures, which are detailed in another tutorial.

Re-exports§

pub use crate::_tutorial as table_of_contents;