Skip to content

Results are limited to the current section: Cloud services

Product news

API reference

Top-level package — re-exports the public API.

PasqalCloudConnection(username='', password='', project_id='', region='fr', **kwargs)

Bases: RemoteConnection

Manager of the connection to PASQAL's cloud platform.

The cloud connection enables to run sequences on simulators or on real QPUs.

PARAMETER DESCRIPTION
username

Your username in the PASQAL cloud platform.

TYPE: str DEFAULT: ''

password

The password for your PASQAL cloud platform account.

TYPE: str DEFAULT: ''

project_id

The project ID associated to the account.

TYPE: str DEFAULT: ''

kwargs

Additional arguments to provide to the PasqalCloudClient()

TYPE: Any DEFAULT: {}

Initializes a connection to the Pasqal cloud platform.

Source code in pasqal_cloud/pasqal_cloud_connection.py
def __init__(
    self,
    username: str = "",
    password: str = "",
    project_id: str = "",
    region: Region = "fr",
    **kwargs: Any,
):
    """Initializes a connection to the Pasqal cloud platform."""
    self.cloud_client = PasqalCloudClient(
        username=username,
        password=password,
        project_id=project_id,
        region=region,
        **kwargs,
    )

submit(sequence, wait=False, open=False, batch_id=None, device_type=None, backend_configuration=None, **kwargs)

Submits the sequence for execution on a remote Pasqal backend.

Source code in pasqal_cloud/pasqal_cloud_connection.py
def submit(
    self,
    sequence: Sequence,
    wait: bool = False,
    open: bool = False,
    batch_id: str | None = None,
    device_type: DeviceTypeName | None = None,
    backend_configuration: EmulationConfig | None = None,
    **kwargs: Any,
) -> RemoteResults:
    """Submits the sequence for execution on a remote Pasqal backend."""
    sequence = self._add_measurement_to_sequence(sequence)

    job_params: list[CreateJob] = make_json_compatible(kwargs.get("job_params", []))

    if sequence.is_parametrized() or sequence.is_register_mappable():
        for params in job_params:
            vars = params.get("variables", {}) or {}
            sequence.build(**vars)

    backend_configuration_str = (
        backend_configuration.to_abstract_repr() if backend_configuration else None
    )
    # If batch_id is not empty, then we can submit new jobs to a
    # batch we just created otherwise, create a new one with
    #  cloud_client.create_batch()
    if batch_id:
        submit_jobs_fn = retry(self.cloud_client.add_jobs)
        old_job_ids = self._get_job_ids(batch_id)
        batch = submit_jobs_fn(
            batch_id,
            jobs=job_params,
            wait=wait,
        )
        new_job_ids = [
            job_id
            for job_id in self._get_job_ids(batch_id)
            if job_id not in old_job_ids
        ]
    else:
        create_batch_fn = retry(self.cloud_client.create_batch)
        batch = create_batch_fn(
            serialized_sequence=sequence.to_abstract_repr(),
            jobs=job_params,
            device_type=device_type,
            backend_configuration=backend_configuration_str,
            wait=wait,
            open=open,
        )
        new_job_ids = self._get_job_ids(batch.id)
    return self.get_results(batch_id=batch.id, job_ids=new_job_ids)

fetch_available_devices()

Fetches the devices available through this connection.

Source code in pasqal_cloud/pasqal_cloud_connection.py
@retry
def fetch_available_devices(self) -> dict[str, Device]:
    """Fetches the devices available through this connection."""
    abstract_devices = self.cloud_client.get_device_specs_dict()
    return {
        name: cast(Device, deserialize_device(dev_str))
        for name, dev_str in abstract_devices.items()
    }

get_results(batch_id, job_ids=None)

Gets the results for a specific batch.

PARAMETER DESCRIPTION
batch_id

The ID that identifies the batch linked to the results.

TYPE: str

job_ids

If given, specifies which jobs within the batch should be included in the results and in what order. If left undefined, all jobs are included and ordered by date of creation.

TYPE: list[str] | None DEFAULT: None

RETURNS DESCRIPTION
RemoteResults

The requested results.

TYPE: RemoteResults

Source code in pasqal_cloud/pasqal_cloud_connection.py
def get_results(
    self,
    batch_id: str,
    job_ids: list[str] | None = None,
) -> RemoteResults:
    """Gets the results for a specific batch.

    Args:
        batch_id: The ID that identifies the batch linked to the results.
        job_ids: If given, specifies which jobs within the batch should
            be included in the results and in what order. If left undefined,
            all jobs are included and ordered by date of creation.

    Returns:
        RemoteResults: The requested results.
    """
    return RemoteResults(batch_id=batch_id, connection=self, job_ids=job_ids)

supports_open_batch()

Flag to confirm this class can support creating an open batch.

Source code in pasqal_cloud/pasqal_cloud_connection.py
def supports_open_batch(self) -> bool:
    """Flag to confirm this class can support creating an open batch."""
    return True

OVHConnection(**kwargs)

Bases: PasqalCloudConnection

PasqalCloud connection designed for OVH users.

This connection class enables OVH users to access Pasqal Cloud services through pre-configured OVH quantum notebooks. See the OVH product page for more information.

Authentication is handled via a token that must be provided through the PASQAL_PULSER_ACCESS_TOKEN environment variable.

RAISES DESCRIPTION
MissingEnvironmentVariableError

If PASQAL_PULSER_ACCESS_TOKEN environment variable is not set.

Source code in pasqal_cloud/ovh.py
def __init__(self, **kwargs: Any) -> None:
    try:
        token = os.environ["PASQAL_PULSER_ACCESS_TOKEN"]
    except KeyError:
        raise MissingEnvironmentVariableError(
            "Missing PASQAL_PULSER_ACCESS_TOKEN environment variable"
        )

    class OvhTokenProvider(TokenProvider):
        def get_token(self) -> str:
            return token

    self.cloud_client = PasqalCloudClient(
        token_provider=OvhTokenProvider(), client_class=OvhClient, **kwargs
    )

supports_open_batch()

Flag to confirm this class cannot support creating an open batch.

Source code in pasqal_cloud/ovh.py
def supports_open_batch(self) -> bool:
    """Flag to confirm this class cannot support creating an open batch."""
    return False

RemoteMPSBackend(sequence, connection, *, config=None, mimic_qpu=False)

Bases: RemoteEmulatorBackend

Backend for executing quantum programs using the EMU-MPS emulator.

The config supports various fields. For a complete list of accepted parameters (passed as **kwargs), refer to the official EMU-MPS documentation: https://pasqal-io.github.io/emulators/latest/emu_mps/api/#mpsconfig

PARAMETER DESCRIPTION
sequence

The quantum sequence to execute on the backend.

TYPE: Sequence

connection

An open PasqalCloud connection.

TYPE: RemoteConnection

config

An EmulationConfig object to configure the backend. If not provided, the default configuration will be used.

TYPE: EmulationConfig | None DEFAULT: None

mimic_qpu

Whether to mimic the validations required for execution on a QPU.

TYPE: bool DEFAULT: False

Source code in pasqal_cloud/backends.py
def __init__(
    self,
    sequence: pulser.Sequence,
    connection: RemoteConnection,
    *,
    config: EmulationConfig | None = None,
    mimic_qpu: bool = False,
) -> None:
    RemoteBackend.__init__(
        self,
        sequence=sequence,
        connection=connection,
        mimic_qpu=mimic_qpu,
    )
    EmulatorBackend.__init__(
        self,
        sequence,
        config=config,
        mimic_qpu=mimic_qpu,
    )

RemoteSVBackend(sequence, connection, *, config=None, mimic_qpu=False)

Bases: RemoteEmulatorBackend

Backend for executing quantum programs using the EMU-SV emulator.

The config supports various fields. For a complete list of accepted parameters (passed as **kwargs), refer to the official EMU-SV documentation: https://pasqal-io.github.io/emulators/latest/emu_sv/api/#svconfig

PARAMETER DESCRIPTION
sequence

The quantum sequence to execute on the backend.

TYPE: Sequence

connection

An open PasqalCloud connection.

TYPE: RemoteConnection

config

An EmulationConfig object to configure the backend. If not provided, the default configuration will be used.

TYPE: EmulationConfig | None DEFAULT: None

mimic_qpu

Whether to mimic the validations required for execution on a QPU.

TYPE: bool DEFAULT: False

Source code in pasqal_cloud/backends.py
def __init__(
    self,
    sequence: pulser.Sequence,
    connection: RemoteConnection,
    *,
    config: EmulationConfig | None = None,
    mimic_qpu: bool = False,
) -> None:
    RemoteBackend.__init__(
        self,
        sequence=sequence,
        connection=connection,
        mimic_qpu=mimic_qpu,
    )
    EmulatorBackend.__init__(
        self,
        sequence,
        config=config,
        mimic_qpu=mimic_qpu,
    )

RemoteEmuFreeBackend(sequence, connection, *, config=None, mimic_qpu=False)

Bases: RemoteEmulatorBackend

Backend for executing quantum programs using pulser-simulation (QuTiP).

The config supports various fields. For a complete list of accepted parameters (passed as **kwargs), refer to the official documentation: https://pulser.readthedocs.io/en/stable/apidoc/_autosummary/pulser_simulation.QutipConfig.html#pulser_simulation.QutipConfig

PARAMETER DESCRIPTION
sequence

The quantum sequence to execute on the backend.

TYPE: Sequence

connection

An open PasqalCloud connection.

TYPE: RemoteConnection

config

An EmulationConfig object to configure the backend. If not provided, the default configuration will be used.

TYPE: EmulationConfig | None DEFAULT: None

mimic_qpu

Whether to mimic the validations required for execution on a QPU.

TYPE: bool DEFAULT: False

Source code in pasqal_cloud/backends.py
def __init__(
    self,
    sequence: pulser.Sequence,
    connection: RemoteConnection,
    *,
    config: EmulationConfig | None = None,
    mimic_qpu: bool = False,
) -> None:
    RemoteBackend.__init__(
        self,
        sequence=sequence,
        connection=connection,
        mimic_qpu=mimic_qpu,
    )
    EmulatorBackend.__init__(
        self,
        sequence,
        config=config,
        mimic_qpu=mimic_qpu,
    )