diff --git a/cirq-google/cirq_google/json_resolver_cache.py b/cirq-google/cirq_google/json_resolver_cache.py index 8a3a138f8e7e..e3e35e28a221 100644 --- a/cirq-google/cirq_google/json_resolver_cache.py +++ b/cirq-google/cirq_google/json_resolver_cache.py @@ -39,6 +39,7 @@ def _class_resolver_dictionary() -> Dict[str, ObjectFactory]: 'FloquetPhasedFSimCalibrationRequest': cirq_google.FloquetPhasedFSimCalibrationRequest, 'PhasedFSimCalibrationResult': cirq_google.PhasedFSimCalibrationResult, 'PhasedFSimCharacterization': cirq_google.PhasedFSimCharacterization, + 'SycamoreTargetGateset': cirq_google.SycamoreTargetGateset, 'XEBPhasedFSimCalibrationOptions': cirq_google.XEBPhasedFSimCalibrationOptions, 'XEBPhasedFSimCalibrationRequest': cirq_google.XEBPhasedFSimCalibrationRequest, 'LocalXEBPhasedFSimCalibrationOptions': cirq_google.LocalXEBPhasedFSimCalibrationOptions, diff --git a/cirq-google/cirq_google/json_test_data/SycamoreTargetGateset.json b/cirq-google/cirq_google/json_test_data/SycamoreTargetGateset.json new file mode 100644 index 000000000000..24866ca6c0e0 --- /dev/null +++ b/cirq-google/cirq_google/json_test_data/SycamoreTargetGateset.json @@ -0,0 +1,5 @@ +{ + "cirq_type": "SycamoreTargetGateset", + "atol": 1e-08, + "tabulation": null +} \ No newline at end of file diff --git a/cirq-google/cirq_google/json_test_data/SycamoreTargetGateset.repr b/cirq-google/cirq_google/json_test_data/SycamoreTargetGateset.repr new file mode 100644 index 000000000000..98c6f4a534ee --- /dev/null +++ b/cirq-google/cirq_google/json_test_data/SycamoreTargetGateset.repr @@ -0,0 +1 @@ +cirq_google.SycamoreTargetGateset(atol=1e-08, tabulation=None) \ No newline at end of file diff --git a/cirq-google/cirq_google/json_test_data/spec.py b/cirq-google/cirq_google/json_test_data/spec.py index 57e83e43a44d..ffe41b148e60 100644 --- a/cirq-google/cirq_google/json_test_data/spec.py +++ b/cirq-google/cirq_google/json_test_data/spec.py @@ -22,7 +22,6 @@ 'WITHOUT_CHI_FLOQUET_PHASED_FSIM_CHARACTERIZATION', 'XmonDevice', 'XMON', - 'SycamoreTargetGateset', ], should_not_be_serialized=[ 'AnnealSequenceSearchStrategy', diff --git a/cirq-google/cirq_google/transformers/target_gatesets/sycamore_gateset.py b/cirq-google/cirq_google/transformers/target_gatesets/sycamore_gateset.py index 71c7b15ffa02..7545ddf45376 100644 --- a/cirq-google/cirq_google/transformers/target_gatesets/sycamore_gateset.py +++ b/cirq-google/cirq_google/transformers/target_gatesets/sycamore_gateset.py @@ -15,7 +15,7 @@ """Target gateset used for compiling circuits to Sycamore + 1-q rotations + measurement gates.""" import itertools -from typing import cast, List, Optional, Sequence +from typing import cast, Any, Dict, List, Optional, Sequence import cirq from cirq.protocols.decompose_protocol import DecomposeResult @@ -165,6 +165,12 @@ def __repr__(self) -> str: return ( f'cirq_google.SycamoreTargetGateset(' f'atol={self.atol}, ' - f'tabulation={self.tabulation}, ' - f')' + f'tabulation={self.tabulation})' ) + + def _json_dict_(self) -> Dict[str, Any]: + return {'atol': self.atol, 'tabulation': self.tabulation} + + @classmethod + def _from_json_dict_(cls, atol, tabulation, **kwargs): + return cls(atol=atol, tabulation=tabulation)