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 CalibrationTag #3423

Merged
merged 5 commits into from
Oct 19, 2020
Merged

Conversation

dstrain115
Copy link
Collaborator

  • Adds a tag to designate a token on a tag to use a specific
    calibration.
  • Since we are adjusting the name from Focused Calibration to
    Calibration API, I have changed this from the formerly named
    FocusedCalibrationTag to CalibrationTag

- Adds a tag to designate a token on a tag to use a specific
calibration.
- Since we are adjusting the name from Focused Calibration to
Calibration API, I have changed this from the formerly named
FocusedCalibrationTag to CalibrationTag
@dstrain115 dstrain115 requested a review from balopat October 18, 2020 20:24
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Oct 18, 2020
@dstrain115 dstrain115 requested a review from mrwojtek October 19, 2020 12:55
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""A class that can be used to denote a physical Z gate."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to update module docstring, or just remove since the class docstring should be sufficient.

For that matter, having separate files for each tag might be a bit overkill; perhaps we could put both physical z tag and calibration tag in a single tags.py file. Up to you though.


class CalibrationTag:
"""Tag to add onto an Operation that specifies alternate parameters.
Google devices support the ability to run a procedure from calibration API
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add blank line between initial summary and rest of docstring.

Google devices support the ability to run a procedure from calibration API
that can tune the device for a specific circuit. This will return a token
as part of the result. Attaching a `CalibrationTag` with that token
designates the device to use that tuned gate instead of the default gate
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the phrasing here is a bit awkward, maybe something like "Attaching a CalibrationTag with that token specifies that the gate should use parameters from that specific calibration, instead of the default gate parameters."

self.token = token

def __str__(self) -> str:
return f'CalibrationTag(\'{self.token}\')'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use repr so that token will be properly escaped:

return f'CalibrationTag({self.token!r})'

Same thing in __repr__ below.

@dstrain115 dstrain115 requested a review from maffoo October 19, 2020 16:15
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.

LGTM



def test_str_repr():
assert (str(cirq.google.CalibrationTag('foo')) == 'CalibrationTag(\'foo\')')
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could pull out cirq.google.CalibrationTag('foo') into a local var.

@dstrain115 dstrain115 merged commit 9811ce8 into quantumlib:master Oct 19, 2020
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.

3 participants