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

Update upload.yml to use codecov token. #5661

Closed
wants to merge 14 commits into from
Closed

Conversation

astralcai
Copy link
Contributor

Before submitting

Please complete the following checklist when submitting a PR:

  • All new features must include a unit test.
    If you've fixed a bug or added code that should be tested, add a test to the
    test directory!

  • All new functions and code must be clearly commented and documented.
    If you do make documentation changes, make sure that the docs build and
    render correctly by running make docs.

  • Ensure that the test suite passes, by running make test.

  • Add a new entry to the doc/releases/changelog-dev.md file, summarizing the
    change, and including a link back to the PR.

  • The PennyLane source code conforms to
    PEP8 standards.
    We check all of our code against Pylint.
    To lint modified files, simply pip install pylint, and then
    run pylint pennylane/path/to/file.py.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context:

Description of the Change:

Benefits:

Possible Drawbacks:

Related GitHub Issues:

astralcai and others added 14 commits April 29, 2024 14:12
**Context:** Currently, `qml.Device` and `qml.devices.Device` are
abstract base classes for `PennyLane` devices. However, the former was
created about 6 years ago, and the second one about 14 months ago. In
particular, the second one follows the [new design
API](https://docs.pennylane.ai/en/stable/code/api/pennylane.devices.Device.html),
and it is the current default choice. The first one remained for
historical reasons and not to break existing code.

**Description of the Change:** A new `qml.devices.LegacyDevice` alias is
introduced for the old `qml.Device`, making it easier to distinguish
between the two. When importing pennylane, in
`pennylane/devices/__init__.py` the old device is imported as
`LegacyDevice`. Additionally, in some parts of the source code, the old
`qml.Device` has been replaced with `qml.devices.LegacyDevice` to
facilitate readability.

*Important note*: The `qml.Device` class is used extensively in the
source code, docs, and tests. In this PR, we just replaced such working
with the new alias in some cases (such as checks) to show how it can
improve readability. In particular, we didn't modify `tests`, docs, and
`.rst` files. The purpose of this PR is to introduce an alias, not to
replace `qml.Device` entirely.

**Benefits:** This feature enhances readability in the code, and many
developers have requested it. It can be confusing to infer the
difference between `qml.Device` (old device API) and
`qml.devices.Device` (new device API). Now, it is clear that we have two
different APIs.

The following code snippet shows how this new alias can be used:
```
>>> import pennylane as qml

>>> qml.devices.LegacyDevice
pennylane._device.Device

>>> qml.Device
pennylane._device.Device

>>> qml.Device == qml.devices.LegacyDevice
True
```

**Possible Drawbacks:** None that I can think of right now.

**Related GitHub Issues:** None.

[sc-57332]
…fer_measurements` and postselection (#5558)

**Context:**
Deferring measurements implies that we replace operations classically
controlled on mid-circuit measurement values by standard controlled
quantum operations. If postselection is used, we can save on the number
of control wires and on the overall number of operations queued by
`defer_measurements`.

Note that a single postselected measurement can reduce the number of
operations drastically, depending on the classical coprocessing.

**Description of the Change:**
This PR changes `defer_measurements` to only queue operations that are
not reduced to the identity because of postselection rules. In addition,
control wires corresponding to postselected measurements are excluded,
as their value is known at transform time already.

To achieve the above, this PR adds a method `_postselected_items` to
`MeasurementValue` that only returns a (pruned) branch together with the
classical processing result of the non-pruned branch.

**Benefits:**
Reduction of operation count and complexity when using
`defer_measurements` with postselection.

**Possible Drawbacks:**

**Related GitHub Issues:**

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Automatic sync from the release candidate to master during a feature
freeze.

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
Co-authored-by: GitHub Actions Bot <>
Co-authored-by: Christina Lee <christina@xanadu.ai>
### Before submitting

Please complete the following checklist when submitting a PR:

- [x] All new features must include a unit test.
If you've fixed a bug or added code that should be tested, add a test to
the
      test directory!

- [x] All new functions and code must be clearly commented and
documented.
If you do make documentation changes, make sure that the docs build and
      render correctly by running `make docs`.

- [x] Ensure that the test suite passes, by running `make test`.

- [x] Add a new entry to the `doc/releases/changelog-dev.md` file,
summarizing the
      change, and including a link back to the PR.

- [x] The PennyLane source code conforms to
      [PEP8 standards](https://www.python.org/dev/peps/pep-0008/).
We check all of our code against [Pylint](https://www.pylint.org/).
      To lint modified files, simply `pip install pylint`, and then
      run `pylint pennylane/path/to/file.py`.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


------------------------------------------------------------------------------------------------------------

**Context:**

**Description of the Change:**

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Automatic sync from the release candidate to master during a feature
freeze.

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com>
Co-authored-by: GitHub Actions Bot <>
**Context:**

We've been seeing a lot of stochastic failures lately. We have random
tests that rely on the global numpy rng. Adding new tests or changing
around the order tests are run in can cause tests to randomly fail,
eating large amounts of CI and developer time.

**Description of the Change:**

Sets a global numpy seed before each test.

**Benefits:**

No more CI flakiness.

**Possible Drawbacks:**

Might still be a "special" seed, with failures on other seed values. We
should periodically update this seed just for testing robustness.

**Related GitHub Issues:**
Automatic sync from the release candidate to master during a feature
freeze.

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com>
Co-authored-by: Pietropaolo Frisoni <pietropaolo.frisoni@xanadu.ai>
Co-authored-by: GitHub Actions Bot <>
Automatic sync from the release candidate to master during a feature
freeze.

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com>
Co-authored-by: Pietropaolo Frisoni <pietropaolo.frisoni@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: GitHub Actions Bot <>
**Context:**

While `qml.equal` has been incredibly helpful in helping us compare
operators, measurements, and tapes, it can sometimes be rather difficult
to determine *why* two operations are not equal.

This new `assert_equal` function will raise and `AssertionError` with
context, making it easier to debug failures occuring in tests or
scripts.

**Description of the Change:**

This PR just sets up the framework by:

1) Allowing the `_equal` function to return either a bool or str.
2) Making `qml.equal` interpret a string as `False`
3) Adding `assert_equal` to raise an `AssertionError` from the output of
`_equal`
4) Implementing the bool-> str conversion for `BasisRotation`

`BasisRotation` is as it an edge case where I can demonstrate what we
want these functions to look like without taking away the core part of
the work.

**Benefits:**

Easier debugging.

**Possible Drawbacks:**

More to maintain.

**Related GitHub Issues:**

---------

Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Automatic sync from the release candidate to master during a feature
freeze.

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com>
Co-authored-by: Pietropaolo Frisoni <pietropaolo.frisoni@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Korbinian Kottmann <43949391+Qottmann@users.noreply.github.com>
Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
Co-authored-by: Guillermo Alonso-Linaje <65235481+KetpuntoG@users.noreply.github.com>
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: Diksha Dhawan <40900030+ddhawan11@users.noreply.github.com>
Co-authored-by: Isaac De Vlugt <isaacdevlugt@gmail.com>
Co-authored-by: Diego <67476785+DSGuala@users.noreply.github.com>
Co-authored-by: trbromley <brotho02@gmail.com>
Co-authored-by: GitHub Actions Bot <>
Copy link
Contributor

github-actions bot commented May 6, 2024

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@astralcai astralcai changed the base branch from master to v0.36.0-rc0 May 6, 2024 21:40
@astralcai astralcai closed this May 6, 2024
@astralcai astralcai deleted the astralcai-patch-1 branch May 6, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants