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

Update Neutral Atoms to Transformers #5311

Merged

Conversation

dstrain115
Copy link
Collaborator

Create function convert_to_neutral_atom_gateset() to
replace PointOptimizer ConvertToNeutralAtomGateset.

Create NeutralAtomGateset that works as a compilation target
gateset.

Create function convert_to_neutral_atom_gateset() to
replace PointOptimizer ConvertToNeutralAtomGateset.

Create NeutralAtomGateset that works as a compilation target
gateset.
@dstrain115 dstrain115 requested review from a team, vtomole and cduck as code owners April 29, 2022 17:29
@CirqBot CirqBot added the size: M 50< lines changed <250 label Apr 29, 2022
Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

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

Looking good overall. Main concern is to avoid introducing the additional convert_to_neutral_atom_gates transformer and instead use the standard API of cirq.optimize_for_target_gateset(circuit, gateset=cirq.NeutralAtomGateset())


if TYPE_CHECKING:
import cirq


@transformers.transformer
def convert_to_neutral_atom_gates(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should just update the deprecation message in ConvertToNeutralAtomGates to point users to the cirq.optimize_for_target_gateset(circuit, gateset=cirq.NeutralAtomGateset) API instead of creating this additional transformer which is essentially just a wrapper. WDYT ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

SGTM, done.

cirq-core/cirq/neutral_atoms/neutral_atom_gateset.py Outdated Show resolved Hide resolved


class NeutralAtomGateset(transformers.CompilationTargetGateset):
def __init__(self, max_parallel_z=None, max_parallel_xy=None):
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Add type annotations to arguments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

import cirq


class NeutralAtomGateset(transformers.CompilationTargetGateset):
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Add docstring

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@tanujkhattar tanujkhattar self-assigned this May 2, 2022
@@ -668,6 +668,7 @@

from cirq.ion import ConvertToIonGates, IonDevice, ms, two_qubit_matrix_to_ion_operations
from cirq.neutral_atoms import (
convert_to_neutral_atom_gates,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove import

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


if TYPE_CHECKING:
import cirq


@deprecated_class(
deadline='v0.16',
fix='Use cirq.optimize_for_target_gateset(' + 'circuit, gateset=NeutralAtomGateset()).',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the break into 2 different strings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Combined.

return 2

def decompose_to_target_gateset(self, op: 'cirq.Operation', moment_idx: int) -> DecomposeResult:
"""Method to rewrite the given operation using gates from this gateset.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add to the docstring that 2q gates are decomposed into CZs because "CZ gates are the highest fidelity 2-qubit gates for neutral atoms." (quoted from docstring of ConvertToNeutralAtomGates optimizer)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@dstrain115 dstrain115 merged commit 7aa198c into quantumlib:master May 2, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
* Update Neutral Atoms to Transformers

Create NeutralAtomGateset that works as a compilation target
gateset.  Point ConvertToNeutralAtomGateset towards
optimize_for_target_gateset instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants