Skip to main content

A tensor-network translation module for Qibo

Project description

Qibotn

The tensor network translation module for Qibo to support large-scale simulation of quantum circuits and acceleration.

Supported Computation

Tensor Network Types:

  • Tensornet (TN)
  • Matrix Product States (MPS)

Tensor Network contractions to:

  • dense vectors
  • expecation values of given Pauli string

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)

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.

Installation

To get started:

pip install qibotn

to install the tools and dependencies. A few extras are provided, check pyproject.toml in case you need them.

Contribute

To contribute, please install using poetry:

git clone https://github.com/qiboteam/qibotn.git
cd qibotn
poetry install

Sample Codes

Single-Node Example

The code below shows an example of how to activate the Cuquantum TensorNetwork backend of Qibo.

import numpy as np
from qibo import Circuit, gates
import qibo

# Below shows how to set the computation_settings
# Note that for MPS_enabled and expectation_enabled parameters the accepted inputs are boolean or a dictionary with the format shown below.
# If computation_settings is not specified, the default setting is used in which all booleans will be False.
# This will trigger the dense vector computation of the tensornet.

computation_settings = {
    "MPI_enabled": False,
    "MPS_enabled": {
        "qr_method": False,
        "svd_method": {
            "partition": "UV",
            "abs_cutoff": 1e-12,
        },
    },
    "NCCL_enabled": False,
    "expectation_enabled": False,
}


qibo.set_backend(
    backend="qibotn", platform="cutensornet", runcard=computation_settings
)  # cuQuantum
# qibo.set_backend(backend="qibotn", platform="qutensornet", runcard=computation_settings) #quimb


# Construct the circuit
c = Circuit(2)
# Add some gates
c.add(gates.H(0))
c.add(gates.H(1))

# Execute the circuit and obtain the final state
result = c()

print(result.state())

Other examples of setting the computation_settings

# Expectation computation with specific Pauli String pattern
computation_settings = {
    "MPI_enabled": False,
    "MPS_enabled": False,
    "NCCL_enabled": False,
    "expectation_enabled": {
        "pauli_string_pattern": "IXZ",
    },
}

# Dense vector computation using multi node through MPI
computation_settings = {
    "MPI_enabled": True,
    "MPS_enabled": False,
    "NCCL_enabled": False,
    "expectation_enabled": False,
}

Multi-Node Example

Multi-node is enabled by setting either the MPI or NCCL enabled flag to True in the computation settings. Below shows the script to launch on 2 nodes with 2 GPUs each. $node_list contains the IP of the nodes assigned.

mpirun -n 4 -hostfile $node_list python test.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qibotn-0.0.2.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qibotn-0.0.2-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file qibotn-0.0.2.tar.gz.

File metadata

  • Download URL: qibotn-0.0.2.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for qibotn-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1d501760e33fa0ec528cd9c3760e9d6b3f1ca000250ed00ea8a07548232f7f73
MD5 2f11c257f5b9bf6bdcd2f8e45b507b7d
BLAKE2b-256 b60ed4f5c59b5f0179f77316ccf9e2eb671f74b7ec724562121afcdf26438411

See more details on using hashes here.

File details

Details for the file qibotn-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: qibotn-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for qibotn-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c12db571d44131d5932f1093241a03f3ff39b3013b1cb1b3e56f3a8ea1fffad7
MD5 b7d199e7d7c1cf258dbe77d1957ec101
BLAKE2b-256 ec455c2c787797626b5ea416ac4dfd944e52b1467cae62ef6e9b8ce823cc0bbb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page