cirq.google.EngineProgram

A program created via the Quantum Engine API.

This program wraps a Circuit with additional metadata used to schedule against the devices managed by Quantum Engine.

project_id A project_id of the parent Google Cloud Project.
program_id Unique ID of the program within the parent project.
context Engine configuration and context to use.
_program The optional current program state.
result_type The type of program that was created.

project_id A project_id of the parent Google Cloud Project.
program_id Unique ID of the program within the parent project.

Methods

add_labels

View source

Adds new labels to a previously created quantum program.

Params:

  • labels: New labels to add to the existing program labels.

Returns
This EngineProgram.

batch_size

View source

Returns the number of programs in a batch program.

Raises
ValueError if the program created was not a batch program.

create_time

View source

Returns when the program was created.

delete

View source

Deletes a previously created quantum program.

Params:

  • delete_jobs: If True will delete all the program's jobs, other this will fail if the program contains any jobs.

description

View source

Returns the description of the program.

engine

View source

Returns the parent Engine object.

Returns
The program's parent Engine.

get_circuit

View source

Returns the cirq Circuit for the Quantum Engine program. This is only supported if the program was created with the V2 protos.

Args
program_num if this is a batch program, the index of the circuit in the batch. This argument is zero-indexed. Negative values indexing from the end of the list.

Returns
The program's cirq Circuit.

get_job

View source

Returns an EngineJob for an existing Quantum Engine job.

Args
job_id Unique ID of the job within the parent program.

Returns
A EngineJob for the job.

labels

View source

Returns the labels of the program.

list_jobs

View source

Returns the list of jobs for this program.

Args
project_id A project_id of the parent Google Cloud Project.
program_id Unique ID of the program within the parent project.
created_after retrieve jobs that were created after this date or time.
created_before retrieve jobs that were created after this date or time.
has_labels retrieve jobs that have labels on them specified by this dict. If the value is set to *, filters having the label regardless of the label value will be filtered. For example, to query programs that have the shape label and have the color label with value red can be queried using

{'color': 'red', 'shape':'*'}

execution_states retrieve jobs that have an execution state that is contained in execution_states. See quantum.enums.ExecutionStatus.State enum for accepted values.

remove_labels

View source

Removes labels with given keys from the labels of a previously created quantum program.

Params:

  • label_keys: Label keys to remove from the existing program labels.

Returns
This EngineProgram.

run

View source

Runs the supplied Circuit via Quantum Engine.

Args
job_id Optional job id to use. If this is not provided, a random id of the format 'job-################YYMMDD' will be generated, where # is alphanumeric and YYMMDD is the current year, month, and day.
param_resolver Parameters to run with the program.
repetitions The number of repetitions to simulate.
processor_ids The engine processors that should be candidates to run the program. Only one of these will be scheduled for execution.
description An optional description to set on the job.
labels Optional set of labels to set on the job.

Returns
A single Result for this run.

run_batch

View source

Runs a batch of circuits on the QuantumEngine.

This method should only be used if the Program object was created with a BatchProgram. The number of parameter sweeps should match the number of circuits within that BatchProgram.

This method does not block until a result is returned. However, no results will be available until the entire batch is complete.

Args
job_id Optional job id to use. If this is not provided, a random id of the format 'job-################YYMMDD' will be generated, where # is alphanumeric and YYMMDD is the current year, month, and day.
params_list Parameter sweeps to run with the program. There must be one Sweepable object for each circuit in the batch. If this is None, it is assumed that the circuits are not parameterized and do not require sweeps.
repetitions The number of circuit repetitions to run.
processor_ids The engine processors that should be candidates to run the program. Only one of these will be scheduled for execution.
description An optional description to set on the job.
labels Optional set of labels to set on the job.

Returns
An EngineJob. If this is iterated over it returns a list of TrialResults. All TrialResults for the first circuit are listed first, then the TrialResults for the second, etc. The TrialResults for a circuit are listed in the order imposed by the associated parameter sweep.

Raises
ValueError if the program was not a batch program or no processors were supplied.

run_calibration

View source

Runs layers of calibration routines on the Quantum Engine.

This method should only be used if the Program object was created with a FocusedCalibration.

This method does not block until a result is returned. However, no results will be available until all calibration routines complete.

Args
job_id Optional job id to use. If this is not provided, a random id of the format 'calibration-################YYMMDD' will be generated, where # is alphanumeric and YYMMDD is the current year, month, and day.
processor_ids The engine processors that should be candidates to run the program. Only one of these will be scheduled for execution.
description An optional description to set on the job.
labels Optional set of labels to set on the job.

Returns
An EngineJob. Results can be accessed with calibration_results().

run_sweep

View source

Runs the program on the QuantumEngine.

In contrast to run, this runs across multiple parameter sweeps, and does not block until a result is returned.

Args
job_id Optional job id to use. If this is not provided, a random id of the format 'job-################YYMMDD' will be generated, where # is alphanumeric and YYMMDD is the current year, month, and day.
params Parameters to run with the program.
repetitions The number of circuit repetitions to run.
processor_ids The engine processors that should be candidates to run the program. Only one of these will be scheduled for execution.
description An optional description to set on the job.
labels Optional set of labels to set on the job.

Returns
An EngineJob. If this is iterated over it returns a list of TrialResults, one for each parameter sweep.

set_description

View source

Sets the description of the program.

Params:

  • description: The new description for the program.

Returns
This EngineProgram.

set_labels

View source

Sets (overwriting) the labels for a previously created quantum program.

Params:

  • labels: The entire set of new program labels.

Returns
This EngineProgram.

update_time

View source

Returns when the program was last updated.