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

Remove use of .device in cirq-google. #4820

Merged
merged 8 commits into from
Jan 11, 2022

Conversation

MichaelBroughton
Copy link
Collaborator

Next step in #4744 . Removes use of device attachment ability in cirq-google. This is a breaking change in the sense that some methods become "more forgiving" which I've highlighted below. Happy to add the tag if people think it's appropriate to label it.

@CirqBot CirqBot added the size: XL lines changed >1000 label Jan 10, 2022
@@ -634,7 +634,6 @@ def _serialize_program(
) -> any_pb2.Any:
if not isinstance(program, cirq.AbstractCircuit):
raise TypeError(f'Unrecognized program type: {type(program)}')
program.device.validate_circuit(program)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Engine no longer validates inside of serialization. As we know this already wasn't doing a great job of catching all the breaks that might come over through engine. Would probably make more sense to couple this up with your new work on the engine emulator. What are your thoughts here @dstrain115 ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is okay, but we should probably modify documentation to make sure that people validate independently of the serialization then. Maybe we could add this to the cirq 1.0 doc list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added to the list thx.

fix=cirq.circuits.circuit._DEVICE_DEP_MESSAGE,
parameter_desc='new_device',
match=lambda args, kwargs: 'new_device' in kwargs,
)
def optimized_for_xmon(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Plan to deprecate the device function signature from this optimizer because it is not a device aware optimizer and all the device was used for was attaching it to the returned circuit.

Comment on lines -327 to -328
if device is None:
raise ValueError('Deserializing schedule requires a device but None was given.')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is a break here that schedules can now have no device. Since we aren't using these anymore I figured this was an acceptable vendor break. @dstrain115

Copy link
Collaborator

Choose a reason for hiding this comment

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

Schedule has been deprecated for over 2.5 years, so we don't need to worry about breakage here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

SG

@MichaelBroughton MichaelBroughton added size: M 50< lines changed <250 and removed size: XL lines changed >1000 labels Jan 11, 2022
Copy link
Collaborator

@dstrain115 dstrain115 left a comment

Choose a reason for hiding this comment

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

I think this is fine. Most of the changes are in deprecated v1/schedule code. so that's no big deal (we should consider deleting some/all of it actually).

Not validating in the engine code is the only concern, but that seems like an unusual operation to do anyway.

@@ -634,7 +634,6 @@ def _serialize_program(
) -> any_pb2.Any:
if not isinstance(program, cirq.AbstractCircuit):
raise TypeError(f'Unrecognized program type: {type(program)}')
program.device.validate_circuit(program)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is okay, but we should probably modify documentation to make sure that people validate independently of the serialization then. Maybe we could add this to the cirq 1.0 doc list?

Comment on lines -327 to -328
if device is None:
raise ValueError('Deserializing schedule requires a device but None was given.')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Schedule has been deprecated for over 2.5 years, so we don't need to worry about breakage here.

@MichaelBroughton MichaelBroughton added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jan 11, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jan 11, 2022
@CirqBot CirqBot merged commit 0a12c88 into quantumlib:master Jan 11, 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 Jan 11, 2022
MichaelBroughton added a commit to MichaelBroughton/Cirq that referenced this pull request Jan 22, 2022
Next step in quantumlib#4744 .  Removes use of device attachment ability in cirq-google. This is a breaking change in the sense that some methods become "more forgiving" which I've highlighted below. Happy to add the tag if people think it's appropriate to label it.
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Next step in quantumlib#4744 .  Removes use of device attachment ability in cirq-google. This is a breaking change in the sense that some methods become "more forgiving" which I've highlighted below. Happy to add the tag if people think it's appropriate to label it.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
Next step in quantumlib#4744 .  Removes use of device attachment ability in cirq-google. This is a breaking change in the sense that some methods become "more forgiving" which I've highlighted below. Happy to add the tag if people think it's appropriate to label it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants