generated from qiskit-community/quantum-prototype-template
-
Notifications
You must be signed in to change notification settings - Fork 60
feat: support Braket noise model #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| from braket.aws import AwsDevice, AwsQuantumTask, AwsQuantumTaskBatch | ||
| from braket.aws.queue_information import QueueDepthInfo | ||
| from braket.circuits import Circuit | ||
| from braket.circuits.noise_model import NoiseModel as BraketNoiseModel | ||
| from braket.device_schema import DeviceActionType | ||
| from braket.devices import Device, LocalSimulator | ||
| from braket.tasks.local_quantum_task import LocalQuantumTask | ||
|
|
@@ -59,7 +60,12 @@ def _get_gateset(self) -> Optional[set[str]]: | |
| class BraketLocalBackend(BraketBackend): | ||
| """BraketLocalBackend.""" | ||
|
|
||
| def __init__(self, name: str = "default", **fields): | ||
| def __init__( | ||
| self, | ||
| name: str = "default", | ||
| noise_model: Optional[BraketNoiseModel] = None, | ||
| **fields, | ||
| ): | ||
| """AWSBraketLocalBackend for local execution of circuits. | ||
|
|
||
| Example: | ||
|
|
@@ -71,11 +77,15 @@ def __init__(self, name: str = "default", **fields): | |
|
|
||
| Args: | ||
| name: name of backend | ||
| noise_model (Optional[NoiseModel]): The Braket noise model to apply to the circuit | ||
| before execution. Noise model can only be added to the devices that support | ||
| noise simulation. | ||
| **fields: extra fields | ||
| """ | ||
| super().__init__(name=name, **fields) | ||
| self.backend_name = name | ||
| self._local_device = LocalSimulator(backend=self.backend_name) | ||
| self._local_device.set_noise_model(noise_model) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have a |
||
| self._target = local_simulator_to_target(self._local_device) | ||
| self.status = self._local_device.status | ||
|
|
||
|
|
@@ -178,6 +188,7 @@ def __init__( # pylint: disable=too-many-arguments | |
| description: str = None, | ||
| online_date: datetime.datetime = None, | ||
| backend_version: str = None, | ||
| noise_model: Optional[BraketNoiseModel] = None, | ||
| **fields, | ||
| ): | ||
| """AWSBraketBackend for execution circuits against AWS Braket devices. | ||
|
|
@@ -196,6 +207,9 @@ def __init__( # pylint: disable=too-many-arguments | |
| description: description of backend | ||
| online_date: online date | ||
| backend_version: backend version | ||
| noise_model (Optional[NoiseModel]): The Braket noise model to apply to the circuit | ||
| before execution. Noise model can only be added to the devices that support | ||
| noise simulation. | ||
| **fields: other arguments | ||
| """ | ||
| super().__init__( | ||
|
|
@@ -208,6 +222,7 @@ def __init__( # pylint: disable=too-many-arguments | |
| ) | ||
| user_agent = f"QiskitBraketProvider/{version.__version__}" | ||
| device.aws_session.add_braket_user_agent(user_agent) | ||
| device.set_noise_model(noise_model) | ||
| self._aws_device = device | ||
| self._target = aws_device_to_target(device=device) | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a qiskit noise model that we would translate to Braket before L88.