🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More
Socket
Book a DemoInstallSign in
Socket

aliro-quantum

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aliro-quantum

Aliro Quantum App

pipPyPI
Version
2.33.0
Maintainers
1

aliro-quantum

This is an api for the Aliro Quantum App

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 1.0.0
  • Package version: 2.33.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

Requirements.

Python 2.7 and 3.4+

Installation & Usage

pip install

pip install aliro-quantum

Then import the package:

import aliro_quantum

Getting Started

Please follow the installation procedure and then run the following:

Aliro Quantum PIP Package Getting Started

Install the Aliro Quantum pip package

pip install aliro-quantum

Import necessary modules

import aliro_quantum
from aliro_quantum.rest import ApiException
from pprint import pprint
from typing import List

Set up authentication

You can retrieve your API token in your "Account" page at https://app.aliro.io/

configuration = aliro_quantum.Configuration()
configuration.api_key['Authorization'] = 'API_TOKEN'
configuration.host = 'https://app.aliro.io'

Retrieve possible languages

At the time of this writing, possible languages are:

  • QASM
  • Quil
quil_language: str
with aliro_quantum.ApiClient(configuration) as api_client:
    info_api_instance = aliro_quantum.InfoApi(api_client)
    try:
        languages_list: aliro_quantum.InfoGetResponse = info_api_instance.info_languages_get(inputs_only=True)
        quil_language = next(
            language_info.value for language_info in languages_list.data if 
            language_info.id == 'quil')
        pprint(languages_list)
    except ApiException as e:
        print("Exception when calling InfoApi->info_languages_get: %s\n" % e)
        raise e
{'data': [{'id': 'qasm', 'value': 'QASM'}, {'id': 'quil', 'value': 'Quil'}]}

Retrieve possible execution types

At the time of this writing, possible execution types are:

  • real
  • simulated
  • both
simulation_only_execution_type: str
with aliro_quantum.ApiClient(configuration) as api_client:
    info_api_instance = aliro_quantum.InfoApi(api_client)
    try:
        execution_type_info_list: aliro_quantum.InfoGetResponse = info_api_instance.info_execution_types_get()
        simulation_only_execution_type = next(
            execution_type_info.value for execution_type_info in execution_type_info_list.data if
            execution_type_info.id == '2')
        pprint(execution_type_info_list)
    except ApiException as e:
        print("Exception when calling InfoApi->auth_login_post: %s\n" % e)
        raise e
{'data': [{'id': '1', 'value': 'real'},
          {'id': '2', 'value': 'simulated'},
          {'id': '3', 'value': 'both'}]}

Get possible device targets and information

devices_list: aliro_quantum.OwnerDetails
with aliro_quantum.ApiClient(configuration) as api_client:
    device_rankings_api_instance = aliro_quantum.DeviceRankingsApi(api_client)
    try:
        devices_list_response: aliro_quantum.DeviceListResponse = device_rankings_api_instance.devices_list_get()
        devices_list = devices_list_response.data
        pprint(devices_list_response)
    except ApiException as e:
        print("Exception when calling DeviceRankingsApi->devices_list_get: %s\n" % e)
        raise e
{'data': {'owners': {'IBM': {'devices': {'ibmq_rome': {'device_id': 'ibmq_rome',
                                                       'display_name': 'ibmq_rome',
                                                       'gates': [{'fidelity': 0.9880405409838382,
                                                                  'gate_type': 'CX',
                                                                  'qubit_from': {'fidelity_rotation': 0.9994152165869413,
                                                                                 'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                                 'name': 4,
                                                                                 'pos_x': 200.0,
                                                                                 'pos_y': 0.0,
                                                                                 'real_qubit': 4},
                                                                  'qubit_to': {'fidelity_rotation': 0.9993837791241802,
                                                                               'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                               'name': 3,
                                                                               'pos_x': 150.0,
                                                                               'pos_y': 0.0,
                                                                               'real_qubit': 3}},
                                                                 {'fidelity': 0.9856693955271434,
                                                                  'gate_type': 'CX',
                                                                  'qubit_from': {'fidelity_rotation': 0.9993837791241802,
                                                                                 'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                                 'name': 3,
                                                                                 'pos_x': 150.0,
                                                                                 'pos_y': 0.0,
                                                                                 'real_qubit': 3},
                                                                  'qubit_to': {'fidelity_rotation': 0.9994152165869413,
                                                                               'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                               'name': 4,
                                                                               'pos_x': 200.0,
                                                                               'pos_y': 0.0,
                                                                               'real_qubit': 4}},
                                                                 {'fidelity': 0.9892630599738325,
                                                                  'gate_type': 'CX',
                                                                  'qubit_from': {'fidelity_rotation': 0.9993837791241802,
                                                                                 'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                                 'name': 3,
                                                                                 'pos_x': 150.0,
                                                                                 'pos_y': 0.0,
                                                                                 'real_qubit': 3},
                                                                  'qubit_to': {'fidelity_rotation': 0.9993763479004819,
                                                                               'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                               'name': 2,
                                                                               'pos_x': 100.0,
                                                                               'pos_y': 0.0,
                                                                               'real_qubit': 2}},
                                                                 {'fidelity': 0.9868122191056748,
                                                                  'gate_type': 'CX',
                                                                  'qubit_from': {'fidelity_rotation': 0.9993763479004819,
                                                                                 'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                                 'name': 2,
                                                                                 'pos_x': 100.0,
                                                                                 'pos_y': 0.0,
                                                                                 'real_qubit': 2},
                                                                  'qubit_to': {'fidelity_rotation': 0.9993837791241802,
                                                                               'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                               'name': 3,
                                                                               'pos_x': 150.0,
                                                                               'pos_y': 0.0,
                                                                               'real_qubit': 3}},
                                                                 {'fidelity': 0.9883232732901912,
                                                                  'gate_type': 'CX',
                                                                  'qubit_from': {'fidelity_rotation': 0.9993763479004819,
                                                                                 'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                                 'name': 2,
                                                                                 'pos_x': 100.0,
                                                                                 'pos_y': 0.0,
                                                                                 'real_qubit': 2},
                                                                  'qubit_to': {'fidelity_rotation': 0.9995167318229694,
                                                                               'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                               'name': 1,
                                                                               'pos_x': 50.0,
                                                                               'pos_y': 0.0,
                                                                               'real_qubit': 1}},
                                                                 {'fidelity': 0.9861370891980876,
                                                                  'gate_type': 'CX',
                                                                  'qubit_from': {'fidelity_rotation': 0.9995167318229694,
                                                                                 'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                                 'name': 1,
                                                                                 'pos_x': 50.0,
                                                                                 'pos_y': 0.0,
                                                                                 'real_qubit': 1},
                                                                  'qubit_to': {'fidelity_rotation': 0.9993763479004819,
                                                                               'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                               'name': 2,
                                                                               'pos_x': 100.0,
                                                                               'pos_y': 0.0,
                                                                               'real_qubit': 2}},
                                                                 {'fidelity': 0.9786906667138251,
                                                                  'gate_type': 'CX',
                                                                  'qubit_from': {'fidelity_rotation': 0.9995167318229694,
                                                                                 'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                                 'name': 1,
                                                                                 'pos_x': 50.0,
                                                                                 'pos_y': 0.0,
                                                                                 'real_qubit': 1},
                                                                  'qubit_to': {'fidelity_rotation': 0.999416000095865,
                                                                               'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                               'name': 0,
                                                                               'pos_x': 0.0,
                                                                               'pos_y': 0.0,
                                                                               'real_qubit': 0}},
                                                                 {'fidelity': 0.9766032827219325,
                                                                  'gate_type': 'CX',
                                                                  'qubit_from': {'fidelity_rotation': 0.999416000095865,
                                                                                 'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                                 'name': 0,
                                                                                 'pos_x': 0.0,
                                                                                 'pos_y': 0.0,
                                                                                 'real_qubit': 0},
                                                                  'qubit_to': {'fidelity_rotation': 0.9995167318229694,
                                                                               'last_reported_fidelity_rotation_datetime': '2020-06-18T09:25:03+00:00',
                                                                               'name': 1,
                                                                               'pos_x': 50.0,
                                                                               'pos_y': 0.0,
                                                                               'real_qubit': 1}}],
                                                       'is_simulator': False,
                                                       'last_calibration': '2020-06-18T09:25:03+00:00',
                                                       'max_shots': 8192,
                                                       'next_available_time': None,
                                                       'price': None,
                                                       't1': 70.59164221606711,
                                                       't2': 92.8079648560683}}}}}}

Choose desired target (owner + device ID) from devices_list

example_owner = list(devices_list.owners.keys())[0]
exmaple_device_id = list(devices_list.owners[example_owner].devices.keys())[0]
example_target = aliro_quantum.OwnerDetails(
    owners={
        example_owner: aliro_quantum.OwnerDetailsOwners(
            devices={
                exmaple_device_id: aliro_quantum.DeviceDetails()
            }
        )
    }
)

pprint(f'Owner: {example_owner}')
pprint(f'Device ID: {exmaple_device_id}')
'Owner: IBM'
'Device ID: ibmq_rome'

Create submission info

submission_name = 'test_submission'
submission_post_parameters = aliro_quantum.Submission(
    circuits=[
        aliro_quantum.Circuit(
            body='DECLARE ro BIT[1]\nH 0\nMEASURE 0 ro[0]\n',
            jobs=[
                aliro_quantum.Job(
                    allocations=aliro_quantum.JobAllocations(
                        input_parameters=aliro_quantum.CompilationParameters(
                            num_allocations=4
                        )
                    ),
                    execution=aliro_quantum.JobExecution(
                        parameters=aliro_quantum.ExecutionParameters(
                            num_shots=200,
                            output_type=simulation_only_execution_type
                        )
                    ),
                    target=example_target
                )
            ],
            language=quil_language
        )
    ],
    name=submission_name
)

Submit the new submission

with aliro_quantum.ApiClient(configuration) as api_client:
    submissions_api_instance = aliro_quantum.SubmissionsApi(api_client)
    try:
        submission_api_response = submissions_api_instance.submissions_post(submission_post_parameters=submission_post_parameters)
        pprint(submission_api_response)
    except ApiException as e:
        print("Exception when calling SubmissionsApi->submissions_post: %s\n" % e)
{'success': True}

Wait for completion

This will likely take a few minutes or more.

submission_details: aliro_quantum.Submission
with aliro_quantum.ApiClient(configuration) as api_client:
    submissions_api_instance = aliro_quantum.SubmissionsApi(api_client)
    try:
        for submission_get_response in submissions_api_instance.submissions_submission_name_stream_get(
            submission_name=submission_name,
            completion_only='true'
        ):
            submission_details = submission_get_response.submission_detail
            break
    except ApiException as e:
        print("Exception when calling SubmissionsApi->submissions_submission_name_stream_get: %s\n" % e)

Print results

Shot-for-shot results will be a list of measurements for each allocation of the circuit.

first_circuit: aliro_quantum.Circuit = submission_details.circuits[0]
first_job: aliro_quantum.Job = first_circuit.jobs[0]
errors: List[aliro_quantum.JobErrors] = first_job.errors
if len(errors):
    pprint(errors)
else:
    execution: aliro_quantum.JobExecution = first_job.execution
    results: aliro_quantum.ExecutionResults = execution.results
    results_simulated: aliro_quantum.ResultsData = results.simulated
    results_simulated_measurements: aliro_quantum.ResultsDataMeasurements = results_simulated.measurements

    pprint(results_simulated_measurements.raw)
[[[1],
  [1],
  [0],
  [0],
  [1],
  [1],
  [1],
  [1],
  [0],
  [1],
  [1],
  [1],
  [1],
  [0],
  [0],
  [1],
  [1],
  [0],
  [0],
  [0],
  [1],
  [1],
  [1],
  [1],
  [0],
  [0],
  [1],
  [1],
  [0],
  [0],
  [1],
  [1],
  [1],
  [0],
  [0],
  [0],
  [1],
  [0],
  [0],
  [0],
  [1],
  [0],
  [0],
  [0],
  [1],
  [0],
  [0],
  [0],
  [1],
  [1]],
 [[0],
  [0],
  [0],
  [0],
  [0],
  [0],
  [0],
  [0],
  [1],
  [0],
  [1],
  [0],
  [1],
  [1],
  [0],
  [1],
  [0],
  [1],
  [0],
  [0],
  [0],
  [1],
  [0],
  [1],
  [0],
  [0],
  [1],
  [1],
  [0],
  [1],
  [0],
  [1],
  [0],
  [0],
  [0],
  [1],
  [1],
  [1],
  [0],
  [1],
  [1],
  [0],
  [1],
  [0],
  [1],
  [1],
  [0],
  [1],
  [1],
  [1]],
 [[1],
  [0],
  [1],
  [0],
  [0],
  [1],
  [1],
  [1],
  [1],
  [1],
  [0],
  [0],
  [1],
  [1],
  [1],
  [1],
  [0],
  [0],
  [1],
  [0],
  [0],
  [0],
  [0],
  [0],
  [0],
  [1],
  [1],
  [1],
  [1],
  [0],
  [1],
  [0],
  [0],
  [1],
  [1],
  [1],
  [1],
  [0],
  [1],
  [1],
  [1],
  [1],
  [0],
  [1],
  [1],
  [1],
  [1],
  [0],
  [0],
  [1]],
 [[0],
  [0],
  [1],
  [0],
  [1],
  [0],
  [1],
  [0],
  [1],
  [1],
  [0],
  [1],
  [1],
  [0],
  [0],
  [0],
  [1],
  [1],
  [1],
  [1],
  [1],
  [0],
  [1],
  [0],
  [1],
  [1],
  [0],
  [0],
  [0],
  [1],
  [1],
  [1],
  [0],
  [0],
  [0],
  [0],
  [0],
  [0],
  [0],
  [1],
  [0],
  [0],
  [0],
  [0],
  [0],
  [0],
  [0],
  [0],
  [0],
  [1]]]

Documentation for API Endpoints

All URIs are relative to https://app.aliro.io

ClassMethodHTTP requestDescription
AuthenticationApiauth_login_postPOST /auth/loginlogin using username and password
CircuitApicircuit_qaoa_postPOST /circuit/qaoacompiles a quantum circuit for use in QAOA
CircuitApicircuit_translation_postPOST /circuit/translationtranslates circuits into other quantum languages
CircuitApicircuit_visualization_getGET /circuit/visualization
CircuitApicircuit_visualization_postPOST /circuit/visualizationconverts a Quil circuit into a PNG image
CredentialsApicredentials_vendor_deleteDELETE /credentials/{vendor}delete vendor credentials for a user
CredentialsApicredentials_vendor_putPUT /credentials/{vendor}add vendor credentials for a user
DeviceRankingsApidevices_list_getGET /devicesListretrieves list of potential devices to run the circuit on
DeviceRankingsApidevices_list_stream_getGET /devicesList/streamstreams device detail updates
DeviceRankingsApidevices_next_available_getGET /devices/nextAvailableretrieves list of next avaiable times for devices
DeviceRankingsApirankings_list_postPOST /rankingsListretrieves predicted device rankings
InfoApiinfo_execution_types_getGET /info/executionTypesget list of possible execution types for jobs
InfoApiinfo_languages_getGET /info/languagesget list of languages in database
JobsApijobs_cancel_job_id_postPOST /jobs/cancel/{jobId}cancel job
SubmissionsApisubmissions_deleteDELETE /submissionsdelete submissions
SubmissionsApisubmissions_getGET /submissionsget all user's submissions
SubmissionsApisubmissions_postPOST /submissionssubmit a new submission
SubmissionsApisubmissions_submission_name_getGET /submissions/{submissionName}get submissions
SubmissionsApisubmissions_submission_name_stream_getGET /submissions/{submissionName}/streamstream submission updates
UserApiuser_information_update_postPOST /user/informationUpdateupdate user email and name
UserApiuser_password_change_postPOST /user/passwordChangechange user password from known password

Documentation For Models

Documentation For Authorization

Aliro users can retrieve their API key in their account page at https://app.aliro.io/

JwtKeyAuth

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Author

nick@aliroquantum.com

Keywords

OpenAPI

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts