Quantum Hardware

Running quantum algorithms through Luna

Here, you can learn how to configure your tokens for accessing quantum hardware through Luna. In addition, you can get further details about the available quantum hardware.

QPU Token Management

Luna offers the possibility to store your access tokens for quantum hardware directly within its system. This step is necessary to run quantum algorithms on the relevant hardware and only needs to be done once.

You can acquire the token for quantum hardware directly from the provider of that hardware. If you have any questions, please feel free to get in touch with us.

# Load the luna packages
from luna_sdk import LunaSolve
from luna_sdk.schemas.enums.qpu_provider import QpuProviderEnum
from luna_sdk.schemas.qpu_token import QpuToken

# Create a Luna object and set your credentials
luna = LunaSolve(username="YOURUSERNAME", password="YOURPASSWORD")

# Set the provider of the quantum hardware, e.g. 'IBM'
provider = QpuProviderEnum.ibm

# Set the token you have received to access the quantum hardware provider
token = '<QPUTOKEN>'

# Set the token's name
token_name = "TokenName"

# Finally, set the token in Luna to be able to access the quantum hardware
luna.set_qpu_token(provider=provider, token=token)

# Create a QPU token for you as a user
qpu_token: QpuToken = luna.user.create_qpu_token(
    name=token_name, 
    provider=provider, 
    token=token
)

# Create a QPU token for your organization
qpu_token: QpuToken = luna.organiztion.create_qpu_token(
    name=token_name, 
    provider=provider, 
    token=token
)

You can always get a list of your tokens:

from typing import Dict, List

# Get a list of all tokens set for your user's account
qpu_tokens: Dict[str, List[QpuToken]] = luna.user.get_qpu_tokens()

# Get a list of all tokens set for your organization
qpu_tokens: List[QpuToken] = luna.organiztion.get_qpu_tokens()

You can also rename any of your tokens:

# Access one of your QPU tokens
qpu_token_id = "QPUTOKENID"

# Rename the user's QPU token
luna.user.update_qpu_token(
    qpu_token_id=qpu_token_id, 
    name="new_token_name"
)

# Rename the organization's QPU token
luna.organization.update_qpu_token(
    qpu_token_id=qpu_token_id, 
    name="new_token_name"
)

And, finally, if you don't want a token to be stored in your account any more, you can remove any tokens you don't need.

# Delete a specific token. Use with caution!

# Delete user's QPU token
luna.user.delete_qpu_token(qpu_token_id=qpu_token_id)

# Delete organization's QPU token
luna.organization.delete_qpu_token(qpu_token_id=qpu_token_id)

Was this page helpful?