@@ -207,6 +207,7 @@ def __init__(
207
207
def __str__ (self ) -> str :
208
208
return f'Engine(project_id={ self .project_id !r} )'
209
209
210
+ # TODO(#6271): Deprecate and remove processor_ids before v1.4
210
211
def run (
211
212
self ,
212
213
program : cirq .AbstractCircuit ,
@@ -219,6 +220,10 @@ def run(
219
220
program_labels : Optional [Dict [str , str ]] = None ,
220
221
job_description : Optional [str ] = None ,
221
222
job_labels : Optional [Dict [str , str ]] = None ,
223
+ * ,
224
+ processor_id : str = "" ,
225
+ run_name : str = "" ,
226
+ device_config_name : str = "" ,
222
227
) -> cirq .Result :
223
228
"""Runs the supplied Circuit via Quantum Engine.
224
229
@@ -236,19 +241,34 @@ def run(
236
241
and day.
237
242
param_resolver: Parameters to run with the program.
238
243
repetitions: The number of repetitions to simulate.
239
- processor_ids: The engine processors that should be candidates
240
- to run the program. Only one of these will be scheduled for
241
- execution .
244
+ processor_ids: Deprecated list of candidate processor ids to run the program.
245
+ Only allowed to contain one processor_id. If the argument `processor_id`
246
+ is non-empty, `processor_ids` will be ignored .
242
247
program_description: An optional description to set on the program.
243
248
program_labels: Optional set of labels to set on the program.
244
249
job_description: An optional description to set on the job.
245
250
job_labels: Optional set of labels to set on the job.
251
+ processor_id: Processor id for running the program. If not set,
252
+ `processor_ids` will be used.
253
+ run_name: A unique identifier representing an automation run for the
254
+ specified processor. An Automation Run contains a collection of
255
+ device configurations for a processor. If specified, `processor_id`
256
+ is required to be set.
257
+ device_config_name: An identifier used to select the processor configuration
258
+ utilized to run the job. A configuration identifies the set of
259
+ available qubits, couplers, and supported gates in the processor.
260
+ If specified, `processor_id` is required to be set.
246
261
247
262
Returns:
248
263
A single Result for this run.
249
264
250
265
Raises:
251
266
ValueError: If no gate set is provided.
267
+ ValueError: If neither `processor_id` or `processor_ids` are set.
268
+ ValueError: If only one of `run_name` and `device_config_name` are specified.
269
+ ValueError: If `processor_ids` has more than one processor id.
270
+ ValueError: If either `run_name` and `device_config_name` are set but
271
+ `processor_id` is empty.
252
272
"""
253
273
return list (
254
274
self .run_sweep (
@@ -262,9 +282,13 @@ def run(
262
282
program_labels = program_labels ,
263
283
job_description = job_description ,
264
284
job_labels = job_labels ,
285
+ processor_id = processor_id ,
286
+ run_name = run_name ,
287
+ device_config_name = device_config_name ,
265
288
)
266
289
)[0 ]
267
290
291
+ # TODO(#6271): Deprecate and remove processor_ids before v1.4
268
292
async def run_sweep_async (
269
293
self ,
270
294
program : cirq .AbstractCircuit ,
@@ -277,6 +301,10 @@ async def run_sweep_async(
277
301
program_labels : Optional [Dict [str , str ]] = None ,
278
302
job_description : Optional [str ] = None ,
279
303
job_labels : Optional [Dict [str , str ]] = None ,
304
+ * ,
305
+ processor_id : str = "" ,
306
+ run_name : str = "" ,
307
+ device_config_name : str = "" ,
280
308
) -> engine_job .EngineJob :
281
309
"""Runs the supplied Circuit via Quantum Engine.Creates
282
310
@@ -297,20 +325,35 @@ async def run_sweep_async(
297
325
and day.
298
326
params: Parameters to run with the program.
299
327
repetitions: The number of circuit repetitions to run.
300
- processor_ids: The engine processors that should be candidates
301
- to run the program. Only one of these will be scheduled for
302
- execution .
328
+ processor_ids: Deprecated list of candidate processor ids to run the program.
329
+ Only allowed to contain one processor_id. If the argument `processor_id`
330
+ is non-empty, `processor_ids` will be ignored .
303
331
program_description: An optional description to set on the program.
304
332
program_labels: Optional set of labels to set on the program.
305
333
job_description: An optional description to set on the job.
306
334
job_labels: Optional set of labels to set on the job.
335
+ processor_id: Processor id for running the program. If not set,
336
+ `processor_ids` will be used.
337
+ run_name: A unique identifier representing an automation run for the
338
+ specified processor. An Automation Run contains a collection of
339
+ device configurations for a processor. If specified, `processor_id`
340
+ is required to be set.
341
+ device_config_name: An identifier used to select the processor configuration
342
+ utilized to run the job. A configuration identifies the set of
343
+ available qubits, couplers, and supported gates in the processor.
344
+ If specified, `processor_id` is required to be set.
307
345
308
346
Returns:
309
347
An EngineJob. If this is iterated over it returns a list of
310
348
TrialResults, one for each parameter sweep.
311
349
312
350
Raises:
313
351
ValueError: If no gate set is provided.
352
+ ValueError: If neither `processor_id` or `processor_ids` are set.
353
+ ValueError: If only one of `run_name` and `device_config_name` are specified.
354
+ ValueError: If `processor_ids` has more than one processor id.
355
+ ValueError: If either `run_name` and `device_config_name` are set but
356
+ `processor_id` is empty.
314
357
"""
315
358
engine_program = await self .create_program_async (
316
359
program , program_id , description = program_description , labels = program_labels
@@ -322,10 +365,14 @@ async def run_sweep_async(
322
365
processor_ids = processor_ids ,
323
366
description = job_description ,
324
367
labels = job_labels ,
368
+ processor_id = processor_id ,
369
+ run_name = run_name ,
370
+ device_config_name = device_config_name ,
325
371
)
326
372
327
373
run_sweep = duet .sync (run_sweep_async )
328
374
375
+ # TODO(#6271): Deprecate and remove processor_ids before v1.4
329
376
async def run_batch_async (
330
377
self ,
331
378
programs : Sequence [cirq .AbstractCircuit ],
@@ -338,6 +385,10 @@ async def run_batch_async(
338
385
program_labels : Optional [Dict [str , str ]] = None ,
339
386
job_description : Optional [str ] = None ,
340
387
job_labels : Optional [Dict [str , str ]] = None ,
388
+ * ,
389
+ processor_id : str = "" ,
390
+ run_name : str = "" ,
391
+ device_config_name : str = "" ,
341
392
) -> engine_job .EngineJob :
342
393
"""Runs the supplied Circuits via Quantum Engine.Creates
343
394
@@ -367,13 +418,23 @@ async def run_batch_async(
367
418
require sweeps.
368
419
repetitions: Number of circuit repetitions to run. Each sweep value
369
420
of each circuit in the batch will run with the same repetitions.
370
- processor_ids: The engine processors that should be candidates
371
- to run the program. Only one of these will be scheduled for
372
- execution .
421
+ processor_ids: Deprecated list of candidate processor ids to run the program.
422
+ Only allowed to contain one processor_id. If the argument `processor_id`
423
+ is non-empty, `processor_ids` will be ignored .
373
424
program_description: An optional description to set on the program.
374
425
program_labels: Optional set of labels to set on the program.
375
426
job_description: An optional description to set on the job.
376
427
job_labels: Optional set of labels to set on the job.
428
+ processor_id: Processor id for running the program. If not set,
429
+ `processor_ids` will be used.
430
+ run_name: A unique identifier representing an automation run for the
431
+ specified processor. An Automation Run contains a collection of
432
+ device configurations for a processor. If specified, `processor_id`
433
+ is required to be set.
434
+ device_config_name: An identifier used to select the processor configuration
435
+ utilized to run the job. A configuration identifies the set of
436
+ available qubits, couplers, and supported gates in the processor.
437
+ If specified, `processor_id` is required to be set.
377
438
378
439
Returns:
379
440
An EngineJob. If this is iterated over it returns a list of
@@ -385,12 +446,17 @@ async def run_batch_async(
385
446
Raises:
386
447
ValueError: If the length of programs mismatches that of params_list, or
387
448
`processor_ids` is not supplied.
449
+ ValueError: If neither `processor_id` or `processor_ids` are set.
450
+ ValueError: If only one of `run_name` and `device_config_name` are specified.
451
+ ValueError: If `processor_ids` has more than one processor id.
452
+ ValueError: If either `run_name` and `device_config_name` are set but
453
+ `processor_id` is empty.
388
454
"""
389
455
if params_list is None :
390
456
params_list = [None ] * len (programs )
391
457
elif len (programs ) != len (params_list ):
392
458
raise ValueError ('Number of circuits and sweeps must match' )
393
- if not processor_ids :
459
+ if not processor_ids and not processor_id :
394
460
raise ValueError ('Processor id must be specified.' )
395
461
engine_program = await self .create_batch_program_async (
396
462
programs , program_id , description = program_description , labels = program_labels
@@ -402,6 +468,9 @@ async def run_batch_async(
402
468
processor_ids = processor_ids ,
403
469
description = job_description ,
404
470
labels = job_labels ,
471
+ processor_id = processor_id ,
472
+ run_name = run_name ,
473
+ device_config_name = device_config_name ,
405
474
)
406
475
407
476
run_batch = duet .sync (run_batch_async )
@@ -778,11 +847,19 @@ def sampler(self, processor_id: Union[str, List[str]]) -> 'cirq_google.Processor
778
847
"""
779
848
return self .get_sampler (processor_id )
780
849
781
- def get_sampler (self , processor_id : Union [str , List [str ]]) -> 'cirq_google.ProcessorSampler' :
850
+ def get_sampler (
851
+ self , processor_id : Union [str , List [str ]], run_name : str = "" , device_config_name : str = ""
852
+ ) -> 'cirq_google.ProcessorSampler' :
782
853
"""Returns a sampler backed by the engine.
783
854
784
855
Args:
785
856
processor_id: String identifier of which processor should be used to sample.
857
+ run_name: A unique identifier representing an automation run for the
858
+ processor. An Automation Run contains a collection of device
859
+ configurations for the processor.
860
+ device_config_name: An identifier used to select the processor configuration
861
+ utilized to run the job. A configuration identifies the set of
862
+ available qubits, couplers, and supported gates in the processor.
786
863
787
864
Returns:
788
865
A `cirq.Sampler` instance (specifically a `engine_sampler.ProcessorSampler`
@@ -798,7 +875,9 @@ def get_sampler(self, processor_id: Union[str, List[str]]) -> 'cirq_google.Proce
798
875
'to get_sampler() no longer supported. Use Engine.run() instead if '
799
876
'you need to specify a list.'
800
877
)
801
- return self .get_processor (processor_id ).get_sampler ()
878
+ return self .get_processor (processor_id ).get_sampler (
879
+ run_name = run_name , device_config_name = device_config_name
880
+ )
802
881
803
882
804
883
def get_engine (project_id : Optional [str ] = None ) -> Engine :
0 commit comments