-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add CalibrationTag #3423
Conversation
- 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
cirq/google/ops/calibration_tag.py
Outdated
# 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.""" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
cirq/google/ops/calibration_tag.py
Outdated
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 |
There was a problem hiding this comment.
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."
cirq/google/ops/calibration_tag.py
Outdated
self.token = token | ||
|
||
def __str__(self) -> str: | ||
return f'CalibrationTag(\'{self.token}\')' |
There was a problem hiding this comment.
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.
There was a problem hiding this 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\')') |
There was a problem hiding this comment.
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.
calibration.
Calibration API, I have changed this from the formerly named
FocusedCalibrationTag to CalibrationTag