cirq_google.engine.stream_manager.StreamManager

Manages communication with Quantum Engine via QuantumRunStream, a bi-directional stream RPC.

The main manager method is submit(), which sends the provided job to Quantum Engine through the stream and returns a future to be completed when either the result is ready or the job has failed. The submitted job can also be cancelled by calling cancel() on the future returned by submit().

A new stream is opened during the first submit() call, and it stays open. If the stream is unused, users can close the stream and free management resources by calling stop().

Methods

stop

View source

Closes the open stream and resets all management resources.

submit

View source

Submits a job over the stream and returns a future for the result.

If submit() is called for the first time since StreamManager instantiation or since the last time stop() was called, it will create a new long-running stream.

The job can be cancelled by calling cancel() on the returned future.

Args
project_name The full project ID resource path associated with the job.
program The Quantum Engine program representing the circuit to be executed. The program name must be set.
job The Quantum Engine job to be executed.

Returns
A future for the job result, or the job if the job has failed.

Raises
StreamError if there is a non-retryable error while executing the job.
ValueError if program name is not set.
concurrent.futures.CancelledError if the stream is stopped while a job is in flight.
google.api_core.exceptions.GoogleAPICallError if the stream breaks with a non-retryable error.