-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: Improved support for IfElseOp
in qiskit_to_tk
#463
Conversation
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.
Looks good, couple of small comments.
@@ -8,6 +8,8 @@ | |||
## 0.64.0 (March 2025) | |||
|
|||
- Update pytket version requirement to 2.0.1. | |||
- Improve {py:func}`qiskit_to_tk` to handle `IfElseOp` (generated by `QuantumCircuit.if_test`) |
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 should be under a new "Unreleased" heading above.
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.
Oops, I mistakenly thought v0.64 was not out yet. Will fix.
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.
fixed 493b3a4
expected_circ.Measure(qreg_tk[0], creg_tk[0]) | ||
expected_circ.Measure(qreg_tk[1], creg_tk[1]) | ||
|
||
assert expected_circ == tkc | ||
|
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.
Can we add one more test where there is no else
condition to make sure that works?
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.
good idea. A test for a single branch using more qubits/bits and a different circuit.
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.
Thanks
|
||
if isinstance(if_else_op.condition[0], Clbit): | ||
if len(bits) != 1: | ||
raise NotImplementedError("Conditions on multiple bits not supported") |
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.
Is there an issues / is this something we want to add in the future?
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.
Possibly but it may be more annoying to handle and maintain. I'm not certain on the limits on what you can express with QuantumCircuit.if_test
(I should check).
I think for now we should stick with single bit conditions and entire register command conditions. If theres a demand for different cases then we can decide to support that.
Description
Adding handling of register conditions for
IfElseOp
.For now I think we should only handle conditions on single bits or entire registers. Conditons involving multiple bits, partial register conditons, or bits from different classical registers are out of scope for now. Handling these cases could be a bit annoying and I'm not sure its worth the maintenence overhead.
driveby: use the new
Circuit.has_implicit_wireswaps
property to make a small simplification totk_to_qiskit
. See bc8f2f9.Related issues
closes #452
Checklist