-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Allow external users to use snapshot_id #6739
base: main
Are you sure you want to change the base?
Allow external users to use snapshot_id #6739
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6739 +/- ##
=======================================
Coverage 97.83% 97.83%
=======================================
Files 1077 1077
Lines 92577 92633 +56
=======================================
+ Hits 90574 90630 +56
Misses 2003 2003 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM. However, I don't think I'm at the point yet in my understanding of Cirq and the internal systems that I'm qualified to review this, so I think this needs someone else's approval.
@@ -156,15 +156,48 @@ class QuantumJob(proto.Message): | |||
|
|||
class DeviceConfigSelector(proto.Message): | |||
r"""- | |||
This message has `oneof`_ fields (mutually exclusive fields). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is auto generated code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, the changes in this file are from gapic client generation
run_name: str | None = "", | ||
snapshot_id: str | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the default value of run_name
is ""
instead of None? Can we make run_name
and snapshot_id
identical -- both use None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted, so now both run_name and snapshot_id default to "" for consistency (See Will's comment)
@@ -105,19 +111,23 @@ def get_sampler( | |||
processor = self._inner_processor() | |||
# If a run_name or config_alias is not provided, initialize them | |||
# to the Processor's default values. | |||
if not run_name and not device_config_name: | |||
if not run_name and not device_config_name and not snapshot_id: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious why before we use if (bool(run_name) or bool(snapshot_id)) ^ bool(device_config_name):
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we use XOR expression to determine (and enforce) the validity of some parameter permutations. Here we check if no values were passed then initialize to the Processors default values.
# If a run_name or config_alias is not provided, initialize them | ||
# to the Processor's default values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the comment here. "If a run_name or config_alias" isn't neither of them provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
@@ -79,6 +80,9 @@ async def run_async( | |||
device_config_name: An identifier used to select the processor configuration | |||
utilized to run the job. A configuration identifies the set of | |||
available qubits, couplers, and supported gates in the processor. | |||
snapshot_id: A unique identifier for an immutable snapshot reference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be documented (and enforced) that it's invalid to specify both run name and snapshot id - both here and elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some documentation here, and enforcement in the subclasses.
@@ -634,7 +686,9 @@ def test_create_job_with_run_name_and_device_config_name( | |||
priority=10, | |||
processor_selector=quantum.SchedulingConfig.ProcessorSelector( | |||
processor='projects/proj/processors/processor0', | |||
device_config_selector=quantum.DeviceConfigSelector(), | |||
device_config_selector=quantum.DeviceConfigSelector( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change remove an existing test case? Should it be preserved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted, and created new test to explicitly test new code
) | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'run_job_kwargs, expected_submit_args', | ||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recognize that this was an existing test, but this massive parameterization block makes it really difficult to figure out what's being tested. Consider adding a new test that explicitly refers to the condition you're demonstrating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, and reverted changes from massive parametrization block
@@ -600,7 +650,7 @@ def test_create_job_with_run_name_and_device_config_name( | |||
priority=10, | |||
processor_selector=quantum.SchedulingConfig.ProcessorSelector( | |||
processor='projects/proj/processors/processor0', | |||
device_config_selector=quantum.DeviceConfigSelector(), | |||
device_config_selector=quantum.DeviceConfigSelector(run_name=""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change needed? I wouldn't expect this PR's change to affect the existing tests of run_name
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a side-effect of moving run_name
into a oneof
"Oneof Impact: When you assign an empty string to a string field within a oneof, protocol buffers interpret this as explicitly setting that field to a value (even if it's an empty value). This triggers the oneof to recognize that field as the active one."
A follow up to PR, CL
Allows external users to set a snapshot_id