Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark external libraries #11

Merged
merged 322 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
322 commits
Select commit Hold shift + click to select a range
d5f2c99
Minor fixes in cirq.py
mlazzarin Nov 10, 2021
2ba7366
Add more libraries
mlazzarin Nov 10, 2021
b8ae1ea
Minor changes in set_precision method for qsim and tfq
mlazzarin Nov 14, 2021
4afac80
Fix name of qsim-gpu and qsim-cuquantum
mlazzarin Nov 14, 2021
f1355a8
Disable fusion for qsim, qsim-gpu and qsim-custatevec
mlazzarin Nov 14, 2021
705a687
Merge branch 'libraries' into fusion
stavros11 Nov 16, 2021
1f6ddea
Add tests for qibo circuits
mlazzarin Nov 17, 2021
ba0d6c4
Add docstring
mlazzarin Nov 17, 2021
afbe146
Rename test_benchmarks.py to test_qibo_benchmarks.py
mlazzarin Nov 17, 2021
c29c938
Remove installation of tfq_nightly from CI
mlazzarin Nov 17, 2021
e3d6f4c
Rename fusion script
stavros11 Nov 17, 2021
e157fda
Remove redudant line
stavros11 Nov 17, 2021
ec68658
Add HybridQ backend
stavros11 Nov 19, 2021
890e1db
Add fusion max_qubits option in compare.py
stavros11 Nov 19, 2021
016c31a
Merge branch 'fusion' into hybridq
stavros11 Nov 19, 2021
0bc0c88
Add fusion option
stavros11 Nov 19, 2021
44fd864
Simplify fusion backends
stavros11 Nov 19, 2021
0b5d2d5
Add fusion library tests
stavros11 Nov 19, 2021
1c06b29
Merge fusion
stavros11 Nov 19, 2021
1ecb828
Fix merge
stavros11 Nov 19, 2021
157ea98
Fix hybridq fusion
stavros11 Nov 19, 2021
a902697
Update for comments
stavros11 Nov 19, 2021
b37ea2f
Install qibo from source in rules
stavros11 Nov 19, 2021
6f4c5a3
Checkout fusion branch
stavros11 Nov 19, 2021
076985e
Install qibojit pre-release
stavros11 Nov 19, 2021
93f40a6
Merge branch 'fusion' into hybridq
stavros11 Nov 19, 2021
a3ca3ad
first commit for projectq library
andrea-pasquale Nov 19, 2021
d6e0693
added projectq to github actions
andrea-pasquale Nov 19, 2021
dd1b6f4
fix swap gate
andrea-pasquale Nov 20, 2021
104f64c
remove print output
andrea-pasquale Nov 20, 2021
c714d58
remove comment
andrea-pasquale Nov 20, 2021
0eb14db
Fix final state shape
stavros11 Nov 21, 2021
8613557
Fix precision setting for qiskit
stavros11 Nov 21, 2021
793f07f
Merge branch 'fusion' into hybridq
stavros11 Nov 21, 2021
61a37d1
Implement more gates
stavros11 Nov 21, 2021
14e078c
Skip tests that are not supported
stavros11 Nov 21, 2021
6746b7f
Add hybridq in rules
stavros11 Nov 21, 2021
0972ac6
Change Python version to 3.8
stavros11 Nov 22, 2021
f4821a3
Fix QAOA test skip
stavros11 Nov 22, 2021
853a9f0
Merge fusion
stavros11 Nov 22, 2021
d8f300e
Rename a method in test_libraries.py
mlazzarin Nov 23, 2021
cb9c1f0
Minor fixes
mlazzarin Nov 23, 2021
8f68991
Fix transpose for ProjectQ
mlazzarin Nov 23, 2021
5f99c53
Merge branch 'qsim' into qsimfusion
stavros11 Nov 23, 2021
5013ade
Add max_qubits option in qsim backends
stavros11 Nov 23, 2021
92b6372
Fix tests
stavros11 Nov 23, 2021
92352a4
Add qsim in rules
stavros11 Nov 23, 2021
c029f21
Fix no newline at end of file
mlazzarin Dec 19, 2021
83b0951
Use released qibo
stavros11 Dec 19, 2021
0e61ecf
Merge fusion
stavros11 Dec 19, 2021
687d0d0
Fix CI
mlazzarin Dec 19, 2021
7986df2
Add hybridq-gpu
stavros11 Dec 19, 2021
103d80b
Fix CU3 gate for hybridq
stavros11 Dec 19, 2021
34c8e4a
Fix Cirq gates
mlazzarin Dec 19, 2021
964841c
Fix tests for qsim gpu and cuquantum
mlazzarin Dec 19, 2021
db06fca
Minor simplification
mlazzarin Dec 19, 2021
32daeb5
Remove space
mlazzarin Dec 19, 2021
30abb22
Fix comparison
mlazzarin Dec 19, 2021
25055be
Add local optimizer to projectq
mlazzarin Dec 20, 2021
a77a86e
Add options for GPU tests
mlazzarin Dec 20, 2021
7939850
Update CU1 gate for Cirq
mlazzarin Dec 20, 2021
99091d5
Update CU3 for Cirq
mlazzarin Dec 20, 2021
e163aef
Fix NameError
mlazzarin Dec 20, 2021
11d226a
Add random rotations for testing
stavros11 Dec 20, 2021
fcd97e2
Fix all circuits
stavros11 Dec 20, 2021
34eb688
Re-enable two qubit gate test
stavros11 Dec 20, 2021
0af455f
Recover original tests
stavros11 Dec 20, 2021
f48eb0a
Merge qsim
stavros11 Dec 20, 2021
9a5d985
Fix typo
stavros11 Dec 20, 2021
2baec33
Merge randomstate
stavros11 Dec 20, 2021
3dea84b
Update rules
stavros11 Dec 20, 2021
1a24e83
fix qulacs
andrea-pasquale Dec 20, 2021
9b96139
remove cu3 atol
andrea-pasquale Dec 20, 2021
2b4e5da
fix qiskit libraries
andrea-pasquale Dec 20, 2021
a91216d
Implement Stavros's suggestion
mlazzarin Dec 21, 2021
c4627d6
Implement libraries list
stavros11 Dec 21, 2021
aea4eef
Implement --add option
stavros11 Dec 21, 2021
13de9b7
Merge pull request #22 from qiboteam/testoptions
stavros11 Dec 21, 2021
e497963
Merge pull request #19 from qiboteam/minor_fixes
stavros11 Dec 21, 2021
2e4d9d7
Merge branch 'libraries' into qsim
mlazzarin Dec 21, 2021
e269329
Merge pull request #14 from qiboteam/qsim
mlazzarin Dec 21, 2021
e78848f
Merge branch 'libraries' into projectq
mlazzarin Dec 21, 2021
47e786c
Merge latest libraries
stavros11 Dec 21, 2021
3aaf341
Fix docstring
stavros11 Dec 21, 2021
f96e861
Merge updated libraries
stavros11 Dec 21, 2021
64e4280
Add gate_fusion flag
mlazzarin Dec 21, 2021
09b1ea2
Implement Marco's fixes
andrea-pasquale Dec 21, 2021
2ab0bea
fix previous commit
andrea-pasquale Dec 21, 2021
9315c96
Merge branch 'randomtests' into projectq
mlazzarin Dec 21, 2021
866facb
Add options argument for libraries
stavros11 Dec 21, 2021
3313ac3
Fix scripts
stavros11 Dec 21, 2021
cc8473c
Fix tests
stavros11 Dec 21, 2021
e1c7078
Remove qibo backends
stavros11 Dec 21, 2021
72fd10e
Add max_parallel_threads to qiskit
stavros11 Dec 21, 2021
0c43e12
Add parallel threshold
stavros11 Dec 21, 2021
ab6a1cc
Fix CU1 definition for QCGPU
mlazzarin Dec 21, 2021
1939fba
Merge fusion branch
stavros11 Dec 21, 2021
5c04ff2
Fix RZZ gate for hybridq
stavros11 Dec 21, 2021
ab2e978
Add simplify option
stavros11 Dec 21, 2021
ae710c0
Add threads setter (not working)
stavros11 Dec 21, 2021
4c17e49
Install hybridq before tensorflow
stavros11 Dec 21, 2021
da03be6
move cu3 gate in qiskit backend
andrea-pasquale Dec 21, 2021
bb0efca
Add U2 and U3 to projectq
mlazzarin Dec 21, 2021
9635e1c
Merge pull request #17 from qiboteam/fusion
stavros11 Dec 21, 2021
453904f
remove unused lines
andrea-pasquale Dec 21, 2021
9d0b1be
Merge branch 'randomtests' into fixcu3gate
andrea-pasquale Dec 21, 2021
d203bd6
fix conflicts
andrea-pasquale Dec 21, 2021
02d606d
Merge pull request #24 from qiboteam/fixqcgpu
mlazzarin Dec 22, 2021
acf7953
Merge branch 'randomtests' into projectq
mlazzarin Dec 22, 2021
9378e53
Add options for ProjectQ
mlazzarin Dec 22, 2021
784fa26
Merge pull request #21 from qiboteam/fixcu3gate
andrea-pasquale Dec 22, 2021
1821de2
Merge pull request #18 from qiboteam/projectq
scarrazza Dec 22, 2021
a510cbc
Merge randomtests branch
stavros11 Dec 22, 2021
3077b0e
Disable tfq tests and add py3.9
stavros11 Dec 22, 2021
10485b2
Add py3.9
stavros11 Dec 22, 2021
d266906
Fix typo in CU3
stavros11 Dec 22, 2021
c23c82a
Merge pull request #20 from qiboteam/randomtests
mlazzarin Dec 22, 2021
64b6344
Remove py3.8
stavros11 Dec 22, 2021
6442335
Add tfq
stavros11 Dec 22, 2021
ac29237
Remove skipped tests
stavros11 Dec 22, 2021
5d50786
Remove nthreads option
stavros11 Dec 28, 2021
32c725b
Rename scripts
mlazzarin Dec 30, 2021
952d32f
Improve scripts
mlazzarin Dec 30, 2021
e3f01f4
Add more benchmark scripts
mlazzarin Dec 30, 2021
4a4ca46
Fix qibo scaling scripts
mlazzarin Dec 30, 2021
1213025
Add plots for qibo scaling benchmarks
mlazzarin Dec 30, 2021
cdbb970
Fi qibo scaling plot
mlazzarin Jan 3, 2022
7be186c
Fix typo
mlazzarin Jan 3, 2022
2548e92
Add benchmark script for qibojit gpu only
mlazzarin Jan 3, 2022
2f3d6e6
Remove hardcoded GPU name
mlazzarin Jan 3, 2022
37c6001
Add plots for qibojit gpu comparison
mlazzarin Jan 3, 2022
a6aee05
Rename circuits.sh
mlazzarin Jan 3, 2022
bb0d450
Implement Stavros's comment about parameters
mlazzarin Jan 3, 2022
080d221
Remove old data files
mlazzarin Jan 3, 2022
31f947a
Update scripts README
mlazzarin Jan 4, 2022
5337a95
Remove custom to_markdown method
mlazzarin Jan 4, 2022
ce67f71
Fix set_precision for Qulacs and ProjectQ
mlazzarin Jan 4, 2022
60da3c2
Implement precision setter
stavros11 Jan 4, 2022
a23b98b
Fix set_precision method for QCGPU
mlazzarin Jan 5, 2022
3273ba7
Merge pull request #27 from qiboteam/fixsetprec
scarrazza Jan 5, 2022
6371766
Merge pull request #25 from qiboteam/hybridq
scarrazza Jan 5, 2022
6c4c4d0
Improve qibo scaling plots
mlazzarin Jan 6, 2022
e85cd27
Add total run time breakdown to plots
mlazzarin Jan 6, 2022
e22ebf5
Major refactoring of benchmark scripts
mlazzarin Jan 6, 2022
078bf44
Remove normalization in qibo breakdown plots
mlazzarin Jan 6, 2022
104a667
Rename benchmark scripts
mlazzarin Jan 6, 2022
e3dfa50
Improve benchmark scripts
mlazzarin Jan 6, 2022
a2d90da
Make library_gpu executable
mlazzarin Jan 6, 2022
fa335fe
Add Makefile to automate logs generation
mlazzarin Jan 6, 2022
e7851c8
Merge libraries
stavros11 Jan 6, 2022
97561d3
Remove benchmultigpu file
stavros11 Jan 6, 2022
7e522cf
Update parameter parser
stavros11 Jan 6, 2022
e26d7b6
Revert "Update parameter parser"
stavros11 Jan 6, 2022
94b7c05
Fix accelerators parser
stavros11 Jan 6, 2022
f9d51f9
Add HybridQ GPU to Makefile
mlazzarin Jan 7, 2022
d935bd1
Merge branch 'libraries' into script
mlazzarin Jan 7, 2022
e84a86a
Remove libraries that do not support double from Makefile
mlazzarin Jan 7, 2022
206c0d2
Remove libraries that do not single prec from Makefile
mlazzarin Jan 7, 2022
96ff794
Add plots for libraries
mlazzarin Jan 14, 2022
d3f4be2
Rename qibo plots notebook
mlazzarin Jan 14, 2022
a7a659b
Improve benchmark scripts
mlazzarin Jan 17, 2022
77a0f1b
Rearrange benchmark scripts
mlazzarin Jan 17, 2022
02293ff
Rename benchmark scripts
mlazzarin Jan 17, 2022
58ddba8
Fix hybridq-gpu name
mlazzarin Jan 18, 2022
8e6f789
Improve scripts and plots for Qibo backends
mlazzarin Jan 18, 2022
3901de1
Fix previous commit
mlazzarin Jan 18, 2022
6025724
Merge pull request #29 from qiboteam/fixhybridq
scarrazza Jan 18, 2022
b21325d
Improve notebook with plots
mlazzarin Jan 19, 2022
cc3addf
Add platform setter to qibo options
mlazzarin Jan 19, 2022
a037d07
Add max_largest_intermediate in hybridq simulate
stavros11 Jan 19, 2022
07d4a82
Add platform setter to main.py benchmarks
mlazzarin Jan 20, 2022
15eb008
Rename qibojit_gpu.ipynb to qibojit.ipynb
mlazzarin Jan 20, 2022
0833eea
Set default platform value to None
mlazzarin Jan 20, 2022
ec8957e
Remove if when setting the backend
mlazzarin Jan 20, 2022
9c05630
Merge pull request #31 from qiboteam/maxhybridq
scarrazza Jan 20, 2022
a7294cf
updating rules
scarrazza Jan 20, 2022
3b489e1
Improve README for scripts
mlazzarin Jan 21, 2022
5b91422
Merge pull request #33 from qiboteam/useurlpip
scarrazza Jan 21, 2022
9babf08
Add platform to logs
mlazzarin Jan 23, 2022
f96fa85
Merge pull request #32 from qiboteam/setplatform
scarrazza Jan 23, 2022
bf5340e
Merge branch 'libraries' into script
mlazzarin Jan 23, 2022
6fc99ab
Add platform option for qibojit benchmark script
mlazzarin Jan 23, 2022
35d4722
Merge latest libraries
stavros11 Jan 25, 2022
da70d39
Add environment.yml file
mlazzarin Jan 26, 2022
36721c5
Fix environment.yml
mlazzarin Jan 28, 2022
3e9368b
Improve README
mlazzarin Jan 28, 2022
72ad133
Pin versions
mlazzarin Jan 28, 2022
72d896e
Add cuquantum to qibo scaling benchmark script
mlazzarin Feb 3, 2022
b7ba3d1
Change TensorFlow version to 2.7.0 in CI
mlazzarin Feb 4, 2022
5ee1a05
Merge pull request #34 from qiboteam/fixci
scarrazza Feb 4, 2022
6dec5e7
Merge branch 'libraries' into script
mlazzarin Feb 4, 2022
6e6b063
Make qibo_circuits.sh executable
mlazzarin Feb 4, 2022
117902a
Add adiabatic evolution benchmark
stavros11 Feb 6, 2022
46a8721
Fix typos
stavros11 Feb 6, 2022
97c9037
Add missing argument
stavros11 Feb 6, 2022
282e2f7
Add test
stavros11 Feb 6, 2022
a87a127
Add scripts
stavros11 Feb 6, 2022
f00afdd
Average simulation times
stavros11 Feb 6, 2022
0fa0670
Add .pdf in gitignore
stavros11 Feb 6, 2022
5d303ca
Merge branch 'libraries' into multigpu
stavros11 Feb 8, 2022
ace6522
Merge pull request #28 from qiboteam/multigpu
scarrazza Feb 9, 2022
bc26f37
Merge branch 'libraries' into evolution
stavros11 Feb 20, 2022
99cdcb3
Fix typo in options definition
stavros11 Feb 24, 2022
30cd897
Merge branch 'libraries' into plotscripts
stavros11 Feb 23, 2022
9901106
Add pdf in gitignore
stavros11 Feb 23, 2022
49ad57b
Add bar plots in script
stavros11 Feb 23, 2022
b250a3c
Add scaling plots in script
stavros11 Feb 23, 2022
bd6c59c
Add library plots
stavros11 Feb 23, 2022
32e94aa
Remove notebooks that are transfered to scripts
stavros11 Feb 23, 2022
68cfc49
Add script that generate devices plot
stavros11 Feb 24, 2022
588a6f2
Add multigpu plot
stavros11 Feb 24, 2022
b49b270
Add notebook that generates plots used in the paper
stavros11 Feb 24, 2022
eb8089f
Update notebook
stavros11 Feb 24, 2022
f00b4a5
Add .dat files in .gitignore
stavros11 Feb 24, 2022
737c740
Merge branch 'libraries' into script
stavros11 Feb 24, 2022
6cdc7fb
Merge pull request #36 from qiboteam/fixqiskitgpu
scarrazza Feb 24, 2022
d4fa6ae
Merge pull request #35 from qiboteam/evolution
scarrazza Feb 24, 2022
677239d
Change hardware.py
stavros11 Feb 25, 2022
943ce8d
Merge branch 'libraries' into script
stavros11 Feb 25, 2022
aeffa1d
Merge latest libraries
stavros11 Feb 25, 2022
2c71d96
Add rocm line
stavros11 Feb 25, 2022
a3d19bd
Update scripts
stavros11 Feb 25, 2022
aba59ca
Add missing number
stavros11 Feb 25, 2022
cafcfb9
Add multigpu script
stavros11 Feb 25, 2022
fb1423f
Update libraries scripts
stavros11 Feb 25, 2022
e1aa2c6
Update notebook
stavros11 Feb 25, 2022
822d989
Add all circuits in multigpu bar plot
stavros11 Feb 25, 2022
84ac0c7
Change colors for Fig. 2
stavros11 Feb 26, 2022
354cc17
Add evolution plots
stavros11 Feb 26, 2022
98f810b
Fix plot names
stavros11 Feb 26, 2022
8045a04
Add HybridQ
stavros11 Feb 26, 2022
d9c8383
Simplify library plots
stavros11 Feb 26, 2022
19e3d28
Update evolution bash scripts
stavros11 Feb 26, 2022
13df622
Finalize plot scripts
stavros11 Feb 26, 2022
32fcd76
Simplify devices plot script
stavros11 Feb 26, 2022
aa1603c
Add qlm line in notebook
stavros11 Feb 27, 2022
c9aa468
Add RTX multigpu line
stavros11 Feb 27, 2022
0315983
Add linestyle option to devices plot
stavros11 Mar 2, 2022
5adbfc6
Clean notebook
stavros11 Mar 2, 2022
2d9c1ba
Add fusion plots
stavros11 Mar 2, 2022
ff3b347
Add bash script for fusion benchmarks
stavros11 Mar 2, 2022
806863e
Fix breakdown bar plot
stavros11 Mar 2, 2022
86b0952
Add fusion comparison with libraries
stavros11 Mar 3, 2022
e30ff57
Fix save names
stavros11 Mar 7, 2022
e016ef8
Add qsim cuquantum data
stavros11 Mar 9, 2022
c6c320e
Remove qsim from figure 6
stavros11 Mar 9, 2022
c94ac03
Add bash script for libraries fusion benchmark
stavros11 Mar 9, 2022
654a17a
Merge pull request #37 from qiboteam/plotscripts
scarrazza Mar 14, 2022
c9a664f
Update legend position
stavros11 Mar 14, 2022
3d66e77
Merge pull request #26 from qiboteam/script
scarrazza Mar 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@ jobs:
python-version: [3.9]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
python -m pip install --upgrade pip
pip install pytest
pip install --pre qibo
pip install qibotf qibojit
pip install qiskit openfermion
- name: Test with jit enabled
pip install qiskit openfermion qulacs hybridq
pip install tensorflow==2.7.0
pip install tensorflow_quantum
pip install projectq
pip install qsimcirq
pip install git+https://github.com/qiboteam/qibo
pip install git+https://github.com/qiboteam/qibojit
- name: Test
run: |
pytest
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,9 @@ dmypy.json

# Pyre type checker
.pyre/

# pdf plots
*.pdf

# benchmark logs
*.dat
126 changes: 82 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,18 @@ This repository contains benchmark scripts for quantum circuit simulation using

## Installing prerequisites

Before executing the simulation please:
In order to run the benchmarks, you need to install the required libraries.

1. Install `Qibo >= 0.1.6rc1` from source or using:
In order to set up an environment with most of the libraries available in this repository,
you can set up a **conda** environment:
```
pip install qibo --pre
conda env create -f environment.yml
```

2. Install `qibojit >= 0.0.2` simulation backend with:
```
pip install qibojit
```
Visit the [CuPy website](https://cupy.dev/) and install the binary/source code version that matches your CUDA version.

3. (optional) Install qibotf simulation backend with:
```
pip install qibotf
```
This will install TensorFlow 2.5.0 automatically, please make sure you have the supported CUDA version.
This recipe doesn't include the installation of CUDA Toolkit, CuPy, cuQuantum nor HybridQ, Qulacs-GPU, qsim GPU and TensorFlow Quantum.

## Supported simulation backends

- [qibojit](https://github.com/qiboteam/qibojit): uses numba on CPU and cupy on GPU for custom operations.
- [qibojit](https://github.com/qiboteam/qibojit): uses numba on CPU and cupy/cuquantum on GPU for custom operations.
- [qibotf](https://github.com/qiboteam/qibotf): uses tf primitives with custom operators on CPU and GPU.
- [tensorflow](https://www.tensorflow.org/): uses tf default primitives.
- [numpy](https://numpy.org/): single-threaded CPU implementation.
Expand All @@ -40,39 +30,49 @@ The script in `benchmarks/main.py` executes the benchmark code following the sup
```
$ python main.py -h

usage: main.py [-h] [--nqubits NQUBITS] [--backend BACKEND] [--circuit CIRCUIT]
[--options OPTIONS] [--nreps NREPS] [--nshots NSHOTS] [--transfer]
[--precision PRECISION] [--memory MEMORY] [--threading THREADING]
[--filename FILENAME]
usage: main.py [-h] [--nqubits NQUBITS] [--backend BACKEND]
[--platform PLATFORM] [--circuit CIRCUIT]
[--circuit-options CIRCUIT_OPTIONS] [--nreps NREPS]
[--nshots NSHOTS] [--transfer] [--precision PRECISION]
[--memory MEMORY] [--threading THREADING] [--filename FILENAME]

optional arguments:
-h, --help show this help message and exit
--nqubits NQUBITS Number of qubits in the circuit.
--backend BACKEND Qibo backend to use for simulation.
--circuit CIRCUIT Type of circuit to use. See README for the list of available circuits.
--options OPTIONS String with options for circuit creation. It should have the form
'arg1=value1,arg2=value2,...' .See README for the list of arguments
that are available for each circuit.
--nreps NREPS Number of repetitions of the circuit execution. Dry run is not
included.
--nshots NSHOTS Number of measurement shots. If used the time required to measure
frequencies (no samples) is measured and logged. If it is ``None`` no
measurements are performed.
--transfer If used the final state array is converted to numpy.If the simulation
device is GPU this requires a transfer from GPU memory to CPU.
--platform PLATFORM Qibo platform to use for simulation.
--circuit CIRCUIT Type of circuit to use. See README for the list of
available circuits.
--circuit-options CIRCUIT_OPTIONS
String with options for circuit creation. It should
have the form 'arg1=value1,arg2=value2,...'. See
README for the list of arguments that are available
for each circuit.
--nreps NREPS Number of repetitions of the circuit execution. Dry
run is not included.
--nshots NSHOTS Number of measurement shots. If used the time required
to measure frequencies (no samples) is measured and
logged. If it is ``None`` no measurements are
performed.
--transfer If used the final state array is converted to numpy.
If the simulation device is GPU this requires a
transfer from GPU memory to CPU.
--precision PRECISION
Numerical precision of the simulation.Choose between 'double' and
'single'.
--memory MEMORY Limit the GPU memory usage when using Tensorflow based backends. The
memory limit should be given in MB. Tensorflow reserves the full
available memory by default.
Numerical precision of the simulation. Choose between
'double' and 'single'.
--memory MEMORY Limit the GPU memory usage when using Tensorflow based
backends. The memory limit should be given in MB.
Tensorflow reserves the full available memory by
default.
--threading THREADING
Switches the numba threading layer when using the qibojit backend on
CPU. See https://numba.pydata.org/numba-doc/latest/user/threading-
layer.html#selecting-a-named-threading-layer for a list of available
Switches the numba threading layer when using the
qibojit backend on CPU. See
https://numba.pydata.org/numba-
doc/latest/user/threading-layer.html#selecting-a-
named-threading-layer for a list of available
threading layers.
--filename FILENAME Directory of file to save the logs in json format.If not given the
logs only be printed and not saved.
--filename FILENAME Directory of file to save the logs in json format. If
not given the logs will only be printed and not saved.
```

Before executing the code keep in mind the following:
Expand All @@ -82,6 +82,47 @@ Before executing the code keep in mind the following:

The `scripts/` folder contains example bash scripts that execute circuit benchmarks for different numbers of qubits. We refer to the README inside this folder for more details.

#### Comparing simulation libraries

In addition to the above `main.py` benchmark, we provide the `compare.py` benchmark for comparing the performance of different simulation libraries.
The usage is similar to `main.py` with the `--backend` flag replaced by the `--library` flag which can be used to select one of the available quantum simulation libraries
(check `python compare.py -h`).

```
$ python compare.py -h

usage: compare.py [-h] [--nqubits NQUBITS] [--library LIBRARY] [--library-options LIBRARY_OPTIONS] [--circuit CIRCUIT] [--circuit-options CIRCUIT_OPTIONS] [--precision PRECISION] [--nreps NREPS]
[--filename FILENAME]

optional arguments:
-h, --help show this help message and exit
--nqubits NQUBITS Number of qubits in the circuit.
--library LIBRARY Quantum simulation library to use in benchmark. See README for the list of available libraries.
--library-options LIBRARY_OPTIONS
String with options for the library. It should have the form 'arg1=value1,arg2=value2,...'. Each library supports different options.
--circuit CIRCUIT Type of circuit to use. See README for the list of available circuits.
--circuit-options CIRCUIT_OPTIONS
String with options for circuit creation. It should have the form 'arg1=value1,arg2=value2,...'. See README for the list of arguments that are available for each circuit.
--precision PRECISION
Numerical precision of the simulation. Choose between 'double' and 'single'.
--nreps NREPS Number of repetitions of the circuit execution. Dry run is not included.
--filename FILENAME Directory of file to save the logs in json format. If not given the logs will only be printed and not saved.

```

Currently the available libraries (defined under `benchmarks/libraries`) are:
- [Qiskit](https://qiskit.org/), defined as ``qiskit`` and ``qiskit-gpu`` in the ``library`` option of ``compare.py``.
- [Qulacs](https://github.com/qulacs/qulacs), defined as ``qulacs`` and ``qulacs-gpu``.
- [Cirq](https://quantumai.google/cirq), defined as ``cirq``.
- [TensorFlow Quantum](https://www.tensorflow.org/quantum), defined as ``tfq``.
- [Qsim](https://quantumai.google/qsim), defined as ``qsim``, ``qsim-gpu`` and ``qsim-cuquantum``.
- [HybridQ](https://github.com/nasa/hybridq), defined as ``hybridq`` and ``hybridq-gpu``.
- [ProjectQ](https://projectq.ch/), defined as ``projectq``.
- [QCGPU](https://qcgpu.github.io/), defined as ``qcgpu``.
- [Qibo](https://qibo.science/), defined as ``qibo``.

All the circuits described below are available for both `main.py` and `compare.py`.

## Benchmark output

The benchmark script prints a summary of the circuit and user selected flags together with:
Expand All @@ -101,9 +142,6 @@ Note that if a GPU is used for simulation then transfer times measure the time r

If `--filename` is given the above logs are saved in json format in the given directory.

The `data/` folder contains example logs. We refer to the README inside this folder for more details. The results are transformed in markdown tables for presentation using pandas DataFrame's in the `data.ipynb` notebook.


## Implemented circuits

Here is a list of the available circuits for benchmarks. As described above the circuit should be selected using the `--circuit` flag and one of the following circuit names. Additional options can be passed using the `--options` flag. The options supported by each circuit are analyzed below. Note that some circuits require additional Python libraries to work as stated below.
Expand Down
53 changes: 53 additions & 0 deletions benchmarks/circuits/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
def parse(options):
"""Parse options from string.

Args:
options (str): String with options.
It should have the form 'arg1=value1,arg2=value2,...'.

Returns:
dict: {'arg1': value1, 'arg2': value2, ...}

"""
kwargs = {}
if options is not None:
for parameter in options.split(","):
if "=" in parameter:
k, v = parameter.split("=")
kwargs[k] = v
else:
raise ValueError(f"Cannot parse parameter {parameter}.")
return kwargs


def get(circuit_name, nqubits, options=None, qibo=False):
if qibo:
from benchmarks.circuits import qibo as module
else:
from benchmarks.circuits import qasm as module

if circuit_name in ("qft", "QFT"):
circuit = module.QFT
elif circuit_name == "one-qubit-gate":
circuit = module.OneQubitGate
elif circuit_name == "two-qubit-gate":
circuit = module.TwoQubitGate
elif circuit_name in ("variational", "variational-circuit"):
circuit = module.VariationalCircuit
elif circuit_name in ("bernstein-vazirani", "bv"):
circuit = module.BernsteinVazirani
elif circuit_name in ("hidden-shift", "hs"):
circuit = module.HiddenShift
elif circuit_name == "qaoa":
circuit = module.QAOA
elif circuit_name == "supremacy":
circuit = module.SupremacyCircuit
elif circuit_name in ("basis-change", "bc"):
circuit = module.BasisChange
elif circuit_name in ("quantum-volume", "qv"):
circuit = module.QuantumVolume
else:
raise NotImplementedError(f"Cannot find circuit {circuit_name}.")

kwargs = parse(options)
return circuit(nqubits, **kwargs)
Loading