tangelo.linq.qpu_connection package

Submodules

tangelo.linq.qpu_connection.braket_connection module

Wrappers around Braket python’s API, to manage quantum experiments run with Braket from Tangelo. Braket is available at https://github.com/aws/amazon-braket-sdk-python

class tangelo.linq.qpu_connection.braket_connection.BraketConnection(s3_bucket=None, folder=None)

Bases: QpuConnection

Wrapper around Amazon Braket API to facilitate quantum job management from Tangelo

static get_backend_info()

Wrapper method to cut down the information returned by AWS SDK and provide a consistent interface for our code.

Returns:

Dictionary containing device information in the format

{
arn: {

provider: <provider>, price: <price>, unit: <unit>,

}

}

job_cancel(job_id)

Attempt to cancel an existing job. May fail depending on job status (e.g too late)

Parameters:

job_id (str) – string representing the job id

Returns:

bool – whether the job was successfully cancelled.

job_results(job_id)

Blocking call requesting job results.

Parameters:

job_id (str) – string representing the job id

Returns:

dict – histogram of measurements

job_status(job_id)

Return job information corresponding to the input job id

Parameters:

job_id (str) – string representing the job id

Returns:

enum | str – status response from the native API

job_submit(backend_arn, n_shots, circuits)

Submit job as batch, return job id(s).

Parameters:
  • backend_arn (str) – arn for braket backend

  • n_shots (int) – Number of shots to use on the target backend

  • circuits (Circuit | List[Circuit]) – Tangelo circuit(s)

Returns:

str | List[str] – Job id(s)

class tangelo.linq.qpu_connection.braket_connection.SupportedBraketProviders(value)

Bases: str, Enum

List of the providers currently supported. Needs to be occasionally updated in the future as new providers arise.

AMAZON = 'Amazon Braket'
IONQ = 'IonQ'
OXFORD = 'Oxford'
RIGETTI = 'Rigetti'
tangelo.linq.qpu_connection.braket_connection.refresh_available_braket_devices()

Function to get the available gate-based devices on Braket. Note: OFFLINE and RETIRED devices are filtered out. :Returns: list of braket.aws.AwsDevice – Available gate-based Braket devices.

tangelo.linq.qpu_connection.ibm_connection module

Wrappers around Qiskit runtime API, to manage quantum experiments run with IBM Cloud or IBM quantum from Tangelo.

class tangelo.linq.qpu_connection.ibm_connection.IBMConnection(ibm_quantum_token=None)

Bases: QpuConnection

Wrapper around IBM Qiskit runtime API to facilitate job submission from Tangelo

get_backend_info()

Return configuration information for each device found on the service

job_cancel(job_id)

Attempt to cancel an existing job. May fail depending on job status (e.g too late)

Parameters:

job_id (str) – string representing the job id

Returns:

bool – whether the job was successfully cancelled.

job_results(job_id)

Blocking call requesting job results.

Parameters:

job_id (str) – string representing the job id

Returns:

dict – histogram of measurements

job_status(job_id)

Return information about the job corresponding to the input job ID

Parameters:

job_id (str) – string representing the job id

Returns:

enum value – status response from the native API

job_submit(program, backend_name, n_shots, circuits, operators=None, runtime_options=None, instance=None)

Submit job, return job ID.

Parameters:
  • program (str) – name of available qiskit-runtime program (e.g sampler, estimator currently)

  • backend_name (str) – name of a qiskit backend

  • n_shots (int) – Number of shots to use on the target backend

  • circuits (Circuit | List[Circuit]) – Tangelo circuit(s)

  • operators (QubitOperator | List[QubitOperator]) – Optional, qubit operators for computing expectation values

  • runtime_options (dict) – Optional, extra keyword arguments for options supported in qiskit-runtime.

  • instance (str) – Optional, desired IBM service instance in the “hub/group/project” format. Default is likely to send to “ibm-q/open/main”

Returns:

str – string representing the job id

tangelo.linq.qpu_connection.ionq_connection module

Python wrappers around IonQ REST API, to facilitate job submission, result retrieval and post-processing Using IonQ services requires an API key. Users are expected to set the environment variable IONQ_APIKEY with the value of this token. IonQ documentation for the API: https://docs.ionq.co IonQ cloud dashboard: https://cloud.ionq.com/

class tangelo.linq.qpu_connection.ionq_connection.IonQConnection(verbose=False)

Bases: QpuConnection

Wrapper about the IonQ REST API, to facilitate job submission and automated post-processing of results

get_backend_info()

Retrieve all the information available about the backends

get_characterization(backend_name=None, charac_url=None)

Retrieve characterization of a target device, either using the IonQ backend string, or an already-retrieved characterization url. The result contains information about number of qubits, fidelity of gates, t1, t2 and other specs, connectivity…

Parameters:
  • backend_name (str) – string identifier for the IonQ backend

  • charac_url (str) – characterization url previously retrieved from IonQ API

Returns:

dict – a dictionary containing various information about the device

property header

Produce the header for REST requests

job_cancel(job_id)

Cancel / delete a job from IonQ servers.

Parameters:

job_id (str) – string representing the job id

Returns:

dict – status response from the REST API

job_get_history()

Returns information about the job corresponding to the input job id

Parameters:

job_id (str) – alphanumeric character string representing the job id

Returns:

dict – status response from the REST API

job_results(job_id, wait_time=60)

Blocking call querying the REST API at a given frequency, until job results are available.

Parameters:
  • job_id (str) – string representing the job id

  • wait_time (int) – Number of seconds between consecutive queries to the IonQ API. If the verbosity is set to True, the status is printed if it changed since the last query.

Returns:

dict – Histogram of measurements

job_status(job_id)

Returns information about the job corresponding to the input job id

Parameters:

job_id (str) – string representing the job id

Returns:

dict – status response from the REST API

job_submit(target_backend, abs_circuit, n_shots, job_name, **job_specs)

Submit job, return job ID.

Parameters:
  • target_backend (str) – name of target device. See IonQ documentation for possible values. Current acceptable values are ‘simulator’ and ‘qpu’

  • abs_circuit (Circuit) – Circuit in Tangelo format

  • n_shots (int) – number of shots (ignored if target_backend is set to simulator

  • job_name (str) – name to make the job more identifiable

  • **job_specs – extra arguments such as lang in the code below; metadata is not currently supported.

Returns:

str – string representing the job id

tangelo.linq.qpu_connection.qemist_cloud_connection module

Python wrappers facilitating quantum experiment submission, monitoring and post-processing, through QEMIST Cloud.

Users are expected to set the environment variables QEMIST_AUTH_TOKEN and QEMIST_PROJECT_ID with values retrieved from their QEMIST Cloud dashboard.

class tangelo.linq.qpu_connection.qemist_cloud_connection.QEMISTCloudConnection

Bases: QpuConnection

Wrapper about the QEMIST Cloud connection to QPUs.

job_cancel(qemist_cloud_job_id)

Cancels the job matching the input job id, if done in time before it starts.

Parameters:

qemist_cloud_job_id (int) – problem handle / job identifier.

Returns:

dict – cancelled problems / subproblems.

job_estimate(circuit, n_shots, backend=None)

Returns an estimate of the cost of running an experiment, for a specified backend or all backends available. Some service providers care about the complexity / structure of the input quantum circuit, some do not.

The backend identifier strings that a user can provide as argument can be obtained by calling this function without specifying a backend. They appear as keys in the returned dictionary. These strings may change with time, as we adjust to the growing cloud quantum offer (services and devices).

Parameters:
  • circuit (Circuit) – the abstract circuit to be run on the target device.

  • n_shots (int) – number of shots in the expriment.

  • backend (str) – the identifier string for the desired backend.

Returns:
  • dict – Returns dict of prices in USD. If backend is not None, dictionary

  • contains the cost for running the desired job. If backend is None,

  • returns dictionary of prices for all supported backends.

job_results(qemist_cloud_job_id)

Blocks until the job results are available. Returns a tuple containing the histogram of frequencies, and also the more in-depth raw data from the cloud services provider as a nested dictionary

Parameters:

qemist_cloud_job_id (int) – problem handle / job identifier.

Returns:
  • dict – Histogram of measurement frequencies.

  • dict – The cloud provider raw data.

job_status(qemist_cloud_job_id)

Returns the current status of the problem, as a string. Possible values: ready, in_progress, complete, cancelled.

Parameters:

qemist_cloud_job_id (int) – problem handle / job identifier.

Returns:

str – current status of the problem, as a string.

job_submit(circuit, n_shots, backend)

Job submission to run a circuit on quantum hardware.

Parameters:
  • circuit – a quantum circuit in the abstract format.

  • n_shots (int) – the number of shots.

  • backend (str) – the identifier string for the desired backend.

Returns:

int – A problem handle / job ID that can be used to retrieve the result or cancel the problem.

tangelo.linq.qpu_connection.qpu_connection module

Abstract parent class encapsulating basic features of compute services for quantum circuit simulation

class tangelo.linq.qpu_connection.qpu_connection.QpuConnection

Bases: ABC

Abstract class encapsulating login/authentication setup and job submission and management

abstract job_cancel(job_id)

Attempt to cancel a previously submitted job, through its job id

abstract job_results(job_id)

Retrieve the results of previously submitted job, through its job id

abstract job_status(job_id)

Retrieve information about a previously submitted job, through its job id

abstract job_submit()

Submit a job to the compute services

Module contents