Align Quantum应用程序
aliro-quantum的Python项目详细描述
阿利罗量子
这是Aliro Quantum应用程序的api
此Python包由OpenAPI Generator项目自动生成:
- API版本:1.0.0
- 软件包版本:2.24.0
- 生成包:org.openapitools.codegen.语言.PythonClientCodegen在
要求
Python 2.7和3.4+
安装和使用
pip安装
pip install aliro-quantum
然后导入包:
^{pr2}$入门
请遵循installation procedure,然后运行以下命令:
Aliro Quantum PIP包入门
安装Aliro Quantum pip包
pip install aliro-quantum
导入必要的模块
importaliro_quantumfromaliro_quantum.restimportApiExceptionfrompprintimportpprintfromtypingimportList
设置身份验证
您可以在https://app.aliro.io/的“帐户”页中检索API令牌
configuration=aliro_quantum.Configuration()configuration.api_key['Authorization']='API_TOKEN'configuration.host='https://app.aliro.io'
检索可能的语言
在撰写本文时,可能的语言有:
- QASM公司
- 绗缝
quil_language:strwithaliro_quantum.ApiClient(configuration)asapi_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.valueforlanguage_infoinlanguages_list.dataiflanguage_info.id=='quil')pprint(languages_list)exceptApiExceptionase:print("Exception when calling InfoApi->info_languages_get: %s\n"%e)raisee
{'data': [{'id': 'qasm', 'value': 'QASM'}, {'id': 'quil', 'value': 'Quil'}]}
检索可能的执行类型
在撰写本文时,可能的执行类型有:
- 真实的
- 模拟
- 两者兼而有之
simulation_only_execution_type:strwithaliro_quantum.ApiClient(configuration)asapi_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.valueforexecution_type_infoinexecution_type_info_list.dataifexecution_type_info.id=='2')pprint(execution_type_info_list)exceptApiExceptionase:print("Exception when calling InfoApi->auth_login_post: %s\n"%e)raisee
{'data': [{'id': '1', 'value': 'real'},
{'id': '2', 'value': 'simulated'},
{'id': '3', 'value': 'both'}]}
获取可能的设备目标和信息
devices_list:aliro_quantum.OwnerDetailswithaliro_quantum.ApiClient(configuration)asapi_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.datapprint(devices_list_response)exceptApiExceptionase:print("Exception when calling DeviceRankingsApi->devices_list_get: %s\n"%e)raisee
{'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}}}}}}
从“设备”列表中选择所需目标(所有者+设备ID)
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'
创建提交信息
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)
提交新提交
withaliro_quantum.ApiClient(configuration)asapi_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)exceptApiExceptionase:print("Exception when calling SubmissionsApi->submissions_post: %s\n"%e)
{'success': True}
等待完成
这可能需要几分钟或更长时间。在
submission_details:aliro_quantum.Submissionwithaliro_quantum.ApiClient(configuration)asapi_client:submissions_api_instance=aliro_quantum.SubmissionsApi(api_client)try:forsubmission_get_responseinsubmissions_api_instance.submissions_submission_name_stream_get(submission_name=submission_name,completion_only='true'):submission_details=submission_get_response.submission_detailbreakexceptApiExceptionase:print("Exception when calling SubmissionsApi->submissions_submission_name_stream_get: %s\n"%e)
打印结果
快照对快照结果将是每个电路分配的测量列表。在
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.errorsiflen(errors):pprint(errors)else:execution:aliro_quantum.JobExecution=first_job.executionresults:aliro_quantum.ExecutionResults=execution.resultsresults_simulated:aliro_quantum.ResultsData=results.simulatedresults_simulated_measurements:aliro_quantum.ResultsDataMeasurements=results_simulated.measurementspprint(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]]]
API终结点文档
所有uri都是相对于https://app.aliro.io
Class | Method | HTTP request | Description |
---|---|---|---|
AuthenticationApi | auth_login_post | POST /auth/login | login using username and password |
CircuitApi | circuit_qaoa_post | POST /circuit/qaoa | compiles a quantum circuit for use in QAOA |
CircuitApi | circuit_translation_post | POST /circuit/translation | translates circuits into other quantum languages |
CircuitApi | circuit_visualization_get | GET /circuit/visualization | |
CircuitApi | circuit_visualization_post | POST /circuit/visualization | converts a Quil circuit into a PNG image |
CredentialsApi | credentials_vendor_delete | DELETE /credentials/{vendor} | delete vendor credentials for a user |
CredentialsApi | credentials_vendor_put | PUT /credentials/{vendor} | add vendor credentials for a user |
DeviceRankingsApi | devices_list_get | GET /devicesList | retrieves list of potential devices to run the circuit on |
DeviceRankingsApi | devices_list_stream_get | GET /devicesList/stream | streams device detail updates |
DeviceRankingsApi | devices_next_available_get | GET /devices/nextAvailable | retrieves list of next avaiable times for devices |
DeviceRankingsApi | rankings_list_post | POST /rankingsList | retrieves predicted device rankings |
InfoApi | info_execution_types_get | GET /info/executionTypes | get list of possible execution types for jobs |
InfoApi | info_languages_get | GET /info/languages | get list of languages in database |
JobsApi | jobs_cancel_job_id_post | POST /jobs/cancel/{jobId} | cancel job |
SubmissionsApi | submissions_delete | DELETE /submissions | delete submissions |
SubmissionsApi | submissions_get | GET /submissions | get all user's submissions |
SubmissionsApi | submissions_post | POST /submissions | submit a new submission |
SubmissionsApi | submissions_submission_name_get | GET /submissions/{submissionName} | get submissions |
SubmissionsApi | submissions_submission_name_stream_get | GET /submissions/{submissionName}/stream | stream submission updates |
UserApi | user_information_update_post | POST /user/informationUpdate | update user email and name |
UserApi | user_password_change_post | POST /user/passwordChange | change user password from known password |
模型文档
- Allocation
- BasicSuccess
- ChangePasswordParams
- Circuit
- CircuitInput
- CompilationParameters
- CompiledCircuit
- CompiledCircuitResponse
- ControlFlowGraphCircuit
- CredentialsAddParameters
- CredentialsAqt
- CredentialsBasic
- CredentialsDeleteParameters
- CredentialsHoneywell
- CredentialsIbm
- CredentialsIbmProvider
- CredentialsRigetti
- CredentialsVendor
- DeleteSubmissionParameters
- DeviceDetails
- DeviceListResponse
- DeviceRanking
- DeviceRankingResponse
- DeviceRankingsParameters
- ExecutionParameters
- ExecutionResults
- Gate
- InfoGetResponse
- InfoGetResponseData
- Job
- JobAllocations
- JobCosts
- JobErrors
- JobExecution
- LoginResponse
- OwnerDetails
- OwnerDetailsOwners
- PidResponse
- Qubit
- Reservation
- ResultsData
- ResultsDataMeasurements
- Submission
- SubmissionDetailResponse
- SubmissionSummary
- SubmissionSummaryJobs
- SubmissionSummaryResponse
- TranslationParameters
- TranslationResponse
- UpdateUserInformationParams
- UserInfo
- VisualizationResponse
授权文件
Aliro用户可以在其帐户页https://app.aliro.io/中检索其API密钥
JwtKeyAuth
- Type:API密钥
- API key参数名:授权
- Location:HTTP头
作者
- 项目
标签: