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

Deprecate SerializableDevice #5522

Conversation

verult
Copy link
Collaborator

@verult verult commented Jun 14, 2022

To be replaced by GridDevice.

@verult verult requested review from wcourtney, a team, vtomole and cduck as code owners June 14, 2022 23:48
@CirqBot CirqBot added the size: L 250< lines changed <1000 label Jun 14, 2022
@verult
Copy link
Collaborator Author

verult commented Jun 15, 2022

Some test failures are caused by initializing the cirq_google Sycamore devices in init files. These devices are instantiated using cg.SerializableDevice.from_proto(), which throws a deprecation warning at init time and fail because tests aren't expecting warnings.

Is there a way to disable deprecation warning assertions during init?

Alternatively, we could move Sycamore devices to GridDevice. We'd make this change without any deprecation warnings, but if we announce this asap to power users it might be OK.

@95-martin-orion
Copy link
Collaborator

Some test failures are caused by initializing the cirq_google Sycamore devices in init files.

I suppose this is the culprit?

Sycamore = SerializableDevice.from_proto(
proto=SYCAMORE_PROTO, gate_sets=[gate_sets.SQRT_ISWAP_GATESET, gate_sets.SYC_GATESET]
)

I think the right move is to convert this to the new, intended format (GridDevice?), but it's not immediately clear how we would handle deprecating the old Sycamore object. PEP 562 might be relevant here, but it might need to be applied at multiple levels to get this working.

@verult
Copy link
Collaborator Author

verult commented Jun 15, 2022

I suppose this is the culprit?

Yup

Definitely agree that deprecating Sycamore prior to replacing is the ideal approach, but deprecating won't resolve the error here I think, because there will still be warnings causing tests to fail.

CirqBot pushed a commit that referenced this pull request Jun 17, 2022
Blocking SerializableDevice deprecation (#5522)

Recirq needs to be updated to use `Sycamore.metadata.qubit_set` in a follow-up.

I put deprecation warnings as docstrings/comments since I don't expect them to have much usage outside Cirq (one exception being `_SYCAMORE_DURATION_PICOS` is used on server side to serialize DeviceSpecification the old way). Let me know if you'd prefer a full deprecation warning.

@dstrain115 
cc @MichaelBroughton @mpharrigan
@verult verult marked this pull request as draft June 19, 2022 19:41
CirqBot pushed a commit that referenced this pull request Jun 20, 2022
* Migrate the different `processor.get_device()` methods and `Engine.get_engine_device()` to GridDevice
* Deprecate the `gate_sets` parameter in various `get_device()` methods, and remove `gate_sets` usages.

A dedicated deprecation decorator was added in order to handle `gate_sets` parameter being passed in as a positional argument.

Originally I had planned to do this after the 0.15 release, but because library code is not allowed to rely on deprecated code within tests, this is blocking SerializableDevice deprecation (#5522).

@dstrain115 @MichaelBroughton
CirqBot pushed a commit that referenced this pull request Jun 21, 2022
Moves the various device-related functions in `virtual_engine_processor.py` to GridDevice. This is blocking SerializableDevice deprecation (#5522) because library code cannot call the deprecated SerializableDevice.

* Rerouted functions in `virtual_engine_processor.py` to `GridDevice`
* Deprecated the `gate_sets` parameter in `virtual_engine_processor.py`
* Move `create_device_from_processor_id()` to GridDevice. @95-martin-orion 
  * Made the return type more general by changing it to `cirq.Device` to allow for new device implementations in the future. 
* Created copies of existing rainbow and weber DeviceSpecifications and changed them to match the new DeviceSpecification format.
  * This update needs to happen now because `create_noiseless_virtual_engine_from_templates()` is updated to return a `GridDevice`, and the templates (rainbow and weber DeviceSpecifications) need to contain data in the new format in order to parse into GridDevice properly.
  * There are no publicly available devices since weber, so I chose to repurpose the existing rainbow and weber information. This was done manually since these devices are no longer available.
    * Gateset and gate_duration information should match previous versions. In particular, they both include the CZ gate with no duration information.

**Reviewer Note**: The first 3 commits are from another pending PR (#5558); please start with the commit "[Move virtual engine functions to GridDevice](2e9ef33)". Don't be discouraged by the line count :) other than the 3 borrowed commits, ~600 lines are from the two new DeviceSpecification messages.

@mpharrigan 
cc @MichaelBroughton @dstrain115
@verult verult force-pushed the cg-device-refactor/serializable-device-deprecation branch from f7ae076 to ce17a45 Compare June 22, 2022 00:10
@verult verult force-pushed the cg-device-refactor/serializable-device-deprecation branch from ce17a45 to cc5246f Compare June 22, 2022 00:46
@verult verult marked this pull request as ready for review June 22, 2022 00:46
@verult
Copy link
Collaborator Author

verult commented Jun 22, 2022

This is ready to for review! @MichaelBroughton @dstrain115

Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

LGTM, do we still want to use the from_proto @dstrain115 ?

@verult
Copy link
Collaborator Author

verult commented Jun 22, 2022

There are a few references on the server side and in Recirq, but they can easily be swapped to GridDevice since they all expect a cirq.Device

@verult verult added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jun 22, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jun 22, 2022
@CirqBot CirqBot merged commit a58b7fc into quantumlib:master Jun 22, 2022
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jun 22, 2022
@verult
Copy link
Collaborator Author

verult commented Jun 22, 2022

Confirmed with @dstrain115 offline - we want to move to GridDevice entirely so SerializableDevice.from_proto won't be needed.

@verult verult mentioned this pull request Jul 7, 2022
40 tasks
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Blocking SerializableDevice deprecation (quantumlib#5522)

Recirq needs to be updated to use `Sycamore.metadata.qubit_set` in a follow-up.

I put deprecation warnings as docstrings/comments since I don't expect them to have much usage outside Cirq (one exception being `_SYCAMORE_DURATION_PICOS` is used on server side to serialize DeviceSpecification the old way). Let me know if you'd prefer a full deprecation warning.

@dstrain115 
cc @MichaelBroughton @mpharrigan
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
* Migrate the different `processor.get_device()` methods and `Engine.get_engine_device()` to GridDevice
* Deprecate the `gate_sets` parameter in various `get_device()` methods, and remove `gate_sets` usages.

A dedicated deprecation decorator was added in order to handle `gate_sets` parameter being passed in as a positional argument.

Originally I had planned to do this after the 0.15 release, but because library code is not allowed to rely on deprecated code within tests, this is blocking SerializableDevice deprecation (quantumlib#5522).

@dstrain115 @MichaelBroughton
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Moves the various device-related functions in `virtual_engine_processor.py` to GridDevice. This is blocking SerializableDevice deprecation (quantumlib#5522) because library code cannot call the deprecated SerializableDevice.

* Rerouted functions in `virtual_engine_processor.py` to `GridDevice`
* Deprecated the `gate_sets` parameter in `virtual_engine_processor.py`
* Move `create_device_from_processor_id()` to GridDevice. @95-martin-orion 
  * Made the return type more general by changing it to `cirq.Device` to allow for new device implementations in the future. 
* Created copies of existing rainbow and weber DeviceSpecifications and changed them to match the new DeviceSpecification format.
  * This update needs to happen now because `create_noiseless_virtual_engine_from_templates()` is updated to return a `GridDevice`, and the templates (rainbow and weber DeviceSpecifications) need to contain data in the new format in order to parse into GridDevice properly.
  * There are no publicly available devices since weber, so I chose to repurpose the existing rainbow and weber information. This was done manually since these devices are no longer available.
    * Gateset and gate_duration information should match previous versions. In particular, they both include the CZ gate with no duration information.

**Reviewer Note**: The first 3 commits are from another pending PR (quantumlib#5558); please start with the commit "[Move virtual engine functions to GridDevice](quantumlib@2e9ef33)". Don't be discouraged by the line count :) other than the 3 borrowed commits, ~600 lines are from the two new DeviceSpecification messages.

@mpharrigan 
cc @MichaelBroughton @dstrain115
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: L 250< lines changed <1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants