Skip to content
Pasqal Documentation

Workloads

Pasqal has developed a set of quantum-based or quantum-inspired algorithms which can be executed using the dedicated workload API. A workload is the execution of one of these algorithms on the Pasqal Cloud infrastructure.

Create a Workload

To submit a new workload, select a type, target one of the available backends and provide a configuration object to execute it.

You can create a workload through the SDK with the following command:

workload = sdk.create_workload(workload_type="<WORKLOAD_TYPE>", backend="<BACKEND>", config={"config_param_1": "value"})

You can cancel the workload by doing:

sdk.cancel_workload(workload.id)

Or refresh the workload status/results by with the following:

workload = sdk.get_workload(workload.id)

Once the workload has been processed, you can print the result like this:

print(f"workload-id: {workload.id}, status: {workload.status}, result: {workload.result}")

Example: Execute a Qadence circuit on the cloud

Qadence (external) is a Python package built by Pasqal which lets you build digital-analog quantum programs. These programs can be sent to the cloud as a workload to execute on our self-hosted emulators.

Let’s define a very simple quantum circuit that creates a Bell state (external) .

from qadence import CNOT, H, QuantumCircuit
circuit = QuantumCircuit(2, H(0), CNOT(0, 1))

Then, initialize the cloud connection using your credentials and project ID.

from qadence.pasqal_cloud_connection import SDK
connection = SDK("john.doe@email.com", "my-password", project_id="proj1")

Qadence provides a WorkloadSpec class which helps you define your workload from a circuit. You need to define the name of the backend to execute the circuit as well as the types of result you want to be computed. Pyqtorch is currently the only backend publicly supported for Qadence workloads.

from qadence import BackendName, I
from pasqal_cloud.device.configuration.result_type import ResultType
from qadence.pasqal_cloud_connection import WorkloadSpec
workload_spec = WorkloadSpec(circuit, BackendName.PYQTORCH, [ResultType.EXPECTATION], observable=I(0)*I(1))

The workload is now ready to be submitted for execution!

from qadence.pasqal_cloud_connection import submit_workload
workload_id = submit_workload(connection, workload_spec)

You can follow its status and once it’s done retrieve the results.

from qadence.pasqal_cloud_connection import submit_workload
workload = connection.get_workload(workload_id)
print(f"Workload {workload.id} results: {workload.result}")