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.solve.parameters.backends import DWaveQpu
dwave_backend = DWaveQpu(token='<YOUR_DWAVE_TOKEN>')
2. Environment Variables¶
Add your tokens as environment variables. You can add them with:
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.
The DwaveQpuBackend
will automatically use the LUNA_DWAVE_TOKEN
environment variable to authenticate with D-Wave.
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:
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:
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:
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
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¶
Implementation of a solve job REST client.
create ¶
create(
name: str,
provider: str,
token: str,
token_type: QpuTokenTypeEnum,
**kwargs: Any,
) -> QpuTokenOut
Create QPU token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the QPU token |
required |
provider
|
str
|
Name of provider |
required |
token
|
str
|
Token |
required |
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. |
required |
**kwargs
|
Any
|
Parameters to pass to |
{}
|
Returns:
Type | Description |
---|---|
QpuTokenOut
|
QpuToken instances. |
create_group_time_quota ¶
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:
Name | Type | Description | Default |
---|---|---|---|
qpu_token_name
|
str
|
The name of the qpu token. Currently, only DWave tokens are supported. |
required |
quota
|
int
|
|
required |
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. |
required |
start
|
Optional[datetime]
|
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 |
None
|
end
|
Optional[datetime]
|
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 |
None
|
create_user_time_quota ¶
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:
Name | Type | Description | Default |
---|---|---|---|
qpu_token_name
|
str
|
The name of the qpu token. Currently, only DWave tokens are supported. |
required |
user_email
|
str
|
Email of the user for whom to add the policy. |
required |
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. |
required |
start
|
Optional[datetime]
|
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 |
None
|
end
|
Optional[datetime]
|
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 |
None
|
delete ¶
Delete QPU token by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the QPU token that should be deleted |
required |
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. |
required |
**kwargs
|
Any
|
Parameters to pass to |
{}
|
delete_group_time_quota ¶
Delete the group policy set on a qpu token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qpu_token_name
|
str
|
The name of the qpu token. |
required |
delete_user_time_quota ¶
Delete a user-specific policy set on a qpu token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qpu_token_name
|
str
|
The name of the qpu token. |
required |
get ¶
Retrieve user QPU token by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the QPU token that should be retrieved |
required |
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. |
PERSONAL
|
**kwargs
|
Any
|
Parameters to pass to |
{}
|
Returns:
Type | Description |
---|---|
QpuTokenOut
|
QpuToken instance. |
get_all ¶
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:
Name | Type | Description | Default |
---|---|---|---|
filter_provider
|
str | None
|
The provider for which qpu tokens should be retrieved |
None
|
token_type
|
QpuTokenTypeEnum | None
|
If you want to retrieve only user or group QPU tokens otherwise all QPU tokens will be retrieved |
None
|
limit
|
int | None
|
Number of items to fetch. Default is 10. |
None
|
offset
|
int | None
|
Optional. Number of items to skip. Default is 0. |
None
|
**kwargs
|
Any
|
Parameters to pass to |
{}
|
Returns:
Type | Description |
---|---|
Dict[QpuTokenTypeEnum, List[QpuTokenOut]]
|
List of QpuTokenOut instances. |
get_group_time_quota ¶
Get the group time quota policy for a qpu token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qpu_token_name
|
str
|
The name of the qpu token. |
required |
Returns:
Type | Description |
---|---|
Optional[QpuTokenTimeQuotaOut]
|
The token policy. None, if no group policy is set on this token. |
get_user_time_quota ¶
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:
Name | Type | Description | Default |
---|---|---|---|
qpu_token_name
|
str
|
The name of the qpu token. |
required |
user_email
|
str
|
Email of the user for whom to get the policy. |
required |
Returns:
Type | Description |
---|---|
Optional[QpuTokenTimeQuotaOut]
|
The token policy. None, if no policy is set on this token for the specified user. |
rename ¶
Update QPU token by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Current name of the QPU token that should be updated |
required |
new_name
|
str
|
The new name |
required |
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. |
required |
**kwargs
|
Any
|
Parameters to pass to |
{}
|
Returns:
Type | Description |
---|---|
QpuTokenOut
|
QpuToken instance. |
update_group_time_quota ¶
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:
Name | Type | Description | Default |
---|---|---|---|
qpu_token_name
|
str
|
The name of the qpu token. |
required |
quota
|
Optional[int]
|
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 |
None
|
start
|
Optional[datetime]
|
The date and time from which the policy is active. If None, the start date won't be updated. Default: None |
None
|
end
|
Optional[datetime]
|
The date and time until which the policy is active. If None, the end date won't be updated. Default: None |
None
|
update_user_time_quota ¶
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:
Name | Type | Description | Default |
---|---|---|---|
qpu_token_name
|
str
|
The name of the qpu token. |
required |
user_email
|
str
|
Email of the user for whom to update the policy. |
required |
quota
|
Optional[int]
|
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 |
None
|
start
|
Optional[datetime]
|
The date and time from which the policy is active. If None, the start date won't be updated. Default: None |
None
|
end
|
Optional[datetime]
|
The date and time until which the policy is active. If None, the end date won't be updated. Default: None |
None
|