AQT Backends¶
Usage¶
Handles to computing resources are obtained through the AQTProvider class.
You can use the provider to access AQT resources:
using the AQT Arnica cloud portal
using offline simulators
using direct access
Selecting a backend at runtime¶
Applications can select one backend at runtime and use it for the entire
script. For example, run the script with AQT_PROVIDER=offline to test a
circuit locally, then set it to direct or cloud and run the script
again. The resulting backend handle can be used the same way in each case:
import os
from qiskit_aqt_provider import AQTProvider
provider_type = os.getenv("AQT_PROVIDER", "offline")
def get_backend(provider: AQTProvider, provider_type: str):
if provider_type == "offline":
return provider.offline.ideal()
if provider_type == "direct":
return provider.direct_access().get_resource(
os.environ["AQT_DIRECT_URL"],
os.environ["AQT_TOKEN"],
)
if provider_type == "cloud":
workspaces = provider.cloud().fetch_workspaces()
workspace = workspaces.get_by_id(os.environ["AQT_WORKSPACE_ID"])
return workspace.get_backend(os.environ["AQT_RESOURCE_ID"])
raise ValueError(f"Unknown provider: {provider_type}")
with AQTProvider() as provider:
backend = get_backend(provider, provider_type)
result = backend.run(circuit).result()
For cloud access, authenticate first as described in the AQT Arnica cloud portal
authentication guide. AQT_PROVIDER accepts offline, cloud, or
direct and defaults to offline.