-
Notifications
You must be signed in to change notification settings - Fork 1
Emit a cirq.Circuit from a squin kernel #311
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
base: main
Are you sure you want to change the base?
Conversation
|
||
# NOTE: need to set the block argument SSA values to the ones present in the frame | ||
# FIXME: this feels wrong, there's probably a better way to do this | ||
for block in region.blocks: |
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.
@Roger-luo @weinbe58 do you know how I can properly get the BlockArguments
and ReturnValues
here? The SSA values are there, but the keys are different in the frame, so I resorted to some not so nice loops & checks.
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.
Right now this will basically be the same as inlining the subroutine as you have it here.
I would either just error here and use inlining pass before running emit or think about how to lower a subroutine to a CircuitOperation
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.
why do we handle multiple blocks here? there is only one block? otherwise there will be some sort of control flows which I don't think Cirq supports anyways?
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.
Right now this will basically be the same as inlining the subroutine as you have it here.
Kind of, but there's an important distinction: the result is wrapped as a CircuitOperation
and added as a subcircuit.
or think about how to lower a subroutine to a CircuitOperation
Well, isn't this how you would do that? In the end, you need to emit another circuit from the subroutine somehow and then add it to the "parent" circuit. So, at some point we just need to step into the subroutine. That is sort of like inlining, but how else would you do it?
I don't see an alternative way to emit a CircuitOperation
. We could probably clean up the way I'm passing in arguments and getting the return value, but I'm not sure how. Do you have an idea?
why do we handle multiple blocks here?
Oversight on my part, I'm now throwing an error if there's more than a single block.
☂️ Python Coverage
Overall Coverage
New Files
Modified Files
|
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
This is pretty much complete for now. One thing that is left is to implement the methods for the noise statements, but I'd leave that to another PR since this one is already quite big as it is. |
Actually the |
@weinbe58 if I understand correctly, this only supports randomly choosing from a set of pauli operators. Are multi-qubit PauliChannels not supported in cirq? |
@david-pl I don't know but Cirq supports user-defined gates with any Kraus operator so any user could define their own multi-qubit Pauli channel if it's not already defined. |
Moved discussion on noise to separate issue #317 |
There's still quite a few things to do here:
Kron
) don't have a 1:1 mapping to a cirq gate. They probably need a "runtime", since they are easy enough to apply to qubits. Alternatively, we could use custom gates in cirq, but I'm not much of a fan.BlockArguments
andReturnValues
in the frame for nested kernels. There's probably a better way to do this, but I don't know how (yet).