-
Notifications
You must be signed in to change notification settings - Fork 47
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
Extend DecomposeClassicalExp
to handle ClExprOp
#1678
Conversation
DecomposeClassicalExp
to handle ClExprOp
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.
Note that this reverts to the file as it was before #1628 .
@@ -464,14 +465,18 @@ def test_extended_qasm() -> None: | |||
|
|||
assert circuit_to_qasm_str(c2, "hqslib1") | |||
|
|||
assert not DecomposeClassicalExp().apply(c) | |||
with pytest.raises(DecomposeClassicalError): |
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 reverts to the test as it was before #1628 .
assert isinstance(output0, Bit) | ||
out_var: Variable = ( | ||
BitRegister(output0.reg_name, len(output_posn)) | ||
if has_reg_output(expr.op) |
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 it not possible to have an incomplete register here?
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.
(for example when using temp bits?)
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 check at line 380 would catch this case and throw an exception. We do not allow this pass to be run on circuits with non-register-aligned ClExprOp
(even though they are valid pytket circuits). I think removing this restriction would be possible, but would make decomposition more complicated, so prefer to keep it unless there is a real need.
Temporary (scratch) bits would not normally form part of a ClExprOp
. They are introduced when decomposing it into elementary classical operations.
Also fix #1581 by adding support for constant expressions (in
ClExprOp
).