Skip to main content

OpenQL Python Package

Project description

OpenQL Framework

Documentation Status Travis Build Status GitHub Actions Build Status PyPI Anaconda

OpenQL is a framework for high-level quantum programming in C++/Python. The framework provides a compiler for compiling and optimizing quantum code. The compiler produces the intermediate quantum assembly language and the compiled micro-code for various target platforms. While the microcode is platform-specific, the quantum assembly code (in cQASM format) is hardware-agnostic and can be simulated on the QX simulator.

OpenQL's source code is released under the Apache 2.0 license.

For detailed user and contributor documentation, please visit the ReadTheDocs page.

Dependencies

The following utilities are required to compile OpenQL from sources:

  • C++ compiler with C++23 support (gcc 11, clang 14, msvc 17)
  • CMake >= 3.12
  • git
  • Python 3.x plus pip, with the following package:
    • conan >= 2.0

Python build specific dependencies

  • SWIG (Linux: >= 3.0.12, Windows: >= 4.0.0)
  • Optionally:
    • Documentation generation: doxygen
    • Convert graphs from dot to pdf, png, etc: Graphviz Dot utility
    • Visualize generated graphs in dot format: XDot
    • Use the visualizer in MacOS: XQuartz
  • And the following Python packages:
    • plumbum
    • qxelarator
    • setuptools
    • wheel
    • Optionally:
      • Testing: numpy, and pytest
      • Documentation generation: m2r2, sphinx==7.0.0, and sphinx-rtd-theme

ARM specific dependencies

We are having problems when using the m4 and zulu-opendjk Conan packages on an ARMv8 architecture. m4 is required by Flex/Bison and zulu-openjdk provides the Java JRE required by the ANTLR generator. So, for the time being, we are installing Flex/Bison and Java manually for this platform.

  • Flex >= 2.6.4
  • Bison >= 3.0
  • Java JRE >= 11

Build

This version of OpenQL can only be compiled via the conan package manager. You'll need to create a default profile before using it for the first time.

The installation of OpenQL dependencies, as well as the compilation, can be done in one go.

git clone https://github.com/QuTech-Delft/OpenQL.git
cd OpenQL
conan profile detect
conan build . -pr=conan/profiles/tests-debug -b missing

Notice:

  • the conan profile command only has to be run only once, and not before every build.
  • the conan build command is building OpenQL in Debug mode with tests using the tests-debug profile.
  • the -b missing parameter asks conan to build packages from sources in case it cannot find the binary packages for the current configuration (platform, OS, compiler, build type...).

Build profiles

A group of predefined profiles is provided under the conan/profiles folder. They follow the [tests-](debug|release)[-unitary] naming convention. For example:

  • release is a Release build without tests and unitary decomposition disabled.
  • tests-debug-unitary is a Debug build with tests and unitary decomposition enabled.

All the profiles set the C++ standard to 23.

Build options

Profiles are a shorthand for command line options. The command above could be written as well as:

conan build . -s:h compiler.cppstd=23 -s:h openql/*:build_type=Debug -o openql/*:build_tests=True -o openql/*:disable_unitary=True -b missing

These are the list of options that could be specified whether in a profile or in the command line:

  • openql/*:build_type: defaulted to Release, set to Debug if you want Debug builds.
  • openql/*:build_tests: defaulted to False, set to True if you want to build tests.
  • openql/*:disable_unitary: defaulted to False, set to True if you want to disable unitary decomposition.
  • openql/*:shared: defaulted to False, set to True if you want OpenQL to be built as a shared library. The default option is mandatory on Windows.

Install

From Python

Install from the project root directory as follows:

python3 -m pip install -v .

You can test if it works by running:

python3 -m pytest -v

From C++

The CMakeLists.txt file in the root directory includes install targets:

conan create --version 0.11.2 . tests-debug -b missing

You can test if it works by doing:

cd test/Debug
ctest -C Debug --output-on-failure

Use from another project

From Python

After installation, you should be able to use the bindings for the original API by just import openql as ql. The new API doesn't have Python bindings yet.

From C++

The easiest way to use OpenQL in a CMake project is to fetch the library and then link against it.

include(FetchContent)
FetchContent_Declare(OpenQL
    GIT_REPOSITORY https://github.com/QuTech-Delft/OpenQL.git
    GIT_TAG "<a given cqasm git tag>"
)
FetchContent_MakeAvailable(OpenQL)
target_include_directories(<your target> SYSTEM PRIVATE "${OpenQL_SOURCE_DIR}/include")
target_link_libraries(<your target> PUBLIC ql)

Note that the following dependencies are required for OpenQL to build:

  • Flex >= 2.6.4
  • Bison >= 3.0
  • Java JRE >= 11

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

qutechopenql-0.12.2-cp312-cp312-win_amd64.whl (3.6 MB view hashes)

Uploaded CPython 3.12 Windows x86-64

qutechopenql-0.12.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.8 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

qutechopenql-0.12.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (6.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.27+ ARM64 manylinux: glibc 2.28+ ARM64

qutechopenql-0.12.2-cp312-cp312-macosx_10_10_universal2.whl (6.4 MB view hashes)

Uploaded CPython 3.12 macOS 10.10+ universal2 (ARM64, x86-64)

qutechopenql-0.12.2-cp311-cp311-win_amd64.whl (3.6 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

qutechopenql-0.12.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.8 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

qutechopenql-0.12.2-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (6.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.27+ ARM64 manylinux: glibc 2.28+ ARM64

qutechopenql-0.12.2-cp311-cp311-macosx_10_10_universal2.whl (6.4 MB view hashes)

Uploaded CPython 3.11 macOS 10.10+ universal2 (ARM64, x86-64)

qutechopenql-0.12.2-cp310-cp310-win_amd64.whl (3.6 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

qutechopenql-0.12.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.8 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

qutechopenql-0.12.2-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (6.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.27+ ARM64 manylinux: glibc 2.28+ ARM64

qutechopenql-0.12.2-cp310-cp310-macosx_11_0_x86_64.whl (6.4 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ x86-64

qutechopenql-0.12.2-cp39-cp39-win_amd64.whl (3.6 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

qutechopenql-0.12.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.8 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

qutechopenql-0.12.2-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (6.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.27+ ARM64 manylinux: glibc 2.28+ ARM64

qutechopenql-0.12.2-cp39-cp39-macosx_11_0_x86_64.whl (6.4 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ x86-64

qutechopenql-0.12.2-cp38-cp38-win_amd64.whl (3.6 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

qutechopenql-0.12.2-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.8 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

qutechopenql-0.12.2-cp38-cp38-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (6.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.27+ ARM64 manylinux: glibc 2.28+ ARM64

qutechopenql-0.12.2-cp38-cp38-macosx_11_0_x86_64.whl (6.4 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ x86-64

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