cirq_google.engine.EngineProgram

A program created via the Quantum Engine API.

Inherits From: AbstractProgram

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.

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.

add_labels_async

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.

batch_size_async

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.

delete_async

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.

delete_job

View source

Deletes the job and result, if any.

delete_job_async

View source

Deletes the job and result, if any.

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.

Returns
The program's cirq Circuit.

get_circuit_async

View source

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

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.ExecutionStatus.State enum for accepted values.

list_jobs_async

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.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.

remove_labels_async

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.
description An optional description to set on the job.
labels Optional set of labels to set on the job.
processor_id Processor id for running the program.
run_name A unique identifier representing an automation run for the specified processor. An Automation Run contains a collection of device configurations for a processor. If specified, processor_id is required to be set.
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. If specified, processor_id is required to be set.

Returns
A single Result for this run.

Raises
ValueError If a processor id hasn't been specified to run the job
ValueError If only one of run_name and device_config_name are specified.
ValueError If either run_name and device_config_name are set but processor_id is empty.

run_async

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.
description An optional description to set on the job.
labels Optional set of labels to set on the job.
processor_id Processor id for running the program.
run_name A unique identifier representing an automation run for the specified processor. An Automation Run contains a collection of device configurations for a processor. If specified, processor_id is required to be set.
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. If specified, processor_id is required to be set.

Returns
A single Result for this run.

Raises
ValueError If a processor id hasn't been specified to run the job
ValueError If only one of run_name and device_config_name are specified.
ValueError If either run_name and device_config_name are set but processor_id is empty.

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.
description An optional description to set on the job.
labels Optional set of labels to set on the job.
processor_id Processor id for running the program.
run_name A unique identifier representing an automation run for the specified processor. An Automation Run contains a collection of device configurations for a processor. If specified, processor_id is required to be set.
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. If specified, processor_id is required to be set.

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

Raises
ValueError If a processor id hasn't been specified to run the job
ValueError If only one of run_name and device_config_name are specified.
ValueError If either run_name and device_config_name are set but processor_id is empty.

run_sweep_async

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.
description An optional description to set on the job.
labels Optional set of labels to set on the job.
processor_id Processor id for running the program.
run_name A unique identifier representing an automation run for the specified processor. An Automation Run contains a collection of device configurations for a processor. If specified, processor_id is required to be set.
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. If specified, processor_id is required to be set.

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

Raises
ValueError If a processor id hasn't been specified to run the job
ValueError If only one of run_name and device_config_name are specified.
ValueError If either run_name and device_config_name are set but processor_id is empty.

set_description

View source

Sets the description of the program.

Params
description The new description for the program.

Returns
This EngineProgram.

set_description_async

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.

set_labels_async

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.