diff --git a/doc/source/QiboTN.png b/doc/source/QiboTN.png new file mode 100644 index 0000000..be6d900 Binary files /dev/null and b/doc/source/QiboTN.png differ diff --git a/doc/source/getting-started/index.rst b/doc/source/getting-started/index.rst index 1cd4702..688df82 100644 --- a/doc/source/getting-started/index.rst +++ b/doc/source/getting-started/index.rst @@ -1,6 +1,7 @@ Getting started =============== + In this section we present the basic aspects of the Qibotn design and provide installation instructions. Please visit the following sections to understand how ``qibotn`` works. diff --git a/doc/source/getting-started/quickstart.rst b/doc/source/getting-started/quickstart.rst index 6650118..2d07834 100644 --- a/doc/source/getting-started/quickstart.rst +++ b/doc/source/getting-started/quickstart.rst @@ -1,12 +1,18 @@ Quick start =========== -In this section, we provide an example of two qubit ciruit simulation using qibotn package in Qibo simulator. First, the backend is to be set with appropriate run card settings, followed by the circuit simulation using Qibo documentation. +In this section, we provide examples on how to use Qibotn to execute tensor network +simulation of quantum circuit. First, we show how to use the Cutensornet and Quimb +backends, while in a second moment we show a complete example of usage of the Quantum +Matcha Tea Backend. -Setting the backend -""""""""""""""""""" +Setting the backend with Cutensornet and Quimb +"""""""""""""""""""""""""""""""""""""""""""""" -QiboTN offers two backends: cutensornet (using cuQuantum library) and qutensornet (using Quimb library) for tensor network based simulations. At present, cutensornet backend works only for GPUs whereas qutensornet for CPUs. The backend can be set using the following command line. +Among the backends provided by Qibotn, we have cutensornet (using cuQuantum library) +and qutensornet (using Quimb library) for tensor network based simulations. +At present, cutensornet backend works only for GPUs whereas qutensornet for CPUs. +These backend can be set using the following command line. To use cuQuantum library, cutensornet can be specified as follows:: @@ -79,3 +85,61 @@ The following is a basic example to execute a two qubit circuit and print the fi # Print the final state print(result.state()) + + +Using the Quantum Matcha Tea backend +"""""""""""""""""""""""""""""""""""" + +In the following we show an example of how the Quantum Matcha Tea backend can be +used to execute a quantum circuit:: + + # We need Qibo to setup the circuit and the backend + from qibo import Circuit, gates + from qibo.backends import construct_backend + + # We need Quantum Matcha Tea to customize the tensor network simulation + from qmatchatea import QCConvergenceParameters + + # Constructing the circuit preparing a GHZ state + def build_GHZ(nqubits): + """Helper function to construct a circuit preparing the GHZ circuit.""" + circ = Circuit(nqubits) + circ.add(gates.H(0)) + [circ.add(gates.CNOT(q, q+1)) for q in range(nqubits-1)] + return circ + + # Set the number of qubits + nqubits = 40 + + # Construct the circuit preparing the GHZ state + circuit = build_GHZ(nqubits) + + # Construct the backend + backend = construct_backend(backend="qibotn", platform="qmatchatea") + + # Customize the low-level backend preferences according to Qibo's formalism + backend.set_device("/CPU:1") + backend.set_precision("double") + + # Customize the tensor network simulation itself + backend.configure_tn_simulation( + ansatz = "MPS", + convergence_params = QCConvergenceParameters(max_bond_dimension=50, cut_ratio=1e-6) + ) + + # Execute the tensor network simulation + outcome = backend.execute_circuit( + circuit = circuit, + nshots=1024, + ) + + # Print some results + print(outcome.probabilities()) + # Should print something like: {'0000000000000000000000000000000000000000': 0.5000000000000001, '1111111111111111111111111111111111111111': 0.5000000000000001} + print(outcome.frequencies()) + # Should print something like: {'0000000000000000000000000000000000000000': 488, '1111111111111111111111111111111111111111': 536} + + +By default, the simulator is choosing a specific method to compute the probabilities, +and for further information we recommend the user to refer to our High-Level-API +docstrings. diff --git a/doc/source/index.rst b/doc/source/index.rst index e30d36d..6dc2092 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -4,29 +4,54 @@ What is QiboTN? =============== -QiboTN is the dedicated `Qibo `_ backend to support large-scale simulation of quantum circuits and acceleration. +Qibotn is an high-level library which integrates tensor network simulation within +the `Qibo `_ ecosystem. -Supported Computation: +If you are familiar with Qibo, you will be well aware of the modularity we provide +through the use of our backends: after building a specific algorithm or quantum +circuit, any of our backends can be selected to perform operations on the +desired hardware (classical or quantum). -- Tensornet (TN) -- Matrix Product States (MPS) +Here, we extend this modularity to one of the most famous quantum inspired simulation +technique. -Tensor Network contractions to: +We do this by relying on well-known and maintained packages, and integrating their +operation into our own dedicated backends. -- dense vectors -- expecation values of given Pauli string +.. image:: QiboTN.png + + +As shown in the figure above, we currently support three different backends, which +correspond to the three mentioned packages: + - `cuQuantum `_: an NVIDIA SDK of optimized libraries and tools for accelerating quantum computing workflows (we refer to the specific `Cutensornet `_ library); + - `quimb `_: an easy but fast python library for ‘quantum information many-body’ calculations, focusing primarily on tensor networks; + - `Quantum Matcha Tea `_: a logical quantum computer emulator powered by matrix product states. + +.. warning:: + + There are currently two ways to use the three backends (`qmatchatea` is + slightly different from the others), but we are working to standardize the interface. + +Thanks to the mentioned packages, we currently support some tensor network ansatze: +Matrix Product States (MPS) on any mentioned backend, Tree Tensor Networks (TTN) +through the Quantum Matcha Tea backend and a more general Tensor Network (TN) ansatz through +Cutensornet and Quimb. + +Supported simulation features +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +We support Tensor Network contractions to: + +- dense vectors (all the backends) +- expecation values of given Pauli string (Cutensornet and Qmatchatea) The supported HPC configurations are: -- single-node CPU -- single-node GPU or GPUs -- multi-node multi-GPU with Message Passing Interface (MPI) -- multi-node multi-GPU with NVIDIA Collective Communications Library (NCCL) +- single-node CPU through Quimb and Qmatchatea +- single-node GPU or GPUs through Cutensornet and Qmatchatea +- multi-node multi-GPU with Message Passing Interface (MPI) through Cutensornet +- multi-node multi-GPU with NVIDIA Collective Communications Library (NCCL) through Cutensornet -Currently, the supported tensor network libraries are: - -- `cuQuantum `_, an NVIDIA SDK of optimized libraries and tools for accelerating quantum computing workflows. -- `quimb `_, an easy but fast python library for ‘quantum information many-body’ calculations, focusing primarily on tensor networks. How to Use the Documentation ============================