diff --git a/.github/workflows/build-wheel-linux-x86_64.yaml b/.github/workflows/build-wheel-linux-x86_64.yaml index c703aa5970..b7104482fe 100644 --- a/.github/workflows/build-wheel-linux-x86_64.yaml +++ b/.github/workflows/build-wheel-linux-x86_64.yaml @@ -471,7 +471,7 @@ jobs: - name: Install PennyLane Plugins run: | python${{ matrix.python_version }} -m pip install PennyLane-Lightning-Kokkos - python${{ matrix.python_version }} -m pip install 'amazon-braket-pennylane-plugin>1.27.1' "boto3==1.26" + python${{ matrix.python_version }} -m pip install 'amazon-braket-pennylane-plugin>=1.31.0' - name: Install OQC client run: | @@ -492,7 +492,7 @@ jobs: python${{ matrix.python_version }} -m pytest frontend/test/pytest -n auto python${{ matrix.python_version }} -m pytest frontend/test/pytest --backend="lightning.kokkos" -n auto python${{ matrix.python_version }} -m pytest frontend/test/async_tests - # python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto + python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto python${{ matrix.python_version }} -m pytest frontend/test/test_oqc/oqc -n auto - name: Run Standalone Plugin Tests diff --git a/.github/workflows/build-wheel-macos-arm64.yaml b/.github/workflows/build-wheel-macos-arm64.yaml index 153b3b816c..b6a79be800 100644 --- a/.github/workflows/build-wheel-macos-arm64.yaml +++ b/.github/workflows/build-wheel-macos-arm64.yaml @@ -477,7 +477,7 @@ jobs: python${{ matrix.python_version }} -m pytest frontend/test/pytest -n auto python${{ matrix.python_version }} -m pytest frontend/test/pytest --backend="lightning.kokkos" -n auto python${{ matrix.python_version }} -m pytest frontend/test/async_tests - # python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto + python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto python${{ matrix.python_version }} -m pytest frontend/test/test_oqc/oqc -n auto - name: Run Standalone Plugin Tests diff --git a/.github/workflows/build-wheel-macos-x86_64.yaml b/.github/workflows/build-wheel-macos-x86_64.yaml index b51bf58b6e..9e99f3b6c3 100644 --- a/.github/workflows/build-wheel-macos-x86_64.yaml +++ b/.github/workflows/build-wheel-macos-x86_64.yaml @@ -445,7 +445,7 @@ jobs: # TODO: Uncomment after fixing https://github.com/PennyLaneAI/pennylane-lightning/issues/552 # python${{ matrix.python_version }} -m pytest frontend/test/pytest --backend="lightning.kokkos" -n auto python${{ matrix.python_version }} -m pytest frontend/test/async_tests - # python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto + python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto python${{ matrix.python_version }} -m pytest frontend/test/test_oqc/oqc -n auto - name: Run Standalone Plugin Tests diff --git a/.github/workflows/check-catalyst.yaml b/.github/workflows/check-catalyst.yaml index 396eea19e6..07c2c0120f 100644 --- a/.github/workflows/check-catalyst.yaml +++ b/.github/workflows/check-catalyst.yaml @@ -565,62 +565,62 @@ jobs: run: | make pytest TEST_BACKEND="lightning.kokkos" SKIP_OQD="true" -# frontend-tests-openqasm-device: -# name: Frontend Tests (backend="openqasm3") -# needs: [constants, llvm, runtime, quantum, determine_runner] -# runs-on: ${{ needs.determine_runner.outputs.runner_group }} -# strategy: -# matrix: -# compiler: ${{ fromJson(needs.constants.outputs.compilers) }} -# -# steps: -# - name: Checkout Catalyst repo -# uses: actions/checkout@v4 -# -# - name: Install device dependencies (OpenQasm device) -# run: | -# pip install amazon-braket-pennylane-plugin -# echo "AWS_DEFAULT_REGION=us-east-1" >> $GITHUB_ENV -# -# - name: Install Deps -# run: | -# sudo apt-get update -# sudo apt-get install -y python3 python3-pip libomp-dev libasan6 make ninja-build -# python3 --version | grep ${{ needs.constants.outputs.primary_python_version }} -# python3 -m pip install -r requirements.txt -# make frontend -# -# - name: Get Cached LLVM Build -# id: cache-llvm-build -# uses: actions/cache@v4 -# with: -# path: llvm-build -# key: ${{ runner.os }}-llvm-${{ needs.constants.outputs.llvm_version }}-default-build-${{ matrix.compiler }} -# fail-on-cache-miss: true -# -# - name: Download Quantum Build Artifact -# uses: actions/download-artifact@v4 -# with: -# name: quantum-build-${{ matrix.compiler }} -# path: quantum-build -# -# - name: Download Catalyst-Runtime Artifact -# uses: actions/download-artifact@v4 -# with: -# name: runtime-build-${{ matrix.compiler }} -# path: runtime-build/lib -# -# - name: Add Frontend Dependencies to PATH -# run: | -# echo "PYTHONPATH=$PYTHONPATH:$(pwd)/quantum-build/python_packages/quantum" >> $GITHUB_ENV -# echo "RUNTIME_LIB_DIR=$(pwd)/runtime-build/lib" >> $GITHUB_ENV -# echo "MLIR_LIB_DIR=$(pwd)/llvm-build/lib" >> $GITHUB_ENV -# echo "CATALYST_BIN_DIR=$(pwd)/quantum-build/bin" >> $GITHUB_ENV -# chmod +x $(pwd)/quantum-build/bin/catalyst-cli # artifact upload does not preserve permissions -# -# - name: Run Python Pytest Tests -# run: | -# make pytest TEST_BRAKET=LOCAL + frontend-tests-openqasm-device: + name: Frontend Tests (backend="openqasm3") + needs: [constants, llvm, runtime, quantum, determine_runner] + runs-on: ${{ needs.determine_runner.outputs.runner_group }} + strategy: + matrix: + compiler: ${{ fromJson(needs.constants.outputs.compilers) }} + + steps: + - name: Checkout Catalyst repo + uses: actions/checkout@v4 + + - name: Install device dependencies (OpenQasm device) + run: | + pip install amazon-braket-pennylane-plugin + echo "AWS_DEFAULT_REGION=us-east-1" >> $GITHUB_ENV + + - name: Install Deps + run: | + sudo apt-get update + sudo apt-get install -y python3 python3-pip libomp-dev libasan6 make ninja-build + python3 --version | grep ${{ needs.constants.outputs.primary_python_version }} + python3 -m pip install -r requirements.txt + make frontend + + - name: Get Cached LLVM Build + id: cache-llvm-build + uses: actions/cache@v4 + with: + path: llvm-build + key: ${{ runner.os }}-llvm-${{ needs.constants.outputs.llvm_version }}-default-build-${{ matrix.compiler }} + fail-on-cache-miss: true + + - name: Download Quantum Build Artifact + uses: actions/download-artifact@v4 + with: + name: quantum-build-${{ matrix.compiler }} + path: quantum-build + + - name: Download Catalyst-Runtime Artifact + uses: actions/download-artifact@v4 + with: + name: runtime-build-${{ matrix.compiler }} + path: runtime-build/lib + + - name: Add Frontend Dependencies to PATH + run: | + echo "PYTHONPATH=$PYTHONPATH:$(pwd)/quantum-build/python_packages/quantum" >> $GITHUB_ENV + echo "RUNTIME_LIB_DIR=$(pwd)/runtime-build/lib" >> $GITHUB_ENV + echo "MLIR_LIB_DIR=$(pwd)/llvm-build/lib" >> $GITHUB_ENV + echo "CATALYST_BIN_DIR=$(pwd)/quantum-build/bin" >> $GITHUB_ENV + chmod +x $(pwd)/quantum-build/bin/catalyst-cli # artifact upload does not preserve permissions + + - name: Run Python Pytest Tests + run: | + make pytest TEST_BRAKET=LOCAL runtime-device-tests: name: Runtime Tests (Linux) diff --git a/.github/workflows/check-pl-compat.yaml b/.github/workflows/check-pl-compat.yaml index 50476f0620..468e1a5994 100644 --- a/.github/workflows/check-pl-compat.yaml +++ b/.github/workflows/check-pl-compat.yaml @@ -39,7 +39,7 @@ jobs: git checkout $(git tag | sort -V | tail -1) - if: ${{ inputs.catalyst == 'release-candidate' }} run: | - git checkout v0.9.0-rc + git checkout v0.10.0-rc - name: Install deps run: | @@ -124,7 +124,7 @@ jobs: uses: actions/checkout@v4 with: repository: PennyLaneAI/pennylane-lightning - ref: v0.39.0_rc + ref: v0.40.0_rc path: lightning_build fetch-depth: 0 @@ -153,7 +153,7 @@ jobs: - name: Install PennyLane (release-candidate) if: ${{ inputs.pennylane == 'release-candidate' }} run: | - pip install --no-deps --force git+https://github.com/PennyLaneAI/pennylane@v0.39.0-rc0 + pip install --no-deps --force git+https://github.com/PennyLaneAI/pennylane@v0.40.0-rc0 - name: Add Frontend Dependencies to PATH run: | @@ -171,9 +171,9 @@ jobs: run: | make pytest TEST_BACKEND="lightning.kokkos" - # - name: Run Frontend Tests (Braket) - # run: | - # make pytest TEST_BRAKET=LOCAL + - name: Run Frontend Tests (Braket) + run: | + make pytest TEST_BRAKET=LOCAL - name: Run Demos run: | # Do not run demos in parallel, seems to cause package issues with numpy. diff --git a/.github/workflows/scripts/linux_arm64/rh8/test_wheels.sh b/.github/workflows/scripts/linux_arm64/rh8/test_wheels.sh index f8f6ab13fc..531dbcce1e 100644 --- a/.github/workflows/scripts/linux_arm64/rh8/test_wheels.sh +++ b/.github/workflows/scripts/linux_arm64/rh8/test_wheels.sh @@ -45,5 +45,5 @@ export PATH=/catalyst/llvm-build/bin:/opt/_internal/cpython-${PYTHON_MAJOR_MINOR /usr/bin/python3 -m pytest -v /catalyst/frontend/test/pytest -n auto /usr/bin/python3 -m pytest -v /catalyst/frontend/test/pytest --backend="lightning.kokkos" -n auto /usr/bin/python3 -m pytest /catalyst/frontend/test/async_tests -# /usr/bin/python3 -m pytest -v /catalyst/frontend/test/pytest --runbraket=LOCAL -n auto +/usr/bin/python3 -m pytest -v /catalyst/frontend/test/pytest --runbraket=LOCAL -n auto /usr/bin/python3 -m pytest /catalyst/frontend/test/test_oqc/oqc -n auto diff --git a/MANIFEST.in b/MANIFEST.in index 49183a875b..6452376cfd 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,4 +3,3 @@ recursive-include frontend/catalyst/lib * recursive-include frontend/catalyst/enzyme * recursive-include frontend/mlir_quantum * recursive-include frontend/catalyst/third_party/cuda/ *.toml -recursive-include frontend/catalyst/third_party/oqd/ *.toml diff --git a/Makefile b/Makefile index 1fc7b8908d..5f2d4de540 100644 --- a/Makefile +++ b/Makefile @@ -194,8 +194,6 @@ wheel: cp $(OQC_BUILD_DIR)/librtd_oqc* $(MK_DIR)/frontend/catalyst/lib cp $(OQC_BUILD_DIR)/oqc_python_module.so $(MK_DIR)/frontend/catalyst/lib cp $(OQC_BUILD_DIR)/backend/*.toml $(MK_DIR)/frontend/catalyst/lib/backend - cp $(OQD_BUILD_DIR)/librtd_oqd* $(MK_DIR)/frontend/catalyst/lib - cp $(OQD_BUILD_DIR)/backend/*.toml $(MK_DIR)/frontend/catalyst/lib/backend cp $(COPY_FLAGS) $(LLVM_BUILD_DIR)/lib/libmlir_float16_utils.* $(MK_DIR)/frontend/catalyst/lib cp $(COPY_FLAGS) $(LLVM_BUILD_DIR)/lib/libmlir_c_runner_utils.* $(MK_DIR)/frontend/catalyst/lib cp $(COPY_FLAGS) $(LLVM_BUILD_DIR)/lib/libmlir_async_runtime.* $(MK_DIR)/frontend/catalyst/lib diff --git a/doc/dev/devices.rst b/doc/dev/devices.rst index e030285439..7e86b5f1a4 100644 --- a/doc/dev/devices.rst +++ b/doc/dev/devices.rst @@ -95,16 +95,3 @@ Supported backend devices include: See the `Catalyst configuration file `__ for natively supported instructions. - - * - ``oqd.default`` - - - Experimental support for execution on `Open Quantum Design (OQD) `__ - trapped-ion hardware. To use OQD with Catalyst, use the ``backend`` argument to specify the - OQD backend to use when initializing the device: - - .. code-block:: python - - dev = qml.device("oqd", backend="default", shots=1024, wires=2) - - See the `Catalyst configuration file `__ - for natively supported instructions. diff --git a/doc/dev/installation.rst b/doc/dev/installation.rst index b3a72a0db8..a6e01d3a6b 100644 --- a/doc/dev/installation.rst +++ b/doc/dev/installation.rst @@ -481,6 +481,12 @@ If you require the Catalyst repository with all its submodules, clone it this wa git clone --recurse-submodules --shallow-submodules git@github.com:PennyLaneAI/catalyst.git +If you need to work on an existing branch, provide its name as a second argument: + +.. code-block:: console + + bash ./setup_dev_from_wheel.sh /path/to/virtual/env branch-name + How Does it Work? ^^^^^^^^^^^^^^^^^ @@ -495,8 +501,7 @@ using the installed Catalyst wheel libraries, hence avoiding compilation. Further Steps ^^^^^^^^^^^^^ -If everything goes well, ``git status`` should not report any changed files. - +``git status`` should not report any changed files when a branch name is not specified. Before making changes to the frontend, make sure you create a new branch: .. code-block:: console @@ -505,6 +510,9 @@ Before making changes to the frontend, make sure you create a new branch: Once in the new branch, make the wanted changes. Use the IDE of your preference. +When specifying a branch to switch to, ``git status`` might report changes in some files. +This is normal. Proceed to make changes in the selected branch. + You can test the changes by executing your sample code under the same virtual environment you used with the scripts. As files in the repository are hard-linked to the Wheel code, you are actually changing the code stored at the Python ``site-packages`` folder as well, and you will be automatically diff --git a/doc/dev/release_notes.rst b/doc/dev/release_notes.rst index 803cdd7c97..d0a972569e 100644 --- a/doc/dev/release_notes.rst +++ b/doc/dev/release_notes.rst @@ -5,6 +5,8 @@ This page contains the release notes for Catalyst. .. mdinclude:: ../releases/changelog-dev.md +.. mdinclude:: ../releases/changelog-0.10.0.md + .. mdinclude:: ../releases/changelog-0.9.0.md .. mdinclude:: ../releases/changelog-0.8.0.md diff --git a/doc/releases/changelog-0.10.0.md b/doc/releases/changelog-0.10.0.md new file mode 100644 index 0000000000..95edec5cf1 --- /dev/null +++ b/doc/releases/changelog-0.10.0.md @@ -0,0 +1,289 @@ +# Release 0.10.0 (current release) + +

New features since last release

+ +* Catalyst can now load and apply local MLIR plugins from the PennyLane frontend. + [(#1317)](https://github.com/PennyLaneAI/catalyst/pull/1317) + [(#1361)](https://github.com/PennyLaneAI/catalyst/pull/1361) + [(#1370)](https://github.com/PennyLaneAI/catalyst/pull/1370) + + Custom compilation passes and dialects in MLIR can be specified for use in Catalyst via a shared + object (`*.so` or `*.dylib` on MacOS) that implements the pass. Details on creating your own + plugin can be found in our + [compiler plugin documentation](https://docs.pennylane.ai/projects/catalyst/en/stable/dev/plugins.html). + At a high level, there are three ways to utilize a plugin once it's properly specified: + + * :func:`~.passes.apply_pass` can be used on QNodes when there is a + [Python entry point](https://packaging.python.org/en/latest/specifications/entry-points/) + defined for the plugin. + + ```python + @catalyst.passes.apply_pass(pass_name) + @qml.qnode(qml.device("lightning.qubit", wires=1)) + def qnode(): + return qml.state() + + @qml.qjit + def module(): + return qnode() + ``` + + * :func:`~.passes.apply_pass_plugin` can be used on QNodes when there is not an entry point + defined for the plugin. + + ```python + @catalyst.passes.apply_pass_plugin(path_to_plugin, pass_name) + @qml.qnode(qml.device("lightning.qubit", wires=1)) + def qnode(): + return qml.state() + + @qml.qjit + def module(): + return qnode() + ``` + + * Specifying multiple compilation pass plugins or dialect plugins directly in :func:`~.qjit` via + the `pass_plugins` and `dialect_plugins` keyword arguments, which must be lists of plugin paths. + + ```python + from pathlib import Path + + plugin = Path("shared_object_file.so") + + @qml.qnode(qml.device("lightning.qubit", wires=0)) + def qnode(): + qml.Hadamard(wires=0) + return qml.state() + + @qml.qjit(pass_plugins=[plugin], dialect_plugins=[plugin]) + def module(): + return catalyst.passes.apply_pass(qnode, "pass_name")() + ``` + + For more information on usage, + visit our [compiler plugin documentation](https://docs.pennylane.ai/projects/catalyst/en/stable/dev/plugins.html). + +

Improvements 🛠

+ +* The lightning runtime now supports finite shots with measuring expectation values of `qml.Hermitian`. + [(#451)](https://github.com/PennyLaneAI/catalyst/pull/451) + +* Pybind11 has been replaced with nanobind for C++/Python bindings in the frontend and in the runtime. + [(#1173)](https://github.com/PennyLaneAI/catalyst/pull/1173) + [(#1293)](https://github.com/PennyLaneAI/catalyst/pull/1293) + [(#1391)](https://github.com/PennyLaneAI/catalyst/pull/1391) + + Nanobind has been developed as a natural successor to the pybind11 library and offers a number of + [advantages](https://nanobind.readthedocs.io/en/latest/why.html#major-additions) like its ability + to target Python's [stable ABI interface](https://docs.python.org/3/c-api/stable.html) starting + with Python 3.12. + +* Catalyst now uses the new compiler API (`catalyst-cli`) to compile quantum code from the Python + frontend instead of using pybind11 as an interface between the compiler and the frontend. + [(#1285)](https://github.com/PennyLaneAI/catalyst/pull/1285) + +* Gates in the gate set `{T, S, Z, Hadamard, RZ, PhaseShift, CNOT}` now have MLIR decompositions to + the gate set `{RX, RY, MS}`, which are useful for trapped ion devices. + [(#1226)](https://github.com/PennyLaneAI/catalyst/pull/1226) + +* `qml.CosineWindow` is now compatible with QJIT. + [(#1166)](https://github.com/PennyLaneAI/catalyst/pull/1166) + +* All PennyLane templates are tested for QJIT compatibility. + [(#1161)](https://github.com/PennyLaneAI/catalyst/pull/1161) + +* Python is now decoupled from the Runtime by using the Python Global Interpreter Lock (GIL) instead + of custom mutexes. + [(#624)](https://github.com/PennyLaneAI/catalyst/pull/624) + + In addition, executables created using :func:`~.debug.compile_executable` no longer require + linking against Python shared libraries after decoupling Python from the Runtime C-API. + [(#1305)](https://github.com/PennyLaneAI/catalyst/pull/1305) + +* The readability of conditional passes in `catalyst.pipelines` has been improved. + [(#1194)](https://github.com/PennyLaneAI/catalyst/pull/1194) + +* The output of compiler instrumentation has been cleaned up by only printing stats after a `pipeline`. + It is still possible to get the more detailed output with `qjit(verbose=True)`. + [(#1343)](https://github.com/PennyLaneAI/catalyst/pull/1343) + +* Stable ABI wheels for Python 3.12 and up are now generated. + [(#1357)](https://github.com/PennyLaneAI/catalyst/pull/1357) + [(#1385)](https://github.com/PennyLaneAI/catalyst/pull/1385) + +* Two new circuit optimization passes, `--disentangle-CNOT` and `--disentangle-SWAP`, are available. + [(#1154)](https://github.com/PennyLaneAI/catalyst/pull/1154) + + The CNOT pass disentangles CNOT gates whenever possible, e.g., when the control bit is known to be + in the `|0>` state, the pass removes the CNOT. The pass uses a finite state machine to propagate + simple one-qubit states, in order to determine the input states to the CNOT. + + Similarly, the SWAP pass disentangles SWAP gates whenever possible by using a finite state machine + to propagate simple one-qubit states, similar to the `--disentangle-CNOT` pass. + + Both passes are implemented in accordance with the algorithm from + J. Liu, L. Bello, and H. Zhou, _Relaxed Peephole Optimization: A Novel Compiler Optimization for Quantum Circuits_, 2020, [arXiv:2012.07711](https://arxiv.org/abs/2012.07711) [quant-ph]. + +* Allow specifying a branch to switch to when setting up a dev environment from the wheels. + [(#1406)](https://github.com/PennyLaneAI/catalyst/pull/1406) + +

Breaking changes 💔

+ +* The `sample` and `counts` measurement primitives now support dynamic shot values across Catalyst, + although, on the PennyLane side, the device's shots is still constrained to a static integer + literal. + [(#1310)](https://github.com/PennyLaneAI/catalyst/pull/1310) + + To support this, `SampleOp` and `CountsOp` in MLIR no longer carry the shots attribute, since + integer attributes are tied to literal values and must be static. + + `DeviceInitOp` now takes in an optional SSA argument for shots, and the device init runtime CAPI + will take in this SSA shots value as an argument and set it as the device shots. The sample and + counts runtime CAPI functions no longer take in the shots argument and will retrieve shots from + the device. + + Correspondingly, the device C++ interface should no longer parse the `DeviceInitOp`'s attributes + dictionary for the shots. For now, we still keep the shots as an attribute so device implementors + can have time to migrate, but we will remove shots from the attribute dictionary in the next + release (`v0.11`) + +* The `toml` module has been migrated to PennyLane with an updated schema for declaring device + capabilities. Devices with TOML files using `schema = 2` will not be compatible with the latest + Catalyst. See the [Custom Devices documentation page](https://docs.pennylane.ai/projects/catalyst/en/stable/dev/custom_devices.html) + for updated instructions on integrating your device with Catalyst and PennyLane. + [(#1275)](https://github.com/PennyLaneAI/catalyst/pull/1275) + +* Handling for the legacy operator arithmetic (the `Hamiltonian` and `Tensor` classes in PennyLane) + has been removed. + [(#1308)](https://github.com/PennyLaneAI/catalyst/pull/1308) + +

Bug fixes 🐛

+ +* Fixed a bug introduced in 0.8 that breaks nested invocations of `qml.adjoint` and `qml.ctrl` (e.g., + `qml.adjoint(qml.adjoint(qml.H(0)))`). + [(#1301)](https://github.com/PennyLaneAI/catalyst/issues/1301) + +* Fixed a bug in :func:`~.debug.compile_executable` that would generate incorrect stride information for + array arguments of the function, in particular when non-64bit datatypes are used. + [(#1338)](https://github.com/PennyLaneAI/catalyst/pull/1338) + +

Internal changes ⚙️

+ +* Catalyst no longer depends on or pins the `scipy` package. Instead, OpenBLAS is sourced directly + from [`scipy-openblas32`](https://pypi.org/project/scipy-openblas32/) or + [Accelerate](https://developer.apple.com/accelerate/) is used. + [(#1322)](https://github.com/PennyLaneAI/catalyst/pull/1322) + [(#1328)](https://github.com/PennyLaneAI/catalyst/pull/1328) + +* The `QuantumExtension` module—previously implemented with pybind11—has been removed. This module + was not included in the distributed wheels and has been deprecated to align with our adoption of + Python's stable ABI, which pybind11 does not support. + [(#1187)](https://github.com/PennyLaneAI/catalyst/pull/1187) + +* Code for using `lightning.qubit` with Catalyst has been moved from the Catalyst repository to + the [Lightning repository](https://github.com/PennyLaneAI/pennylane-lightning) so that Catalyst + wheels will build faster. + [(#1227)](https://github.com/PennyLaneAI/catalyst/pull/1227) + [(#1307)](https://github.com/PennyLaneAI/catalyst/pull/1307) + [(#1312)](https://github.com/PennyLaneAI/catalyst/pull/1312) + +* `catalyst-cli` and `quantum-opt` are now compiled with `default` visibility, which allows for MLIR + plugins to work. + [(#1287)](https://github.com/PennyLaneAI/catalyst/pull/1287) + +* The patching mechanism of autograph's `allowlist` has been streamlined to only be used in places + where it's required. + [(#1332)](https://github.com/PennyLaneAI/catalyst/pull/1332) + [(#1337)](https://github.com/PennyLaneAI/catalyst/pull/1337) + +* Each qnode now has its own transformation schedule. Instead of relying on the name of the qnode, + each qnode now has a transformation module, which denotes the transformation schedule, embedded in + its MLIR representation. + [(#1323)](https://github.com/PennyLaneAI/catalyst/pull/1323) + +* The `apply_registered_pass_p` primitive has been removed and the API for scheduling passes to run + using the transform dialect has been refactored. In particular, passes are appended to a tuple as + they are being registered and they will be run in order. If there are no local passes, the global + `pass_pipeline` is scheduled. Furthermore, this commit also reworks the caching mechanism for + primitives, which is important as qnodes and functions are primitives and now that we can apply + passes to them, they are distinct based on which passes have been scheduled to run on them. + [(#1317)](https://github.com/PennyLaneAI/catalyst/pull/1317) + +* Python C-API calls have been replaced with Stable ABI calls. + [(#1354)](https://github.com/PennyLaneAI/catalyst/pull/1354) + +* A framework for loading and interacting with databases containing hardware information and + calibration data for Open Quantum Design (OQD) trapped-ion quantum devices has been added. + [(#1348)](https://github.com/PennyLaneAI/catalyst/pull/1348) + + A new module, `catalyst.utils.toml_utils`, was also added to assist in loading information from + these databases, which are stored as text files in TOML format. In particular, this module + contains a new function, :func:`~.utils.toml_utils.safe_eval`, to safely evaluate mathematical + expressions: + + ```python + >>> from catalyst.utils.toml_utils import safe_eval + >>> safe_eval("2 * math.pi * 1e9") + 6283185307.179586 + ``` + +* A default backend for OQD trapped-ion quantum devices has been added. + [(#1355)](https://github.com/PennyLaneAI/catalyst/pull/1355) + [(#1403)](https://github.com/PennyLaneAI/catalyst/pull/1355) + + Support for OQD devices is still under development, therefore the OQD modules are currently not + included in the distributed wheels. + +* As a step towards supporting dynamic shots across catalyst, `expval` and `var` operations no + longer keep the static shots attribute. + [(#1360)](https://github.com/PennyLaneAI/catalyst/pull/1360) + +* A new `ion` dialect has been added for Catalyst programs targeting OQD trapped-ion quantum devices. + [(#1260)](https://github.com/PennyLaneAI/catalyst/pull/1260) + [(#1372)](https://github.com/PennyLaneAI/catalyst/pull/1372) + + The `ion` dialect defines the set of physical properties of the device, such as the ion species + and their atomic energy levels, as well as the operations to manipulate the qubits in the + trapped-ion system, such as laser pulse durations, polarizations, detuning frequencies, etc. + + A new pass, `--quantum-to-ion`, has also been added to convert logical gate-based circuits in the + Catalyst `quantum` dialect to laser pulse operations in the `ion` dialect. This pass accepts + logical quantum gates from the set `{RX, RY, MS}`, where `MS` is the Mølmer–Sørensen gate. Doing + so enables the insertion of physical device parameters into the IR, which will be necessary when + lowering to OQD's backend calls. The physical parameters are read in from + [TOML](https://toml.io/en/) files during the `--quantum-to-ion` conversion. The TOML files are + assumed to exist by the pass (the paths to the TOML file locations are taken in as pass options), + with the intention that they are generated immediately before compilation during + hardware-calibration runs. + +* The Catalyst IR has been extended to support literal values as opposed to SSA Values for static + parameters of quantum gates by adding a new gate called `StaticCustomOp` with lowering to regular + `CustomOp`. + [(#1387)](https://github.com/PennyLaneAI/catalyst/pull/1387) + +

Documentation 📝

+ +* A new tutorial going through how to write a new MLIR pass is available. The tutorial writes an + empty pass that prints `hello world`. The code for the tutorial is located in + [a separate github branch](https://github.com/PennyLaneAI/catalyst/commit/ba7b3438667963b307c07440acd6d7082f1960f3). + [(#872)](https://github.com/PennyLaneAI/catalyst/pull/872) + +* The `catalyst-cli` documentation has been updated to reflect the removal of the `func-name` option + for transformation passes. + [(#1368)](https://github.com/PennyLaneAI/catalyst/pull/1368) + +

Contributors ✍️

+ +This release contains contributions from (in alphabetical order): + +Astral Cai, +Joey Carter, +David Ittah, +Erick Ochoa Lopez, +Mehrdad Malekmohammadi, +William Maxwell, +Romain Moyard, +Shuli Shu, +Ritu Thombre, +Raul Torres, +Paul Haochen Wang. diff --git a/doc/releases/changelog-0.9.0.md b/doc/releases/changelog-0.9.0.md index 8131f5d78b..cbf0e17cf9 100644 --- a/doc/releases/changelog-0.9.0.md +++ b/doc/releases/changelog-0.9.0.md @@ -1,4 +1,4 @@ -# Release 0.9.0 (current release) +# Release 0.9.0

New features

diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 2b90faf3ab..c0fe876fca 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -1,220 +1,19 @@ -# Release 0.10.0-dev (development release) +# Release 0.11.0 (development release)

New features since last release

-* Catalyst can now load local MLIR plugins from python. Including support for `entry_points`. - [(#1317)](https://github.com/PennyLaneAI/catalyst/pull/1317) - [(#1361)](https://github.com/PennyLaneAI/catalyst/pull/1361) - [(#1370)](https://github.com/PennyLaneAI/catalyst/pull/1370) -

Improvements 🛠

-* Lightning runtime shot-measurement support for Hermitian observables. - [(#451)](https://github.com/PennyLaneAI/catalyst/pull/451) - -* Replace pybind11 with nanobind for C++/Python bindings in the frontend and in the runtime. - [(#1173)](https://github.com/PennyLaneAI/catalyst/pull/1173) - [(#1293)](https://github.com/PennyLaneAI/catalyst/pull/1293) - [(#1391)](https://github.com/PennyLaneAI/catalyst/pull/1391) - - Nanobind has been developed as a natural successor to the pybind11 library and offers a number of - [advantages](https://nanobind.readthedocs.io/en/latest/why.html#major-additions), in particular, - its ability to target Python's [stable ABI interface](https://docs.python.org/3/c-api/stable.html) - starting with Python 3.12. - -* Catalyst now uses the new compiler API to compile quantum code from the python frontend. - Frontend no longer uses pybind11 to connect to the compiler. Instead, it uses subprocess instead. - [(#1285)](https://github.com/PennyLaneAI/catalyst/pull/1285) - -* Add a MLIR decomposition for the gate set {"T", "S", "Z", "Hadamard", "RZ", "PhaseShift", "CNOT"} - to the gate set {RX, RY, MS}. It is useful for trapped ion devices. It can be used thanks to - `quantum-opt --ions-decomposition`. - [(#1226)](https://github.com/PennyLaneAI/catalyst/pull/1226) - -* qml.CosineWindow is now compatible with QJIT. - [(#1166)](https://github.com/PennyLaneAI/catalyst/pull/1166) - -* All PennyLane templates are tested for QJIT compatibility. - [(#1161)](https://github.com/PennyLaneAI/catalyst/pull/1161) - -* Decouple Python from the Runtime by using the Python Global Interpreter Lock (GIL) instead of - custom mutexes. - [(#624)](https://github.com/PennyLaneAI/catalyst/pull/624) - - In addition, executables created using :func:`~.debug.compile_executable` no longer require - linking against Python shared libraries after decoupling Python from the Runtime C-API. - [(#1305)](https://github.com/PennyLaneAI/catalyst/pull/1305) - -* Improves the readability of conditional passes in pipelines - [(#1194)](https://github.com/PennyLaneAI/catalyst/pull/1194) - -* Cleans up the output of compiler instrumentation. - [(#1343)](https://github.com/PennyLaneAI/catalyst/pull/1343) - -* Generate stable ABI wheels for Python 3.12 and up. - [(#1357)](https://github.com/PennyLaneAI/catalyst/pull/1357) - [(#1385)](https://github.com/PennyLaneAI/catalyst/pull/1385) - -* A new circuit optimization pass, `--disentangle-CNOT`, is available. - [(#1154)](https://github.com/PennyLaneAI/catalyst/pull/1154) - - The pass disentangles CNOT gates whenever possible, e.g. when the control bit - is known to be in |0>, the pass removes the CNOT. The pass uses a finite state - machine to propagate simple one-qubit states, in order to determine - the input states to the CNOT. - - The algorithm is taken from [Relaxed Peephole Optimization: A Novel Compiler Optimization for Quantum Circuits, by Ji Liu, Luciano Bello, and Huiyang Zhou](https://arxiv.org/abs/2012.07711). - -* A new circuit optimization pass, `--disentangle-SWAP`, is available. - [(#1297)](https://github.com/PennyLaneAI/catalyst/pull/1297) - - The pass disentangles SWAP gates whenever possible by using a finite state - machine to propagate simple one-qubit states, similar to the `--disentangle-CNOT` pass. - - The algorithm is taken from [Relaxed Peephole Optimization: A Novel Compiler Optimization for Quantum Circuits, by Ji Liu, Luciano Bello, and Huiyang Zhou](https://arxiv.org/abs/2012.07711). -

Breaking changes 💔

-* The `sample` and `counts` measurement primitives now support dynamic shot values across catalyst, although at the PennyLane side, the device shots still is constrained to a static integer literal. - - To support this, `SampleOp` and `CountsOp` in mlir no longer carry the shots attribute, since integer attributes are tied to literal values and must be static. - - `DeviceInitOp` now takes in an optional SSA argument for shots, and the device init runtime CAPI will take in this SSA shots value as an argument and set it as the device shots. - The sample and counts runtime CAPI functions no longer take in the shots argument and will retrieve shots from the device. - - Correspondingly, the device C++ interface should no longer parse the `DeviceInitOp`'s attributes dictionary for the shots. - For now we still keep the shots as an attribute so device implementors can have time to migrate, but we will remove shots from the attribute dictionary in the next release. - - [(#1170)](https://github.com/PennyLaneAI/catalyst/pull/1170) - [(#1310)](https://github.com/PennyLaneAI/catalyst/pull/1310) - -* The `toml` module has been migrated to PennyLane with an updated schema for declaring device - capabilities. Devices with TOML files using `schema = 2` will not be compatible with the latest - Catalyst. See [Custom Devices](https://docs.pennylane.ai/projects/catalyst/en/stable/dev/custom_devices.html) - for updated instructions on integrating your device with Catalyst and PennyLane - [(#1275)](https://github.com/PennyLaneAI/catalyst/pull/1275) - -* Handling for the legacy operator arithmetic (the `Hamiltonian` and `Tensor` classes in PennyLane) - is removed. - [(#1308)](https://github.com/PennyLaneAI/catalyst/pull/1308) +

Deprecations 👋

Bug fixes 🐛

-* Fix bug introduced in 0.8 that breaks nested invocations of `qml.adjoint` and `qml.ctrl`. - [(#1301)](https://github.com/PennyLaneAI/catalyst/issues/1301) - -* Fix a bug in `debug.compile_executable` which would generate incorrect stride information for - array arguments of the function, in particular when non-64bit datatypes are used. - [(#1338)](https://github.com/PennyLaneAI/catalyst/pull/1338) - -

Deprecations 👋

-

Internal changes ⚙️

-* Catalyst no longer depends on or pins the `scipy` package, instead OpenBLAS is sourced directly - from [`scipy-openblas32`](https://pypi.org/project/scipy-openblas32/) or Accelerate is used. - [(#1322)](https://github.com/PennyLaneAI/catalyst/pull/1322) - [(#1328)](https://github.com/PennyLaneAI/catalyst/pull/1328) - -* The `QuantumExtension` module (previously implemented with pybind11) has been removed. This module - was not included in the distributed wheels and has been deprecated to align with our adoption of - Python's stable ABI, which pybind11 does not support. - [(#1187)](https://github.com/PennyLaneAI/catalyst/pull/1187) - -* Remove Lightning Qubit Dynamic plugin from Catalyst. - [(#1227)](https://github.com/PennyLaneAI/catalyst/pull/1227) - [(#1307)](https://github.com/PennyLaneAI/catalyst/pull/1307) - [(#1312)](https://github.com/PennyLaneAI/catalyst/pull/1312) - -* `catalyst-cli` and `quantum-opt` are compiled with `default` visibility, which allows for MLIR plugins to work. - [(#1287)](https://github.com/PennyLaneAI/catalyst/pull/1287) - -* Sink patching of autograph's allowlist. - [(#1332)](https://github.com/PennyLaneAI/catalyst/pull/1332) - [(#1337)](https://github.com/PennyLaneAI/catalyst/pull/1337) - -* Each qnode now has its own transformation schedule. - Instead of relying on the name of the qnode, each qnode now has a transformation module, - which denotes the transformation schedule, embedded in its MLIR representation. - [(#1323)](https://github.com/PennyLaneAI/catalyst/pull/1323) - -* The `apply_registered_pass_p` primitive is removed. The API for scheduling passes - to run using the transform dialect has been refactored. In particular, - passes are appended to a tuple as they are being registered and they will - be run in order. If there are no local passes, the global `pass_pipeline` is - scheduled. Furthermore, this commit also reworks the caching mechanism for - primitives, which is important as qnodes and functions are primitives and - now that we can apply passes to them, they are distinct based on which - passes have been scheduled to run on them. - [(#1317)](https://github.com/PennyLaneAI/catalyst/pull/1317) - -* Replace Python C-API calls with Stable ABI calls. - [(#1354)](https://github.com/PennyLaneAI/catalyst/pull/1354) - -* A framework for loading and interacting with databases containing hardware information and - calibration data for Open Quantum Design (OQD) trapped-ion quantum devices has been added. - [(#1348)](https://github.com/PennyLaneAI/catalyst/pull/1348) - - A new module, `catalyst.utils.toml_utils`, was also added to assist in loading information from - these databases, which are stored as text files in TOML format. In particular, this module - contains a new function, :func:`~.utils.toml_utils.safe_eval`, to safely evaluate mathematical - expressions: - - ```python - >>> from catalyst.utils.toml_utils import safe_eval - >>> safe_eval("2 * math.pi * 1e9") - 6283185307.179586 - ``` - -* A default backend for OQD trapped-ion quantum devices has been added. - [(#1355)](https://github.com/PennyLaneAI/catalyst/pull/1355) - -* `expval` and `var` operations no longer keep the static shots attribute, as a step towards supporting dynamic shots across catalyst. - [(#1360)](https://github.com/PennyLaneAI/catalyst/pull/1360) - -* A new `ion` dialect has been added for Catalyst programs targeting OQD trapped-ion quantum devices. - [(#1260)](https://github.com/PennyLaneAI/catalyst/pull/1260) - [(#1372)](https://github.com/PennyLaneAI/catalyst/pull/1372) - - The `ion` dialect defines the set of physical properties of the device, such as the ion species - and their atomic energy levels, as well as the operations to manipulate the qubits in the - trapped-ion system, such as laser pulse durations, polarizations, detuning frequencies, etc. - - A new pass, `--quantum-to-ion`, has also been added to convert logical gate-based circuits in the - Catalyst `quantum` dialect to laser pulse operations in the `ion` dialect. This pass accepts - logical quantum gates from the set {RX, RY, Mølmer–Sørensen (MS)}. Doing so enables the insertion - of physical device parameters into the IR, which will be necessary when lowering to OQD's backend - calls. The physical parameters are read in from [TOML](https://toml.io/en/) files during the - `--quantum-to-ion` conversion. The TOML files are assumed to exist by the pass (the paths to the - TOML file locations are taken in as pass options), with the intention that they are generated - immediately before compilation during hardware-calibration runs. - -* IR is now extended to support literal values as opposed to SSA Values for static parameters of - quantum gates by adding a new gate called StaticCustomOp with lowering to regular customOp. - [(#1387)](https://github.com/PennyLaneAI/catalyst/pull/1387) -

Documentation 📝

-* A new tutorial going through how to write a new MLIR pass is available. The tutorial writes an - empty pass that prints hello world. The code of the tutorial is at - [a separate github branch](https://github.com/PennyLaneAI/catalyst/commit/ba7b3438667963b307c07440acd6d7082f1960f3). - [(#872)](https://github.com/PennyLaneAI/catalyst/pull/872) - -* Updated catalyst-cli documentation to reflect the removal of func-name option for trasnformation passes. - [(#1368)](https://github.com/PennyLaneAI/catalyst/pull/1368) -

Contributors ✍️

This release contains contributions from (in alphabetical order): - -Astral Cai, -Joey Carter, -David Ittah, -Erick Ochoa Lopez, -Mehrdad Malekmohammadi, -William Maxwell -Romain Moyard, -Shuli Shu, -Ritu Thombre, -Raul Torres, -Paul Haochen Wang. diff --git a/frontend/catalyst/_version.py b/frontend/catalyst/_version.py index 5b6f37e69b..6f24d5f16e 100644 --- a/frontend/catalyst/_version.py +++ b/frontend/catalyst/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.10.0-dev35" +__version__ = "0.11.0-dev0" diff --git a/frontend/test/lit/test_multi_qubit_gates.py b/frontend/test/lit/test_multi_qubit_gates.py index eae80ae881..95f4212b10 100644 --- a/frontend/test/lit/test_multi_qubit_gates.py +++ b/frontend/test/lit/test_multi_qubit_gates.py @@ -69,19 +69,21 @@ def circuit(): # We should replace instead create a custom device that has support for ISWAP # and PSWAP (which I think are unsupported in lightning.qubit and hence why they # would be decomposed. -# COM: CHECK-LABEL: public @jit_circuit +""" + + +# CHECK-LABEL: public @jit_circuit @qjit(target="mlir") @qml.qnode(qml.device("braket.local.qubit", wires=2, shots=100)) def circuit(x: float): - # COM: CHECK: {{%.+}} = quantum.custom "ISWAP"() {{.+}} : !quantum.bit, !quantum.bit + # CHECK: {{%.+}} = quantum.custom "ISWAP"() {{.+}} : !quantum.bit, !quantum.bit qml.ISWAP(wires=[0, 1]) - # COM: CHECK: {{%.+}} = quantum.custom "PSWAP"({{%.+}}) {{.+}} : !quantum.bit, !quantum.bit + # CHECK: {{%.+}} = quantum.custom "PSWAP"({{%.+}}) {{.+}} : !quantum.bit, !quantum.bit qml.PSWAP(x, wires=[0, 1]) return qml.probs() print(circuit.mlir) -""" # CHECK-LABEL: public @jit_isingZZ_circuit diff --git a/frontend/test/pytest/test_braket_local_devices.py b/frontend/test/pytest/test_braket_local_devices.py index c8c999d5e5..8dd4ddd154 100644 --- a/frontend/test/pytest/test_braket_local_devices.py +++ b/frontend/test/pytest/test_braket_local_devices.py @@ -23,9 +23,9 @@ try: qml.device("braket.local.qubit", backend="default", wires=1) -except (qml.DeviceError, ImportError): +except qml.DeviceError: pytest.skip( - "skipping Braket local tests because ``amazon-braket-pennylane-plugin`` is not installed or could not be imported", + "skipping Braket local tests because ``amazon-braket-pennylane-plugin`` is not installed", allow_module_level=True, ) diff --git a/setup.py b/setup.py index 0926063144..704e89029c 100644 --- a/setup.py +++ b/setup.py @@ -84,7 +84,6 @@ entry_points = { "pennylane.plugins": [ "oqc.cloud = catalyst.third_party.oqc:OQCDevice", - "oqd = catalyst.third_party.oqd:OQDDevice", "softwareq.qpp = catalyst.third_party.cuda:SoftwareQQPP", "nvidia.custatevec = catalyst.third_party.cuda:NvidiaCuStateVec", "nvidia.cutensornet = catalyst.third_party.cuda:NvidiaCuTensorNet", @@ -331,7 +330,11 @@ def run(self): packages=find_namespace_packages( where="frontend", include=["catalyst", "catalyst.*", "mlir_quantum"], - exclude=["catalyst.third_party.oqc.*"], + exclude=[ + "catalyst.third_party.oqc.*", + "catalyst.third_party.oqd.*", + "catalyst.third_party.oqd", # Exclude OQD from wheels as it is still under development + ], ), package_dir={"": "frontend"}, include_package_data=True, diff --git a/setup_dev_from_wheel.sh b/setup_dev_from_wheel.sh index 62905b56f6..d9aab33377 100644 --- a/setup_dev_from_wheel.sh +++ b/setup_dev_from_wheel.sh @@ -3,6 +3,9 @@ # Python environment path PYTHON_ENV_PATH=$1 +# Branch to switch to +BRANCH=$2 + # Exit on any error set -e @@ -69,6 +72,11 @@ checkout_nightly_build(){ link_repo_to_wheel(){ echo "Linking Catalyst repository to Catalyst Wheel..." + + # switch to branch if given + if [ ! -z "${BRANCH}" ]; then + git switch $BRANCH + fi export SITEPKGS=$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])') export CATALYST_WHEEL=$SITEPKGS/catalyst @@ -81,7 +89,7 @@ restore_catalyst_config(){ # After linking the Wheel sources, _configuration.py will contain the entry: 'INSTALLED=True'. # Hence, we restore the file from the repository. cd $CATALYST_DIR - git checkout frontend/catalyst/_configuration.py + git checkout frontend/catalyst/_configuration.py frontend/catalyst/_version.py } report_changed_files(){