Pasqal Cloud Connection
WorkloadNotDoneError
Bases: Exception
Is raised if a workload is not yet finished running on remote.
WorkloadSpec(circuit, backend, result_types, parameter_values=None, observable=None)
dataclass
Specification of a workload to be executed on Pasqal Cloud.
This data class defines a single workload specification that is to be executed on Pasqal's cloud platform.
PARAMETER | DESCRIPTION |
---|---|
circuit
|
The quantum circuit to be executed.
TYPE:
|
backend
|
The backend to execute the workload on. Not all backends are available on the
cloud platform. Currently the supported backend is
TYPE:
|
result_types
|
The types of result to compute for this workload. The circuit will be run for all result types specified here one by one.
TYPE:
|
parameter_values
|
If the quantum circuit has feature parameters, values for those need to
be provided. In the case there are only variational parameters, this field is
optional. In the case there are no parameters, this field needs to be
TYPE:
|
observable
|
Observable that is used when
TYPE:
|
WorkloadStoppedError
Bases: Exception
Is raised when a workload has stopped running on remote for some reason.
check_status(connection, workload_id)
Checks if the workload is successfully finished on remote connection.
PARAMETER | DESCRIPTION |
---|---|
connection
|
A
TYPE:
|
workload_id
|
the id
TYPE:
|
RAISES | DESCRIPTION |
---|---|
WorkloadNotDoneError
|
Is raised when the workload status is "PENDING", "RUNNING" or "PAUSED". |
WorkloadStoppedError
|
Is raise when the workload status is "CANCELED", "TIMED_OUT" or "ERROR". |
ValueError
|
Is raised when the workload status has an unsupported value. |
RETURNS | DESCRIPTION |
---|---|
Workload
|
The workload result if its status is "DONE" as a |
Source code in qadence/pasqal_cloud_connection.py
get_result(connection, workload_id, timeout=60.0, refresh_time=1.0)
Repeatedly checks if a workload has finished and returns the result.
PARAMETER | DESCRIPTION |
---|---|
connection
|
A
TYPE:
|
workload_id
|
the id
TYPE:
|
timeout
|
Time in seconds after which the function times out. Defaults to 60.0.
TYPE:
|
refresh_time
|
Time in seconds after which the remote is requested to update the status again, when the workload is not finished yet. Defaults to 1.0.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
TimeoutError
|
description |
RETURNS | DESCRIPTION |
---|---|
Workload
|
The workload result if its status is "DONE" as a |
Source code in qadence/pasqal_cloud_connection.py
get_spec_from_model(model, result_types, parameter_values=None, observable=None)
Creates a WorkloadSpec
from a quantum model.
This function creates a WorkloadSpec
from a QuantumModel
and the other arguments provided.
The circuit, that is extracted from the model, is the original circuit that was used to
initialize the model, not the backend converted circuit in model.circuit
. The backend set in
the model will be used in the workload specification.
It is important to note that in case there is an observable defined in the model, it is ignored in the workload specification. To provide an observable to the workload specification, it is only possible to set it in the observable argument of this function.
PARAMETER | DESCRIPTION |
---|---|
model
|
The quantum model that defines the circuit and backend for the workload spec.
TYPE:
|
result_types
|
A list of result types that is requested in this workload.
TYPE:
|
parameter_values
|
The parameter values that should be used during execution of the workload.
TYPE:
|
observable
|
Observable that is used when
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
WorkloadSpec
|
A |
Source code in qadence/pasqal_cloud_connection.py
submit_workload(connection, workload)
Uploads a workload to Pasqal's Cloud and returns the created workload ID.
PARAMETER | DESCRIPTION |
---|---|
connection
|
A
TYPE:
|
workload
|
A
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
A workload id as a |