Skip to content

Commit 615f2cc

Browse files
committed
very messy support for subspace-restricted error metrics
1 parent 3f2d7e9 commit 615f2cc

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

pygsti/report/factory.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,10 @@ def construct_standard_report(results, title="auto",
11991199
ws = ws or _ws.Workspace()
12001200

12011201
advanced_options = advanced_options or {}
1202+
n_leak = advanced_options.get('n_leak', 0)
1203+
# ^ Not sure if this is a good place to pass this parameter.
1204+
# A better implementation would be to store this info in model.basis
1205+
# (for the various models).
12021206
linlogPercentile = advanced_options.get('linlog percentile', 5)
12031207
nmthreshold = advanced_options.get('nmthreshold', DEFAULT_NONMARK_ERRBAR_THRESHOLD)
12041208
embed_figures = advanced_options.get('embed_figures', True)
@@ -1331,8 +1335,12 @@ def construct_standard_report(results, title="auto",
13311335
'gauge_opt_labels': tuple(gauge_opt_labels),
13321336
'max_lengths': tuple(Ls),
13331337
'switchbd_maxlengths': tuple(swLs),
1334-
'show_unmodeled_error': bool('ShowUnmodeledError' in flags)
1338+
'show_unmodeled_error': bool('ShowUnmodeledError' in flags),
1339+
'n_leak' : n_leak
13351340
}
1341+
# ^ Not sure if this is a good place to pass n_leak.
1342+
# A better implementation would be to store this info in model.basis
1343+
# (for the various models).
13361344

13371345
templates = dict(
13381346
html='~standard_html_report',

pygsti/report/reportables.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,14 @@ def maximum_trace_dist(gate, mx_basis):
998998
Maximum_trace_dist = _modf.opfn_factory(maximum_trace_dist)
999999
# init args == (model, op_label)
10001000

1001+
def leaky_maximum_trace_dist(gate, mx_basis):
1002+
closestUOpMx = _alg.find_closest_unitary_opmx(gate)
1003+
_tools.jamiolkowski_iso(closestUOpMx, mx_basis, mx_basis)
1004+
n_leak = 1
1005+
return _tools.leaky_jtracedist(gate, closestUOpMx, mx_basis, n_leak)
1006+
1007+
Leaky_maximum_trace_dist = _modf.opfn_factory(leaky_maximum_trace_dist)
1008+
10011009

10021010
def angles_btwn_rotn_axes(model):
10031011
"""
@@ -1069,6 +1077,12 @@ def entanglement_fidelity(a, b, mx_basis):
10691077
Entanglement_fidelity = _modf.opsfn_factory(entanglement_fidelity)
10701078
# init args == (model1, model2, op_label)
10711079

1080+
def leaky_entanglement_fidelity(a, b, mx_basis):
1081+
n_leak = 1
1082+
return _tools.leaky_entanglement_fidelity(a, b, mx_basis, n_leak)
1083+
1084+
Leaky_entanglement_fidelity = _modf.opsfn_factory(leaky_entanglement_fidelity)
1085+
10721086

10731087
def entanglement_infidelity(a, b, mx_basis):
10741088
"""
@@ -1095,6 +1109,11 @@ def entanglement_infidelity(a, b, mx_basis):
10951109
Entanglement_infidelity = _modf.opsfn_factory(entanglement_infidelity)
10961110
# init args == (model1, model2, op_label)
10971111

1112+
def leaky_entanglement_infidelity(a, b, mx_basis):
1113+
return 1 - leaky_entanglement_fidelity(a, b, mx_basis)
1114+
1115+
Leaky_entanglement_infidelity = _modf.opsfn_factory(leaky_entanglement_infidelity)
1116+
10981117

10991118
def closest_unitary_fidelity(a, b, mx_basis): # assume vary model1, model2 fixed
11001119
"""
@@ -1186,6 +1205,12 @@ def jtrace_diff(a, b, mx_basis): # assume vary model1, model2 fixed
11861205
Jt_diff = _modf.opsfn_factory(jtrace_diff)
11871206
# init args == (model1, model2, op_label)
11881207

1208+
def leaky_jtrace_diff(a, b, mx_basis):
1209+
n_leak = 1
1210+
return _tools.leaky_jtracedist(a, b, mx_basis, n_leak)
1211+
1212+
Leaky_Jt_diff = _modf.opsfn_factory(leaky_jtrace_diff)
1213+
11891214

11901215
if _CVXPY_AVAILABLE:
11911216

@@ -2394,10 +2419,14 @@ def info_of_opfn_by_name(name):
23942419
info = {
23952420
"inf": ("Entanglement|Infidelity",
23962421
"1.0 - <psi| 1 x Lambda(psi) |psi>"),
2422+
"la-inf": ("Entanglement|Infidelity (subspace)",
2423+
"TO-WRITE"),
23972424
"agi": ("Avg. Gate|Infidelity",
23982425
"d/(d+1) (entanglement infidelity)"),
23992426
"trace": ("1/2 Trace|Distance",
24002427
"0.5 | Chi(A) - Chi(B) |_tr"),
2428+
"la-trace" : ("1/2 Trace|Distance (subspace)",
2429+
"TO-WRITE"),
24012430
"diamond": ("1/2 Diamond-Dist",
24022431
"0.5 sup | (1 x (A-B))(rho) |_tr"),
24032432
"nuinf": ("Non-unitary|Ent. Infidelity",
@@ -2467,12 +2496,18 @@ def evaluate_opfn_by_name(name, model, target_model, op_label_or_string,
24672496
if name == "inf":
24682497
fn = Entanglement_infidelity if b else \
24692498
Circuit_entanglement_infidelity
2499+
elif name == "la-inf":
2500+
assert b
2501+
fn = Leaky_entanglement_infidelity
24702502
elif name == "agi":
24712503
fn = Avg_gate_infidelity if b else \
24722504
Circuit_avg_gate_infidelity
24732505
elif name == "trace":
24742506
fn = Jt_diff if b else \
24752507
Circuit_jt_diff
2508+
elif name == "la-trace":
2509+
assert b
2510+
fn = Leaky_Jt_diff
24762511
elif name == "diamond":
24772512
fn = HalfDiamondNorm if b else \
24782513
CircuitHalfDiamondNorm

pygsti/report/section/gauge.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,13 @@ def final_model_spam_vs_target_table(workspace, switchboard=None, confidence_lev
168168
@_Section.figure_factory(4)
169169
def final_gates_vs_target_table_gauge_var(workspace, switchboard=None, confidence_level=None,
170170
ci_brevity=1, **kwargs):
171+
if kwargs.get('n_leak', 0) == 0:
172+
display = ('inf', 'agi', 'trace', 'diamond', 'nuinf', 'nuagi')
173+
else:
174+
display = ('inf', 'la-inf', 'agi', 'trace', 'la-trace', 'diamond', 'nuinf', 'nuagi')
171175
return workspace.GatesVsTargetTable(
172176
switchboard.mdl_final, switchboard.mdl_target, _cri(1, switchboard, confidence_level, ci_brevity),
173-
display=('inf', 'agi', 'trace', 'diamond', 'nuinf', 'nuagi')
177+
display=display
174178
)
175179

176180
@_Section.figure_factory(3)

0 commit comments

Comments
 (0)