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

Add cirq.SqrtIswapTargetGateset for (parameterized & non-parameterized) compilation to sqrt iswaps. #5025

Merged
merged 3 commits into from
Feb 28, 2022

Conversation

tanujkhattar
Copy link
Collaborator

@tanujkhattar tanujkhattar commented Feb 25, 2022

cc @MichaelBroughton @dstrain115

@CirqBot CirqBot added the size: L 250< lines changed <1000 label Feb 25, 2022
@tanujkhattar tanujkhattar added the Ready for Re-Review For when reviewers take their time. label Feb 25, 2022
Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

We are packing a lot into this PR and it's getting a little hard for me to follow test changes with deprecations woven in as well, would you mind splitting out the deprecation into a seperate PR ? Also why do we mention the support of measurement gates in this transformer it doesn't look like we are inserting measurements as a part of the circuit transformation process ?

@tanujkhattar tanujkhattar changed the title Add cirq.SqrtIswapTargetGateset to replace cirq.MergeInteractionsToSqrtIswap and cg.ConvertToSqrtIswapGates. Add cirq.SqrtIswapTargetGateset for (parameterized & non-parameterized) compilation to sqrt iswaps. Feb 26, 2022
@tanujkhattar
Copy link
Collaborator Author

@MichaelBroughton As discussed offline, I've removed deprecations from this PR and they will follow up in the next PR once this is checked in.

I've also abstracted out the parameterized gate compilation logic to a cirq.parameterized_2q_op_to_sqrt_iswap_operations analytical method and used it in cirq.SqrtIswapTargetGateset. Also added a few more tests that demonstrate the power of implicit decompose + parameterized compilation to support compilation of parameterized gates which are not directly supported by the analytical method.

The PR is ready for a re-review! PTAL

Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

LGTM after nits.

f')'
)

def _value_equality_values_(self) -> Any:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this need a corresponding decorator on the top of the class to auto generate other equalities ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Equalities are auto generated because the class derives from cirq.Gateset, which is decorated with @value.value_equality().

Added additional tests to assert this.

Comment on lines +53 to +55
A parameterized `cirq.OP_TREE` implementing `op` using only `cirq.SQRT_ISWAP`
(or `cirq.SQRT_ISWAP_INV`) and parameterized single qubit rotations OR
None or NotImplemented if decomposition of `op` is not known.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it an op_tree or a DecomposeResult ? (from fxn return type hint)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DecomposeResult is Union[cirq.OP_TREE, None, NotImplementedType] -- the docstring covers all 3 cases.

@tanujkhattar tanujkhattar merged commit 6c45d9c into quantumlib:master Feb 28, 2022
@tanujkhattar tanujkhattar deleted the sqrt_iswap_gateset branch February 28, 2022 18:33
95-martin-orion pushed a commit to 95-martin-orion/Cirq that referenced this pull request Mar 2, 2022
…zed) compilation to sqrt iswaps. (quantumlib#5025)

* Move parameterized decomposition to analytical decomposers and split PR to remove deprecations

* Add equality tests
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…zed) compilation to sqrt iswaps. (quantumlib#5025)

* Move parameterized decomposition to analytical decomposers and split PR to remove deprecations

* Add equality tests
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
…zed) compilation to sqrt iswaps. (quantumlib#5025)

* Move parameterized decomposition to analytical decomposers and split PR to remove deprecations

* Add equality tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready for Re-Review For when reviewers take their time. size: L 250< lines changed <1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cirq.MergeInteractions should also allow FSim and other future decompositions
3 participants