Skip to main content

Python wrapper for the MIMIQ Quantanium statevector engine.

Project description

Quantanium-python

Python Wrapper for the MIMIQ Quantanium statevector engine.

Prerequisites

Before installing, ensure you have:

  • Python (version 3.10, 3.11, or 3.12)
  • Git installed on your system
  • Virtual environment support (e.g., venv)

Installation

Quantanium is implemented in C++, with a wrapper written in the Python programming language to enhance usability and ensure support with MIMIQ API. For the released versions of Quantanium, we provide binaries via our Git repository, specifically for the Linux platform, which only require a functional Python environment to install. You can do this very easily following the instructions from the next subsection.

Installation Quantanium-python from Binary

Installation Steps:

create a new python environment:

python -m venv .quantanium_venv

activate your environment:

source .quantanium/bin/acitvate

Download the latest release here: https://github.com/qperfect-io/quantanium-python/releases/latest

Extract the content of the zip file using

To install the wheel make sure to select the correct file for your system.

  • the number after cp[NUM] in the name of the whl file must match your python version
  • If you are using macos take the file with macos included in the name, otherwise take the file with manylinux. (not built for windows yet)

For example to install the wheels on ubuntu for python 3.12 run:

pip install  quantaniumpy-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Troubleshooting

  • If installation fails, check that you have the correct Python version (python --version).
  • Ensure all dependencies are installed.
  • In some cases you should consider upgrading via the 'pip install --upgrade pip' command.

Installation from Source

You can also build and install Quantaniumpy from source. Note, in this way, a g++ or clang++ compiler is necessary: make sure that the compiler installed.

In order to install quantaniumpy from source, please follow the next set of instructions:

  1. Clone this repository with
$ git git@git.unistra.fr:code-quantum/quantanium.git
$ cd quantanium
  1. Initialize all the dependencies of the project by typing the following instruction in the command line of your shell terminal:
$ git submodule init && git submodule update
  1. Setup the build directory and build C++ code with python wrapper support by the following instructions in the command line of your shell terminal:
$ mkdir release-python

$ cd release-python

$ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On -DQUANTANIUM_WITH_PYTHON=On ../

$ cmake --build . -j 4
  1. Since C++ source code is built, you have to prepare your library environement. In order to do this, please, navigate to root folder of the project quantanium and make the following set of commands:
$ cd ..
$ mkdir python/quantaniumpy/lib
$ cp release-python/lib/quantaniumpy.cpython-310-x86_64-linux-gnu.so python/quantaniumpy/lib
$ export PYTHONPATH=$PYTHONPATH:../../release-python/lib
  • You may need to export path to spdlog library:
export LD_LIBRARY_PATH=../../release-python/libs/spdlog
  1. Building the Python Package with Poetry
  • Navigate to the directory of the python project (supposing you are still in the root folder of the project quantanium):
cd python/
  • Set up Python virtual development environment

Virtual environments are used for development to isolate the development environment from system-wide packages. This way helps to avoid inadvertently becoming dependent on a particular system configuration and makes it easy to maintain multiple environments: e.g. for older versions of Quantanium. Start by creating a new virtual environment with venv:

python -m venv ~/.venvs/quapy 

Activate the environment by invoking the activation command:

source ~/.venvs/quapy/bin/activate
  • Ensure you have Poetry installed. If you don't have it installed, you can install it using the following command:
python -m pip install poetry
  • Build the package using Poetry:
poetry build
  1. Install the package, use pip to install the wheel file generated by Poetry:
pip install dist/quantaniumpy-0.1.0-py3-none-any.whl

Accessible Functions

All accessible functions are defined within the Quantanium class inside Quantanium.py. These include:

  • convert_qasm_to_qua_circuit(qasm_file): Converts a QASM file to a qua::Circuit.
  • convert_qua_to_mimiq_circuit(qua_circuit): Converts a qua::Circuit to a mimiq::Circuit.
  • convert_mimiq_to_qua_circuit(mimiq_circuit): Converts a mimiq::Circuit back to a qua::Circuit.
  • convert_qua_results_to_mimiq_results(qua_results): Converts qua::Results to mimiq::Results.
  • execute(circuit, label="pyapi_v1.0", algorithm="auto", nsamples=1000, bitstrings=None, timelimit=300, bonddim=None, entdim=None, seed=None, qasmincludes=None): Executes the given circuit.

Quick Start

In order to start, you can use an example script from folder examples, e.g.:

$ python examples/example_qasm.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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

quantanium-0.1.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

quantanium-0.1.12-cp312-cp312-macosx_13_0_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 13.0+ x86-64

quantanium-0.1.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

quantanium-0.1.12-cp311-cp311-macosx_13_0_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 13.0+ x86-64

quantanium-0.1.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

quantanium-0.1.12-cp310-cp310-macosx_13_0_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 13.0+ x86-64

File details

Details for the file quantanium-0.1.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quantanium-0.1.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ce0a6ee1a401335fd2e76ad26bb703ee2bf6f1287ebe41e5d1c0869db181ab5
MD5 c178840916bd21b640d008ab51d4beea
BLAKE2b-256 97da84fcb299041978a06f0e4445f89901aa50f9b2633ff6cd30f03b7b98848b

See more details on using hashes here.

File details

Details for the file quantanium-0.1.12-cp312-cp312-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for quantanium-0.1.12-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 cf4a27ea8ecc8fcf5655f62113bb7f3ab5f8c54374563f993cc94ab6dc7568d7
MD5 1b75fee96ed85735a916a3f5aa680ae5
BLAKE2b-256 d75499b45ae9d148c90409131b5b17320c8ae84a2f17780c8e284a262710891c

See more details on using hashes here.

File details

Details for the file quantanium-0.1.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quantanium-0.1.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 576442be51ad1a6a45dfece8c6cd912f59bf3cb399ccde88c2698609a3845957
MD5 7d88c15ece19db073799747a2f900c46
BLAKE2b-256 04af7e6cd0a1b203b8d865023a31c1adec12766c01866d1f6880126fd71b4a5a

See more details on using hashes here.

File details

Details for the file quantanium-0.1.12-cp311-cp311-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for quantanium-0.1.12-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 95fdcd10753bff809a89f963529b236ad27308e5c0eea6e2058d39e6fb602f02
MD5 2bd115db4f554afbd11a93f119203095
BLAKE2b-256 a24bf4be839c285abfb6bae7bef1606c8de2c1b5d411d6d89e2640e8188f74d0

See more details on using hashes here.

File details

Details for the file quantanium-0.1.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for quantanium-0.1.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 801150c1bcba0c830a7184cf4df57ff0b8819806688a619d702da72a70ac8a4e
MD5 a66b42972992d9fd9d83f7f14777b6e5
BLAKE2b-256 0427106d038658b6bddcf10adabfa8c9408b88449a01a95c689edbae34e2f89c

See more details on using hashes here.

File details

Details for the file quantanium-0.1.12-cp310-cp310-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for quantanium-0.1.12-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 178d1f6b0cb0553d442289110aa9597f4d24ac53f194156dcac1f05ec3ef9669
MD5 5f4a6b0c3b82a2ca2a2f29be1f21684c
BLAKE2b-256 3fc487f55db9071ae876e8b3f620d433b3e88928fddb6941b48245a45be5991c

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