Skip to content

QPU Tokens

Quantum Processing Unit (QPU) tokens are essential for accessing quantum hardware through Luna. These tokens are provided by specific quantum hardware providers and are necessary for running quantum algorithms on actual quantum computers.


Using QPU Tokens

Visit the respective provider's website and follow their instructions to obtain your QPU tokens. Check out our Integrations to see the supported providers.

Luna provides three ways to use QPU tokens. You can use them directly in your code, set them as environment variables, or upload them to Luna and use them in your code.

1. Directly in Code

You can use the tokens directly in your code by passing them as arguments to the Luna API. This is useful for quick testing and prototyping.

from luna_quantum.backends import DWaveQpu

dwave_backend = DWaveQpu(token='<YOUR_DWAVE_TOKEN>')

2. Environment Variables

Add your tokens as environment variables. You can add them with:

terminal
export LUNA_DWAVE_TOKEN=your_dwave_token
export LUNA_QCTRL_TOKEN=your_qctrl_token
export LUNA_AWS_ACCESS_KEY=your_aws_access_key
export LUNA_AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key

Then you don't need to pass the tokens explicitly in your code. Luna will automatically use the corresponding environment variables to authenticate with the providers.

from luna_quantum.backends import DWaveQpu

dwave_backend = DWaveQpu()  # Will read LUNA_DWAVE_TOKEN if set

The DWaveQpu will automatically use the LUNA_DWAVE_TOKEN environment variable to authenticate with D-Wave when no token is explicitly provided.

3. Upload and Use QPU Tokens

You can upload your tokens to Luna. This is useful for managing multiple tokens and sharing them across your team. Therefore, Luna distinguishes between personal and group QPU Tokens.

First, upload your QPU Token:

ls = LunaSolve(api_key='your_luna_api_key')
personal_qpu_token = ls.qpu_token.create(
    provider='dwave',
    name='personal-token',
    token='your_dwave_token',
    token_type="personal"
)
ls = LunaSolve(api_key='your_luna_api_key')
group_qpu_token = ls.qpu_token.create(
    provider='dwave',
    name='group-token',
    token='your_dwave_token',
    token_type="group"
)

Personal Tokens

A personal QPU Token is for personal use only. Only you can use this token.

Share QPU Tokens

With a group QPU Token, you can share a token without disclosing it. All members of your organization can use this token.

Then you can use the token with:

from luna_quantum.client.schemas.qpu_token.qpu_token import PersonalQpuToken

personal_qpu_token = PersonalQpuToken(name="my_personal_token")
backend = DWaveQpu(token=personal_qpu_token)
from luna_quantum.client.schemas.qpu_token.qpu_token import GroupQpuToken

group_qpu_token = GroupQpuToken(name="my_group_token")
backend = DWaveQpu(token=group_qpu_token)

Sharing QPU Tokens only available for Academic and Enterprise customers.

List Your Uploaded QPU Tokens

Get a list of all your QPU tokens, including both personal and shared tokens:

# get all qpu tokens
my_qpu_tokens = ls.qpu_token.get_all()

# Specify limit and offset, and filter by token type and provider
my_qpu_tokens = ls.qpu_token.get_all(
    limit=50,
    offset=0,
    token_type="personal", # or "group"
    filter_provider="dwave",
)

Get the Provider Name

You can get the provider name by accessing the provider property of the respective backend:

from luna_quantum.backends import DWave

backend = DWave()
print(backend.provider)

Rename Your Uploaded QPU Tokens

Rename a QPU token:

from luna_quantum.client.schemas.enums.qpu_token_type import QpuTokenTypeEnum

ls.qpu_token.rename(
    name='my-personal-token',
    new_name='my-renamed-token',
    token_type=QpuTokenTypeEnum.PERSONAL
)

Renaming QPU Tokens

You can rename your personal QPU Tokens. A shared token can only be renamed by the admin of the organization.

Delete Your Uploaded QPU Tokens

from luna_quantum.client.schemas.enums.qpu_token_type import QpuTokenTypeEnum
from luna_quantum import LunaSolve
ls = LunaSolve(api_key='your_luna_api_key')
ls.qpu_token.delete(name='my-personal-token', token_type=QpuTokenType.PERSONAL)

Deleting QPU Tokens

You can delete your personal QPU Tokens. A shared token can only be deleted by the admin of the organization.

API Reference

Working with the QpuTokenRestClient

We recommend using QpuTokenRestClient via the LunaSolve object:

from luna_quantum import LunaSolve

qpu_token_client = LunaSolve().qpu_token

Implementation of a solve job REST client.

create(name: str, provider: str, token: str, token_type: QpuTokenTypeEnum, **kwargs: Any) -> QpuTokenOut

Create QPU token.

Parameters:

  • name (str) –

    Name of the QPU token

  • provider (str) –

    Name of provider

  • token (str) –

    Token

  • token_type (QpuTokenTypeEnum) –

    There are two types of QPU tokens: PERSONAL and GROUP. All users of a group can use group QPU tokens. User QPU tokens can only be used by the user who created them.

  • **kwargs (Any, default: {} ) –

    Parameters to pass to httpx.request.

Returns:

  • QpuTokenOut

    QpuToken instances.

get_all(filter_provider: str | None = None, token_type: QpuTokenTypeEnum | None = None, limit: int | None = None, offset: int | None = None, **kwargs: Any) -> dict[QpuTokenTypeEnum, list[QpuTokenOut]]

Retrieve a list of QPU tokens.

Parameters:

  • filter_provider (str | None, default: None ) –

    The provider for which qpu tokens should be retrieved

  • token_type (QpuTokenTypeEnum | None, default: None ) –

    If you want to retrieve only user or group QPU tokens otherwise all QPU tokens will be retrieved

  • limit (int | None, default: None ) –

    Number of items to fetch. Default is 10.

  • offset (int | None, default: None ) –

    Optional. Number of items to skip. Default is 0.

  • **kwargs (Any, default: {} ) –

    Parameters to pass to httpx.request.

Returns:

  • Dict[QpuTokenTypeEnum, List[QpuTokenOut]]

    List of QpuTokenOut instances.

get(name: str, token_type: QpuTokenTypeEnum = QpuTokenTypeEnum.PERSONAL, **kwargs: Any) -> QpuTokenOut

Retrieve user QPU token by id.

Parameters:

  • name (str) –

    Name of the QPU token that should be retrieved

  • token_type (QpuTokenTypeEnum, default: PERSONAL ) –

    There are two types of QPU tokens: PERSONAL and GROUP. All users of a group can use group QPU tokens. User QPU tokens can only be used by the user who created them.

  • **kwargs (Any, default: {} ) –

    Parameters to pass to httpx.request.

Returns:

  • QpuTokenOut

    QpuToken instance.

rename(name: str, new_name: str, token_type: QpuTokenTypeEnum, **kwargs: Any) -> QpuTokenOut

Update QPU token by id.

Parameters:

  • name (str) –

    Current name of the QPU token that should be updated

  • new_name (str) –

    The new name

  • token_type (QpuTokenTypeEnum) –

    There are two types of QPU tokens: PERSONAL and GROUP. All users of a group can use group QPU tokens. User QPU tokens can only be used by the user who created them.

  • **kwargs (Any, default: {} ) –

    Parameters to pass to httpx.request.

Returns:

  • QpuTokenOut

    QpuToken instance.

delete(name: str, token_type: QpuTokenTypeEnum, **kwargs: Any) -> None

Delete QPU token by name.

Parameters:

  • name (str) –

    Name of the QPU token that should be deleted

  • token_type (QpuTokenTypeEnum) –

    There are two types of QPU tokens: PERSONAL and GROUP. All users of a group can use organization QPU tokens. User QPU tokens can only be used by the user who created them.

  • **kwargs (Any, default: {} ) –

    Parameters to pass to httpx.request.

create_group_time_quota(qpu_token_name: str, quota: int, start: datetime | None = None, end: datetime | None = None, **kwargs: Any) -> None

Create a time quota policy for a shared QPU token for the entire group.

Parameters:

  • qpu_token_name (str) –

    The name of the qpu token. Currently, only DWave tokens are supported.

  • quota (int) –
  • quota (int) –

    The amount of quota to add. For DWave Quantum Annealing, which is currently the only algorithm that supports time quota, this is the qpu access time in nanoseconds.

  • start (Optional[datetime], default: None ) –

    The date and time from which the policy is active. If None, the current date and time will be used. If the policy is currently not effective, the token cannot be used at all. Default: None

  • end (Optional[datetime], default: None ) –

    The date and time until which the policy is active. If None, the policy if effective until 265 days after the start date. If the policy is currently not effective, the token cannot be used at all. Default: None

get_group_time_quota(qpu_token_name: str, **kwargs: Any) -> QpuTokenTimeQuotaOut | None

Get the group time quota policy for a qpu token.

Parameters:

  • qpu_token_name (str) –

    The name of the qpu token.

Returns:

  • Optional[QpuTokenTimeQuotaOut]

    The token policy. None, if no group policy is set on this token.

update_group_time_quota(qpu_token_name: str, quota: int | None = None, start: datetime | None = None, end: datetime | None = None, **kwargs: Any) -> None

Update the details on a group qpu time quota policy.

Parameters:

  • qpu_token_name (str) –

    The name of the qpu token.

  • quota (Optional[int], default: None ) –

    The amount of quota. For DWave Quantum Annealing, which is currently the only supported solver, this is the qpu access time in nanoseconds. If None, the available quota won't be updated. Default: None

  • start (Optional[datetime], default: None ) –

    The date and time from which the policy is active. If None, the start date won't be updated. Default: None

  • end (Optional[datetime], default: None ) –

    The date and time until which the policy is active. If None, the end date won't be updated. Default: None

delete_group_time_quota(qpu_token_name: str, **kwargs: Any) -> None

Delete the group policy set on a qpu token.

Parameters:

  • qpu_token_name (str) –

    The name of the qpu token.

create_user_time_quota(qpu_token_name: str, user_email: str, quota: int, start: datetime | None = None, end: datetime | None = None, **kwargs: Any) -> None

Create a time quota policy for a shared QPU token for a single user.

Parameters:

  • qpu_token_name (str) –

    The name of the qpu token. Currently, only DWave tokens are supported.

  • user_email (str) –

    Email of the user for whom to add the policy.

  • quota (int) –

    The amount of quota to add. For DWave Quantum Annealing, which is currently the only algorithm that supports time quota, this is the qpu access time in nanoseconds.

  • start (Optional[datetime], default: None ) –

    The date and time from which the policy is active. If None, the current date and time will be used. If the policy is currently not effective, the token cannot be used at all. Default: None

  • end (Optional[datetime], default: None ) –

    The date and time until which the policy is active. If None, the policy if effective until 265 days after the start date. If the policy is currently not effective, the token cannot be used at all. Default: None

get_user_time_quota(qpu_token_name: str, user_email: str, **kwargs: Any) -> QpuTokenTimeQuotaOut | None

Get a user-specific time quota policy for a qpu token.

Parameters:

  • qpu_token_name (str) –

    The name of the qpu token.

  • user_email (str) –

    Email of the user for whom to get the policy.

Returns:

  • Optional[QpuTokenTimeQuotaOut]

    The token policy. None, if no policy is set on this token for the specified user.

update_user_time_quota(qpu_token_name: str, user_email: str, quota: int | None = None, start: datetime | None = None, end: datetime | None = None, **kwargs: Any) -> None

Update the details on a user-specific qpu time quota policy.

Parameters:

  • qpu_token_name (str) –

    The name of the qpu token.

  • user_email (str) –

    Email of the user for whom to update the policy.

  • quota (Optional[int], default: None ) –

    The amount of quota. For DWave Quantum Annealing, which is currently the only supported solver, this is the qpu access time in nanoseconds. If None, the available quota won't be updated. Default: None

  • start (Optional[datetime], default: None ) –

    The date and time from which the policy is active. If None, the start date won't be updated. Default: None

  • end (Optional[datetime], default: None ) –

    The date and time until which the policy is active. If None, the end date won't be updated. Default: None

delete_user_time_quota(qpu_token_name: str, user_email: str, **kwargs: Any) -> None

Delete a user-specific policy set on a qpu token.

Parameters:

  • qpu_token_name (str) –

    The name of the qpu token.