-
Notifications
You must be signed in to change notification settings - Fork 631
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
Qualtran-pl interoperability #6921
base: master
Are you sure you want to change the base?
Conversation
Hello. You may have forgotten to update the changelog!
|
pennylane/io/qualtran_io.py
Outdated
def __repr__(self): | ||
return f'FromBloq({self._hyperparameters["bloq"]})' | ||
|
||
def compute_decomposition(self, wires, **kwargs): # pylint: disable=arguments-differ |
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.
this looks reasonable to me after a quick skim 👌
>>> qml.get_bloq_registers_info(Swap(3)) | ||
{'x': Wires([0, 1, 2]), 'y': Wires([3, 4, 5])} |
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.
A bit confusing but what does bitsize=3
in this case? Do we get a SWAP on three wires?
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.
The Bloq Swap basically swaps N bit registers. So in this case you would get qml.SWAP([0, 3]), qml.SWAP([1. 4]), qml.SWAP([2, 5])
Maybe SWAP is not the best example since the qualtran Swap is different from the QML Swap.
r""" | ||
A shim for using bloqs as a PennyLane operation. |
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.
Might want to use an adapter instead of a shim -
r""" | |
A shim for using bloqs as a PennyLane operation. | |
r"""An adapter for using Qualtran [bloqs](https://qualtran.readthedocs.io/en/latest/bloqs/index.html) as a PennyLane operation. |
] | ||
assert qml.FromBloq(cbloq, wires=range(24)).decomposition() == expected | ||
|
||
def test_composite_bloq(self): |
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.
consider adding a test that compares the unitary matrices
- derived using
Bloq.tensor_contract()
- derived using
FromBloq(b).matrix()
- reference
using a non-atomic bloq b
Context:
Qᴜᴀʟᴛʀᴀɴ (quantum algorithms translator) contains a set of abstractions for representing quantum programs and a library of quantum algorithms expressed in that language. It is useful for resource estimation and researchers have expressed interest in its usage but don't have a direct path to make whatever is in qualtran executable on a PL device. (On the other way around, PL users at times want to leverage qualtran's resource counting methods but don't have a convenient solution at hand -- we don't implement this in this PR.) We first implement the Qualtran->PL direction, but leave room for the reverse as well. We also need to pip install from our fork/branch that implements the
as_pl_op()
functions for various bloqs. (https://github.com/PennyLaneAI/Qualtran-PL/tree/bloq_to_op)Description of the Change:
This PR implements the adapter class that allows PL users to use Qualtran bloqs as PL operations.
Benefits:
Qualtran-native users can easily export their bloqs/composite bloqs into executable circuits that benefit from PL features. Pennylane-native users can import Qualtran bloqs that may be useful to their workflows.
Possible Drawbacks:
Autodiff might not be well-supported. We might also have trouble with certain edge case bloqs (e.g. bookkeeping bloqs).
Related GitHub Issues:
[sc-81998] [sc-84160]
Code block (for now):