Aliro Q.Network
Project description
aliro-aqn
This is an api for the Aliro Q.Network
This Python package is automatically generated by the OpenAPI Generator project:
- API version: 1.50.0
- Package version: 1.50.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
Requirements.
Python 2.7 and 3.4+
Installation & Usage
pip install
If the python package is hosted on a repository, you can install directly using:
pip install aliro-quantum-networking
Then import the package:
import aliro_quantum_networking
Getting Started
## Import necessary modules
import aliro_quantum_networking
from contextlib import contextmanager
from aliro_quantum_networking.models import ClassicalChannel, MemoryInput, Node, QuantumConnection, \
Request, SubmissionAqnInput, SubmissionAqnOutput, SubmissionAqnBaseGlobalSettings, SubmissionOverviewInput
from aliro_quantum_networking.rest import ApiException
from pprint import pprint
from matplotlib import pyplot as plt
from typing import ContextManager
import uuid
## Set up authentication
# You can retrieve your API token in your "Account" page at https://aqn.aliro.io/#/user
configuration = aliro_quantum_networking.Configuration()
configuration.api_key['Authorization'] = 'API_TOKEN'
configuration.host = 'https://aqn.aliro.io/v1'
## Define nodes
# Define the nodes in your topology.
#
# In this example, there will be a linear topology, having two end nodes with 25 quantum memories and 1 repeater between them with 50 quantum memories.
default_coherence_time = 10 # seconds
default_raw_fidelity = 0.85
memory_request_size = 5
def new_node_memory() -> MemoryInput:
return MemoryInput(
coherence_time=default_coherence_time,
memory_type='MemoryInput',
raw_fidelity=default_raw_fidelity
)
end_node_1 = Node(
name='alice',
memories=[new_node_memory() for i in range(memory_request_size)]
)
end_node_2 = Node(
name='bob',
memories=[new_node_memory() for i in range(memory_request_size)]
)
repeater_1 = Node(
name='repeater1',
memories=[new_node_memory() for i in range(memory_request_size * 2)]
)
submission_nodes = [
end_node_1,
repeater_1,
end_node_2
]
## Define quantum connections
# Define the quantum connections between nodes in your topology.
#
# In this example, there will be two quantum connections, one between the repeater and each of the end nodes.
default_quantum_connection_attenuation = 1e-5 # decibels/kilometer
default_quantum_channel_distance = 5e3 # meters
quantum_connections = [
QuantumConnection(
attenuation=default_quantum_connection_attenuation,
distance=default_quantum_channel_distance,
node_from=submission_nodes[0].name,
node_to=submission_nodes[1].name
),
QuantumConnection(
attenuation=default_quantum_connection_attenuation,
distance=default_quantum_channel_distance,
node_from=submission_nodes[1].name,
node_to=submission_nodes[2].name
)
]
## Define classical channels
# Define the classical channels between nodes in the topology.
#
# In this example, there will be an all-to-all classical connection topology.
default_classical_channel_delay = 25e7 # picoseconds
default_classical_channel_distance = 1e3 # meters
submission_classical_channels = []
for i in submission_nodes:
for j in submission_nodes:
if i.name != j.name:
submission_classical_channels.append(
ClassicalChannel(
delay=default_classical_channel_delay,
distance=default_classical_channel_distance,
node_from=i.name,
node_to=j.name
)
)
## Define the desired network request
# Define the desired network request to simulate
default_request_target_fidelity = 0.9
default_request_simulation_start_time = 1e12
default_request_simulation_end_time = 1e14
network_request = Request(
memory_size=memory_request_size,
node_from=submission_nodes[0].name,
node_to=submission_nodes[2].name,
target_fidelity=default_request_target_fidelity,
time_beginning=default_request_simulation_start_time,
time_end=default_request_simulation_end_time
)
## Define full submission API input
# Put all inputs into the full input to send to the Aliro API
submission_name = f'SubmissionTest_{uuid.uuid4().hex}'
submission_input = SubmissionAqnInput(
classical_channels=submission_classical_channels,
global_settings=SubmissionAqnBaseGlobalSettings(
excitation_rate=80000000,
purification_protocol_name='BBPSSW_X'
),
nodes=submission_nodes,
quantum_connections=quantum_connections,
request=network_request,
submission_overview=SubmissionOverviewInput(
name=submission_name,
runs=1,
timeout=10,
timeline_stop_time=3e12,
submission_overview_type='SubmissionOverviewInput'
)
)
## Define submissions API instance context
# This will set up our API client and catch errors.
# This will be the same for all of our calls in this example, so we can define a reusable context here.
@contextmanager
def submissions_api_client(api_method_name: str) -> ContextManager[aliro_quantum_networking.SubmissionsApi]:
with aliro_quantum_networking.ApiClient(configuration) as api_client:
submissions_api_instance = aliro_quantum_networking.SubmissionsApi(api_client)
try:
yield submissions_api_instance
except ApiException as e:
print(f"Exception when calling SubmissionsApi->{api_method_name}: {e}\n")
## Submit the new submission
submission_id: str
with submissions_api_client(api_method_name='submissions_post') as submissions_api_instance:
submission_api_response = submissions_api_instance.submissions_post(submission_aqn_input=submission_input)
pprint(submission_api_response)
submission_id = submission_api_response.submission_id
## Wait for completion
# This will likely take a few minutes or more.
submission_details: SubmissionAqnOutput
with submissions_api_client(api_method_name='submissions_details_stream_get') as submissions_api_instance:
for submission_get_response in submissions_api_instance.submissions_details_stream_get(
submission_id=submission_id
):
submission_details = submission_get_response
submission_is_complete = submission_details.submission_overview.complete_date
if submission_is_complete:
break
## Display number of entangled memories
PICOSECONDS_PER_SECOND = 1e12
fig, axes = plt.subplots(1, 3)
axes[0].set_ylabel("Number of Entangled Memories")
axes[1].set_xlabel("Simulation Time (s)")
first_run_results = submission_details.run_results[0]
node_names = [submission_node.name for submission_node in submission_nodes]
result_memories_all_nodes = [first_run_results.nodes[node_name].memories for node_name in node_names]
for node_name, node_result_memories, axis in zip(node_names, result_memories_all_nodes, axes):
data = sorted(info.entangled_at_time / PICOSECONDS_PER_SECOND for info in node_result_memories if info.entangled_at_time)
axis.set_title(node_name)
axis.plot(data, range(1, len(data) + 1), marker="o")
fig.tight_layout()
## Display fidelities for entangled memories
fig, axes = plt.subplots(1,3)
axes[0].set_ylabel("Fidelity")
axes[1].set_xlabel("Memory Number")
def set_ax_properties(axis, data):
data_length = len(data)
axis.bar(range(data_length), data)
for fidelity in (default_raw_fidelity, 0.9):
axis.plot([0, data_length], 2 * [fidelity], "k--")
axis.set_ylim(0.7,1)
for node_name, node_result_memories, axis in zip(node_names, result_memories_all_nodes, axes):
data = [info.fidelity for info in node_result_memories]
axis.set_title(node_name)
set_ax_properties(axis, data)
fig.tight_layout()
Documentation for API Endpoints
All URIs are relative to http://localhost:3998/v1
Class | Method | HTTP request | Description |
---|---|---|---|
AuthenticationApi | auth_login_post | POST /auth/login | login using username and password |
SubmissionsApi | submissions_details_stream_get | GET /submissions/details/stream | get details about a submission's results |
SubmissionsApi | submissions_post | POST /submissions | submit a new submission |
UserApi | user_api_key_post | POST /user/apiKey | generate Aliro API key for user |
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 |
Documentation For Models
- ApiKey
- ApiKeyResponse
- BasicSuccess
- ChangePasswordParameters
- ClassicalChannel
- CredentialsBasic
- LoginResponse
- Memory
- MemoryBase
- MemoryInput
- MemoryOutput
- MemoryOutputAllOf
- Node
- QuantumConnection
- Request
- SubmissionAqn
- SubmissionAqnBase
- SubmissionAqnInput
- SubmissionAqnOutput
- SubmissionAqnOutputAllOf
- UpdateUserInformationParameters
- UserInfo
Documentation For Authorization
JwtKeyAuth
- Type: API key
- API key parameter name: Authorization
- Location: HTTP header
Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aliro-quantum-networking-1.50.0.tar.gz
.
File metadata
- Download URL: aliro-quantum-networking-1.50.0.tar.gz
- Upload date:
- Size: 44.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e16b309bb441ad5783cfc1d5ed8c55646451ebb95bdf9bd3186d7197d5c64d1e |
|
MD5 | 0e83c66944920874a2faac579ffa97d8 |
|
BLAKE2b-256 | 41fb4ba16fe0b6b5219cf880ccac56a19f9eafc08eff397fc2af23cc443a47f5 |
File details
Details for the file aliro_quantum_networking-1.50.0-py3-none-any.whl
.
File metadata
- Download URL: aliro_quantum_networking-1.50.0-py3-none-any.whl
- Upload date:
- Size: 92.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03b0d8ac0f43413422176733b197fd853e2de4a66444464a1adc5dcfde272d0e |
|
MD5 | c91418e7307184ee052742bee08366e8 |
|
BLAKE2b-256 | 456e744b75faca9e9be9b9910dffd949583b61f4c3fd6dc5af72b76766186bf3 |