Skip to content

Commit

Permalink
improved HTML reporting when n_leak=1
Browse files Browse the repository at this point in the history
rileyjmurray committed Jan 17, 2025
1 parent 1b85e82 commit a351c31
Showing 3 changed files with 27 additions and 1 deletion.
13 changes: 13 additions & 0 deletions pygsti/report/reportables.py
Original file line number Diff line number Diff line change
@@ -1167,6 +1167,14 @@ def frobenius_diff(a, b, mx_basis): # assume vary model1, model2 fixed
# init args == (model1, model2, op_label)


def leaky_gate_frob_dist(a, b, mx_basis):
n_leak = 1
return _tools.subspace_restricted_fro_dist(a, b, mx_basis, n_leak)


Leaky_gate_frob_dist = _modf.opsfn_factory(leaky_gate_frob_dist)


def jtrace_diff(a, b, mx_basis): # assume vary model1, model2 fixed
"""
Jamiolkowski trace distance between a and b
@@ -2455,6 +2463,8 @@ def info_of_opfn_by_name(name):
"where (a_i,b_i) are corresponding eigenvalues of A and B."),
"frob": ("Frobenius|Distance",
"sqrt( sum( (A_ij - B_ij)^2 ) )"),
"la-frob": ("Frobenius|Distance (subspace)",
"TO WRITE"),
"unmodeled": ("Un-modeled|Error",
"The per-operation budget used to account for un-modeled errors (model violation)")
}
@@ -2539,6 +2549,9 @@ def evaluate_opfn_by_name(name, model, target_model, op_label_or_string,
elif name == "evnudiamond":
fn = Eigenvalue_nonunitary_diamondnorm if b else \
Circuit_eigenvalue_nonunitary_diamondnorm
elif name == "la-frob":
assert b
fn = Leaky_gate_frob_dist
elif name == "frob":
fn = Fro_diff if b else \
Circuit_fro_diff
2 changes: 1 addition & 1 deletion pygsti/report/section/gauge.py
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ def final_gates_vs_target_table_gauge_var(workspace, switchboard=None, confidenc
if kwargs.get('n_leak', 0) == 0:
display = ('inf', 'agi', 'trace', 'diamond', 'nuinf', 'nuagi')
else:
display = ('inf', 'la-inf', 'agi', 'trace', 'la-trace', 'diamond', 'nuinf', 'nuagi')
display = ('la-frob', 'la-inf', 'la-trace', 'frob', 'inf', 'trace', 'agi', 'diamond', 'nuinf', 'nuagi')
return workspace.GatesVsTargetTable(
switchboard.mdl_final, switchboard.mdl_target, _cri(1, switchboard, confidence_level, ci_brevity),
display=display
13 changes: 13 additions & 0 deletions pygsti/tools/optools.py
Original file line number Diff line number Diff line change
@@ -619,6 +619,19 @@ def leading_dxd_submatrix_basis_vectors(d: int, n: int, current_basis, return_la
return submatrix_basis_vectors


def subspace_restricted_fro_dist(a, b, mx_basis, n_leak=0):
diff = a - b
if n_leak == 0:
return _np.linalg.norm(diff, 'fro')
if n_leak == 1:
d = int(_np.sqrt(a.shape[0]))
assert a.shape == b.shape == (d**2, d**2)
B = leading_dxd_submatrix_basis_vectors(d-n_leak, d, mx_basis)
P = B @ B.T.conj()
return _np.linalg.norm(diff @ P)
raise ValueError()


def average_gate_fidelity(a, b, mx_basis='pp', is_tp=None, is_unitary=None):
"""
Computes the average gate fidelity (AGF) between two gates.

0 comments on commit a351c31

Please sign in to comment.