AQT Arnica cloud portal

This guide covers usage of the Qiskit AQT provider package with the AQT Arnica cloud portal.

Tip

Use the Arnica cloud example script as a basis for your scripts, to help make them more resilient.

Usage

The recommended way to use the AQTProvider class to access AQT Arnica cloud resources is as a context manager. This will ensure that connections are properly cleaned up when leaving the context.

from qiskit_aqt_provider import AQTProvider

with AQTProvider() as provider:
   cloud = provider.cloud()
   ...

Handling transient errors

Submitting jobs to the Arnica cloud portal involves lots of steps that might go wrong; there could be network errors, authentication problems, long queues, and many more. Because of the way Qiskit jobs work, a link between the Job object in your script and the remote circuit needs to be maintained. Any single issue could cause this link to be broken and mean that your results are lost. We therefore strongly recommend persisting your jobs immediately after submitting them. This will allow the link between the Job and the remote circuit to be restored at any time.

from qiskit_aqt_provider import AQTProvider
from qiskit_aqt_provider.persistence import FileJobStore

store = FileJobStore()

with AQTProvider() as provider:
  cloud = provider.cloud()
  ...
  backend = workspace.get_backend("my_backend_id")
  job = backend.run(my_transpiled_circuit)
  print(job.job_id())
  job.persist(store=store)  # save it in case something bad happens
  job.result()  # wait for the result

Now that you’ve persisted the Job (and kept a record of the job ID), you can easily restore it at any time, even in a different process:

# later...
with AQTProvider() as provider:
  cloud = provider.cloud()
  ...
  backend = workspace.get_backend("my_backend_id")
  job = backend.restore_job(job_id, store=store)  # job_id that was printed previously
  job.result()  # wait for the result

See the Job Persistence documentation for more information.

Authentication

Using an Arnica account

Tip

Use this method if you were asked to create your own account to use the AQT Arnica portal.

Call log_in to start the authentication flow and store your access token securely on the local machine.

from qiskit_aqt_provider import AQTProvider

with AQTProvider() as provider:
   cloud = provider.cloud()
   cloud.log_in()

Hint

The access token has an expiration time of 10 hours. After this time, you’ll need to call the log_in method again to refresh your token. You shouldn’t need to enter your password again unless you last logged in a very long time ago. You can safely call log_in at any time, as nothing will happen if your access token is still valid.

Using client credentials

Tip

Use this method if you received client credentials from AQT to use the Arnica portal.

Pass an instance of the ArnicaConfig helper class to AQTProvider, then call log_in to exchange your credentials for an access token, which is stored on the local machine.

from qiskit_aqt_provider import AQTProvider
from qiskit_aqt_provider.aqt_provider import ArnicaConfig

config = ArnicaConfig()
config.client_id="YOUR_CLIENT_ID"
config.client_secret="YOUR_CLIENT_SECRET"

with AQTProvider() as provider:
   cloud = provider.cloud(config)
   cloud.log_in()

Using a static API token (deprecated)

Removed in version 2.0.0: Static API tokens are no longer supported. If you’ve only received a static access token from AQT, you can contact AQT support to get an account.

Listing accessible resources

Cloud resources can be accessed through a workspace. Each workspace may contain multiple resources, which can be of different types (device or simulator).

To see which workspaces you have access to, call the fetch_workspaces method on the cloud handle:

...
all_workspaces = cloud.fetch_workspaces()
for workspace in all_workspaces:
    print(workspace.id)

Hint

You should have received the ID of the workspace(s) you have access to from AQT. If you’re not sure which to use, please contact AQT support.

Get a provider for a single workspace by passing its ID to the get_by_id method on the workspaces handle:

workspace = all_workspaces.get_by_id("my_workspace_id")

Then list the backends available in that workspace by calling the list_backends method on the workspace handle:

...
backends = workspace.list_backends()
for backend in backends:
    print(backend.id, backend.type)

And finally get a handle to a specific backend by passing its ID to the get_backend method on the workspace handle:

...
backend = workspace.get_backend("my_backend_id")

If no backend with the given ID is found, a QiskitBackendNotFoundError exception is raised.

Quantum register size

The number of qubits available on a given resource may vary. This is because the number of ions loaded in an AQT quantum computing resource is adjustable. All-to-all connectivity is always guaranteed, independently of the number of available qubits.

The number of qubits available for cloud resources cannot be configured with this provider.

Warning

The number of qubits is fetched from the API when initializing the resource handle, i.e. when calling get_backend. Subsequent transpilation calls will assume that at least this number of qubits is available.