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 qml.matrix docs for wire ordering with qnodes #4874

Merged
merged 8 commits into from Nov 27, 2023

Conversation

mudit2812
Copy link
Contributor

Context:
qml.matrix wire ordering with the new default.qubit was causing problems when device.wires=None. This is because when device.wires=None, the tape wires are used, the order of which is determined by which wires are used first, even with sequential integer wire labels.

Description of the Change:

  • Added documentation to qml.matrix to provide more details on how the wire order is determined when using qml.matrix with a QNode.

Benefits:
Users may be less confused if qml.matrix gives a matrix with an unexpected wire order.

Possible Drawbacks:

Related GitHub Issues:

@mudit2812 mudit2812 requested a review from a team November 23, 2023 15:34
Copy link

codecov bot commented Nov 23, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (370d9d4) 99.65% compared to head (d4e7983) 99.64%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4874      +/-   ##
==========================================
- Coverage   99.65%   99.64%   -0.02%     
==========================================
  Files         385      385              
  Lines       34719    34569     -150     
==========================================
- Hits        34599    34446     -153     
- Misses        120      123       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mudit2812
Copy link
Contributor Author

[sc-50654]

pennylane/ops/functions/matrix.py Outdated Show resolved Hide resolved
pennylane/ops/functions/matrix.py Outdated Show resolved Hide resolved
pennylane/ops/functions/matrix.py Outdated Show resolved Hide resolved
Copy link
Contributor

@trbromley trbromley left a comment

Choose a reason for hiding this comment

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

Thanks @mudit2812! I like the addition of the note box to make things very clear. Can we also have it in the wire_order arg docstring?

        wire_order (Sequence[Any], optional): Order of the wires in the quantum circuit.
            The default wire order depends on the type of ``op``:

            - If ``op`` is a :class:`~.QNode`, then the wire order is determined by the
              associated device's wires, if provided.

            - Otherwise, the wire order is determined by the order in which wires
              appear in the circuit.

            - See the usage details for more information.

Feel free to reword some of the above!

Copy link
Contributor

@lillian542 lillian542 left a comment

Choose a reason for hiding this comment

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

One formatting thing not rendering correctly, otherwise looks good to me! 🚀

pennylane/ops/functions/matrix.py Outdated Show resolved Hide resolved
@mudit2812 mudit2812 enabled auto-merge (squash) November 24, 2023 22:37
@mudit2812 mudit2812 merged commit d6a8049 into master Nov 27, 2023
35 checks passed
@mudit2812 mudit2812 deleted the matrix-wire-order branch November 27, 2023 14:01
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.

None yet

4 participants