Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BlockEncode support to Catalyst #483

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build-wheel-linux-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ jobs:
fail-on-cache-miss: True

# Build Catalyst-Runtime
# TODO: Update git tag to v0.35.0 after the next lightning release.
- name: Build Catalyst-Runtime
run: |
cmake -S runtime -B runtime-build -G Ninja \
Expand All @@ -278,7 +279,7 @@ jobs:
-DPYTHON_EXECUTABLE=$(which python${{ matrix.python_version }}) \
-Dpybind11_DIR=$(python${{ matrix.python_version }} -c "import pybind11; print(pybind11.get_cmake_dir())") \
-DENABLE_LIGHTNING_KOKKOS=ON \
-DLIGHTNING_GIT_TAG="v0.34.0" \
-DLIGHTNING_GIT_TAG="2716864521c539429bd382b92151a918d1a076ce" \
dime10 marked this conversation as resolved.
Show resolved Hide resolved
-DKokkos_ENABLE_SERIAL=ON \
-DKokkos_ENABLE_OPENMP=ON \
-DENABLE_WARNINGS=OFF \
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-wheel-macos-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ jobs:
fail-on-cache-miss: True

# Build Catalyst-Runtime
# TODO: Update git tag to v0.35.0 after the next lightning release.
- name: Build Catalyst-Runtime
run: |
cmake -S runtime -B runtime-build -G Ninja \
Expand All @@ -275,7 +276,7 @@ jobs:
-DPYTHON_EXECUTABLE=$(which python${{ matrix.python_version }}) \
-Dpybind11_DIR=$(python${{ matrix.python_version }} -c "import pybind11; print(pybind11.get_cmake_dir())") \
-DENABLE_LIGHTNING_KOKKOS=ON \
-DLIGHTNING_GIT_TAG="v0.34.0" \
-DLIGHTNING_GIT_TAG="2716864521c539429bd382b92151a918d1a076ce" \
dime10 marked this conversation as resolved.
Show resolved Hide resolved
-DKokkos_ENABLE_SERIAL=ON \
-DKokkos_ENABLE_OPENMP=ON \
-DKokkos_ENABLE_COMPLEX_ALIGN=OFF \
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-wheel-macos-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,15 @@ jobs:
brew install libomp

# Build Catalyst-Runtime
# TODO: Update git tag to v0.35.0 after the next lightning release.
- name: Build Catalyst-Runtime
run: |
cmake -S runtime -B runtime-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$GITHUB_WORKSPACE/runtime-build/lib \
-DPYTHON_EXECUTABLE=$(which python${{ matrix.python_version }}) \
-Dpybind11_DIR=$(python${{ matrix.python_version }} -c "import pybind11; print(pybind11.get_cmake_dir())") \
-DLIGHTNING_GIT_TAG="v0.34.0" \
-DLIGHTNING_GIT_TAG="2716864521c539429bd382b92151a918d1a076ce" \
dime10 marked this conversation as resolved.
Show resolved Hide resolved
-DENABLE_LIGHTNING_KOKKOS=ON \
-DKokkos_ENABLE_SERIAL=ON \
-DKokkos_ENABLE_OPENMP=ON \
Expand Down
3 changes: 3 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

<h3>Improvements</h3>

* Add support for the `BlockEncode` operator in Catalyst.
[(#483)](https://github.com/PennyLaneAI/catalyst/pull/483)

* Remove copies of TOML device configuration files for Lightning device in Catalyst.
[(#472)](https://github.com/PennyLaneAI/catalyst/pull/472)

Expand Down
4 changes: 2 additions & 2 deletions frontend/catalyst/pennylane_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ class QJITDevice(qml.QubitDevice):

@staticmethod
def _get_operations_to_convert_to_matrix(_config):
# We currently override and only set MultiControlledX to preserve current behaviour.
# We currently override and only set a few gates to preserve existing behaviour.
# We could choose to read from config and use the "matrix" gates.
# However, that affects differentiability.
# None of the "matrix" gates with more than 2 qubits parameters are differentiable.
# TODO: https://github.com/PennyLaneAI/catalyst/issues/398
return {"MultiControlledX"}
return {"MultiControlledX", "BlockEncode"}
dime10 marked this conversation as resolved.
Show resolved Hide resolved

@staticmethod
def _check_mid_circuit_measurement(config):
Expand Down
2 changes: 2 additions & 0 deletions frontend/test/pytest/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def circuit():

qml.MultiControlledX(wires=[0, 1, 2, 3])

qml.BlockEncode(np.array([[1, 1, 1], [0, 1, 0]]), wires=[0, 1, 2])

# Unsupported:
# qml.SX(wires=0)
# qml.ISWAP(wires=[0,1])
Expand Down
3 changes: 2 additions & 1 deletion runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ ENABLE_LIGHTNING?=ON
ENABLE_LIGHTNING_KOKKOS?=OFF
ENABLE_OPENQASM?=OFF
ENABLE_ASAN?=OFF
LIGHTNING_GIT_TAG_VALUE?="v0.34.0"
# TODO: Update to v0.35.0 after the next lightning release.
LIGHTNING_GIT_TAG_VALUE?="2716864521c539429bd382b92151a918d1a076ce"
dime10 marked this conversation as resolved.
Show resolved Hide resolved
NPROC?=$(shell python3 -c "import os; print(os.cpu_count())")

BUILD_TARGETS := rt_capi
Expand Down
Loading