Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
Browse files Browse the repository at this point in the history
…o capture_qml_cond
  • Loading branch information
PietropaoloFrisoni committed Jul 29, 2024
2 parents 4cee045 + ce1db61 commit 64ebe82
Show file tree
Hide file tree
Showing 33 changed files with 2,174 additions and 371 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/scripts/set_nightly_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 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.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
This module bumps the PennyLane development version by one unit.
"""

import os
import re

version_file_path = os.path.join(os.path.dirname(__file__), "../../../pennylane/_version.py")

assert os.path.isfile(version_file_path)

with open(version_file_path, "r+", encoding="UTF-8") as f:
lines = f.readlines()

version_line = lines[-1]
assert "__version__ = " in version_line

pattern = r"(\d+).(\d+).(\d+)-dev(\d+)"
match = re.search(pattern, version_line)
assert match

major, minor, bug, dev = match.groups()

replacement = f'__version__ = "{major}.{minor}.{bug}-dev{int(dev)+1}"\n'
lines[-1] = replacement

f.seek(0)
f.writelines(lines)
f.truncate()
48 changes: 48 additions & 0 deletions .github/workflows/upload-nightly-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build nightly PennyLane releases for TestPyPI

on:
schedule:
# Run every weekday at 5:50 EDT (cron is in UTC)
- cron: "50 9 * * 1-5"
workflow_dispatch:

jobs:
setup:
name: Setup the release
runs-on: ubuntu-latest
steps:
- name: Checkout PennyLane repo
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.NIGHTLY_VERSION_UPDATE_DEPLOY_KEY }}

- name: Bump dev version
run: |
python $GITHUB_WORKSPACE/.github/workflows/scripts/set_nightly_version.py
- name: Push new version
run: |
git config --global user.email '${{ secrets.AUTO_UPDATE_VERSION_RINGO_EMAIL }}'
git config --global user.name "ringo-but-quantum"
git add $GITHUB_WORKSPACE/pennylane/_version.py
git commit -m "[no ci] bump nightly version"
git push
upload:
name: Upload wheels to TestPyPI
needs: [setup]
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Build wheels
run: |
python -m pip install build
python -m build --wheel --outdir dist
- name: Upload wheels
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist
6 changes: 6 additions & 0 deletions doc/development/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Pending deprecations
- Deprecated in v0.38
- Will be removed in v0.39

* 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`.

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

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

- Deprecated in v0.38
Expand Down
2 changes: 1 addition & 1 deletion doc/releases/changelog-0.37.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -929,4 +929,4 @@ Kenya Sakka,
Jay Soni,
Kazuki Tsuoka,
Haochen Paul Wang,
David Wierichs.
David Wierichs.
38 changes: 31 additions & 7 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@
* The `qml.cond` function can be captured into plxpr.
[(#5999)](https://github.com/PennyLaneAI/pennylane/pull/5999)

* A new method `process_density_matrix` has been added to the `ProbabilityMP` and `DensityMatrixMP`
classes, allowing for more efficient handling of quantum density matrices, particularly with batch
processing support. This method simplifies the calculation of probabilities from quantum states
represented as density matrices.
[(#5830)](https://github.com/PennyLaneAI/pennylane/pull/5830)

* Resolved the bug in `qml.ThermalRelaxationError` where there was a typo from `tq` to `tg`.
[(#5988)](https://github.com/PennyLaneAI/pennylane/issues/5988)

* A new method `process_density_matrix` has been added to the `ProbabilityMP` and `DensityMatrixMP` classes, allowing for more efficient handling of quantum density matrices, particularly with batch processing support. This method simplifies the calculation of probabilities from quantum states represented as density matrices.
[(#5830)](https://github.com/PennyLaneAI/pennylane/pull/5830)

* The `qml.PrepSelPrep` template is added. The template implements a block-encoding of a linear
combination of unitaries.
[(#5756)](https://github.com/PennyLaneAI/pennylane/pull/5756)
[(#5987)](https://github.com/PennyLaneAI/pennylane/pull/5987)

* The `split_to_single_terms` transform is added. This transform splits expectation values of sums
into multiple single-term measurements on a single tape, providing better support for simulators
* A new function `qml.registers` has been added, enabling the creation of registers, which are implemented as a dictionary of `Wires` instances.
[(#5957)](https://github.com/PennyLaneAI/pennylane/pull/5957)

* The `split_to_single_terms` transform is added. This transform splits expectation values of sums
into multiple single-term measurements on a single tape, providing better support for simulators
that can handle non-commuting observables but don't natively support multi-term observables.
[(#5884)](https://github.com/PennyLaneAI/pennylane/pull/5884)

Expand All @@ -36,6 +42,10 @@

<h3>Improvements 🛠</h3>

* `qml.devices.LegacyDeviceFacade` has been added to map the legacy devices to the new
device interface.
[(#5927)](https://github.com/PennyLaneAI/pennylane/pull/5927)

* Added the `compute_sparse_matrix` method for `qml.ops.qubit.BasisStateProjector`.
[(#5790)](https://github.com/PennyLaneAI/pennylane/pull/5790)

Expand All @@ -53,6 +63,12 @@
* `QuantumScript.hash` is now cached, leading to performance improvements.
[(#5919)](https://github.com/PennyLaneAI/pennylane/pull/5919)

* Set operations are now supported by Wires.
[(#5983)](https://github.com/PennyLaneAI/pennylane/pull/5983)

* `qml.dynamic_one_shot` now supports circuits using the `"tensorflow"` interface.
[(#5973)](https://github.com/PennyLaneAI/pennylane/pull/5973)

* The representation for `Wires` has now changed to be more copy-paste friendly.
[(#5958)](https://github.com/PennyLaneAI/pennylane/pull/5958)

Expand Down Expand Up @@ -111,6 +127,9 @@
Hamiltonians.
[(#5950)](https://github.com/PennyLaneAI/pennylane/pull/5950)

* The `CNOT` operator no longer decomposes to itself. Instead, it raises a `qml.DecompositionUndefinedError`.
[(#6039)](https://github.com/PennyLaneAI/pennylane/pull/6039)

<h4>Community contributions 🥳</h4>

* `DefaultQutritMixed` readout error has been added using parameters `readout_relaxation_probs` and
Expand All @@ -126,7 +145,7 @@
the circuit.
[(#5907)](https://github.com/PennyLaneAI/pennylane/pull/5907)

* `queue_idx` attribute has been removed from the `Operator`, `CompositeOp`, and `SymboliOp` classes.
* `queue_idx` attribute has been removed from the `Operator`, `CompositeOp`, and `SymbolicOp` classes.
[(#6005)](https://github.com/PennyLaneAI/pennylane/pull/6005)

* `qml.from_qasm` no longer removes measurements from the QASM code. Use
Expand Down Expand Up @@ -187,6 +206,11 @@
Instead, use `default.qubit` as it now supports backpropagation through the several backends.
[(#5997)](https://github.com/PennyLaneAI/pennylane/pull/5997)

* 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`.
[(#6032)](https://github.com/PennyLaneAI/pennylane/pull/6032)

<h3>Documentation 📝</h3>

* Improves the docstring for `QuantumScript.expand` and `qml.tape.tape.expand_tape`.
Expand Down Expand Up @@ -229,12 +253,12 @@ Ahmed Darwish,
Lillian M. A. Frederiksen,
Pietropaolo Frisoni,
Emiliano Godinez,
Austin Huang,
Renke Huang,
Josh Izaac,
Soran Jahangiri,
Korbinian Kottmann,
Christina Lee,
Austin Huang,
William Maxwell,
Vincent Michaud-Rioux,
Anurav Modak,
Expand Down
2 changes: 1 addition & 1 deletion pennylane/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from pennylane.configuration import Configuration
from pennylane.drawer import draw, draw_mpl
from pennylane.tracker import Tracker

from pennylane.registers import registers
from pennylane.io import *
from pennylane.measurements import (
counts,
Expand Down
2 changes: 1 addition & 1 deletion pennylane/_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.38.0-dev"
__version__ = "0.38.0-dev3"
2 changes: 2 additions & 0 deletions pennylane/debugging/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

def _is_snapshot_compatible(dev):
# The `_debugger` attribute is a good enough proxy for snapshot compatibility
if isinstance(dev, qml.devices.LegacyDeviceFacade):
return _is_snapshot_compatible(dev.target_device)
return hasattr(dev, "_debugger")


Expand Down
2 changes: 2 additions & 0 deletions pennylane/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
DefaultTensor
NullQubit
DefaultQutritMixed
LegacyDeviceFacade
Preprocessing Transforms
------------------------
Expand Down Expand Up @@ -152,6 +153,7 @@ def execute(self, circuits, execution_config = qml.devices.DefaultExecutionConfi
from .device_constructor import device, refresh_devices
from .device_api import Device
from .default_qubit import DefaultQubit
from .legacy_facade import LegacyDeviceFacade

# DefaultQubitTF and DefaultQubitAutograd not imported here since this
# would lead to an automatic import of tensorflow and autograd, which are
Expand Down
5 changes: 1 addition & 4 deletions pennylane/devices/default_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,7 @@ def preprocess(

transform_program.add_transform(validate_device_wires, self.wires, name=self.name)
transform_program.add_transform(
mid_circuit_measurements,
device=self,
mcm_config=config.mcm_config,
interface=config.interface,
mid_circuit_measurements, device=self, mcm_config=config.mcm_config
)
transform_program.add_transform(
decompose,
Expand Down
2 changes: 1 addition & 1 deletion pennylane/devices/execution_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __post_init__(self):
None,
):
raise ValueError(f"Invalid mid-circuit measurements method '{self.mcm_method}'.")
if self.postselect_mode not in ("hw-like", "fill-shots", None):
if self.postselect_mode not in ("hw-like", "fill-shots", "pad-invalid-samples", None):
raise ValueError(f"Invalid postselection mode '{self.postselect_mode}'.")


Expand Down
Loading

0 comments on commit 64ebe82

Please sign in to comment.