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

Uniform Python format to adhere PL style; Always decompose qml.QFT in Lightning #924

Merged
merged 11 commits into from
Oct 1, 2024
6 changes: 6 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@

### Improvements

* Always decompose `qml.QFT` in Lightning.
[(#924)](https://github.com/PennyLaneAI/pennylane-lightning/pull/924)

* Uniform Python format to adhere PennyLane style.
[(#924)](https://github.com/PennyLaneAI/pennylane-lightning/pull/924)

* Remove dynamic decomposition rules in Lightning.
[(#926)](https://github.com/PennyLaneAI/pennylane-lightning/pull/926)

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Checkout PennyLane-Lightning
uses: actions/checkout@v4

- name: Install dependencies
run:
python -m pip install -r requirements-dev.txt
python -m pip install -r requirements.txt
maliasadi marked this conversation as resolved.
Show resolved Hide resolved

- name: Run isort & black --check
run: make format-python check=1 verbose=1
Expand All @@ -38,7 +38,7 @@ jobs:
uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt update && sudo apt -y install python3 python3-pip python-is-python3 && python -m pip install -r requirements-dev.txt
run: sudo apt update && sudo apt -y install python3 python3-pip python-is-python3 && python -m pip install -r requirements.txt

- name: Run formatter
run: PATH=$PATH:/home/ubuntu/.local/bin/:$(dirname $(which python3))/ ./bin/format --check ./pennylane_lightning/core/src
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ format-cpp:
./bin/format $(CHECK) ./pennylane_lightning

format-python:
isort --py 311 --profile black -l 100 -p pennylane_lightning ./pennylane_lightning ./mpitests ./tests ./scripts $(ICHECK) $(VERBOSE)
black -l 100 ./pennylane_lightning ./mpitests ./tests ./scripts $(CHECK) $(VERBOSE)
isort --py 312 --profile black -l 100 -p pennylane_lightning ./pennylane_lightning ./mpitests ./tests ./scripts $(ICHECK) $(VERBOSE)
black -t py310 -t py311 -t py312 -l 100 ./pennylane_lightning ./mpitests ./tests ./scripts $(CHECK) $(VERBOSE)

.PHONY: check-tidy
check-tidy:
Expand Down
1 change: 0 additions & 1 deletion pennylane_lightning/core/_state_vector_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class LightningBaseStateVector(ABC):
"""

def __init__(self, num_wires: int, dtype: Union[np.complex128, np.complex64]):

if dtype not in [np.complex64, np.complex128]:
raise TypeError(f"Unsupported complex type: {dtype}")

Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.39.0-dev33"
__version__ = "0.39.0-dev34"
1 change: 0 additions & 1 deletion pennylane_lightning/lightning_gpu/lightning_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def _mebibytesToBytes(mebibytes):
"QubitCarry",
"QubitSum",
"OrbitalRotation",
"QFT",
"ECR",
"BlockEncode",
"C(BlockEncode)",
Expand Down
1 change: 0 additions & 1 deletion pennylane_lightning/lightning_gpu/lightning_gpu.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ GlobalPhase = { properties = [ "differentiable" ] }
[operators.gates.decomp]

BasisState = {}
QFT = {}
QubitStateVector = {}
StatePrep = {}
MultiControlledX = {}
Expand Down
1 change: 0 additions & 1 deletion pennylane_lightning/lightning_kokkos/_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def __init__(
self,
kokkos_state,
) -> None:

super().__init__(kokkos_state)

self._measurement_lightning = self._measurement_dtype()(kokkos_state.state_vector)
Expand Down
2 changes: 0 additions & 2 deletions pennylane_lightning/lightning_kokkos/_state_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def __init__(
kokkos_args=None,
sync=True,
): # pylint: disable=too-many-arguments

super().__init__(num_wires, dtype)

self._device_name = "lightning.kokkos"
Expand Down Expand Up @@ -280,7 +279,6 @@ def _apply_lightning(
elif isinstance(operation, qml.ops.Controlled) and isinstance(
operation.base, qml.GlobalPhase
): # apply n-controlled gate

# Kokkos do not support the controlled gates except for GlobalPhase
self._apply_lightning_controlled(operation)
else: # apply gate as a matrix
Expand Down
1 change: 0 additions & 1 deletion pennylane_lightning/lightning_kokkos/lightning_kokkos.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
"QubitCarry",
"QubitSum",
"OrbitalRotation",
"QFT",
"ECR",
"BlockEncode",
"C(BlockEncode)",
Expand Down
1 change: 0 additions & 1 deletion pennylane_lightning/lightning_kokkos/lightning_kokkos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ T = { properties = [ "invertible", "differe

BasisState = {}
MultiControlledX = {}
QFT = {}
QubitStateVector = {}
StatePrep = {}
ControlledQubitUnitary = {}
Expand Down
1 change: 0 additions & 1 deletion pennylane_lightning/lightning_qubit/_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def __init__(
kernel_name: str = None,
num_burnin: int = None,
) -> None:

super().__init__(qubit_state)

self._mcmc = mcmc
Expand Down
1 change: 0 additions & 1 deletion pennylane_lightning/lightning_qubit/_state_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class LightningStateVector(LightningBaseStateVector): # pylint: disable=too-few
"""

def __init__(self, num_wires, dtype=np.complex128):

super().__init__(num_wires, dtype)

self._device_name = "lightning.qubit"
Expand Down
1 change: 0 additions & 1 deletion pennylane_lightning/lightning_qubit/lightning_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
"QubitCarry",
"QubitSum",
"OrbitalRotation",
"QFT",
"ECR",
"BlockEncode",
"C(BlockEncode)",
Expand Down
1 change: 0 additions & 1 deletion pennylane_lightning/lightning_qubit/lightning_qubit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ T = { properties = [ "invertible", "controllable", "differe
# default, but can be useful to express a deviation from this device's regular
# strategy in PennyLane.
MultiControlledX = {}
QFT = {}

# Gates which should be translated to QubitUnitary
[operators.gates.matrix]
Expand Down
1 change: 0 additions & 1 deletion pennylane_lightning/lightning_tensor/lightning_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
"QubitCarry",
"QubitSum",
"OrbitalRotation",
"QFT",
"ECR",
"BlockEncode",
"C(BlockEncode)",
Expand Down
19 changes: 9 additions & 10 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
git+https://github.com/PennyLaneAI/pennylane.git@master
build
ninja
flaky
pybind11
pytest~=8.0.0
pre-commit>=2.19.0
pytest>=7.1.2
pytest-benchmark
pytest-cov
pytest-mock
pytest-cov>=3.0.0
pytest-mock>=3.7.0
pytest-xdist>=2.5.0
pytest-split
pytest-xdist
pre-commit>=2.19.0
black==24.3.0
flaky>=3.7.0
black>=21
clang-tidy~=16.0
clang-format~=16.0
isort==5.13.2
click==8.0.4
cmake
custatevec-cu12
cutensornet-cu12
pylint
scipy
pylint==2.7.4
git+https://github.com/PennyLaneAI/pennylane.git@master
12 changes: 6 additions & 6 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pytest~=8.0.0
pytest>=7.1.2
pytest-benchmark
pytest-cov
pytest-mock
pytest-xdist
flaky
git+https://github.com/PennyLaneAI/pennylane.git@master
pytest-cov>=3.0.0
pytest-mock>=3.7.0
pytest-xdist>=2.5.0
flaky>=3.7.0
git+https://github.com/PennyLaneAI/pennylane.git@master
18 changes: 11 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
ninja
flaky
pennylane>=0.34
pybind11
pytest~=8.0.0
pytest-cov
pytest-mock
scipy
pytest-xdist
pytest>=7.1.2
pytest-cov>=3.0.0
pytest-mock>=3.7.0
pytest-xdist>=2.5.0
flaky>=3.7.0
black>=21
clang-tidy~=16.0
clang-format~=16.0
isort==5.13.2
pylint==2.7.4
pennylane>=0.37
1 change: 0 additions & 1 deletion tests/lightning_qubit/test_jacobian_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def calculate_reference(tape, execute_and_derivatives=False):

@staticmethod
def process_and_execute(statevector, tape, execute_and_derivatives=False):

wires = statevector.num_wires
device = LightningDevice(wires)
if execute_and_derivatives:
Expand Down
44 changes: 0 additions & 44 deletions tests/test_decomposition.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_native_mcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def func(x, y):
):
func(*params)
if device_name == "lightning.kokkos":

with pytest.raises(
qml.DeviceError,
match=r"Measurement shadow\(wires=\[0\]\) not accepted with finite shots on "
Expand Down
Loading