-
Notifications
You must be signed in to change notification settings - Fork 12
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
Noise Aware ZNE #96
Noise Aware ZNE #96
Changes from 7 commits
4b682e9
50ba175
c376357
367cb42
8479da1
a394657
835f656
4dce153
362365f
ce8ddea
925ac5f
9f3cad1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
from pytket.backends.backendresult import BackendResult | ||
from pytket.utils.outcomearray import OutcomeArray | ||
import uuid | ||
from pytket.passes import BasePass | ||
from typing import Dict, List, Optional, Iterator | ||
from pytket.passes import BasePass, CustomPass | ||
from typing import Dict, List, Optional, Iterator, Sequence, Iterable | ||
from pytket import Circuit, Bit | ||
|
||
|
||
|
@@ -51,6 +51,20 @@ def __init__( | |
self.max_batch_size = max_batch_size | ||
self.result_dict = result_dict | ||
|
||
def default_compilation_pass(self, **kwargs) -> BasePass: | ||
|
||
def transform(circuit: Circuit) -> Circuit: | ||
return circuit | ||
|
||
return CustomPass(transform=transform) | ||
|
||
def rebase_pass(self): | ||
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. return type for function ( |
||
|
||
def transform(circuit: Circuit) -> Circuit: | ||
return circuit | ||
|
||
return CustomPass(transform=transform) | ||
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. same again: |
||
|
||
def run_circuit( | ||
self, | ||
circuit: Circuit, | ||
|
@@ -70,6 +84,17 @@ def run_circuit( | |
handle = self.process_circuit(circuit, n_shots, **kwargs) | ||
return self.get_result(handle=handle) | ||
|
||
def process_circuits( | ||
self, | ||
circuits: Sequence[Circuit], | ||
n_shots: Sequence[int], | ||
) -> List[uuid.UUID]: | ||
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. Ah, do you use 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. I do, in part as I don't know how to create new unique 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. Never mind, figured it out :P |
||
|
||
return [ | ||
self.process_circuit(circuit=circuit, n_shots=n) | ||
for circuit, n in zip(circuits, n_shots) | ||
] | ||
|
||
def process_circuit( | ||
self, | ||
circuit: Circuit, | ||
|
@@ -104,6 +129,11 @@ def process_circuit( | |
|
||
return handle | ||
|
||
def get_results(self, handles: Iterable[uuid.UUID]) -> List[BackendResult]: | ||
return [ | ||
self.get_result(handle) for handle in handles | ||
] | ||
|
||
def get_result(self, handle: uuid.UUID) -> BackendResult: | ||
"""Retrieve result from backend. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,10 @@ def gen_UnCorrelated_SPAM_MitRes( | |
""" | ||
if backend.backend_info is None: | ||
raise ValueError("Backend has no backend_info attribute.") | ||
if backend.backend_info.architecture is None: | ||
raise ValueError( | ||
"Backend Architecture has no specified Nodes, please use a Backend with a specified Architecture." | ||
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. I'd change the error message to: |
||
) | ||
if len(backend.backend_info.architecture.nodes) == 0: | ||
raise ValueError( | ||
"Backend Architecture has no specified Nodes, please use a Backend with a specified Architecture." | ||
|
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.
I'd just do this:
return CustomPass(transform=lambda circuit: circuit)