Skip to content
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

Add quality check of calibration results #25

Merged
merged 24 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add calibration fraction as a parameter and kwarg
  • Loading branch information
Daniel Mills authored and Daniel Mills committed Dec 13, 2021
commit 6e28c44d0447f88fcc6f46dfba25a7b835689219
5 changes: 4 additions & 1 deletion qermit/clifford_noise_characterisation/ccl.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ def gen_CDR_MitEx(
of the calibration circuits and 0.
:key distance_tolerance: The absolute tolerance on the distance between
expectation values of the calibration and original circuit.
:key calibration_fraction: The upper bound on the fraction of calibration
circuits which have noisy expectation values far from that of the
original circuit.
"""
_states_sim_mitex = copy.copy(
kwargs.get(
Expand Down Expand Up @@ -516,7 +519,7 @@ def gen_CDR_MitEx(

_post_task_graph = TaskGraph(_label="QualityCheckCorrect")
_post_task_graph.parallel(_post_calibrate_task_graph)
_post_task_graph.prepend(cdr_quality_check_task_gen(distance_tolerance=kwargs.get("distance_tolerance", 0.1)))
_post_task_graph.prepend(cdr_quality_check_task_gen(distance_tolerance=kwargs.get("distance_tolerance", 0.1), calibration_fraction=kwargs.get("calibration_fraction", 0.5)))

_experiment_taskgraph.prepend(
ccl_state_task_gen(n_non_cliffords, n_pairs, total_state_circuits)
Expand Down
8 changes: 6 additions & 2 deletions qermit/clifford_noise_characterisation/cdr_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def correct(self, noisy_expectation: float) -> float:
)


def cdr_quality_check_task_gen(distance_tolerance: float) -> MitTask:
def cdr_quality_check_task_gen(distance_tolerance: float, calibration_fraction: float) -> MitTask:
"""
Check quality of calibration results. In particular, ensure that a
significant proportion of the calibrations circuits have noisy expectation
Expand All @@ -80,6 +80,10 @@ def cdr_quality_check_task_gen(distance_tolerance: float) -> MitTask:
:param distance_tolerance: The absolute tolerance on the distance between
expectation values of the calibration and original circuit.
:type distance_tolerance: float
:param calibration_fraction: The upper bound on the fraction of calibration
circuits which have noisy expectation values far from that of the
original circuit.
:type calibration_fraction: float
"""

def cdr_quality_check_task(
Expand Down Expand Up @@ -123,7 +127,7 @@ def cdr_quality_check_task(

# Raise a warning if the calibration circuits regularly have noisy
# expectation value far from the original circuit.
if is_far_count > len(calibration) / 2:
if is_far_count > len(calibration) * calibration_fraction:
warnings.warn(
"Training data regularly differers significantly from original circuit. Fit may be poor."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

differers -> differs

)
Expand Down