Skip to content

Commit

Permalink
Merge branch 'compatible-np-2.0' of https://github.com/PennyLaneAI/pe…
Browse files Browse the repository at this point in the history
…nnylane into update_jax
  • Loading branch information
PietropaoloFrisoni committed Sep 16, 2024
2 parents 1b27526 + 591671d commit c481f4a
Show file tree
Hide file tree
Showing 84 changed files with 893 additions and 8,143 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/install_deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ inputs:
description: The version of Python to use in order to run unit tests
required: false
default: '3.10'
install_numpy_2:
description: Indicate if numpy 2.0+ should be installed or not
required: false
type: boolean
default: false
numpy_2_version:
description: The version of numpy 2.0 to use in order to run unit tests
required: false
type: string
default: '2.0.0'
install_jax:
description: Indicate if JAX should be installed or not
required: false
Expand Down Expand Up @@ -77,13 +67,6 @@ runs:
pip install -r requirements-ci.txt --upgrade
pip install -r requirements-dev.txt --upgrade
- name: Install numpy 2.0 version
shell: bash
if: inputs.install_numpy_2 == 'true'
env:
NUMPY2_VERSION: ${{ inputs.numpy_2_version != '' && format('~={0}', inputs.numpy_2_version) || '' }}
run: pip install "numpy${{ env.NUMPY2_VERSION }}"

- name: Install PyTorch
shell: bash
if: inputs.install_pytorch == 'true'
Expand Down
31 changes: 11 additions & 20 deletions .github/workflows/interface-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ jobs:
cat >matrix_max_parallel.json <<-EOF
{
"default": 1,
"core-tests": 8,
"core-tests": 5,
"gradients-tests": 2,
"jax-tests": 5,
"tf-tests": 2,
"tf-tests": 3,
"device-tests": 2
}
EOF
Expand Down Expand Up @@ -152,16 +152,14 @@ jobs:
fromJSON(needs.setup-ci-load.outputs.python-version).torch-tests
|| fromJSON(needs.setup-ci-load.outputs.python-version).default
}}
numpy-2-install: [true, false]
if: ${{ !contains(fromJSON(needs.setup-ci-load.outputs.jobs-to-skip), 'torch-tests') }}
uses: ./.github/workflows/unit-test.yml
with:
job_name: torch-tests (${{ matrix.python-version }}, numpy 2.0 ${{ matrix.numpy-2-install }})
job_name: torch-tests (${{ matrix.python-version }})
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-torch-${{ matrix.python-version }}-${{ matrix.numpy-2-install }}
coverage_artifact_name: core-interfaces-coverage-torch-${{ matrix.python-version }}
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_numpy_2: ${{ matrix.numpy-2-install }}
install_jax: false
install_tensorflow: false
install_pytorch: true
Expand All @@ -187,16 +185,14 @@ jobs:
fromJSON(needs.setup-ci-load.outputs.python-version).autograd-tests
|| fromJSON(needs.setup-ci-load.outputs.python-version).default
}}
numpy-2-install: [true, false]
if: ${{ !contains(fromJSON(needs.setup-ci-load.outputs.jobs-to-skip), 'autograd-tests') }}
uses: ./.github/workflows/unit-test.yml
with:
job_name: autograd-tests (${{ matrix.python-version }}, numpy 2.0 ${{ matrix.numpy-2-install }})
job_name: autograd-tests (${{ matrix.python-version }})
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-autograd-${{ matrix.python-version }}-${{ matrix.numpy-2-install }}
coverage_artifact_name: core-interfaces-coverage-autograd-${{ matrix.python-version }}
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_numpy_2: ${{ matrix.numpy-2-install }}
install_jax: false
install_tensorflow: false
install_pytorch: false
Expand Down Expand Up @@ -300,16 +296,14 @@ jobs:
fromJSON(needs.setup-ci-load.outputs.python-version).core-tests
|| fromJSON(needs.setup-ci-load.outputs.python-version).default
}}
numpy-2-install: [true, false]
if: ${{ !contains(fromJSON(needs.setup-ci-load.outputs.jobs-to-skip), 'core-tests') }}
uses: ./.github/workflows/unit-test.yml
with:
job_name: core-tests (${{ matrix.group }}, ${{ matrix.python-version }}, numpy 2.0 ${{ matrix.numpy-2-install }})
job_name: core-tests (${{ matrix.group }}, ${{ matrix.python-version }})
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-core-${{ matrix.python-version }}-${{ matrix.group }}-${{ matrix.numpy-2-install }}
coverage_artifact_name: core-interfaces-coverage-core-${{ matrix.python-version }}-${{ matrix.group }}
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_numpy_2: ${{ matrix.numpy-2-install }}
install_jax: false
install_tensorflow: false
install_pytorch: false
Expand Down Expand Up @@ -387,8 +381,7 @@ jobs:
# catalyst requires the latest version of pennylane that is about to be released.
# Installing catalyst after pennylane to make sure that the latest catalyst is used.
install_catalyst_nightly: true
# using lightning master does not work for the tests with external libraries
install_pennylane_lightning_master: false
install_pennylane_lightning_master: true
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: external
additional_pip_packages: pyzx matplotlib stim quimb mitiq pennylane-qiskit ply
Expand Down Expand Up @@ -511,16 +504,14 @@ jobs:
fromJSON(needs.setup-ci-load.outputs.python-version).data-tests
|| fromJSON(needs.setup-ci-load.outputs.python-version).default
}}
numpy-2-install: [true, false]
if: ${{ !contains(fromJSON(needs.setup-ci-load.outputs.jobs-to-skip), 'data-tests') }}
uses: ./.github/workflows/unit-test.yml
with:
job_name: data-tests (${{ matrix.python-version }}, numpy 2.0 ${{ matrix.numpy-2-install }})
job_name: data-tests (${{ matrix.python-version }})
branch: ${{ inputs.branch }}
coverage_artifact_name: data-coverage-${{ matrix.python-version }}-${{ matrix.numpy-2-install }}
coverage_artifact_name: data-coverage-${{ matrix.python-version }}
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_numpy_2: ${{ matrix.numpy-2-install }}
install_jax: false
install_tensorflow: false
install_pytorch: false
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ on:
required: false
type: string
default: '3.10'
install_numpy_2:
description: Indicate if numpy 2.0+ should be installed or not
required: false
type: boolean
default: false
numpy_2_version:
description: The version of numpy 2.0 to use in order to run unit tests
required: false
type: string
default: '2.0'
pipeline_mode:
description: The pipeline mode can be unit-tests, benchmarks, or reference-benchmark
required: false
Expand Down Expand Up @@ -168,8 +158,6 @@ jobs:
uses: ./.github/workflows/install_deps
with:
python_version: ${{ inputs.python_version }}
numpy_2_version: ${{ inputs.numpy_2_version }}
install_numpy_2: ${{ inputs.install_numpy_2 }}
install_pytorch: ${{ inputs.install_pytorch }}
install_tensorflow: ${{ inputs.install_tensorflow }}
install_jax: ${{ inputs.install_jax }}
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ clean-docs:

test:
$(PYTHON) $(TESTRUNNER)
$(PYTHON) $(PLUGIN_TESTRUNNER) --device=default.qubit.autograd

coverage:
@echo "Generating coverage report..."
$(PYTHON) $(TESTRUNNER) $(COVERAGE)
$(PYTHON) $(PLUGIN_TESTRUNNER) --device=default.qubit.autograd $(COVERAGE) --cov-append

.PHONY:format
format:
Expand Down
29 changes: 21 additions & 8 deletions doc/development/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ deprecations are listed below.
Pending deprecations
--------------------

* All of the legacy devices (any with the name ``default.qubit.{autograd,torch,tf,jax,legacy}``) are deprecated. Use ``default.qubit`` instead,
as it supports backpropagation for the many backends the legacy devices support.
* ``Device``, ``QubitDevice``, and ``QutritDevice`` will no longer be imported top level in v0.40. They instead
we be available as ``qml.devices.LegacyDevice``, ``qml.devices.QubitDevice``, and ``qml.devices.QutritDevice``
respectively.

- Deprecated in v0.38
- Will be removed in v0.39
- Deprecated top level access in v0.39
- Top level access removed in v0.40

* The logic for internally switching a device for a different backpropagation
compatible device is now deprecated, as it was in place for the deprecated ``default.qubit.legacy``.
* `QNode.gradient_fn` is deprecated. Please use `QNode.diff_method` instead. `QNode.get_gradient_fn` can also be used to
process the diff method.

- Deprecated in v0.38
- Will be removed in v0.39
- Deprecated in v0.39
- Will be removed in v0.40

* The ``decomp_depth`` argument in ``qml.device`` is deprecated.

Expand Down Expand Up @@ -82,6 +83,18 @@ Other deprecations
Completed deprecation cycles
----------------------------

* All of the legacy devices (any with the name ``default.qubit.{autograd,torch,tf,jax,legacy}``) are removed. Use ``default.qubit`` instead,
as it supports backpropagation for the many backends the legacy devices support.

- Deprecated in v0.38
- Removed in v0.39

* The logic for internally switching a device for a different backpropagation
compatible device is removed, as it was in place for removed ``default.qubit.legacy``.

- Deprecated in v0.38
- Removed in v0.39

* `Operator.expand` is now removed. Use `qml.tape.QuantumScript(op.deocomposition())` instead.

- Deprecated in v0.38
Expand Down
2 changes: 2 additions & 0 deletions doc/development/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This page contains the release notes for PennyLane.

.. mdinclude:: ../releases/changelog-dev.md

.. mdinclude:: ../releases/changelog-0.38.1.md

.. mdinclude:: ../releases/changelog-0.38.0.md

.. mdinclude:: ../releases/changelog-0.37.0.md
Expand Down
2 changes: 1 addition & 1 deletion doc/releases/changelog-0.38.0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:orphan:

# Release 0.38.0 (current release)
# Release 0.38.0

<h3>New features since last release</h3>

Expand Down
14 changes: 14 additions & 0 deletions doc/releases/changelog-0.38.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
:orphan:

# Release 0.38.1 (current release)

<h3>Bug fixes 🐛</h3>

* Fix float-to-complex casting in various places across PennyLane.
[(#6260)](https://github.com/PennyLaneAI/pennylane/pull/6260)

<h3>Contributors ✍️</h3>

This release contains contributions from (in alphabetical order):

Mudit Pandey
24 changes: 22 additions & 2 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

<h3>Improvements 🛠</h3>

* PennyLane is now compatible with NumPy 2.0.
[(#6061)](https://github.com/PennyLaneAI/pennylane/pull/6061)

* `qml.qchem.excitations` now optionally returns fermionic operators.
[(#6171)](https://github.com/PennyLaneAI/pennylane/pull/6171)

Expand All @@ -25,9 +28,10 @@
* Differentiation of hybrid programs via `qml.grad` and `qml.jacobian` can now be captured
into plxpr. When evaluating a captured `qml.grad` (`qml.jacobian`) instruction, it will
dispatch to `jax.grad` (`jax.jacobian`), which differs from the Autograd implementation
without capture.
without capture. Pytree inputs and outputs are supported.
[(#6120)](https://github.com/PennyLaneAI/pennylane/pull/6120)
[(#6127)](https://github.com/PennyLaneAI/pennylane/pull/6127)
[(#6134)](https://github.com/PennyLaneAI/pennylane/pull/6134)

* Improve unit testing for capturing of nested control flows.
[(#6111)](https://github.com/PennyLaneAI/pennylane/pull/6111)
Expand Down Expand Up @@ -59,10 +63,12 @@
* Remove support for Python 3.9.
[(#6223)](https://github.com/PennyLaneAI/pennylane/pull/6223)

* `DefaultQubitTF`, `DefaultQubitTorch`, and `DefaultQubitJax` are removed. Please use `default.qubit` for all interfaces.
* `DefaultQubitTF`, `DefaultQubitTorch`, `DefaultQubitJax`, and `DefaultQubitAutograd` are removed.
Please use `default.qubit` for all interfaces.
[(#6207)](https://github.com/PennyLaneAI/pennylane/pull/6207)
[(#6208)](https://github.com/PennyLaneAI/pennylane/pull/6208)
[(#6209)](https://github.com/PennyLaneAI/pennylane/pull/6209)
[(#6210)](https://github.com/PennyLaneAI/pennylane/pull/6210)

* `expand_fn`, `max_expansion`, `override_shots`, and `device_batch_transform` are removed from the
signature of `qml.execute`.
Expand All @@ -81,8 +87,17 @@
* `Operator.expand` is now removed. Use `qml.tape.QuantumScript(op.deocomposition())` instead.
[(#6227)](https://github.com/PennyLaneAI/pennylane/pull/6227)


<h3>Deprecations 👋</h3>

* `Device`, `QubitDevice`, and `QutritDevice` will no longer be accessible via top-level import in v0.40.
They will still be accessible as `qml.devices.LegacyDevice`, `qml.devices.QubitDevice`, and `qml.devices.QutritDevice`
respectively.
[(#6238)](https://github.com/PennyLaneAI/pennylane/pull/6238/)

* `QNode.gradient_fn` is deprecated. Please use `QNode.diff_method` and `QNode.get_gradient_fn` instead.
[(#6244)](https://github.com/PennyLaneAI/pennylane/pull/6244)

<h3>Documentation 📝</h3>

<h3>Bug fixes 🐛</h3>
Expand All @@ -102,13 +117,18 @@
* The ``qml.Qubitization`` template now orders the ``control`` wires first and the ``hamiltonian`` wires second, which is the expected according to other templates.
[(#6229)](https://github.com/PennyLaneAI/pennylane/pull/6229)

* The ``qml.FABLE`` template now returns the correct value when JIT is enabled.
[(#6263)](https://github.com/PennyLaneAI/pennylane/pull/6263)

* <h3>Contributors ✍️</h3>

This release contains contributions from (in alphabetical order):

Guillermo Alonso,
Utkarsh Azad,
Lillian M. A. Frederiksen,
Pietropaolo Frisoni,
Emiliano Godinez,
Christina Lee,
William Maxwell,
Lee J. O'Riordan,
Expand Down
19 changes: 17 additions & 2 deletions pennylane/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
PennyLane can be directly imported.
"""

import numpy as _np


from pennylane.boolean_fn import BooleanFn
import pennylane.numpy
Expand Down Expand Up @@ -180,13 +178,30 @@ def __getattr__(name):
if name == "plugin_devices":
return pennylane.devices.device_constructor.plugin_devices

from warnings import warn # pylint: disable=import-outside-toplevel

if name == "QubitDevice":
warn(
"QubitDevice will no longer be accessible top level. Please access "
" the class as pennylane.devices.QubitDevice",
PennyLaneDeprecationWarning,
)
return pennylane.devices._qubit_device.QubitDevice # pylint:disable=protected-access

if name == "QutritDevice":
warn(
"QutritDevice will no longer be accessible top level. Please access "
" the class as pennylane.devices.QutritDevice",
PennyLaneDeprecationWarning,
)
return pennylane.devices._qutrit_device.QutritDevice # pylint:disable=protected-access

if name == "Device":
warn(
"Device will no longer be accessible top level. Please access "
" the class as pennylane.devices.LegacyDevice",
PennyLaneDeprecationWarning,
)
return pennylane.devices._legacy_device.Device # pylint:disable=protected-access

raise AttributeError(f"module 'pennylane' has no attribute '{name}'")
Expand Down
Loading

0 comments on commit c481f4a

Please sign in to comment.