Skip to content

Commit

Permalink
Merge pull request #25 from qiboteam/pre-commit-all
Browse files Browse the repository at this point in the history
Run pre-commit on all files
  • Loading branch information
alecandido authored Feb 8, 2024
2 parents 89e97b4 + c69fd5f commit 1ed3832
Show file tree
Hide file tree
Showing 5 changed files with 428 additions and 23 deletions.
9 changes: 9 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi

nix_direnv_watch_file flake.nix
nix_direnv_watch_file flake.lock
if ! use flake . --impure; then
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.devenv
56 changes: 33 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,33 @@ To get started, `python setup.py install` to install the tools and dependencies.
# 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](https://github.com/NVIDIA/cuQuantum), an NVIDIA SDK of optimized libraries and tools for accelerating quantum computing workflows.
- [quimb](https://quimb.readthedocs.io/en/latest/), an easy but fast python library for ‘quantum information many-body’ calculations, focusing primarily on tensor networks.

- [cuQuantum](https://github.com/NVIDIA/cuQuantum), an NVIDIA SDK of optimized libraries and tools for accelerating quantum computing workflows.
- [quimb](https://quimb.readthedocs.io/en/latest/), an easy but fast python library for ‘quantum information many-body’ calculations, focusing primarily on tensor networks.

# Sample Codes

## Single-Node Example

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

```py
import numpy as np
from qibo import Circuit, gates
Expand All @@ -36,20 +43,22 @@ import qibo
# 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
"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="cutensornet", runcard=computation_settings
) # cuQuantum
# qibo.set_backend(backend="qibotn", platform="qutensornet", runcard=computation_settings) #quimb


Expand All @@ -70,25 +79,26 @@ Other examples of setting the computation_settings
```py
# Expectation computation with specific Pauli String pattern
computation_settings = {
'MPI_enabled': False,
'MPS_enabled': False,
'NCCL_enabled': False,
'expectation_enabled': {
'pauli_string_pattern': "IXZ"
"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
"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.

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.

```sh
mpirun -n 4 -hostfile $node_list python test.py
Expand Down
Loading

0 comments on commit 1ed3832

Please sign in to comment.