Skip to content

estimation

Classes:

OqtopusEstimationBackend

OqtopusEstimationBackend(
    config: OqtopusConfig | None = None,
)

A OQTOPUS backend for a estimation.

Parameters:

  • config

    (OqtopusConfig | None, default: None ) –

    A :class:OqtopusConfig for circuit execution. If this parameter is None and both environment variables OQTOPUS_URL and OQTOPUS_API_TOKEN exist, create a :class:OqtopusConfig using the values of the OQTOPUS_URL, OQTOPUS_API_TOKEN, and OQTOPUS_PROXY environment variables.

    If this parameter is None and the environment variables do not exist, the default section in the ~/.oqtopus file is read.

Methods:

  • estimate

    Execute a estimation of a circuit.

  • estimate_qasm

    Execute estimation of the program.

  • retrieve_job

    Retrieve the job with the given id from OQTOPUS Cloud.

estimate

estimate(
    program: NonParametricQuantumCircuit,
    operator: Operator,
    device_id: str,
    shots: int,
    name: str | None = None,
    description: str | None = None,
    transpiler_info: dict | None = None,
    simulator_info: dict | None = None,
    mitigation_info: dict | None = None,
) -> OqtopusEstimationJob

Execute a estimation of a circuit.

The circuit is transpiled on OQTOPUS Cloud. The QURI Parts transpiling feature is not supported. The circuit is converted to OpenQASM 3.0 format and sent to OQTOPUS Cloud.

Parameters:

  • program

    (NonParametricQuantumCircuit) –

    The circuit to be estimated.

  • operator

    (Operator) –

    The observable operator applied to the circuit.

  • device_id

    (str) –

    The device id to be executed.

  • shots

    (int) –

    Number of repetitions of each circuit, for estimation.

  • name

    (str | None, default: None ) –

    The name to be assigned to the job. Defaults to None.

  • description

    (str | None, default: None ) –

    The description to be assigned to the job. Defaults to None.

  • transpiler_info

    (dict | None, default: None ) –

    The transpiler information. Defaults to None.

  • simulator_info

    (dict | None, default: None ) –

    The simulator information. Defaults to None.

  • mitigation_info

    (dict | None, default: None ) –

    The mitigation information. Defaults to None.

Returns:

estimate_qasm

estimate_qasm(
    program: str,
    operator: Operator,
    device_id: str,
    shots: int,
    name: str | None = None,
    description: str | None = None,
    transpiler_info: dict | None = None,
    simulator_info: dict | None = None,
    mitigation_info: dict | None = None,
) -> OqtopusEstimationJob

Execute estimation of the program.

The program is transpiled on OQTOPUS Cloud. QURI Parts OQTOPUS does not support QURI Parts transpiling feature.

Parameters:

  • program

    (str) –

    The program to be estimated.

  • operator

    (Operator) –

    The observable operator applied to the circuit.

  • device_id

    (str) –

    The device id to be executed.

  • shots

    (int) –

    Number of repetitions of each circuit, for estimation.

  • name

    (str | None, default: None ) –

    The name to be assigned to the job. Defaults to None.

  • description

    (str | None, default: None ) –

    The description to be assigned to the job. Defaults to None.

  • transpiler_info

    (dict | None, default: None ) –

    The transpiler information. Defaults to None.

  • simulator_info

    (dict | None, default: None ) –

    The simulator information. Defaults to None.

  • mitigation_info

    (dict | None, default: None ) –

    The mitigation information. Defaults to None.

Returns:

Raises:

  • ValueError

    If shots is not a positive integer.

  • ValueError

    Imaginary part of coefficient is not supported.

  • BackendError

    If job is wrong or if an authentication error occurred, etc.

retrieve_job

retrieve_job(job_id: str) -> OqtopusEstimationJob

Retrieve the job with the given id from OQTOPUS Cloud.

Parameters:

  • job_id

    (str) –

    The id of the job to retrieve.

Returns:

Raises:

  • BackendError

    If job cannot be found or if an authentication error occurred, etc.

OqtopusEstimationJob

OqtopusEstimationJob(job: JobsJobDef, job_api: JobApi)

A job for a estimation.

Parameters:

Raises:

  • ValueError

    If job or job_api is None.

Methods:

  • cancel

    Cancel the job.

  • refresh

    Retrieve the latest job information from OQTOPUS Cloud.

  • result

    Wait until the job progress to the end and returns the result of the job.

  • to_json

    Return a json string representation of the OqtopusEstimationJob.

  • wait_for_completion

    Wait until the job progress to the end.

Attributes:

  • description (str) –

    The description of the job.

  • device_id (str) –

    The device id of the job.

  • ended_at (datetime) –

    The ended_at of the job.

  • execution_time (float) –

    The execution time of the job.

  • job_id (str) –

    The id of the job.

  • job_info (dict) –

    The detail information of the job.

  • job_type (str) –

    The job type of the job.

  • mitigation_info (dict) –

    The mitigation info of the job.

  • name (str) –

    The name of the job.

  • ready_at (datetime) –

    The ready_at of the job.

  • running_at (datetime) –

    The running_at of the job.

  • shots (int) –

    The shots of the job.

  • simulator_info (dict) –

    The simulator info of the job.

  • status (str) –

    The status of the job.

  • submitted_at (datetime) –

    The submitted_at of the job.

  • transpiler_info (dict) –

    The transpiler info of the job.

description property

description: str

The description of the job.

Returns:

  • str ( str ) –

    The description of the job.

device_id property

device_id: str

The device id of the job.

Returns:

  • str ( str ) –

    The device id of the job.

ended_at property

ended_at: datetime

The ended_at of the job.

Returns:

  • datetime ( datetime ) –

    The ended_at of the job.

execution_time property

execution_time: float

The execution time of the job.

Returns:

  • float ( float ) –

    The execution time of the job.

job_id property

job_id: str

The id of the job.

Returns:

  • str ( str ) –

    The id of the job.

job_info property

job_info: dict

The detail information of the job.

Returns:

  • dict ( dict ) –

    The detail information of the job.

job_type property

job_type: str

The job type of the job.

Returns:

  • str ( str ) –

    The job type of the job.

mitigation_info property

mitigation_info: dict

The mitigation info of the job.

Returns:

  • dict ( dict ) –

    The mitigation info of the job.

name property

name: str

The name of the job.

Returns:

  • str ( str ) –

    The name of the job.

ready_at property

ready_at: datetime

The ready_at of the job.

Returns:

  • datetime ( datetime ) –

    The ready_at of the job.

running_at property

running_at: datetime

The running_at of the job.

Returns:

  • datetime ( datetime ) –

    The running_at of the job.

shots property

shots: int

The shots of the job.

Returns:

  • int ( int ) –

    The shots of the job.

simulator_info property

simulator_info: dict

The simulator info of the job.

Returns:

  • dict ( dict ) –

    The simulator info of the job.

status property

status: str

The status of the job.

Returns:

  • str ( str ) –

    The status of the job.

submitted_at property

submitted_at: datetime

The submitted_at of the job.

Returns:

  • datetime ( datetime ) –

    The submitted_at of the job.

transpiler_info property

transpiler_info: dict

The transpiler info of the job.

Returns:

  • dict ( dict ) –

    The transpiler info of the job.

cancel

cancel() -> None

Cancel the job.

If the job statuses are success, failure, or cancelled, then cannot be cancelled and an error occurs.

Raises:

  • BackendError

    If job cannot be found or if an authentication error occurred or if job cannot be cancelled, etc.

refresh

refresh() -> None

Retrieve the latest job information from OQTOPUS Cloud.

Raises:

  • BackendError

    If job cannot be found or if an authentication error occurred or timeout occurs, etc.

result

result(
    timeout: float | None = None, wait: float = 10.0
) -> OqtopusEstimationResult

Wait until the job progress to the end and returns the result of the job.

If the status of job is not succeeded or failed, or cancelled, the job is retrieved from OQTOPUS Cloud at intervals of wait seconds. If the job does not progress to the end after timeout seconds, raise :class:BackendError.

Parameters:

  • timeout

    (float | None, default: None ) –

    The number of seconds to wait for job.

  • wait

    (float, default: 10.0 ) –

    Time in seconds between queries.

Returns:

Raises:

  • BackendError

    If job cannot be found or if an authentication error occurred or timeout occurs, etc.

to_json

to_json() -> str

Return a json string representation of the OqtopusEstimationJob.

Returns:

  • str ( str ) –

    A json string representation of the OqtopusEstimationJob.

wait_for_completion

wait_for_completion(
    timeout: float | None = None, wait: float = 10.0
) -> JobsJobDef | None

Wait until the job progress to the end.

Calling this function waits until the job progress to the end such as succeeded or failed, cancelled.

Parameters:

  • timeout

    (float | None, default: None ) –

    The number of seconds to wait for job.

  • wait

    (float, default: 10.0 ) –

    Time in seconds between queries.

Returns:

  • JobsJobDef | None

    JobsJobDef | None: If a timeout occurs, it returns None. Otherwise, it returns the Job.

OqtopusEstimationResult

OqtopusEstimationResult(result: dict[str, Any])

A result of a estimation job.

Parameters:

  • result

    (dict[str, Any]) –

    A result of dict type.

Raises:

  • ValueError

    If estimation does not exist in result.

Examples:

An example of a dict of result is as below:

.. code-block::

{
    "estimation": {
        "exp_value": 2.0,
        "stds": 1.1
    }
}

exp_value represents the expectation value. In the above case, exp_value is defined as a real number 2.0. stds represents the standard deviation value.

Attributes:

  • exp_value (float | None) –

    Returns the expectation value.

  • stds (float | None) –

    Returns the standard deviation.

exp_value property

exp_value: float | None

Returns the expectation value.

stds property

stds: float | None

Returns the standard deviation.