Skip to content

Commit

Permalink
Merge branch 'master' into kitaev_model
Browse files Browse the repository at this point in the history
  • Loading branch information
ddhawan11 committed Sep 20, 2024
2 parents 81c9766 + 2aee2e1 commit d92d431
Show file tree
Hide file tree
Showing 204 changed files with 3,320 additions and 4,063 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/install_deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ inputs:
description: The version of Python to use in order to run unit tests
required: false
default: '3.10'
install_numpy_1:
description: Indicate if numpy 1 should be installed or not
required: false
type: boolean
default: false
install_jax:
description: Indicate if JAX should be installed or not
required: false
default: 'true'
jax_version:
description: The version of JAX to install for any job that requires JAX
required: false
default: '0.4.23'
default: '0.4.28'
install_tensorflow:
description: Indicate if TensorFlow should be installed or not
required: false
Expand Down Expand Up @@ -67,6 +72,11 @@ runs:
pip install -r requirements-ci.txt --upgrade
pip install -r requirements-dev.txt --upgrade
- name: Install numpy 1 version
shell: bash
if: inputs.install_numpy_1 == 'true'
run: pip install "numpy==1.26.4"

- name: Install PyTorch
shell: bash
if: inputs.install_pytorch == 'true'
Expand All @@ -86,7 +96,7 @@ runs:
if: inputs.install_jax == 'true'
env:
JAX_VERSION: ${{ inputs.jax_version != '' && format('=={0}', inputs.jax_version) || '' }}
run: pip install "jax${{ env.JAX_VERSION}}" "jaxlib${{ env.JAX_VERSION }}" scipy~=1.12.0
run: pip install "jax${{ env.JAX_VERSION}}" "jaxlib${{ env.JAX_VERSION }}"

- name: Install additional PIP packages
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/interface-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ jobs:
install_pennylane_lightning_master: true
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: jax and not qcut and not finite-diff and not param-shift
pytest_additional_args: --splits 5 --group ${{ matrix.group }}
pytest_additional_args: --dist=loadscope --splits 5 --group ${{ matrix.group }}
pytest_durations_file_path: '.github/workflows/jax_tests_durations.json'
pytest_store_durations: ${{ inputs.pytest_store_durations }}
additional_pip_packages: pytest-split
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/numpy_1_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: NumPy 1 - Tests
on:

schedule:
# Runs daily at 6 AM UTC (1 AM Toronto in winter, 2 AM in summer)
- cron: '0 6 * * *'

# Allows to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
group: numpy-1-unit-tests-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
uses: ./.github/workflows/numpy_1_unit-tests.yml
with:
branch: ${{ github.ref }}
230 changes: 230 additions & 0 deletions .github/workflows/numpy_1_unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
# TODO: remove this workflow once compatibility with NumPy 1
# will no longer be tested.

name: NumPy 1 - Unit Tests - Interfaces
on:
workflow_call:
inputs:
branch:
description: The PennyLane branch to checkout and run unit tests for
required: true
type: string
pipeline_mode:
description: The pipeline mode can be unit-tests, benchmarks, or reference-benchmarks
required: false
type: string
default: 'unit-tests'
disable_new_opmath:
description: Whether to disable the new op_math or not when running the tests
required: false
type: string
default: "False"

jobs:
setup-ci-load:
runs-on: ubuntu-latest

steps:
- name: Setup Python Versions
id: python_versions

run: |
cat >python_versions.json <<-EOF
{
"default": ["3.10", "3.11", "3.12"],
"torch-tests": ["3.10", "3.12"],
"jax-tests": ["3.10", "3.12"],
"external-libraries-tests": ["3.10"],
"data-tests": ["3.10"]
}
EOF
jq . python_versions.json
echo "python_versions=$(jq -r tostring python_versions.json)" >> $GITHUB_OUTPUT
- name: Set NumPy Version
id: numpy_version
run: echo "NUMPY_VERSION=1.26" >> $GITHUB_ENV

- name: Setup Matrix Max Parallel
id: max_parallel
run: |
cat >matrix_max_parallel.json <<-EOF
{
"default": 1,
"core-tests": 5,
"jax-tests": 10,
"torch-tests": 2
}
EOF
jq . matrix_max_parallel.json
echo "matrix_max_parallel=$(jq -r tostring matrix_max_parallel.json)" >> $GITHUB_OUTPUT
outputs:
matrix-max-parallel: ${{ steps.max_parallel.outputs.matrix_max_parallel }}
python-version: ${{ steps.python_versions.outputs.python_versions }}

torch-tests:
needs:
- setup-ci-load
strategy:
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).torch-tests
|| fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).default
}}
matrix:
python-version: >-
${{
fromJSON(needs.setup-ci-load.outputs.python-version).torch-tests
|| fromJSON(needs.setup-ci-load.outputs.python-version).default
}}
uses: ./.github/workflows/unit-test.yml
with:
job_name: torch-tests (${{ matrix.python-version }}, numpy-1.26)
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-torch-${{ matrix.python-version }}-numpy-1.26
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_numpy_1: true
install_jax: false
install_tensorflow: false
install_pytorch: true
install_pennylane_lightning_master: true
pytest_markers: torch and not qcut and not finite-diff and not param-shift
requirements_file: ${{ github.event_name == 'schedule' && strategy.job-index == 0 && 'torch.txt' || '' }}
disable_new_opmath: ${{ inputs.disable_new_opmath }}


autograd-tests:
needs:
- setup-ci-load
strategy:
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).autograd-tests
|| fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).default
}}
matrix:
python-version: >-
${{
fromJSON(needs.setup-ci-load.outputs.python-version).autograd-tests
|| fromJSON(needs.setup-ci-load.outputs.python-version).default
}}
uses: ./.github/workflows/unit-test.yml
with:
job_name: autograd-tests (${{ matrix.python-version }}, numpy-1.26)
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-autograd-${{ matrix.python-version }}-numpy-1.26
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_numpy_1: true
install_jax: false
install_tensorflow: false
install_pytorch: false
install_pennylane_lightning_master: true
pytest_markers: autograd and not qcut and not finite-diff and not param-shift
disable_new_opmath: ${{ inputs.disable_new_opmath }}


jax-tests:
needs:
- setup-ci-load
strategy:
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).jax-tests
|| fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).default
}}
matrix:
group: [1, 2, 3, 4, 5]
python-version: >-
${{
fromJSON(needs.setup-ci-load.outputs.python-version).jax-tests
|| fromJSON(needs.setup-ci-load.outputs.python-version).default
}}
uses: ./.github/workflows/unit-test.yml
with:
job_name: jax-tests (${{ matrix.group }}, ${{ matrix.python-version }}, numpy-1.26)
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-jax-${{ matrix.python-version }}-${{ matrix.group }}-numpy-1.26
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_numpy_1: true
install_jax: true
install_tensorflow: false
install_pytorch: false
install_pennylane_lightning_master: true
pytest_markers: jax and not qcut and not finite-diff and not param-shift
pytest_additional_args: --dist=loadscope --splits 5 --group ${{ matrix.group }}
additional_pip_packages: pytest-split
requirements_file: ${{ github.event_name == 'schedule' && strategy.job-index == 0 && 'jax.txt' || '' }}
disable_new_opmath: ${{ inputs.disable_new_opmath }}


core-tests:
needs:
- setup-ci-load
strategy:
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).core-tests
|| fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).default
}}
matrix:
group: [1, 2, 3, 4, 5]
python-version: >-
${{
fromJSON(needs.setup-ci-load.outputs.python-version).core-tests
|| fromJSON(needs.setup-ci-load.outputs.python-version).default
}}
uses: ./.github/workflows/unit-test.yml
with:
job_name: core-tests (${{ matrix.group }}, ${{ matrix.python-version }}, numpy-1.26)
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-core-${{ matrix.python-version }}-${{ matrix.group }}-numpy-1.26
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_numpy_1: true
install_jax: false
install_tensorflow: false
install_pytorch: false
install_pennylane_lightning_master: true
pytest_markers: core and not qcut and not finite-diff and not param-shift
pytest_additional_args: --splits 5 --group ${{ matrix.group }}
additional_pip_packages: pytest-split
requirements_file: ${{ github.event_name == 'schedule' && strategy.job-index == 0 && 'core.txt' || '' }}
disable_new_opmath: ${{ inputs.disable_new_opmath }}


data-tests:
needs:
- setup-ci-load
strategy:
max-parallel: >-
${{
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).data-tests
|| fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).default
}}
matrix:
python-version: >-
${{
fromJSON(needs.setup-ci-load.outputs.python-version).data-tests
|| fromJSON(needs.setup-ci-load.outputs.python-version).default
}}
uses: ./.github/workflows/unit-test.yml
with:
job_name: data-tests (${{ matrix.python-version }}, numpy-1.26)
branch: ${{ inputs.branch }}
coverage_artifact_name: data-coverage-${{ matrix.python-version }}-numpy-1.26
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_numpy_1: true
install_jax: false
install_tensorflow: false
install_pytorch: false
install_pennylane_lightning_master: true
pytest_markers: data
additional_pip_packages: h5py
disable_new_opmath: ${{ inputs.disable_new_opmath }}
6 changes: 6 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ on:
required: false
type: string
default: '3.10'
install_numpy_1:
description: Indicate if numpy 1 should be installed or not
required: false
type: boolean
default: false
pipeline_mode:
description: The pipeline mode can be unit-tests, benchmarks, or reference-benchmark
required: false
Expand Down Expand Up @@ -158,6 +163,7 @@ jobs:
uses: ./.github/workflows/install_deps
with:
python_version: ${{ inputs.python_version }}
install_numpy_1: ${{ inputs.install_numpy_1 }}
install_pytorch: ${{ inputs.install_pytorch }}
install_tensorflow: ${{ inputs.install_tensorflow }}
install_jax: ${{ inputs.install_jax }}
Expand Down
11 changes: 7 additions & 4 deletions doc/code/qml_qinfo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ qml.qinfo
Overview
--------

.. warning::

The ``qinfo`` module is deprecated and scheduled to be removed in v0.40. Most quantum information transforms
are available as measurement processes (see the :mod:`~pennylane.measurements` module for more details).
Additionally, the transforms are also available as standalone functions in the :mod:`~pennylane.math` and
:mod:`~pennylane.gradients` modules.

This module provides a collection of methods to return quantum information quantities from :class:`~.QNode`
returning :func:`~pennylane.state`.

Expand All @@ -15,8 +22,4 @@ Transforms
.. automodapi:: pennylane.qinfo.transforms
:no-heading:
:no-inherited-members:
:skip: metric_tensor
:skip: adjoint_metric_tensor
:skip: transform
:skip: classical_fisher
:skip: quantum_fisher
9 changes: 2 additions & 7 deletions doc/development/adding_operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ knows a native implementation for ``FlipAndRotate``). It also defines an adjoint
# as the class differs from the standard `__init__` call signature of
# (*data, wires=wires, **hyperparameters), the _unflatten method that
# must be defined as well
# _unflatten recreates a opeartion from the serialized data and metadata of ``Operator._flatten``
# _unflatten recreates a operation from the serialized data and metadata of ``Operator._flatten``
# copied_op = type(op)._unflatten(*op._flatten())
wires = metadata[0]
hyperparams = dict(metadata[1])
Expand Down Expand Up @@ -245,12 +245,7 @@ If the above operator omitted the ``_unflatten`` custom definition, it would rai
The new gate can be used with PennyLane devices. Device support for an operation can be checked via
``dev.stopping_condition(op)``. If ``True``, then the device supports the operation.

``DefaultQubitLegacy`` first checks if the operator has a matrix using the :attr:`~.Operator.has_matrix` property.
If the Operator doesn't have a matrix, the device then checks if the name of the Operator is explicitly specified in
:attr:`~DefaultQubitLegacy.operations` or :attr:`~DefaultQubitLegacy.observables`.

Other devices that do not inherit from ``DefaultQubitLegacy`` only check if the name is explicitly specified in the ``operations``
property.
``DefaultQubit`` first checks if the operator has a matrix using the :attr:`~.Operator.has_matrix` property.

- If the device registers support for an operation with the same name,
PennyLane leaves the gate implementation up to the device. The device
Expand Down
Loading

0 comments on commit d92d431

Please sign in to comment.