-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
410 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,27 @@ to directly manipulate them if required by, for instance, optimal pulse shaping. | |
|
||
!!! note | ||
The Pulser backend is still experimental and the interface might change in the future. | ||
Please note that it does not support `DiffMode.AD`. | ||
Please note that it does not support `DiffMode.AD`. | ||
|
||
!!! note | ||
With the Pulser backend, `qadence` simulations can be executed on the cloud emulators available on the PASQAL | ||
cloud platform. In order to do so, make to have valid credentials for the PASQAL cloud platform and use | ||
the following configuration for the Pulser backend: | ||
|
||
```python exec="off" source="material-block" html="1" session="pulser-basic" | ||
config = { | ||
"cloud_configuration": { | ||
"username": "<changeme>", | ||
"password": "<changeme>", | ||
"project_id": "<changeme>", # the project should have access to emulators | ||
"platform": "EMU_FREE" # choose between `EMU_TN` and `EMU_FREE` | ||
} | ||
} | ||
``` | ||
|
||
For inquiries and more details on the cloud credentials, please contact | ||
[[email protected]](mailto:[email protected]). | ||
|
||
|
||
## Default qubit interaction | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass, field | ||
from typing import Callable | ||
|
||
from qadence.backend import BackendConfiguration | ||
from qadence.logger import get_logger | ||
from qadence.transpile import digitalize, fill_identities | ||
|
||
logger = get_logger(__name__) | ||
|
||
default_passes: list[Callable] = [fill_identities, digitalize] | ||
|
||
|
||
@dataclass | ||
class Configuration(BackendConfiguration): | ||
# FIXME: currently not used | ||
# credentials for connecting to the cloud | ||
# and executing on real QPUs | ||
cloud_credentials: dict = field(default_factory=dict) | ||
# Braket requires gate-level parameters | ||
use_gate_params = True | ||
"""Credentials for connecting to the cloud | ||
and executing on the QPUs available on Amazon Braket""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
from functools import lru_cache | ||
from typing import Optional | ||
|
||
from pasqal_cloud import AUTH0_CONFIG, PASQAL_ENDPOINTS, SDK, Auth0Conf, Endpoints, TokenProvider | ||
|
||
from .config import DEFAULT_CLOUD_ENV, CloudConfiguration | ||
|
||
|
||
@lru_cache(maxsize=5) | ||
def _get_client( | ||
username: Optional[str] = None, | ||
password: Optional[str] = None, | ||
project_id: Optional[str] = None, | ||
environment: Optional[str] = None, | ||
token_provider: Optional[TokenProvider] = None, | ||
) -> SDK: | ||
auth0conf: Optional[Auth0Conf] = None | ||
endpoints: Optional[Endpoints] = None | ||
|
||
username = os.environ.get("PASQAL_CLOUD_USERNAME", "") if username is None else username | ||
password = os.environ.get("PASQAL_CLOUD_PASSWORD", "") if password is None else password | ||
project_id = os.environ.get("PASQAL_CLOUD_PROJECT_ID", "") if project_id is None else project_id | ||
|
||
environment = ( | ||
os.environ.get("PASQAL_CLOUD_ENV", DEFAULT_CLOUD_ENV) | ||
if environment is None | ||
else environment | ||
) | ||
|
||
# setup configuration for environments different than production | ||
if environment == "preprod": | ||
auth0conf = AUTH0_CONFIG["preprod"] | ||
endpoints = PASQAL_ENDPOINTS["preprod"] | ||
elif environment == "dev": | ||
auth0conf = AUTH0_CONFIG["dev"] | ||
endpoints = PASQAL_ENDPOINTS["dev"] | ||
|
||
if all([username, password, project_id]) or all([token_provider, project_id]): | ||
pass | ||
else: | ||
raise Exception("You must either provide project_id and log-in details or a token provider") | ||
|
||
return SDK( | ||
username=username, | ||
password=password, | ||
project_id=project_id, | ||
auth0=auth0conf, | ||
endpoints=endpoints, | ||
token_provider=token_provider, | ||
) | ||
|
||
|
||
def get_client(credentials: CloudConfiguration) -> SDK: | ||
return _get_client( | ||
username=credentials.username, | ||
password=credentials.password, | ||
project_id=credentials.project_id, | ||
environment=credentials.environment, | ||
token_provider=credentials.token_provider, | ||
) |
Oops, something went wrong.