-
Notifications
You must be signed in to change notification settings - Fork 44
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
Flatten nested controls in ControlledViaAnd
#1373
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.
add a test and ideally a little demo to the doc notebook.
also can you add a description to the PR
@classmethod | ||
def _get_ctrl_spec( | ||
self, | ||
cls, |
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.
where is this called? doesn't the call site need to be updated?
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.
It is only used in one location, to convert cirq style controls to CtrlSpec
:
Qualtran/qualtran/_infra/gate_with_registers.py
Lines 499 to 501 in db8b993
ctrl_spec = self._get_ctrl_spec( | |
num_controls, control_values, control_qid_shape, ctrl_spec=ctrl_spec | |
) |
I made this a class method so that I can call it in #1348 (as the code doesn't depend on the instance).
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 you please update that existing call in gate_with_registers.py
to call it as a class method, i.e. GateWithRegisters._get_ctrl_spec
instead of 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.
done
d8433de
to
5824406
Compare
Override
ControlledViaAnd.get_ctrl_system
so thatControlledViaAnd(bloq, spec1).controlled(spec2)
now returnsControlledViaAnd(bloq, spec)
wherespec
is the sequence ofspec1, spec2
.