Skip to content

Commit

Permalink
Merge pull request #3 from unitaryfund/qrack_source_install
Browse files Browse the repository at this point in the history
Install Qrack from source on build
  • Loading branch information
WrathfulSpatula authored May 29, 2024
2 parents 81e0ec8 + cd416b3 commit 3149766
Show file tree
Hide file tree
Showing 11 changed files with 346 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- uses: actions/checkout@v2

- name: Run Black
run: black -l 100 pennylane_qulacs/ --check
run: black -l 100 pennylane_qrack/ --check
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "catalyst"]
path = catalyst
url = https://github.com/PennyLaneAI/catalyst.git

15 changes: 6 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@ project(qrack_device)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option (ENABLE_OPENCL "Use OpenCL optimizations" ON)
find_package (OpenCL)
option(ENABLE_OPENCL "Use OpenCL optimizations" ON)
find_package(OpenCL)
if (NOT OpenCL_FOUND)
set (ENABLE_OPENCL OFF)
endif (NOT OpenCL_FOUND)

link_directories(/usr/local/lib/qrack /usr/lib/qrack)

add_library(qrack_device SHARED pennylane_qrack/qrack_device.cpp)
target_link_directories(qrack_device PUBLIC ${CMAKE_SOURCE_DIR}/catalyst/runtime/include /usr/local/lib/qrack /usr/lib/qrack "C:\\Program Files\\qrack")
target_include_directories(qrack_device PUBLIC ${CMAKE_SOURCE_DIR}/catalyst/runtime/include)
if (ENABLE_OPENCL)
target_link_libraries(qrack_device qrack OpenCL)
target_link_libraries(qrack_device PUBLIC qrack OpenCL)
else (ENABLE_OPENCL)
target_link_libraries(qrack_device qrack)
target_link_libraries(qrack_device PUBLIC qrack)
endif (ENABLE_OPENCL)
target_include_directories(qrack_device PUBLIC catalyst/runtime/include)
set_property(TARGET qrack_device PROPERTY POSITION_INDEPENDENT_CODE ON)
install(TARGETS qrack_device LIBRARY DESTINATION pennylane_qrack)

2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include pennylane_qrack/*
include catalyst/runtime/lib/backend/common/*
include catalyst/runtime/include/*
include Makefile
include CMakeLists.txt
include requirements.txt
Expand Down
25 changes: 21 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,50 @@ This plugin is addapted from the `PennyLane-Qulacs plugin, <https://github.com/P

`PennyLane <https://pennylane.readthedocs.io>`__ is a cross-platform Python library for quantum machine learning, automatic differentiation, and optimization of hybrid quantum-classical computations.

`vm6502q/qrack <https://github.com/vm6502q>`__ is a software library for quantum computing, written in C++ and with GPU support.
`unitaryfund/qrack <https://github.com/unitaryfund/qrack>`__ (formerly **vm6502q/qrack**) is a software library for quantum computing, written in C++ and with GPU support.

Features
========

* Provides access to a PyQrack simulator backend via the ``qrack.simulator`` device
* Provides access to a (C++) Qrack simulator backend for Catalyst (also) via the ``qrack.simulator`` device

Installation
============

This plugin requires Python version 3.6 or above, as well as PennyLane. Installation of this plugin, as well as all dependencies, can be done using ``pip``:
This plugin requires Python version 3.6 or above, as well as PennyLane and the Qrack library.

You can choose to go the `releases <https://github.com/unitaryfund/qrack/releases>`__ page of Qrack to download a packaged artifact for your system and **install it in your system directories** (like `/usr` or `/usr/local` on Linux and UNIX based systems, including Mac), **or** you can opt to **build and install from source**, which might be easier, and this gives you maximum control over build configurations, like choice of CUDA over OpenCL GPU acceleration!

See the Qrack README and documentation for the many build options of qrack, but, after checking out the Qrack repository and entering its root folder, this might be the best and simplest way to build and install Qrack:

```sh
$ mkdir _build
$ cd _build
$ cmake -DCPP_STD=14 ..
$ make all -j$(nproc --all)
$ sudo make install
```

After installing Qrack, installation of this plugin as well as all its Python dependencies can be done using ``pip`` (or ``pip3``, as appropriate):

.. code-block:: bash
$ pip install pennylane-qrack
$ pip3 install pennylane-qrack
Dependencies
~~~~~~~~~~~~

PennyLane-Qrack requires the following libraries be installed:

* `Python <http://python.org/>`__ >= 3.8
* `Qrack <https://github.com/unitaryfund/qrack>`__ >= 9.0

as well as the following Python packages:

* `PennyLane <http://pennylane.readthedocs.io/>`__ >= 0.32
* `PyQrack <https://github.com/vm6502q/pyqrack>`__ >= 0.13.0
* `Catalyst <https://docs.pennylane.ai/projects/catalyst/en/stable/index.html>`__ >= 0.6
* `PyQrack <https://github.com/vm6502q/pyqrack>`__ >= 1.28.0


If you currently do not have Python 3 installed, we recommend
Expand Down
2 changes: 1 addition & 1 deletion catalyst
Submodule catalyst updated 47 files
+1 −1 .dep-versions
+53 −2 doc/changelog.md
+1 −0 doc/conf.py
+116 −29 doc/dev/installation.rst
+1 −0 doc/requirements.txt
+95 −65 frontend/catalyst/api_extensions/callbacks.py
+32 −9 frontend/catalyst/api_extensions/differentiation.py
+11 −3 frontend/catalyst/api_extensions/error_mitigation.py
+134 −91 frontend/catalyst/api_extensions/function_maps.py
+2 −1 frontend/catalyst/compiler.py
+10 −1 frontend/catalyst/device/__init__.py
+10 −7 frontend/catalyst/device/decomposition.py
+201 −26 frontend/catalyst/device/qjit_device.py
+8 −5 frontend/catalyst/jax_tracer.py
+576 −572 frontend/catalyst/jit.py
+29 −16 frontend/catalyst/qfunc.py
+2 −2 frontend/catalyst/third_party/cuda/catalyst_to_cuda_interpreter.py
+0 −263 frontend/catalyst/utils/runtime.py
+38 −0 frontend/catalyst/utils/runtime_environment.py
+66 −10 frontend/catalyst/utils/toml.py
+230 −185 frontend/test/lit/test_decomposition.py
+90 −94 frontend/test/lit/test_quantum_control.py
+24 −29 frontend/test/pytest/test_config_functions.py
+4 −3 frontend/test/pytest/test_custom_devices.py
+1 −1 frontend/test/pytest/test_debug.py
+42 −55 frontend/test/pytest/test_decomposition.py
+8 −8 frontend/test/pytest/test_device_api.py
+51 −0 frontend/test/pytest/test_gradient.py
+17 −0 frontend/test/pytest/test_jit_behaviour.py
+33 −0 frontend/test/pytest/test_mid_circuit_measurement.py
+26 −0 frontend/test/pytest/test_mitigation.py
+84 −24 frontend/test/pytest/test_preprocess.py
+30 −0 frontend/test/pytest/test_vmap.py
+1 −0 mlir/include/Catalyst/Transforms/Passes.h
+11 −0 mlir/include/Catalyst/Transforms/Passes.td
+28 −0 mlir/include/Gradient/Transforms/EnzymeConstants.h
+1 −0 mlir/lib/Catalyst/Transforms/CMakeLists.txt
+1 −0 mlir/lib/Catalyst/Transforms/RegisterAllPasses.cpp
+67 −0 mlir/lib/Catalyst/Transforms/RegisterInactiveCallbackPass.cpp
+1 −1 mlir/lib/Catalyst/Transforms/catalyst_to_llvm.cpp
+1 −7 mlir/lib/Gradient/Transforms/ConversionPatterns.cpp
+1 −1 mlir/test/Catalyst/ConversionTest.mlir
+56 −0 mlir/test/Catalyst/RegisterInactive.mlir
+2 −2 runtime/CMakeLists.txt
+31 −8 runtime/lib/backend/lightning/CMakeLists.txt
+1 −1 runtime/lib/capi/ExecutionContext.hpp
+1 −1 runtime/lib/capi/RuntimeCAPI.cpp
Loading

0 comments on commit 3149766

Please sign in to comment.