-
Notifications
You must be signed in to change notification settings - Fork 1.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
Initialize processor sampler with the default device config key #6521
Changes from 17 commits
bcd3533
69ed553
bc55c9d
9b1309b
7845b3c
73a493d
e2cf369
92637bf
42c4939
47a7e3f
02e54c7
eaf153c
0e1726e
53a66a5
10d42bb
85c28c4
4848cb0
a70f2ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,13 +14,14 @@ | |
|
||
import datetime | ||
|
||
import logging | ||
from typing import Dict, List, Optional, TYPE_CHECKING, Union | ||
|
||
from google.protobuf import any_pb2 | ||
|
||
import cirq | ||
from cirq_google.cloud import quantum | ||
from cirq_google.api import v2 | ||
from cirq_google.cloud import quantum | ||
from cirq_google.devices import grid_device | ||
from cirq_google.engine import abstract_processor, calibration, processor_sampler, util | ||
|
||
|
@@ -80,6 +81,8 @@ def __init__( | |
self.context = context | ||
self._processor = _processor | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
def __repr__(self) -> str: | ||
return ( | ||
f'<EngineProcessor: processor_id={self.processor_id!r}, ' | ||
|
@@ -110,8 +113,22 @@ def get_sampler( | |
Returns: | ||
A `cirq.Sampler` instance (specifically a `engine_sampler.ProcessorSampler` | ||
that will send circuits to the Quantum Computing Service | ||
when sampled.1 | ||
when sampled. | ||
""" | ||
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 or not device_config_name: | ||
logging.info( | ||
"Cannot specify only one of `run_name` and `device_config_name`. " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a user tried to specify a config then they probably didn't intend to use the default. If we automatically fix it for them, then they may not notice and wind up running the experiment with a different config than they expected. They should acknowledge the issue by fixing the incorrect config, so we should probably still raise an error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered this, but thought logging that we're switching to the default values would be sufficient since there's precedent for switching to a simulator if the user is unable to connect to the But, I think this is a good concern so I opted to only initialize with the default value if |
||
"Using the Processor's default values instead.\n" | ||
"Default run_name: `%s`\n" | ||
"Default device_config_name: `%s`\n", | ||
processor.default_device_config_key.run, | ||
processor.default_device_config_key.config_alias, | ||
) | ||
run_name = processor.default_device_config_key.run | ||
device_config_name = processor.default_device_config_key.config_alias | ||
return processor_sampler.ProcessorSampler( | ||
processor=self, run_name=run_name, device_config_name=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.
Do you know if there's a policy on logging in Cirq? I only see it used for tests in Google-managed code (cirq-core and cirq-google). I do see some examples of print statements coupled with a verbosity flag, e.g.:
Cirq/cirq-google/cirq_google/engine/engine_client.py
Line 151 in 4afe4ae