Skip to main content

Hybrid Simulator for Quantum Circuits

Project description

HybridQ: A Hybrid Simulator for Quantum Circuits

Binder GitHub License Language grade: Python Language grade: C++
Tutorials
PyPI Downloads Downloads-week
Documentation Cite

HybridQ is a highly extensible platform designed to provide a common framework to integrate multiple state-of-the-art techniques to simulate large scale quantum circuits on a variety of hardware. HybridQ provides tools to manipulate, develop, and extend noiseless and noisy circuits for different hardware architectures. HybridQ also supports large-scale high-performance computing (HPC) simulations, automatically balancing workload among different processor nodes and enabling the use of multiple backends to maximize parallel efficiency. Everything is then glued together by a simple and expressive language that allows seamless switching from one technique to another as well as from one hardware to the next, without the need to write lengthy translations, thus greatly simplifying the development of new hybrid algorithms and techniques.

Getting Started

Tutorials on how to use HybridQ can be found in hybridq/tutorials.

Contributors

Salvatore Mandrà
Jeffrey Marshall (noise models)

How To Cite

[1] S. Mandrà, J. Marshall, E. Rieffel, and R. Biswas, "HybridQ: A Hybrid Simulator for Quantum Circuits", IEEE/ACM Second International Workshop on Quantum Computing Software (QCS) (2021)

Publications Using HybridQ

[1] X. Mi, P. Roushan, C. Quintana, S. Mandrà, J. Marshall, et al., "Information scrambling in quantum circuits", Science 374, 6574 (2021)

Documentation

For technical documentation on how to use HybridQ, see hybridq/docs.

Installation

HybridQ can be installed by either using pip:

pip install hybridq

directly from the GitHub repository (to locally compile HybridQ C++ libraries):

pip install git+https://github.com/nasa/hybridq

using a zip file:

pip install hybridq.zip

or by using conda:

conda env create -f envinronment.yml

HybridQ is also available as docker container (compiled for a generic x86-64 architecture):

docker pull smandra/hybridq

Installation Troubleshoots

HybridQ depends on KaHyPar, which requires the Boost C++ Library installed in the system. To properly install KaHyPar, the following steps usually work:

  1. Clone KaHyPar:
git clone git@github.com:SebastianSchlag/kahypar.git /tmp/kahypar \
    --depth=1 \
    --recursive \
    --branch 1.2.1
  1. Force installation of minimal Boost library:
  • BSD:
sed -i '' -e "$(echo -e '/option(KAHYPAR_USE_MINIMAL_BOOST/,/)/c\' \
                "\noption(KAHYPAR_USE_MINIMAL_BOOST \"\" ON)")" \
          /tmp/kahypar/CMakeLists.txt
  • GNU:
sed -i '/option(KAHYPAR_USE_MINIMAL_BOOST/,/)/c\option(KAHYPAR_USE_MINIMAL_BOOST \"\" ON)'  \
          /tmp/kahypar/CMakeLists.txt
  1. Install KaHyPar:
export CXXFLAGS='-fPIC' && pip install -U /tmp/kahypar/ --force-reinstall

Alternatively, it is possible to use Conda to properly install KaHyPar:

  1. Clone/unzip HybridQ repository and enter local copy of repository
  2. Create new Conda environment: conda env create -f environment.yml
  3. Activate environment: conda activate hybridq
  4. Install dependencies: conda install make cmake libboost
  5. Export Boost library: export BOOST_ROOT=$CONDA_PREFIX
  6. Reinstall KaHyPar: pip install -U git+https://github.com/kahypar/kahypar@1.2.1 --force-reinstall

Depending on the system, the user may still need to install an updated version of gcc/g++ to complete the installation of KaHyPar. On MacOSX, it is suggested to use clang++ as compiler for KaHyPar because of potential linking problems. To force the use of clang++ to compile KaHyPar, run export CXX=clang++ before point 6.

OpenMP

HybridQ uses OpenMP to parallelize the C++ evolution core. However, clang on MacOSX does not directly support OpenMP. The easiest way to overcome this limitation is to install a version of g++ which support the standard C++17. Otherwise, HybridQ will be installed without OpenMP support.

MPI Auto-detection

HybridQ is able to auto-detect the use of MPI by checking if HybridQ has been launched by either using mpiexec or mpirun. However, auto-detection may be interfere with other libraries/software. To this end, HybridQ will ignore the auto-detection of MPI if DISABLE_MPI_AUTODETECT is set to any values, that is export DISABLE_MPI_AUTODETECT=1.

RuntimeError: Cannot set NUMBA_NUM_THREADS to a different value once the threads have been launched

After its first launch, quimb pre-compiles some parts of its library using numba. Such error arises when NUMBA_NUM_THREADS is changed after the quimb library is pre-cached. The error may be removed by clearing quimb cache as:

  1. Locate quimb installation folder: python -m pip show quimb
  2. Clear cache: rm -fr /path/to/quimb/__pycache__

If the problem persists, try to clean quimb cache and set NUMBA_NUM_THREADS to the desired number (typically, the number of physical cores).

Run HybridQ in a Docker Container

HybridQ supports the installation in Docker containers. To create a Docker container, it is sufficient to run:

docker-compose build

which will install HybridQ in the hybridq container (source files will be stored in /opt/hybridq/). The baseline for the Docker container is quay.io/pypa/manylinux2014_x86_64. By default, hybridq container is built by using the general native architecture. To use a different architecture, run for instance:

docker-compose build --build-arg ARCH=x86-64

with ARCH being any available gcc architecture. The container is built using python3.7. If a different version of python is needed, it is possible to specify its version in building time:

docker-compose build --build-arg PYTHON=cp38-cp38

Available versions are:

  • cp37-cp37m
  • cp38-cp38
  • cp39-cp39

Once the container is built, HybridQ can be directly used as follows:

docker run --rm hybridq -c 'hybridq /opt/hybridq/examples/circuit.qasm /dev/null --verbose'

and tests can be run as follows:

docker run --rm hybridq -c 'pytest -vx /opt/hybridq/tests/tests.py'

Licence

Copyright © 2021, United States Government, as represented by the Administrator of the National Aeronautics and Space Administration. All rights reserved.

The HybridQ: A Hybrid Simulator for Quantum Circuits platform is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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

hybridq-0.8.2.tar.gz (135.7 kB view details)

Uploaded Source

Built Distributions

hybridq-0.8.2-py3-none-manylinux2014_x86_64.whl (282.6 kB view details)

Uploaded Python 3

hybridq-0.8.2-py3-none-manylinux2010_x86_64.whl (283.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.12+ x86-64

hybridq-0.8.2-py3-none-macosx_10_9_x86_64.whl (656.8 kB view details)

Uploaded Python 3 macOS 10.9+ x86-64

File details

Details for the file hybridq-0.8.2.tar.gz.

File metadata

  • Download URL: hybridq-0.8.2.tar.gz
  • Upload date:
  • Size: 135.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.9.11

File hashes

Hashes for hybridq-0.8.2.tar.gz
Algorithm Hash digest
SHA256 636f6b774696264dc6e80e87261125a6b18e75bcca0314119dd00cf51cacfcad
MD5 9ac019057110d4c3f8c034e6f476682b
BLAKE2b-256 38232dc2a9d3618a609d887043f84b1bee2814ef729098c961848b95dd57babb

See more details on using hashes here.

File details

Details for the file hybridq-0.8.2-py3-none-manylinux2014_x86_64.whl.

File metadata

  • Download URL: hybridq-0.8.2-py3-none-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 282.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.9.11

File hashes

Hashes for hybridq-0.8.2-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 37fb75069c4bf17885e8963f45488de97aa2fc095d2b4b04d4fb80d1a1419e34
MD5 ff41984319e974d520eac2fd7b5f6c51
BLAKE2b-256 f8378250e863c63f985e6220103804283d4fd73c8c471e1872b0e61fe4cb8bce

See more details on using hashes here.

File details

Details for the file hybridq-0.8.2-py3-none-manylinux2010_x86_64.whl.

File metadata

  • Download URL: hybridq-0.8.2-py3-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 283.1 kB
  • Tags: Python 3, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.9.11

File hashes

Hashes for hybridq-0.8.2-py3-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 e4439b9c529b903570a5818139ebf326cefb9632778e7e80f1b6b9cec30d23eb
MD5 1733c006f028c870daa7619f7f447fe9
BLAKE2b-256 e03f5240b7ad83161b1df2deaee7c85a05cf2590855eb0a25b8973e2548c679f

See more details on using hashes here.

File details

Details for the file hybridq-0.8.2-py3-none-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: hybridq-0.8.2-py3-none-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 656.8 kB
  • Tags: Python 3, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.9.11

File hashes

Hashes for hybridq-0.8.2-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cb53b3a7ec9b910633373002ff25c244585fbc91298576be01e1dcefd3e153c0
MD5 50d71d4e5cf583838b3e21c930436068
BLAKE2b-256 b9b5bc0a994eecbbfdb242b5a7ba80a9fcc56b6a51ccd884dd12f3fa2e6620e4

See more details on using hashes here.

Supported by

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