-
Notifications
You must be signed in to change notification settings - Fork 714
Add smart default mappings to PL-QT #7604
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
Merged
Merged
Conversation
This file contains hidden or 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
soranjh
approved these changes
Jun 20, 2025
Co-authored-by: Soran Jahangiri <40344468+soranjh@users.noreply.github.com>
Co-authored-by: Soran Jahangiri <40344468+soranjh@users.noreply.github.com>
obliviateandsurrender
approved these changes
Jun 20, 2025
Contributor
obliviateandsurrender
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving conditional on minor comments.
Co-authored-by: Utkarsh <utkarshazad98@gmail.com>
a9fbc84 to
f3969b3
Compare
ec8ab75 to
bbea644
Compare
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jun 20, 2025
…rcuits and operators to Qualtran bloqs (#7197) **Context:** We implement the adapter class `ToBloq` and a user-facing function `to_bloq` that converts a PennyLane Operator or QNode to a Qualtran bloq/cbloq. In this PR, we specifically target the ability to convert PennyLane decompositions to their Qualtran equivalent. When a PennyLane Operator is wrapped with the ToBloq class or is wrapped with `qml.to_bloq(..., map_ops=False)`, `decompose_bloq()` will return the PennyLane decomposition. This enables us to use functions in Qualtran, such as `draw_musical_score`, `call_graph()` and many more. Important to note that calling `to_bloq()` on basic gates that have **direct** equivalents (e.g. Hadamard, RX...) will **always** return the Qualtran equivalent, even if `map_ops=False`. We do this because in order for some Qualtran functionality to work properly, it needs to see exactly `qt.Hadamard()` rather than `qml.ToBloq(qml.Hadamard())`; if for some reason, someone really wants to use the wrapped bloq, they can always call `qml.ToBloq()` on the operator directly to "force" the wrapping. We also implement the outlines for more bespoke functionality, namely implementing `_get_op_call_graph()` for QPE and expanding `_map_to_bloq()` to have a default and custom mapping options. We further expand on these functionalities in the wrapper PR (#7536) and the mapper PR (#7604). **Description of the Change:** Implementation of the `ToBloq` class, `to_bloq()` function, and `_map_to_bloq()` function. Also includes stubs for `_get_op_call_graph()`. There is also a number of tests for all the functions, including those that verify that the "round-trip" works, and that the decompositions are accurate. **Benefits:** PL ops and qnodes can be translated to Bloqs, which can then be used as-is for deeper analysis in Qualtran. **Related GitHub Issues:** [[sc-87435](https://app.shortcut.com/xanaduai/story/87435)] [sc-89901] --------- Co-authored-by: Utkarsh <utkarshazad98@gmail.com> Co-authored-by: Soran Jahangiri <40344468+soranjh@users.noreply.github.com> Co-authored-by: Diego <67476785+DSGuala@users.noreply.github.com>
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.
Context:
In this PR, we add smart default mappings to certain operators that have exact or highly similar equivalents in Qualtran. We don't add smart defaults when the mapping would not be very similar, instead opting to let users use a custom mapping instead due to the differences.
There are a few mappings that would make sense to have but are not supported. We outline them below and with some brief reasoning.
qml.TrotterProduct/TrotterizedQFunc: qt.TrotterizedUnitary can only trotterize Bloqs that meet certain technical requirements, of which ToBloq cannot achieve.
qml.StatePrep: Unclear which StatePrep to map to
qml.PrepSelPrep: Maps to qt.LCUBlockEncoding but unclear how to map the inner Select and Prep
qml.Qubitization: There doesn't exist a factory function that produces a generic enough qt.QubitizationWalkOperator
Description of the Change:
Added smart default mappings
Benefits:
Easy to use mappings
Possible Drawbacks:
Related GitHub Issues: