Skip to content

Add coupler pulse gate #4130

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

Merged
merged 14 commits into from
Jun 28, 2021
Merged

Conversation

dstrain115
Copy link
Collaborator

@dstrain115 dstrain115 commented May 24, 2021

Adds a shaped trapezoidal pulse gate for experimental gate sets.

  • Adds cirq_google.experimental.ops.CouplerPulse
  • Adds json serialization
  • Adds google api serialization

@dstrain115 dstrain115 requested review from cduck, vtomole and a team as code owners May 24, 2021 20:06
@dstrain115 dstrain115 requested a review from maffoo May 24, 2021 20:06
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label May 24, 2021
@dstrain115 dstrain115 requested a review from wcourtney May 24, 2021 20:06
Copy link
Contributor

@maffoo maffoo left a comment

Choose a reason for hiding this comment

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

Mostly looks good, just a few minor comments.

serialized_gate_id='pulse',
args=[
op_serializer.SerializingArg(
serialized_name='coupling_mhz', serialized_type=float, op_getter='coupling_mhz'
Copy link
Contributor

Choose a reason for hiding this comment

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

Internally we tend to use the standard case for units, even when it clashes with case conventions, so this would be coupling_MHz.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This violates case conventions per Google python style guide, so I don't think it is a good convention to follow.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for lowercase

@balopat
Copy link
Contributor

balopat commented Jun 8, 2021

Do we want to add this gate to XMonDevice.duration_of as well?

@dstrain115
Copy link
Collaborator Author

Do we want to add this gate to XMonDevice.duration_of as well?

I am not sure we want this as a supported gate of XMonDevice. Sycamores are not XMonDevice objects.

@dstrain115 dstrain115 requested a review from maffoo June 15, 2021 16:29
@dstrain115
Copy link
Collaborator Author

A review of this PR next week would be nice, so we can get this in and proceed.

@balopat
Copy link
Contributor

balopat commented Jun 22, 2021

Do we want to add this gate to XMonDevice.duration_of as well?

I am not sure we want this as a supported gate of XMonDevice. Sycamores are not XMonDevice objects.

🤦 oh of course.

However, my main point was that this gate is not included in the duration logic anywhere. _SYCAMORE_DURATIONS_PICOS does have a map of gate ids to picos but that static mapping is inconvenient. Is it going to be a problem that we are sending down gates in circuits without gate_duration_picos set? If not then we can ignore this. At the moment this gate is not simulatable anyway, because it doesn't have a unitary and/or a decomposition...

@dstrain115
Copy link
Collaborator Author

However, my main point was that this gate is not included in the duration logic anywhere. _SYCAMORE_DURATIONS_PICOS does have a map of gate ids to picos but that static mapping is inconvenient. Is it going to be a problem that we are sending down gates in circuits without gate_duration_picos set? If not then we can ignore this. At the moment this gate is not simulatable anyway, because it doesn't have a unitary and/or a decomposition...

gate_duration_picos is only useful client-side. It is not used anywhere except to create the device specification in order to be used in cirq client-side (for instance, for noise models or timing diagrams).

I don't see a great way to add this to device timing right now, since it has a variable length. We currently don't have a way to set a variable length in the device specification, so we currently leave it blank. WaitGate is also in this class (and the "fsim" serializer, since SYC, identity, and sqrt(iSWAP) have different lengths). We could put in a lambda function somewhere, but then that would break the 'serializable' portion of the serializable device.

I'm reluctant to really spend too much time in this, since this is a experimental feature that is interacting with a design that is currently in-flight (Device durations).

Copy link
Contributor

@balopat balopat 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 one more nit around the namespacing

@@ -127,6 +127,10 @@
SerializableGateSet,
)

from cirq_google.experimental.ops import (
Copy link
Contributor

Choose a reason for hiding this comment

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

This essentially makes this feature "public" - how about just keeping it public within cirq_google.experimental? experimental is already imported to the cirq_google namespace.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also,cirq_google.experimental is setup in the json testing framework as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's fine, but it does imply an eventual breakage if we ever move it out of experimental for anyone using it. Given that it is in experimental, I suppose that's okay, but it will inconvenience a handful of researchers.

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we can then deprecate the experimental reference and gracefully transition. It might just be dropped eventually as well, and then that will be the deprecation. In the meantime though we don't inconvenience other users of cirq_google by adding it to the main namespace.

def __repr__(self) -> str:
return (
'cirq_google.experimental.ops.coupler_pulse.'
+ f'CouplerPulse(hold_time={repr(self.hold_time)}, '
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can use formatting code to get the repr:

Suggested change
+ f'CouplerPulse(hold_time={repr(self.hold_time)}, '
+ f'CouplerPulse(hold_time={self.hold_time!r}, '

Same thing applies in a few places below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't know you could do that. Cool. Done.

@balopat balopat added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jun 28, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jun 28, 2021
@CirqBot CirqBot merged commit b1801ab into quantumlib:master Jun 28, 2021
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jun 28, 2021
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Adds a shaped trapezoidal pulse gate for experimental gate sets.

-  Adds `cirq_google.experimental.ops.CouplerPulse`
-  Adds json serialization
- Adds google api serialization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants