Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial Engine client for Calibration API (#3474)
* Add initial Engine client for Calibration API - Adds run_calibration to Engine and EngineProgram. - Adds calibration_results() to EngineJob to retrieve results. - Adds CalibrationLayer and CalibrationResult container data classes for sending and storing results, respectively.
- Loading branch information
1 parent
8bf262e
commit 359a102
Showing
18 changed files
with
580 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
|
||
from cirq.google.api.v2 import ( | ||
batch_pb2, | ||
calibration_pb2, | ||
device_pb2, | ||
metrics_pb2, | ||
program_pb2, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2020 The Cirq Developers | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# 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. | ||
# | ||
import dataclasses | ||
from typing import Dict, TYPE_CHECKING, Union | ||
|
||
if TYPE_CHECKING: | ||
import cirq | ||
|
||
|
||
@dataclasses.dataclass | ||
class CalibrationLayer: | ||
"""Python implementation of the proto found in | ||
cirq.google.api.v2.calibration_pb2.FocusedCalibrationLayer for use | ||
in Engine calls.""" | ||
calibration_type: str | ||
program: 'cirq.Circuit' | ||
args: Dict[str, Union[str, float]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2020 The Cirq Developers | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# 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. | ||
# | ||
import dataclasses | ||
import datetime | ||
from typing import Optional, TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
import cirq | ||
import cirq.google.api.v2.calibration_pb2 as calibration_pb2 | ||
|
||
|
||
@dataclasses.dataclass | ||
class CalibrationResult: | ||
"""Python implementation of the proto found in | ||
cirq.google.api.v2.calibration_pb2.CalibrationLayerResult for use | ||
in Engine calls. | ||
Note that, if these fields are not filled out by the calibration API, | ||
they will be set to the default values in the proto, as defined here: | ||
https://developers.google.com/protocol-buffers/docs/proto3#default | ||
These defaults will converted to `None` by the API client. | ||
""" | ||
code: 'calibration_pb2.CalibrationLayerCode' | ||
error_message: Optional[str] | ||
token: Optional[str] | ||
valid_until: Optional[datetime.datetime] | ||
metrics: 'cirq.google.Calibration' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.