Skip to content

Commit 48eac7d

Browse files
committed
improved HTML reporting when n_leak=1
1 parent 778b15b commit 48eac7d

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

pygsti/report/reportables.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,14 @@ def frobenius_diff(a, b, mx_basis): # assume vary model1, model2 fixed
11801180
# init args == (model1, model2, op_label)
11811181

11821182

1183+
def leaky_gate_frob_dist(a, b, mx_basis):
1184+
n_leak = 1
1185+
return _tools.subspace_restricted_fro_dist(a, b, mx_basis, n_leak)
1186+
1187+
1188+
Leaky_gate_frob_dist = _modf.opsfn_factory(leaky_gate_frob_dist)
1189+
1190+
11831191
def jtrace_diff(a, b, mx_basis): # assume vary model1, model2 fixed
11841192
"""
11851193
Jamiolkowski trace distance between a and b
@@ -2456,6 +2464,8 @@ def info_of_opfn_by_name(name):
24562464
"where (a_i,b_i) are corresponding eigenvalues of A and B."),
24572465
"frob": ("Frobenius|Distance",
24582466
"sqrt( sum( (A_ij - B_ij)^2 ) )"),
2467+
"la-frob": ("Frobenius|Distance (subspace)",
2468+
"TO WRITE"),
24592469
"unmodeled": ("Un-modeled|Error",
24602470
"The per-operation budget used to account for un-modeled errors (model violation)")
24612471
}
@@ -2540,6 +2550,9 @@ def evaluate_opfn_by_name(name, model, target_model, op_label_or_string,
25402550
elif name == "evnudiamond":
25412551
fn = Eigenvalue_nonunitary_diamondnorm if b else \
25422552
Circuit_eigenvalue_nonunitary_diamondnorm
2553+
elif name == "la-frob":
2554+
assert b
2555+
fn = Leaky_gate_frob_dist
25432556
elif name == "frob":
25442557
fn = Fro_diff if b else \
25452558
Circuit_fro_diff

pygsti/report/section/gauge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def final_gates_vs_target_table_gauge_var(workspace, switchboard=None, confidenc
171171
if kwargs.get('n_leak', 0) == 0:
172172
display = ('inf', 'agi', 'trace', 'diamond', 'nuinf', 'nuagi')
173173
else:
174-
display = ('inf', 'la-inf', 'agi', 'trace', 'la-trace', 'diamond', 'nuinf', 'nuagi')
174+
display = ('la-frob', 'la-inf', 'la-trace', 'frob', 'inf', 'trace', 'agi', 'diamond', 'nuinf', 'nuagi')
175175
return workspace.GatesVsTargetTable(
176176
switchboard.mdl_final, switchboard.mdl_target, _cri(1, switchboard, confidence_level, ci_brevity),
177177
display=display

pygsti/tools/optools.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,19 @@ def leading_dxd_submatrix_basis_vectors(d: int, n: int, current_basis, return_la
619619
return submatrix_basis_vectors
620620

621621

622+
def subspace_restricted_fro_dist(a, b, mx_basis, n_leak=0):
623+
diff = a - b
624+
if n_leak == 0:
625+
return _np.linalg.norm(diff, 'fro')
626+
if n_leak == 1:
627+
d = int(_np.sqrt(a.shape[0]))
628+
assert a.shape == b.shape == (d**2, d**2)
629+
B = leading_dxd_submatrix_basis_vectors(d-n_leak, d, mx_basis)
630+
P = B @ B.T.conj()
631+
return _np.linalg.norm(diff @ P)
632+
raise ValueError()
633+
634+
622635
def average_gate_fidelity(a, b, mx_basis='pp', is_tp=None, is_unitary=None):
623636
"""
624637
Computes the average gate fidelity (AGF) between two gates.

0 commit comments

Comments
 (0)