-
Notifications
You must be signed in to change notification settings - Fork 604
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
Add TransformTrace
, TransformTracer
and TransformInterpreter
classes for transforming PLxPR
#6389
Draft
mudit2812
wants to merge
174
commits into
master
Choose a base branch
from
plxpr-transform-base
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+928
−6
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…AI/pennylane into plxpr-interpreter-base
Co-authored-by: David Wierichs <[email protected]>
…mplexWarnings` (#6543) **Context:** - This PR addresses a recurring ComplexWarning issue that appears when using differentiable workflows involving both complex and float types, particularly during backpropagation. Users have reported this issue (see an example [here](https://discuss.pennylane.ai/t/casting-of-complex-to-float-when-using-phaseshift-in-circuit-for-qml/7439)), and [internal discussions](https://xanaduhq.slack.com/archives/C0743CNS9E3/p1730329623028289) have concluded that while the warning is generally harmless, it can still be confusing for users. **Description of the Change:** - A warning note has been added to the Gradients and training page in the documentation. The note explains the origin of the ComplexWarning, assures users that it is non-critical in this context, and provides a code snippet to suppress the warning. **Benefits:** - Clarifies to users that the ComplexWarning does not indicate a calculation error, which can help avoid unnecessary troubleshooting. - Offers an easy method to suppress the warning **Possible Drawbacks:** - Suppressing warnings could potentially hide other, less common issues involving complex numbers in more advanced workflows - Users may overlook the warning's informational value if they suppress it without fully understanding the implications **Related GitHub Issues:** --------- Co-authored-by: Mudit Pandey <[email protected]>
…amples (#6544) **Context:** - The `qml.AmplitudeEmbedding` docstring examples currently includes an unnecessary return, `qml.expval(qml.Z(0))`, which isn’t referenced or needed in the examples. This can confuse users, it adds an extra detail without contributing to the main purpose of the examples. **Description of the Change:** - Removes the unused qml.expval(qml.Z(0)) return statement from all qml.AmplitudeEmbedding examples **Benefits:** - Streamlines example code **Possible Drawbacks:** N/A **Related GitHub Issues:**
Follow up PR to #6460
**Context:** Prior to this fix, the `repr` for `Identity` was incorrectly indexing `self.wires` at zero. This returned incorrect string representations. ```python >>> repr(qml.I([0, 1, 2, 3]) 'I(0)' ``` This was potentially not caught as the `__repr__` method was not being tested. After this fix, the entire `self.wires` attribute is being processed. This returns the intended string representations of the operator, ```python >>> repr(qml.I([0, 1, 'a', 3]) 'I([0,1,'a',3])' >>> repr(qml.I([0]) 'I(0)' >>> repr(qml.I()) 'I()' ``` **Description of the Change:** 1. Corrected the handling of `self.wires` in `Identity.__repr__`. 2. Added a test to `test_identity.py` to make sure the string representation is accurate. **Benefits:** Code accuracy and clarity. **Possible Drawbacks:** N/A Fixes [sc-77328] --------- Co-authored-by: Mudit Pandey <[email protected]>
**Context:** **Description of the Change:** **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: Andrija Paurevic <[email protected]>
…6521) **Context:** As the higher order primitives `for`, `while`, and `cond` get more feature-rich, especially with the incoming changes for dynamically shaped arrays, it can be hard to keep track of what order the arguments come in. This will get harder when we have to add in more positional arguments for the dynamically shaped array dimensions. **Description of the Change:** Updates `for`, `while` and `cond` to store slices into the positionally arguments instead of numbers of the different types of arguments. Now we can simply consume: ``` args[provided_slice] ``` instead of having to do: ``` args[some_calcualtion_for_start: some_calculation_for_end] ``` I also rewrote some of the logic in the for conditional to make it easier to construct all the relevant data. **Benefits:** **Possible Drawbacks:** For the for loop, the slices into the arguments start after the `start, stop, step` instead of including the offset by three. I wasn't quite sure which one made more sense. **Related GitHub Issues:** [sc-77579] --------- Co-authored-by: David Wierichs <[email protected]>
Context: Completing the deprecation cycle of `qml.shadows.shadow_expval`. Description of the Change: 1. Update deprecations.rst 2. Update changelog-dev.md 3. Remove all deprecated source code No references found in Catalyst, Lightning or QML. [sc-77485] --------- Co-authored-by: lillian542 <[email protected]> Co-authored-by: Mudit Pandey <[email protected]> Co-authored-by: Christina Lee <[email protected]>
**Context:** See EPIC: [[P1] Update PennyLane GitHub repo README content positioning for researchers](https://app.shortcut.com/xanaduai/epic/76283/p1-update-content-in-pennylane-github-repository-readme?cf_workflow=500000005&ct_workflow=all&group_by=none) --------- Co-authored-by: Josh Izaac <[email protected]> Co-authored-by: ixfoduap <[email protected]>
**Context:** Follow up PR addressing the `-0.01%` project code coverage issue that slipped through the cracks in #6530. **Description of the Change:** Removed the relevant check because it was being exclusively tested by a removed unit test (associated with `qml.shadows.shadow_expval`), Here's the old test that was removed which was testing that logic branch: ```python ... def test_non_shadow_error(self): """Test that an exception is raised when the decorated QNode does not return shadows""" dev = qml.device("default.qubit", wires=1, shots=100) @partial(qml.shadows.shadow_expval, H=qml.PauliZ(0)) @qml.qnode(dev) def circuit(): qml.Hadamard(0) return qml.expval(qml.PauliZ(0)) msg = "Tape measurement must be ClassicalShadowMP, got 'ExpectationMP'" with pytest.raises(ValueError, match=msg): circuit() ... ``` **Benefits:** Better code coverage. **Possible Drawbacks:** None. [sc-77485]
mudit2812
changed the title
Add
Add Nov 12, 2024
TransformTrace
, TransformTracer
and TransformTraceInterpreter
classes for transforming PLxPRTransformTrace
, TransformTracer
and TransformInterpreter
classes for transforming PLxPR
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds 3 new classes to
qml.capture
to facilitate transforming PLxPR natively without the need to first createQuantumScript
s.TransformInterpreter
will be used to evaluate PLxPR for the purposes of applying transforms.TransformInterpreter
will useTransformTrace
andTransformTracer
to transform primitives that are being evaluated.TransformDispatcher
,TransformContainer
, andTransformProgram
.qml.capture
to give a detailed explanation of how the framework for applying transforms natively to PLxPR works.qml.capture.enable()
andqml.capture.disable()
to dispatch tojax
when using pennylane classes with capture enabled, and toautograd
when capture is disabled. This assumes that users won't be silly and try to usepennylane.numpy
with capture enabled.[sc-75560]