Remote devices handling

In order to facilitate the handling of remote QPUs, helper functions were implemented. Most of them are aimed at internal usage even though you can absolutely use them yourself. As a user, the elements of this page of interest for you are most likely:

Provider specifics

Even though most of our interfaces use abstractions such that you do not need to know on which provider’s QPU your code is running, we need at some point to tackle the specifics of each providers. Most (hopefully all soon) of it is tackle in these modules.

IBM

Connection

config_ibm_account(token)[source]

Configure and save locally IBM Quantum account’s information.

Parameters

token (str) – IBM Quantum API token.

Raises

IBMRemoteExecutionError – If the account could not be saved.

get_IBMProvider()[source]

Returns the IBMProvider needed to get one or several backends for execution.

Raises

IBMRemoteExecutionError – In the account was not properly configured previously.

Return type

IBMProvider

Example

>>> instance = get_IBMProvider()
>>> instance.backends()
[<IBMBackend('ibmq_qasm_simulator')>,
 <IBMBackend('simulator_extended_stabilizer')>,
 <IBMBackend('simulator_mps')>,
 <IBMBackend('simulator_stabilizer')>,
 <IBMBackend('simulator_statevector')>,
 <IBMBackend('ibm_brisbane')>,
 <IBMBackend('ibm_kyoto')>,
 <IBMBackend('ibm_osaka')>]
get_QiskitRuntimeService()[source]

Returns the QiskitRuntimeService needed for remote connection and execution.

Raises

IBMRemoteExecutionError – When the qiskit runtime is not configured or the configuration cannot be retrieved.

Return type

QiskitRuntimeService

Example

>>> service = get_QiskitRuntimeService()
>>> service.jobs()
[<RuntimeJob('cmdj3b4nktricigarn8g', 'estimator')>,
 <RuntimeJob('cmdj3a74mi97k7j7ujv0', 'sampler')>,
 <RuntimeJob('cmama29054sir2cq94og', 'estimator')>,
 <RuntimeJob('cmama14pduldih1q4ktg', 'sampler')>,
 <RuntimeJob('cm7vds4pduldih1k1mq0', 'sampler')>]
get_active_account_info()[source]

Returns the information concerning the active IBMQ account.

Returns

The description containing the account information.

Return type

str

Example

>>> print(get_active_account_info())
    Channel: ibm_quantum
    Instance: ibm-q-startup/colibritd/default
    Token: bf5e5*****
    URL: https://auth.quantum-computing.ibm.com/api
    Verify: True
get_all_job_ids()[source]

Retrieves all the job ids of this account from the several IBM remote providers (IBMProvider, QiskitRuntimeService, …).

Returns

The list of job ids.

Return type

list[str]

Example

>>> get_all_job_ids()
['cm6pp7e879ps6bbo7m30', 'cm6ou0q70abqioeudkd0', 'cm6opgcpduldih1hq7j0', 'cm01vp4pduldih0uoi2g',
'cnvw8z3b08x0008y3e4g', 'cnvw7qyb08x0008y3e0g', 'cnvw7fdvn4c0008a6ztg', 'cnvw79dvn4c0008a6zt0',
'cnvw64rb08x0008y3dx0', 'cnvw5z7wsx00008wybcg', 'cmdj3b4nktricigarn8g', 'cmdj3a74mi97k7j7ujv0',
'cmama29054sir2cq94og', 'cmama14pduldih1q4ktg', 'cm80qmi70abqiof0o170', 'cm80qlkpduldih1k4png',
'cm80pb1054sir2ck9i3g', 'cm80pa6879ps6bbqg2pg', 'cm7vdugiidfp3m8rg02g', 'cm7vds4pduldih1k1mq0']
get_backend(device)[source]

Retrieves the IBM Q remote device corresponding to the device in parameter.

Parameters

device (IBMDevice) – The IBMDevice to get from IBMQ provider.

Returns

The requested backend.

Raises
  • ValueError – If the required backend is a local simulator.

  • IBMRemoteExecutionError – If the device was not found.

Return type

BackendV1

Example

>>> brisbane = get_backend(IBMDevice.IBM_BRISBANE)
>>> brisbane.properties().gates[0].parameters
[Nduv(datetime.datetime(2024, 1, 9, 11, 3, 18, tzinfo=tzlocal()), gate_error, , 0.00045619997922344296),
 Nduv(datetime.datetime(2024, 1, 9, 15, 41, 39, tzinfo=tzlocal()), gate_length, ns, 60)]
setup_ibm_account()[source]

Setups and updates the IBM Q account using the existing configuration and by asking for the token .

test_connection()[source]

Tests if the connection to the provider works.

Returns

False if login failed.

Return type

bool

Execution

check_job_compatibility(job)[source]

Checks whether the job in parameter has coherent and compatible attributes.

Parameters

job (Job) – Job for which we want to check compatibility.

Raises

DeviceJobIncompatibleError – If there is a mismatch between information contained in the job (measure and job_type, device and job_type, etc…).

compute_expectation_value(ibm_circuit, ibm_backend, job)[source]

Configures observable job and run it locally, and returns the corresponding Result.

Parameters
  • ibm_circuit (QuantumCircuit) – QuantumCircuit (already reversed bits)

  • ibm_backend (Optional[BackendV1 | BackendV2]) – The IBM backend (local of remote) on which we execute the job.

  • job (Job) – Mpqp job describing the observable job to run.

Returns

The result of the job.

Return type

Result

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

extract_result(result, job=None, device=IBMDevice.AER_SIMULATOR, ibm_job=None)[source]

Parses a result from IBM execution (remote or local) in a MPQP Result.

Parameters
  • result (QiskitResult | EstimatorResult | SamplerResult) – Result returned by IBM after running of the job.

  • job (Optional[Job]) – MPQP job used to generate the run. Enables a more complete result.

  • device (IBMDevice) – IBMDevice on which the job was submitted. Used to know if the run was remote or local

  • ibm_job (Optional[IBMJob | RuntimeJob]) – IBM or Runtime job used to retrieve info about the circuit and the submitted job (in the remote case).

Returns

The qiskit result converted to our format.

Return type

Result

get_result_from_ibm_job_id(job_id)[source]

Retrieves from IBM remote platform and parse the result of the job_id given in parameter. If the job is still running, we wait (blocking) until it is DONE.

Parameters

job_id (str) – Id of the remote IBM job.

Returns

The result converted to our format.

Return type

Result

run_aer(job)[source]

Executes the job on the right AER local simulator precised in the job in parameter.

Parameters

job (Job) – Job to be executed.

Returns

the result of the job.

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

run_ibm(job)[source]

Executes the job on the right IBM Q device precised in the job in parameter.

Parameters

job (Job) – Job to be executed.

Returns

The result of the job.

Return type

Result

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

run_ibmq(job)[source]

Submits the job on the right IBMQ remote device, precised in the job in parameter, and waits until the job is completed.

Parameters

job (Job) – Job to be executed.

Returns

A Result after submission and execution of the job.

Return type

Result

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

submit_ibmq(job)[source]

Submits the job on the remote IBM device (quantum computer or simulator).

Parameters

job (Job) – Job to be executed.

Returns

IBM’s job id and the qiskit job itself.

Return type

tuple[str, RuntimeJob | IBMJob]

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

Atos/Eviden

Connection

config_qlm_account(username, password, global_config)[source]

Configures and saves locally QLM account’s information.

Parameters
  • username (str) – QLM username.

  • password (str) – QLM password.

  • global_config (bool) – If True, this QLM account will be configured to work even outside MPQP.

Raises

QLMRemoteExecutionError – If the account could not be saved.

Return type

bool

get_QLMaaSConnection()[source]

Connects to the QLM and returns the QLMaaSConnection. If the connection was already established, we only return the one stored in global variable, otherwise we instantiate a new QLMaaSConnection.

get_all_job_ids()[source]

Retrieves from the remote QLM all the job-ids associated with this account.

Returns

List of all job-ids associated with this account.

Return type

list[str]

Example

>>> get_all_job_ids()
['Job144361', 'Job144360', 'Job144359', 'Job144358', 'Job144357', 'Job143334', 'Job143333', 'Job143332',
'Job141862', 'Job141861', 'Job141722', 'Job141720', 'Job141716', 'Job141715', 'Job141712', 'Job19341']
setup_qlm_account()[source]

Setups the QLM account, by looking at the existing configuration, asking for username/password and updating the current account.

Return type

tuple[str, list[Any]]

Execution

extract_observable_result(myqlm_result, job=None, device=ATOSDevice.MYQLM_PYLINALG)[source]

Constructs a Result from the result given by the myQLM/QLM run in observable mode.

Parameters
  • myqlm_result (QLM_Result) – Result returned by myQLM/QLM after running of the job.

  • job (Optional[Job]) – Original MPQP job used to generate the run. Used to retrieve more easily info to instantiate the result.

  • device (ATOSDevice) – ATOSDevice on which the job was submitted. Used to know if the run was remote or local.

Returns

A Result containing the result info extracted from the myQLM/QLM observable result.

Return type

Result

extract_result(myqlm_result, job=None, device=ATOSDevice.MYQLM_PYLINALG)[source]

Constructs a Result from the result given by the myQLM/QLM run.

Parameters
  • myqlm_result (QLM_Result) – Result returned by myQLM/QLM after running of the job.

  • job (Optional[Job]) – Original MPQP job used to generate the run. Used to retrieve more easily info to instantiate the result.

  • device (ATOSDevice) – ATOSDevice on which the job was submitted. Used to know if the run was remote or local.

Returns

A Result containing the result info extracted from the myQLM/QLM result.

Return type

Result

extract_sample_result(myqlm_result, job=None, device=ATOSDevice.MYQLM_PYLINALG)[source]

Constructs a Result from the result given by the myQLM/QLM run in sample mode.

Parameters
  • myqlm_result (QLM_Result) – Result returned by myQLM/QLM after running of the job.

  • job (Optional[Job]) – Original MPQP job used to generate the run. Used to retrieve more easily info to instantiate the result.

  • device (ATOSDevice) – ATOSDevice on which the job was submitted. Used to know if the run was remote or local.

Returns

A Result containing the result info extracted from the myQLM/QLM sample result.

Return type

Result

extract_state_vector_result(myqlm_result, job=None, device=ATOSDevice.MYQLM_PYLINALG)[source]

Constructs a Result from the result given by the myQLM/QLM run in state vector mode.

Parameters
  • myqlm_result (QLM_Result) – Result returned by myQLM/QLM after running of the job.

  • job (Optional[Job]) – Original MPQP job used to generate the run. Used to retrieve more easily info to instantiate the result.

  • device (ATOSDevice) – ATOSDevice on which the job was submitted. Used to know if the run was remote or local.

Returns

A Result containing the result info extracted from the myQLM/QLM statevector result.

Return type

Result

generate_hardware_model(noises, nb_qubits)[source]

Generates the QLM HardwareModel corresponding to the list of NoiseModel in parameter. The algorithm consider the cases when there are gate noise, for all qubits or specific to some, and the same for idle noise.

Parameters
  • noises (list[NoiseModel]) – List of NoiseModel of a QCircuit used to generate a QLM HardwareModel.

  • nb_qubits (int) – Number of qubits of the circuit.

Returns

The HardwareModel corresponding to the combination of NoiseModels given in parameter.

Return type

HardwareModel

generate_observable_job(myqlm_circuit, job)[source]

Generates a myQLM job from the myQLM circuit and observable.

Parameters
  • myqlm_circuit (Circuit) – MyQLM circuit of the job.

  • job (Job) – Original MPQP job used to generate the myQLM job.

Returns

A myQLM Job for retrieving the expectation value of the observable.

Return type

JobQLM

generate_sample_job(myqlm_circuit, job)[source]

Generates a myQLM job from the myQLM circuit and job sample info (target, shots, …).

Parameters
  • myqlm_circuit (Circuit) – MyQLM circuit of the job.

  • job (Job) – Original mpqp job used to generate the myQLM job.

Returns

A myQLM Job for sampling the circuit according to the mpqp Job parameters.

Return type

JobQLM

generate_state_vector_job(myqlm_circuit)[source]

Generates a myQLM job from the myQLM circuit.

Parameters

myqlm_circuit (Circuit) – MyQLM circuit of the job.

Returns

A myQLM Job to retrieve the statevector of the circuit.

Return type

JobQLM

get_local_qpu(device)[source]

Returns the myQLM local QPU associated with the ATOSDevice given in parameter.

Parameters

device (ATOSDevice) – ATOSDevice referring to the myQLM local QPU.

Raises

ValueError – If the required backend is a remote simulator.

Return type

QPUHandler

get_remote_qpu(device, job)[source]

Returns the QLM remote QPU associated with the ATOSDevice given in parameter.

Parameters
  • device (ATOSDevice) – ATOSDevice referring to the QLM remote QPU.

  • job (Job) – MPQP job containing all info about the execution.

Raises

ValueError – If the required backend is a local simulator.

get_result_from_qlm_job_id(job_id)[source]

Retrieves the QLM result, described by the job_id in parameter, from the remote QLM and converts it in a MPQP Result. If the job is still running, we wait (blocking) until its status becomes DONE.

Parameters

job_id (str) – Id of the remote QLM job.

Returns

The converted result.

Raises
Return type

Result

job_pre_processing(job)[source]

Extracts the myQLM circuit and check if job.type and job.measure are coherent.

Parameters

job (Job) – Mpqp job used to instantiate the myQLM circuit.

Returns

The myQLM Circuit translated from the circuit of the job in parameter.

Return type

Circuit

run_QLM(job)[source]

Submits the job on the remote QLM machine and waits for it to be done.

Parameters

job (Job) – Job to be executed.

Returns

A Result after submission and execution of the job.

Raises

ValueError – If the device is not a remote QLM device of the enum ATOSDevice.

Return type

Result

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

run_atos(job)[source]

Executes the job on the right ATOS device precised in the job in parameter.

Parameters

job (Job) – Job to be executed.

Returns

A Result after submission and execution of the job.

Return type

Result

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

run_myQLM(job)[source]

Executes the job on the local myQLM simulator.

Parameters

job (Job) – Job to be executed.

Returns

A Result after submission and execution of the job.

Return type

Result

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

submit_QLM(job)[source]

Submits the job on the remote QLM machine.

Parameters

job (Job) – Job to be executed.

Returns

The job_id and the AsyncResult of the submitted job.

Raises
  • ValueError – When job of type different from \(STATE_VECTOR\), \(OBSERVABLE\) or \(SAMPLE\)

  • NotImplementedError – If the basis given is not the ComputationalBasis

Return type

tuple[str, ‘AsyncResult’]

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

AWS

Connection

get_all_partial_ids()[source]

Retrieves all the task ids of this account/group from AWS and extracts the significant part.

Example

>>> get_all_partial_ids()
['6a46ae9a-d02f-4a23-b46f-eae43471bc22',
 '11db7e68-2b17-4b00-a4ec-20f662fd4876',
 '292d329f-727c-4b92-83e1-7d4bedd4b243',
 '4b94c703-2ce8-480b-b3f3-ecb2580dbb82',
 'edc094aa-23e8-4a8c-87be-f2e09281d79d',
 'af9e623a-dd1c-4ecb-9db6-dbbd1af08110']
Return type

list[str]

get_all_task_ids()[source]

Retrieves all the task ids of this account/group from AWS.

Example

>>> get_all_task_ids()
['arn:aws:braket:us-east-1:752542621531:quantum-task/6a46ae9a-d02f-4a23-b46f-eae43471bc22',
 'arn:aws:braket:us-east-1:752542621531:quantum-task/11db7e68-2b17-4b00-a4ec-20f662fd4876',
 'arn:aws:braket:us-east-1:752542621531:quantum-task/292d329f-727c-4b92-83e1-7d4bedd4b243',
 'arn:aws:braket:us-east-1:752542621531:quantum-task/4b94c703-2ce8-480b-b3f3-ecb2580dbb82',
 'arn:aws:braket:us-east-1:752542621531:quantum-task/edc094aa-23e8-4a8c-87be-f2e09281d79d',
 'arn:aws:braket:us-east-1:752542621531:quantum-task/af9e623a-dd1c-4ecb-9db6-dbbd1af08110']
Return type

list[str]

get_aws_braket_account_info()[source]

Get AWS Braket credentials information including access key ID, obfuscated secret access key, and region.

Returns

A formatted string containing AWS credentials information with an obfuscated secret access key.

Return type

str

Example

>>> get_aws_braket_account_info()
    access_key_id: 'AKIA26NYJ***********'
    secret_access_key: 'sMDad***********************************'
    region: 'us-east-1'
get_braket_device(device, is_noisy=False)[source]

Returns the AwsDevice device associate with the AWSDevice in parameter.

Parameters
  • device (AWSDevice) – AWSDevice element describing which remote/local AwsDevice we want.

  • is_noisy (bool) – If the expected device is noisy or not.

Raises

AWSBraketRemoteExecutionError – If the device or the region could not be retrieved.

Return type

BraketDevice

Example

>>> device = get_braket_device(AWSDevice.BRAKET_RIGETTI_ASPEN_M_3)
>>> device.properties.action['braket.ir.jaqcd.program'].supportedResultTypes
[ResultType(name='Sample', observables=['x', 'y', 'z', 'h', 'i'], minShots=10, maxShots=100000),
 ResultType(name='Expectation', observables=['x', 'y', 'z', 'h', 'i'], minShots=10, maxShots=100000),
 ResultType(name='Variance', observables=['x', 'y', 'z', 'h', 'i'], minShots=10, maxShots=100000),
 ResultType(name='Probability', observables=None, minShots=10, maxShots=100000)]
setup_aws_braket_account()[source]

Setups the connection to an Amazon Braket account using user input.

This function checks whether an Amazon Braket account is already configured and prompts the user to update it if needed. It then collects the user’s AWS access key, AWS secret key (hidden input), and the AWS region for Amazon Braket. The function attempts to configure the Amazon Braket account using the provided credentials.

Returns

A tuple containing a message indicating the result of the setup (e.g., success, cancelled, or error, …) and an empty list. The list is included for consistency with the existing code structure.

Return type

tuple[str, list[Any]]

Execution

apply_noise_to_braket_circuit(braket_circuit, noises, nb_qubits)[source]

Apply noise models to a Braket circuit.

This function applies noise models to a given Braket circuit based on the specified noise models and the number of qubits in the circuit. It modifies the original circuit by adding noise instructions and returns a new circuit with the noise applied.

Parameters
  • braket_circuit (Circuit) – The Braket circuit to apply noise to.

  • noises (list[mpqp.noise.noise_model.NoiseModel]) – A list of noise models to apply to the circuit.

  • nb_qubits (int) – The number of qubits in the circuit.

Returns

A new circuit with the noise applied.

Return type

Circuit

extract_result(braket_result, job=None, device=AWSDevice.BRAKET_LOCAL_SIMULATOR)[source]

Constructs a Result from the result given by the run with Braket.

Parameters
  • braket_result (GateModelQuantumTaskResult) – Result returned by myQLM/QLM after running of the job.

  • job (Optional[Job]) – Original mpqp job used to generate the run. Used to retrieve more easily info to instantiate the result.

  • device (AWSDevice) – AWSDevice on which the job was submitted.

Returns

The braket result converted to our format.

Return type

Result

get_result_from_aws_task_arn(task_arn)[source]

Retrieves the result, described by the job_id in parameter, from the remote QLM and converts it into an mpqp result.

If the job is still running, we wait (blocking) until it is DONE.

Parameters

task_arn (str) – Arn of the remote aws task.

Raises

AWSBraketRemoteExecutionError – When the status of the task is unknown.

Return type

Result

run_braket(job)[source]

Executes the job on the right AWS Braket device (local or remote) precised in the job in parameter and waits until the task is completed, then returns the Result.

Parameters

job (Job) – Job to be executed.

Returns

The result of the job.

Return type

Result

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

submit_job_braket(job)[source]

Submits the job to the right local/remote device and returns the generated task.

Parameters

job (Job) – Job to be executed.

Returns

The task’s id and the Task itself.

Raises
  • ValueError – If the job type is not supported for noisy simulations, or if it is of type OBSERVABLE but got no ExpectationMeasure.

  • NotImplementedError – If the job type is not STATE_VECTOR, SAMPLE or OBSERVABLE.

Return type

tuple[str, ‘QuantumTask’]

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

Google

Connection

get_all_job_ids()[source]

Retrieves all job IDs associated with google jobs.

Returns

A list of job IDs.

Return type

list[str]

# TODO: get job of google

get_google_account_info()[source]

Get the IonQ API key from the environment variables.

Returns

A string containing the IonQ API key.

Return type

str

Execution

extract_result(result, job=None, device=None)[source]

Extracts the needed data from cirq result and packages it into a MPQP Result.

Parameters
  • result (StateVectorTrialResult | cirq_result | list[float] | list[ObservableMeasuredResult]) – The result of the simulation.

  • job (Optional[Job]) – The original job. Defaults to None.

  • device (Optional[GOOGLEDevice]) – The device used for the simulation. Defaults to None.

Returns

The formatted result.

Return type

Result

Raises
  • NotImplementedError – If the job is None or the type is not supported.

  • ValueError – If the result type does not match the expected type for the job type.

extract_result_OBSERVABLE(result, job, device=None)[source]

Extracts the result from an observable-based job.

Parameters
  • result (list[float] | list[ObservableMeasuredResult]) – The result of the simulation.

  • job (Job) – The original job.

  • device (Optional[GOOGLEDevice]) – The device used for the simulation. Defaults to None.

Returns

The formatted result.

Return type

Result

extract_result_SAMPLE(result, job, device=None)[source]

Extracts the result from a sample-based job.

Parameters
  • result (cirq_result) – The result of the simulation.

  • job (Job) – The original job.

  • device (Optional[GOOGLEDevice]) – The device used for the simulation. Defaults to None.

Returns

The formatted result.

Return type

Result

extract_result_STATE_VECTOR(result, job, device=None)[source]

Extracts the result from a state vector-based job.

Parameters
  • result (StateVectorTrialResult) – The result of the simulation.

  • job (Job) – The original job.

  • device (Optional[GOOGLEDevice]) – The device used for the simulation. Defaults to None.

Returns

The formatted result.

Return type

Result

run_google(job)[source]

Executes the job on the right Google device precised in the job in parameter.

Parameters

job (Job) – Job to be executed.

Returns

A Result after submission and execution of the job. Note:

Return type

Result

Note

This function is not meant to be used directly, please use :func:run<mpqp.execution.runner.run> instead.

run_google_remote(job)[source]

Executes the job remotely on a Google quantum device. At present, only IonQ devices are supported.

Parameters

job (Job) – job to be executed.

Returns

The result after submission and execution of the job.

Return type

Result

Raises
  • ValueError – If the job’s device is not an instance of GOOGLEDevice.

  • NotImplementedError – If the job’s device is not supported (only IonQ devices are supported currently).

  • NotImplementedError – If the job type or basis measure is not supported.

run_local(job)[source]

Executes the job locally.

Parameters

job (Job) – The job to be executed.

Returns

The result after submission and execution of the job.

Return type

Result

Raises

ValueError – If the job device is not GOOGLEDevice.

run_local_processor(job)[source]

Executes the job locally on processor.

Parameters

job (Job) – The job to be executed.

Returns

The result after submission and execution of the job.

Return type

Result

Connection setup

key Connection

config_aqt_key()[source]

# TODO add aqt in list of provider Configure the AQT account by setting the API token.

Returns

A message indicating the result of the configuration and an empty list.

Return type

tuple

config_ionq_key()[source]

Configure the IonQ account by setting the API token.

Returns

A message indicating the result of the configuration and an empty list.

Return type

tuple

config_key(key_name, configuration_name, test_connection)[source]

Configure a key by setting the API token.

Returns

A message indicating the result of the configuration and an empty list.

Return type

tuple

Parameters
  • key_name (str) –

  • configuration_name (str) –

  • test_connection (Callable[[str], bool]) –

get_aqt_job_ids()[source]

Retrieves all job IDs associated with AQT jobs. # TODO

Returns

A list of job IDs.

Return type

list[str]

get_ionq_job_ids()[source]

Retrieves ionq job IDs associated with IonQ jobs.

Returns

A list of job IDs.

Return type

list[str]

test_aqt_connection(key=None)[source]

# TODO install qiskit_aqt_provider by updating qiskit to 1.0.0 Test the connection to the AQT service.

Returns

True if the connection is successful, False otherwise.

Return type

bool

Parameters

key (Optional[str]) –

test_ionq_connection(key=None)[source]

Test the connection to the IonQ service.

Returns

True if the connection is successful, False otherwise.

Return type

bool

Parameters

key (Optional[str]) –

Connection setup script

The setup_connections script helps you configuring the connections for all the supported remote backends. In time, it will also guide you to retrieve the tokens, passwords, etc… but for now, it is a prerequisite that you already have these credentials to use this script.

Information concerning which provider is configured and related credentials are stored in the ~/.mpqp file.

main_setup()[source]

Main function of the script, triggering the choice selection, and guiding you through the steps needed to configure each provider access. This function has to be executed from a terminal like environment, allowing you to type tokens and alike.

print_config_info()[source]

Displays the information stored for each provider.

The details on how to get these information can be found in the section Setup remote accesses.

On disk configuration manager

This module takes care of saving and loading the configuration of supported providers.

get_env_variable(key)[source]

Loads the .mpqp env file and returns the value associated with the key in parameter. If the variable does not exist, an empty string is returned.

Parameters

key (str) – The key for which we want to get the value.

Return type

str

Example

>>> save_env_variable("BRAKET_CONFIGURED", 'True')
True
>>> get_env_variable("BRAKET_CONFIGURED")
'True'
>>> get_env_variable("RaNdOM")
''
get_existing_config_str()[source]

Gets the content of the .mpqp config file.

Returns

The string with .mpqp file content.

Return type

str

Example

>>> save_env_variable('QLM_USER', 'hjaffali')
True
>>> save_env_variable('QLM_PASSWD', '****************')
True
>>> save_env_variable('QLM_CONFIGURED', 'True')
True
>>> save_env_variable('BRAKET_CONFIGURED', 'True')
True
>>> print(get_existing_config_str()) 
QLM_USER='hjaffali'
QLM_PASSWD='****************'
QLM_CONFIGURED='True'
BRAKET_CONFIGURED='True'
load_env_variables()[source]

Loads the variables stored in the .mpqp file.

Returns

True if the variables are loaded correctly.

Return type

bool

Example

>>> os.getenv("IBM_CONFIGURED")
>>> open(os.path.expanduser("~") + "/.mpqp", "w").write("IBM_CONFIGURED='True'\n")
22
>>> os.getenv("IBM_CONFIGURED")
>>> load_env_variables()
True
>>> os.getenv("IBM_CONFIGURED")
'True'
save_env_variable(key, value)[source]

Adds or updates the key environment variable in .mpqp file.

Parameters
  • key (str) – Name of the environment variable.

  • value (str) – Value to be saved.

Returns

True if the save was successful.

Return type

bool

Examples

>>> get_env_variable("RaNdOM")
''
>>> save_env_variable("RaNdOM", "azertyuiop")
True
>>> get_env_variable("RaNdOM")
'azertyuiop'