Skip to content

Commit ab86979

Browse files
authored
Flush deprecations before minor release (#6622)
* Remove deprecated constants from cirq_google module. Long past the `v0.16` deprecation deadline, constants were invalid for almost 2 years after #5762. * Remove deprecated method `cirq_google.Engine.sampler()` Long past the `v1.0` deprecation deadline. * Purge deprecated arguments to `EngineProcessor.list_calibrations` `earliest_timestamp_seconds` and `latest_timestamp_seconds` are long past the `v1.0` deadline. * Remove deprecated function `cirq_ionq.ionq_devices.decompose_to_device`. Long past the `v0.16` deadline. Ref: https://github.com/quantumlib/Cirq/blob/main/release.md#before-you-release-flush-the-deprecation-backlog
1 parent a9776d0 commit ab86979

File tree

9 files changed

+6
-139
lines changed

9 files changed

+6
-139
lines changed

cirq-google/cirq_google/__init__.py

-24
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"""Classes for working with Google's Quantum Engine API."""
1616

1717
import sys
18-
from cirq import _compat
1918
from cirq_google import api
2019

2120
from cirq_google._version import __version__
@@ -114,26 +113,3 @@
114113
from cirq_google.json_resolver_cache import _class_resolver_dictionary
115114

116115
_register_resolver(_class_resolver_dictionary)
117-
118-
119-
_SERIALIZABLE_GATESET_DEPRECATION_MESSAGE = (
120-
'SerializableGateSet and associated classes (GateOpSerializer, GateOpDeserializer,'
121-
' SerializingArgs, DeserializingArgs) will no longer be supported.'
122-
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of a device'
123-
' is represented as a cirq.Gateset and is available as'
124-
' GridDevice.metadata.gateset.'
125-
' Engine methods no longer require gate sets to be passed in.'
126-
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.'
127-
)
128-
129-
130-
_compat.deprecate_attributes(
131-
__name__,
132-
{
133-
'XMON': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
134-
'FSIM_GATESET': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
135-
'SQRT_ISWAP_GATESET': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
136-
'SYC_GATESET': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
137-
'NAMED_GATESETS': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
138-
},
139-
)

cirq-google/cirq_google/engine/engine.py

-16
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from google.protobuf import any_pb2
3535

3636
import cirq
37-
from cirq._compat import deprecated
3837
from cirq_google.api import v2
3938
from cirq_google.engine import (
4039
abstract_engine,
@@ -564,21 +563,6 @@ def get_processor(self, processor_id: str) -> engine_processor.EngineProcessor:
564563
"""
565564
return engine_processor.EngineProcessor(self.project_id, processor_id, self.context)
566565

567-
@deprecated(deadline="v1.0", fix="Use get_sampler instead.")
568-
def sampler(self, processor_id: Union[str, List[str]]) -> 'cirq_google.ProcessorSampler':
569-
"""Returns a sampler backed by the engine.
570-
571-
Args:
572-
processor_id: String identifier, or list of string identifiers,
573-
determining which processors may be used when sampling.
574-
575-
Returns:
576-
A `cirq.Sampler` instance (specifically a `engine_sampler.ProcessorSampler`
577-
that will send circuits to the Quantum Computing Service
578-
when sampled.
579-
"""
580-
return self.get_sampler(processor_id)
581-
582566
def get_sampler(
583567
self, processor_id: Union[str, List[str]], run_name: str = "", device_config_name: str = ""
584568
) -> 'cirq_google.ProcessorSampler':

cirq-google/cirq_google/engine/engine_processor.py

+2-28
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ def _date_to_timestamp(
4242
return None
4343

4444

45-
def _fix_deprecated_seconds_kwargs(kwargs):
46-
if 'earliest_timestamp_seconds' in kwargs:
47-
kwargs['earliest_timestamp'] = kwargs['earliest_timestamp_seconds']
48-
del kwargs['earliest_timestamp_seconds']
49-
if 'latest_timestamp_seconds' in kwargs:
50-
kwargs['latest_timestamp'] = kwargs['latest_timestamp_seconds']
51-
del kwargs['latest_timestamp_seconds']
52-
return kwargs
53-
54-
5545
class EngineProcessor(abstract_processor.AbstractProcessor):
5646
"""A processor available via the Quantum Engine API.
5747
@@ -238,20 +228,6 @@ def get_device(self) -> cirq.Device:
238228
raise ValueError('Processor does not have a device specification')
239229
return grid_device.GridDevice.from_proto(spec)
240230

241-
@cirq._compat.deprecated_parameter(
242-
deadline='v1.0',
243-
fix='Change earliest_timestamp_seconds to earliest_timestamp.',
244-
parameter_desc='earliest_timestamp_seconds',
245-
match=lambda args, kwargs: 'earliest_timestamp_seconds' in kwargs,
246-
rewrite=lambda args, kwargs: (args, _fix_deprecated_seconds_kwargs(kwargs)),
247-
)
248-
@cirq._compat.deprecated_parameter(
249-
deadline='v1.0',
250-
fix='Change latest_timestamp_seconds to latest_timestamp.',
251-
parameter_desc='latest_timestamp_seconds',
252-
match=lambda args, kwargs: 'latest_timestamp_seconds' in kwargs,
253-
rewrite=lambda args, kwargs: (args, _fix_deprecated_seconds_kwargs(kwargs)),
254-
)
255231
def list_calibrations(
256232
self,
257233
earliest_timestamp: Optional[Union[datetime.datetime, datetime.date, int]] = None,
@@ -260,10 +236,8 @@ def list_calibrations(
260236
"""Retrieve metadata about a specific calibration run.
261237
262238
Params:
263-
earliest_timestamp_seconds: The earliest timestamp of a calibration
264-
to return in UTC.
265-
latest_timestamp_seconds: The latest timestamp of a calibration to
266-
return in UTC.
239+
earliest_timestamp: The earliest timestamp of a calibration to return in UTC.
240+
latest_timestamp: The latest timestamp of a calibration to return in UTC.
267241
268242
Returns:
269243
The list of calibration data with the most recent first.

cirq-google/cirq_google/engine/engine_processor_test.py

-18
Original file line numberDiff line numberDiff line change
@@ -414,24 +414,6 @@ def test_list_calibrations(list_calibrations):
414414
list_calibrations.assert_called_with('a', 'p', f'timestamp >= {today_midnight_timestamp}')
415415

416416

417-
@mock.patch('cirq_google.engine.engine_client.EngineClient.list_calibrations_async')
418-
def test_list_calibrations_old_params(list_calibrations):
419-
# Disable pylint warnings for use of deprecated parameters
420-
# pylint: disable=unexpected-keyword-arg
421-
list_calibrations.return_value = [_CALIBRATION]
422-
processor = cg.EngineProcessor('a', 'p', EngineContext())
423-
with cirq.testing.assert_deprecated('Change earliest_timestamp_seconds', deadline='v1.0'):
424-
assert [
425-
c.timestamp for c in processor.list_calibrations(earliest_timestamp_seconds=1562500000)
426-
] == [1562544000021]
427-
list_calibrations.assert_called_with('a', 'p', 'timestamp >= 1562500000')
428-
with cirq.testing.assert_deprecated('Change latest_timestamp_seconds', deadline='v1.0'):
429-
assert [
430-
c.timestamp for c in processor.list_calibrations(latest_timestamp_seconds=1562600000)
431-
] == [1562544000021]
432-
list_calibrations.assert_called_with('a', 'p', 'timestamp <= 1562600000')
433-
434-
435417
@mock.patch('cirq_google.engine.engine_client.EngineClient.get_calibration_async')
436418
def test_get_calibration(get_calibration):
437419
get_calibration.return_value = _CALIBRATION

cirq-google/cirq_google/engine/engine_test.py

-6
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,6 @@ def test_sampler_with_unary_rpcs(client):
741741
assert results[i].measurements == {'q': np.array([[0]], dtype='uint8')}
742742
assert client().create_program_async.call_args[0][0] == 'proj'
743743

744-
with cirq.testing.assert_deprecated('sampler', deadline='1.0'):
745-
_ = engine.sampler(processor_id='tmp')
746-
747744
with pytest.raises(ValueError, match='list of processors'):
748745
_ = engine.get_sampler(['test1', 'test2'])
749746

@@ -764,9 +761,6 @@ def test_sampler_with_stream_rpcs(client):
764761
assert results[i].measurements == {'q': np.array([[0]], dtype='uint8')}
765762
assert client().run_job_over_stream.call_args[1]['project_id'] == 'proj'
766763

767-
with cirq.testing.assert_deprecated('sampler', deadline='1.0'):
768-
_ = engine.sampler(processor_id='tmp')
769-
770764
with pytest.raises(ValueError, match='list of processors'):
771765
_ = engine.get_sampler(['test1', 'test2'])
772766

cirq-ionq/cirq_ionq/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from cirq_ionq.calibration import Calibration
1818

19-
from cirq_ionq.ionq_devices import IonQAPIDevice, decompose_to_device
19+
from cirq_ionq.ionq_devices import IonQAPIDevice
2020

2121
from cirq_ionq.ionq_gateset import IonQTargetGateset, decompose_all_to_all_connect_ccz_gate
2222

cirq-ionq/cirq_ionq/ionq_devices.py

-31
Original file line numberDiff line numberDiff line change
@@ -72,34 +72,3 @@ def validate_operation(self, operation: cirq.Operation):
7272

7373
def is_api_gate(self, operation: cirq.Operation) -> bool:
7474
return operation in self.gateset
75-
76-
77-
@cirq._compat.deprecated(
78-
deadline='v0.16',
79-
fix='Use cirq.optimize_for_target_gateset(circuit, '
80-
'gateset=cirq_ionq.IonQTargetGateset(atol)) '
81-
'instead.',
82-
)
83-
def decompose_to_device(operation: cirq.Operation, atol: float = 1e-8) -> cirq.OP_TREE:
84-
"""Decompose operation to ionq native operations.
85-
86-
87-
Merges single qubit operations and decomposes two qubit operations
88-
into CZ gates.
89-
90-
Args:
91-
operation: `cirq.Operation` to decompose.
92-
atol: absolute error tolerance to use when declaring two unitary
93-
operations equal.
94-
95-
Returns:
96-
cirq.OP_TREE containing decomposed operations.
97-
98-
Raises:
99-
ValueError: If supplied operation cannot be decomposed
100-
for the ionq device.
101-
102-
"""
103-
return cirq.optimize_for_target_gateset(
104-
cirq.Circuit(operation), gateset=ionq_gateset.IonQTargetGateset(), ignore_failures=False
105-
).all_operations()

docs/google/devices.md

+2-13
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ $$
191191
\right]
192192
$$
193193

194-
This gate has a duration of 12ns and can be used in `cirq_google.SYC_GATESET`
195-
or in the `cirq_google.FSIM_GATESET`.
194+
This gate has a duration of 12ns.
196195

197196
#### Square root of iSWAP
198197

@@ -214,8 +213,7 @@ $$
214213
\right]
215214
$$
216215

217-
This gate has a duration of 32ns and can be used in
218-
`cirq_google.SQRT_ISWAP_GATESET` or in the `cirq_google.FSIM_GATESET`.
216+
This gate has a duration of 32ns.
219217

220218
This gate is implemented by using an entangling gate surrounded by
221219
Z gates. The preceding Z gates are physical Z gates and will absorb
@@ -237,15 +235,6 @@ to see if it is available on the processor you are using.
237235
This gate is equivalent to FSimGate(0, π). It has an approximate duration
238236
of 26ns.
239237

240-
#### FSim gateset
241-
242-
The `cirq.FSIM_GATESET` provides all three of the above gates in one set.
243-
In addition, by using this combined gate set, the FSimGate can be parameterized,
244-
which allows for efficient sweeps across varying two-qubit gates.
245-
Note that providing a theta/phi combination that
246-
is not one of the above gates will cause an error when run on hardware.
247-
248-
249238
### Wait gate
250239

251240
For decay experiments and other applications, a WaitGate is provided

docs/google/engine.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ circuit = cirq.Circuit(
8080
engine = cg.Engine(project_id=YOUR_PROJECT_ID)
8181

8282
# Create a sampler from the engine
83-
sampler = engine.sampler(processor_id='PROCESSOR_ID', gate_set=cg.SYC_GATESET)
83+
sampler = engine.get_sampler(processor_id='PROCESSOR_ID')
8484

8585
# This will run the circuit and return the results in a 'Result'
8686
results = sampler.run(circuit, repetitions=1000)
@@ -193,7 +193,6 @@ engine = cirq_google.Engine(project_id='YOUR_PROJECT_ID')
193193
# Create a sampler from the engine
194194
job = engine.run_batch(circuit_list,
195195
processor_id='PROCESSOR_ID',
196-
gate_set=cirq_google.FSIM_GATESET,
197196
repetitions=1000,
198197
params_list=param_list)
199198
results = job.results()

0 commit comments

Comments
 (0)