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

QNode.execute_kwargs no longer has mcm_config key #1452

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

andrijapau
Copy link
Contributor

@andrijapau andrijapau commented Jan 13, 2025

Context:

PennyLaneAI/pennylane#6807 deprecates mcm_config as an argument to qml.execute. Instead it is designed to have signature parity with QNode, instead accepting both postselect_mode and mcm_method as arguments and creating a MCMConfig internally.

❗ As a side-effect, QNode.execute_kwargs no longer has a mcm_config key.

This PR updates Catalyst source code to reflect that.

Description of the Change:

Use postselect_mode and mcm_method keys for QNode.execute_kwargs instead of mcm_config.

Benefits: Signature parity with QNode and better testing capabilities.

Possible Drawbacks: None identified.

[sc-80541]

@andrijapau andrijapau changed the title fix: Update files that still use mcm_config as key to exec_kwargs QNode.execute_kwargs no longer has "mcm_config" key Jan 13, 2025
@andrijapau andrijapau changed the title QNode.execute_kwargs no longer has "mcm_config" key QNode.execute_kwargs no longer has mcm_config key Jan 13, 2025
Copy link
Contributor

@dime10 dime10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andrijapau !

Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md on your branch 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.

@andrijapau andrijapau requested a review from a team January 14, 2025 21:16
@andrijapau
Copy link
Contributor Author

@dime10, does this need to be in the changelog? 🙇🏼‍♂️

@dime10
Copy link
Contributor

dime10 commented Jan 14, 2025

@dime10, does this need to be in the changelog? 🙇🏼‍♂️

It's alright from my side, but if you want to add it you can do it in the Internal Changes :)

albi3ro added a commit to PennyLaneAI/pennylane that referenced this pull request Jan 24, 2025
**Context:**

Further `qml.workflow` clean-up. This enables `qml.execute` to mimic the
signature of `QNode`. This ensures that we don't get incompatible
configurations because we have two different entry points.

**Description of the Change:**

### **Eco-System**
- [x] Catalyst: PennyLaneAI/catalyst#1452
- [x] Lightning: No instances of deprecated code found.
- [x] QML Demos: No instances of deprecated code found.

### **Plugins**
- [x] Pennylane-AQT: No instances of deprecated code found.
- [x] Pennylane-Qiskit: No instances of deprecated code found.
- [x] Pennylane-IonQ: No instances of deprecated code found.
- [x] Pennylane-Qrack: No instances of deprecated code found.
- [x] Pennylane-Cirq: No instances of deprecated code found.
- [x] Pennylane-Qulacs: No instances of deprecated code found.

Introduce kwargs `postselect_mode` and `mcm_method` to `qml.execute`
signature. Raise deprecation warning to user if they try to use
`mcm_config` kwarg.

Side-effect: Had to `xfail` any tests that had to do with Catalyst since
they assume certain keys from the `QNode.execute_kwargs`. Will be
reverted in #6873.

**Benefits:**

Keyword parity with `qml.QNode`.

**Possible Drawbacks:** None identified.

[sc-80541]

---------

Co-authored-by: Christina Lee <[email protected]>
Co-authored-by: Yushao Chen (Jerry) <[email protected]>
mudit2812 added a commit to PennyLaneAI/pennylane that referenced this pull request Jan 24, 2025
commit 666941f
Author: Andrija Paurevic <[email protected]>
Date:   Fri Jan 24 11:22:28 2025 -0500

    `qml.execute` no longer accepts `mcm_config` argument (#6807)

    **Context:**

    Further `qml.workflow` clean-up. This enables `qml.execute` to mimic the
    signature of `QNode`. This ensures that we don't get incompatible
    configurations because we have two different entry points.

    **Description of the Change:**
    - [x] Catalyst: PennyLaneAI/catalyst#1452
    - [x] Lightning: No instances of deprecated code found.
    - [x] QML Demos: No instances of deprecated code found.
    - [x] Pennylane-AQT: No instances of deprecated code found.
    - [x] Pennylane-Qiskit: No instances of deprecated code found.
    - [x] Pennylane-IonQ: No instances of deprecated code found.
    - [x] Pennylane-Qrack: No instances of deprecated code found.
    - [x] Pennylane-Cirq: No instances of deprecated code found.
    - [x] Pennylane-Qulacs: No instances of deprecated code found.

    Introduce kwargs `postselect_mode` and `mcm_method` to `qml.execute`
    signature. Raise deprecation warning to user if they try to use
    `mcm_config` kwarg.

    Side-effect: Had to `xfail` any tests that had to do with Catalyst since
    they assume certain keys from the `QNode.execute_kwargs`. Will be
    reverted in #6873.

    **Benefits:**

    Keyword parity with `qml.QNode`.

    **Possible Drawbacks:** None identified.

    [sc-80541]

    ---------

    Co-authored-by: Christina Lee <[email protected]>
    Co-authored-by: Yushao Chen (Jerry) <[email protected]>

commit dbb3315
Author: ringo-but-quantum <[email protected]>
Date:   Fri Jan 24 09:51:39 2025 +0000

    [no ci] bump nightly version

commit f367e01
Author: Rashid N H M <[email protected]>
Date:   Thu Jan 23 10:47:17 2025 -0500

    Add merge queue trigger for required workflows (#6860)

    **Context:**
    This pull request adds a new trigger to the existing workflows that run
    `on.pull_request`. This trigger indicates to GitHub which workflows
    needs to be run when a merge queue is building.

    **Description of the Change:**
    The change is adding `on.merge_group` to our required workflows.

    **Benefits:**
    This change itself will not enable merge queues, that needs to be
    enabled from the admin settings of branch protection rules.

    The changes in this PR mainly tell merge queues which workflows to run.

    **Possible Drawbacks:**
    Usage of merge queue is a new thing for pennylane, if issues arise we
    can rollback.

    **Related GitHub Issues:**
    None. [sc-82039]

commit 8a12fa5
Author: Andrija Paurevic <[email protected]>
Date:   Thu Jan 23 10:06:38 2025 -0500

    Promote `gradient_kwargs` to a positional keyword argument in `QNode` (#6828)

    **Context:**
    `gradient_kwargs` is now a positional keyword argument for the `QNode`.
    This means you can not simply express,
    ```python
    qml.QNode(func, dev, h=1)
    ```
    instead, you must deliberately,
    ```python
    qml.QNode(func, dev, gradient_kwargs={"h":1})
    ```
    This allows easier and cleaner input validation.

    This PR could have wide-spread impact as it is very common to just
    specify `gradient_kwargs` casually as additional kwargs.
    - [x] Catalyst: PennyLaneAI/catalyst#1480
    - [x] Lightning:
    PennyLaneAI/pennylane-lightning#1045
    - [x] QML Demos: No instances of deprecated code found.
    - [x] Pennylane-AQT: No instances of deprecated code found.
    - [x] Pennylane-Qiskit: No instances of deprecated code found.
    - [x] Pennylane-IonQ: No instances of deprecated code found.
    - [x] Pennylane-Qrack: No instances of deprecated code found.
    - [x] Pennylane-Cirq: No instances of deprecated code found.
    - [x] Pennylane-Qulacs: No instances of deprecated code found.

    **Description of the Change:**

    Allow additional kwargs for now to ensure same functionality, but raise
    a deprecation warning. Append those additional kwargs to the internal
    gradient_kwargs dictionary.

    **Benefits:** Improved input validation for users.

    **Possible Drawbacks:** Might have missed some eco-system changes.
    Especially with CI **sometimes** not raising
    `PennyLaneDeprecationWarning`s as errors 😢 .

    [sc-81531]

    ---------

    Co-authored-by: Christina Lee <[email protected]>

commit 875ae11
Author: Christina Lee <[email protected]>
Date:   Thu Jan 23 09:31:47 2025 -0500

    Revert end-to-end jitting with default qubit (#6869)

    **Context:**

    In #6788 , we started allowing executions on default qubit to be jitted
    from end-to-end. Unfortunately, we found that the compilation overheads
    on these executions can get very, very expensive. So until we find a way
    to reduce the compilation overheads, we are using pure callbacks and
    conversion to numpy.

    **Description of the Change:**

    Default to `convert_to_numpy=False`, and xfail relevant tests. This
    change can be undone once we figure out how to resolve the compilation
    issue.

    **Benefits:**

    Reduced compilation overheads, because the execution itself does not get
    compiled.

    **Possible Drawbacks:**

    Slow down on post-compiled workflows. No way to jit an entire execution
    on default qubit.

    **Related GitHub Issues:**

    ---------

    Co-authored-by: Pietropaolo Frisoni <[email protected]>

commit 63cca88
Author: ringo-but-quantum <[email protected]>
Date:   Thu Jan 23 09:51:30 2025 +0000

    [no ci] bump nightly version

commit 61dbc71
Author: Andrija Paurevic <[email protected]>
Date:   Wed Jan 22 16:15:54 2025 -0500

    Deprecate `qml.gradients.hamiltonian_grad` (#6849)

    **Context:**

    **Description of the Change:**

    _Source-Code_

    Standard deprecation of `hamiltonian_grad` function.

    _Test suite_

    I noticed that the tests I've removed from `test_parameter_shift.py`
    have improved duplicates in `tests/workflow/interfaces` under the
    `TestHamiltonianWorkflows` test class. Therefore, they were all removed
    except `test_jax`. The reason is that this test follows the outdated
    workflow that still hits the branch in
    `parameter_shift.py::expval_param_shift` that raises the deprecation
    warning. So, I've added a warning and left that test. This should be
    removed with the `hamiltonian_grad` function next release.

    **Impact:**

    No deprecated code found elsewhere. Impact to the eco-system should be
    minimal.

    [sc-81526]

commit 3e1521b
Author: Mudit Pandey <[email protected]>
Date:   Wed Jan 22 11:09:07 2025 -0500

    [Capture] Add a `QmlPrimitive` class to differentiate between different types of primitives (#6847)

    This PR adds a `QmlPrimitive` subclass of `jax.core.Primitive`. This
    class contains a `prim_type` property set using a new `PrimitiveType`
    enum. `PrimitiveType`s currently available are "default", "operator",
    "measurement", "transform", and "higher_order". This can be made more or
    less fine grained as needed, but should be enough to differentiate
    between different types of primitives for now. Additionally, this PR:

    * updates `NonInterpPrimitive` to be a subclass of `QmlPrimitive`
    * updates all existing PennyLane primitives to be either `QmlPrimitive`
    or `NonInterpPrimitive`. See [this
    comment](#6851 (comment))
    to see the logic used to determine which `Primitive` subclass is used
    for each primitive.
    * updates `PlxprInterpreter.eval` and `CancelInversesInterpreter.eval`
    to use this `prim_type` property.

    [sc-82420]

    ---------

    Co-authored-by: Pietropaolo Frisoni <[email protected]>

commit fdf34ec
Author: ringo-but-quantum <[email protected]>
Date:   Wed Jan 22 09:51:47 2025 +0000

    [no ci] bump nightly version

commit 90dc57c
Author: Christina Lee <[email protected]>
Date:   Tue Jan 21 16:21:11 2025 -0500

    [Capture] Add backprop validation (#6852)

    **Context:**

    We currently use un-validated backprop for differentiation with program
    capture. This leads to some unintuitive errors if you try and take a
    gradient on lightning with capture enabled.

    **Description of the Change:**

    Adds some validation to make sure the device supports backprop. Adds the
    backprop logic to a `_backprop` jvp function, and dispatches to that
    method based on the diff method.

    **Benefits:**

    Improved error messages when backprop or the requested diff method isn't
    supported.

    **Possible Drawbacks:**

    The code currently is a little clunky, but it is private so we should be
    able to move things around once we have more information.

    **Related GitHub Issues:**

    [sc-82166]

commit 98bb29b
Author: Isaac De Vlugt <[email protected]>
Date:   Tue Jan 21 14:14:39 2025 -0500

    `lie_closure_dense` typo in docstring (#6858)

    **Context:**

    **Description of the Change:** Docstring code example

    **Benefits:** Docstring code example works

    **Possible Drawbacks:** 0️⃣

    **Related GitHub Issues:**

commit fe9c9a1
Author: Yushao Chen (Jerry) <[email protected]>
Date:   Tue Jan 21 13:48:22 2025 -0500

    Fix the deprecated usage of `MultiControlledX` in labs (#6862)

    **Context:**
    In the tests
    `pennylane/labs/tests/resource_estimation/ops/op_math/test_controlled_ops.py`
    there are several test suites that were using the deprecated interfaces
    of `MultiControlledX`, which will fail after the removal of
    corresponding deprecated `control_wires` arg.
    We fix the usages in this PR.

    **Description of the Change:**

    **Benefits:**

    **Possible Drawbacks:**

    **Related GitHub Issues:**

commit 872607d
Author: Mudit Pandey <[email protected]>
Date:   Tue Jan 21 11:48:25 2025 -0500

    Bump `torch` version in CI to 2.5.0 (#6868)

    As name says. We should be testing against the latest version of
    `torch`. This PR updates the torch version used in CI to `2.5.0`.

    Also updated torch installation to use `~=` instead of `==` for choosing
    the version, so that bug fix releases (highest possible `2.5.X`) are
    automatically used instead of sticking with `2.5.0`. This should be a
    safe change to make, as torch only adds bug fixes to patch releases and
    no breaking changes
    ([ref](https://lightning.ai/docs/pytorch/stable/versioning.html)).

commit 633b5bd
Author: Mudit Pandey <[email protected]>
Date:   Tue Jan 21 10:14:00 2025 -0500

    Update docs workflow schedule (#6867)

    [sc-82706]

    Docs workflow currently opens a PR to update stable deps on Wednesday,
    while the tests workflow opens the stable deps update PR on Monday.
    Having 2 PRs per week for the same thing is annoying, so the schedule
    time for the docs workflow should be the same as the tests workflow.

commit 37de975
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Tue Jan 21 09:31:51 2025 -0500

    Update stable dependency files (#6856)

commit a97fca5
Author: ringo-but-quantum <[email protected]>
Date:   Tue Jan 21 09:51:51 2025 +0000

    [no ci] bump nightly version

commit 5eaaccb
Author: David Wierichs <[email protected]>
Date:   Tue Jan 21 10:05:20 2025 +0100

    Add some explanations on `NonInterpPrimitive` class (#6851)

    **Context:**
    The capture module uses a variant of `jax.core.Primitive` called
    `NonInterpPrimitive`.
    There were questions about why we need this and what it does.

    **Description of the Change:**
    This PR only adds some explanations to the respective `md` file to
    motivate our usage of this primitive variant.

    **Benefits:**
    Explain code

    **Possible Drawbacks:**
    N/A

    **Related GitHub Issues:**

    ---------

    Co-authored-by: Mudit Pandey <[email protected]>
    Co-authored-by: Pietropaolo Frisoni <[email protected]>
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.

3 participants