Skip to content

Commit

Permalink
Merge branch 'master' into device-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
albi3ro committed May 31, 2024
2 parents 7b1cb33 + 2a36a35 commit cab818c
Show file tree
Hide file tree
Showing 17 changed files with 1,481 additions and 916 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: Docker builds
on:
push:
branches:
- master
on: workflow_dispatch

jobs:
base-tests:
Expand Down
6 changes: 3 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag
extension-pkg-whitelist=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag

[TYPECHECK]

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy
ignored-modules=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy

# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set). This supports can work
# with qualified names.
ignored-classes=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy,pennylane.numpy.random,pennylane.numpy.linalg,pennylane.numpy.builtins,pennylane.operation,rustworkx,kahypar
ignored-classes=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy,pennylane.numpy.random,pennylane.numpy.linalg,pennylane.numpy.builtins,pennylane.operation,rustworkx,kahypar

[MESSAGES CONTROL]

Expand Down
1 change: 1 addition & 0 deletions doc/development/guide/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ be installed alongside PennyLane:
* `appdirs <https://github.com/ActiveState/appdirs>`_
* `semantic-version <https://github.com/rbarrois/python-semanticversion>`_ >= 2.7
* `autoray <https://github.com/jcmgray/autoray>`__ >= 0.6.11
* `packaging <https://github.com/pypa/packaging>`_

The following Python packages are optional:

Expand Down
9 changes: 9 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

<h3>Improvements 🛠</h3>

* Added `packaging` in the required list of packages.
[(#5769)](https://github.com/PennyLaneAI/pennylane/pull/5769).

* Logging now allows for an easier opt-in across the stack, and also extends control support to `catalyst`.
[(#5528)](https://github.com/PennyLaneAI/pennylane/pull/5528).

Expand All @@ -24,6 +27,9 @@
* The sorting order of parameter-shift terms is now guaranteed to resolve ties in the absolute value with the sign of the shifts.
[(#5582)](https://github.com/PennyLaneAI/pennylane/pull/5582)

* `qml.transforms.split_non_commuting` can now handle circuits containing measurements of multi-term observables.
[(#5729)](https://github.com/PennyLaneAI/pennylane/pull/5729)

<h4>Mid-circuit measurements and dynamic circuits</h4>

* The `dynamic_one_shot` transform uses a single auxiliary tape with a shot vector and `default.qubit` implements the loop over shots with `jax.vmap`.
Expand Down Expand Up @@ -190,6 +196,9 @@

<h3>Bug fixes 🐛</h3>

* Disable Docker builds on PR merge.
[(#5777)](https://github.com/PennyLaneAI/pennylane/pull/5777)

* The validation of the adjoint method in `DefaultQubit` correctly handles device wires now.
[(#5761)](https://github.com/PennyLaneAI/pennylane/pull/5761)

Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ m2r2
numpy
pygments-github-lexers
semantic_version==2.10
packaging
scipy
docutils==0.16
sphinx~=3.5.0; python_version < "3.10"
Expand Down
3 changes: 2 additions & 1 deletion pennylane/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# Copyright 2018-2024 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@


import numpy as _np

from semantic_version import SimpleSpec, Version

from pennylane.boolean_fn import BooleanFn
Expand Down
2 changes: 1 addition & 1 deletion pennylane/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from sys import version_info
from typing import List, Optional

from semantic_version import Version
from packaging.version import Version

PL_CATALYST_MIN_VERSION = Version("0.6.0")

Expand Down
6 changes: 3 additions & 3 deletions pennylane/devices/default_qubit_tf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# Copyright 2018-2024 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@
import itertools

import numpy as np
import semantic_version
from packaging.version import Version

import pennylane as qml

Expand All @@ -29,7 +29,7 @@

from tensorflow.python.framework.errors_impl import InvalidArgumentError

SUPPORTS_APPLY_OPS = semantic_version.match(">=2.3.0", tf.__version__)
SUPPORTS_APPLY_OPS = Version(tf.__version__) >= Version("2.3.0")

except ImportError as e: # pragma: no cover
raise ImportError("default.qubit.tf device requires TensorFlow>=2.0") from e
Expand Down
8 changes: 5 additions & 3 deletions pennylane/devices/default_qubit_torch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# Copyright 2018-2024 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,12 +18,14 @@
import logging
import warnings

import semantic_version
from packaging.version import Version

try:
import torch

VERSION_SUPPORT = semantic_version.match(">=1.8.1", torch.__version__)
VERSION_SUPPORT = Version(torch.__version__) >= Version(
"1.8.1",
)
if not VERSION_SUPPORT: # pragma: no cover
raise ImportError("default.qubit.torch device requires Torch>=1.8.1")

Expand Down
7 changes: 6 additions & 1 deletion pennylane/ops/qubit/hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,9 @@ def __rmatmul__(self, H):
ops1 = self.ops.copy()

if isinstance(H, (Tensor, Observable)):
qml.QueuingManager.remove(H)
qml.QueuingManager.remove(self)
terms = [copy(H) @ op for op in ops1]

return qml.simplify(Hamiltonian(coeffs1, terms))

return NotImplemented
Expand All @@ -790,11 +791,15 @@ def __add__(self, H):
return self

if isinstance(H, Hamiltonian):
qml.QueuingManager.remove(H)
qml.QueuingManager.remove(self)
coeffs = qml.math.concatenate([self_coeffs, copy(H.coeffs)], axis=0)
ops.extend(H.ops.copy())
return qml.simplify(Hamiltonian(coeffs, ops))

if isinstance(H, (Tensor, Observable)):
qml.QueuingManager.remove(H)
qml.QueuingManager.remove(self)
coeffs = qml.math.concatenate(
[self_coeffs, qml.math.cast_like([1.0], self_coeffs)], axis=0
)
Expand Down
4 changes: 2 additions & 2 deletions pennylane/qnn/keras.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018-2021 Xanadu Quantum Technologies Inc.
# Copyright 2018-2024 Xanadu Quantum Technologies Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@
from collections.abc import Iterable
from typing import Optional, Text

from semantic_version import Version
from packaging.version import Version

try:
import tensorflow as tf
Expand Down
Loading

0 comments on commit cab818c

Please sign in to comment.