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

cleanup remaining uses of old control specialization interface #1490

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

anurudhp
Copy link
Contributor

@anurudhp anurudhp commented Nov 7, 2024

Removes the finally uses of the old SpecializedSingleQubitControlledExtension interface in favour of the new interface from #1451.

For controlled versions of LCUBlockEncoding, SelectBlockEncoding etc, do not update the subbloqs to controlled. Instead, use the appropriate subbloq/controlled-subbloq when decomposing/building call graph.

@anurudhp anurudhp force-pushed the 2024/11/06-refactor-ctrl-sys branch from f0b0dc5 to 56544d6 Compare November 7, 2024 14:35
@anurudhp
Copy link
Contributor Author

anurudhp commented Nov 7, 2024

@fdmalone

@@ -142,6 +142,9 @@ def get_ctrl_system(self, ctrl_spec: 'CtrlSpec') -> Tuple['Bloq', 'AddControlled
def adjoint(self) -> 'Bloq':
return self

def _has_unitary_(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this necessary in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cirq.has_unitary fails to realize that this is unitary because when it decomposes, it gets And^dagger gates which aren't unitary (#1488)

@@ -63,7 +62,7 @@ class BernoulliEncoder(SelectOracle, SpecializedSingleQubitControlledExtension):

@cached_property
def control_registers(self) -> Tuple[Register, ...]:
return () if self.control_val is None else (Register('control', QBit()),)
return ()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to keep around this property if it's just empty? (I missed the older PRs so probably need to read those)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SelectOracle has this as an abstract property, but as there's no special controlled version I just return ().

Ideally the select/prepare interfaces should be updated to the newer BlockEncoding style interfaces (would be a major refactor), but as of now as callees use .control_registers, I'm keeping it as-is.

Copy link
Collaborator

@fdmalone fdmalone left a comment

Choose a reason for hiding this comment

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

LGTM

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.

nice

@mpharrigan mpharrigan merged commit 7497989 into quantumlib:main Nov 7, 2024
8 checks passed
@anurudhp anurudhp deleted the 2024/11/06-refactor-ctrl-sys branch November 7, 2024 19:33
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.

3 participants