Skip to content
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

Merged
merged 9 commits into from
Sep 30, 2024

Conversation

anurudhp
Copy link
Contributor

@anurudhp anurudhp commented Sep 1, 2024

Override ControlledViaAnd.get_ctrl_system so that ControlledViaAnd(bloq, spec1).controlled(spec2) now returns ControlledViaAnd(bloq, spec) where spec is the sequence of spec1, spec2.

Copy link
Collaborator

@mpharrigan mpharrigan left a 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

Comment on lines +374 to +376
@classmethod
def _get_ctrl_spec(
self,
cls,
Copy link
Collaborator

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?

Copy link
Contributor Author

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:

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).

Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

qualtran/bloqs/mcmt/controlled_via_and.py Outdated Show resolved Hide resolved
@mpharrigan mpharrigan enabled auto-merge (squash) September 30, 2024 17:17
@mpharrigan mpharrigan merged commit 70dd9f5 into quantumlib:main Sep 30, 2024
8 checks passed
@anurudhp anurudhp deleted the 2024/09/01-nested-ctrls branch September 30, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants