Skip to content

Commit f94ce11

Browse files
changed perturbation value that computes SPAM physical subspace. Any smaller than this and perturbations along the S errgens showed up as the identity operator
1 parent d449c05 commit f94ce11

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pygsti/modelmembers/povms/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def convert(povm, to_type, basis, ideal_povm=None, flatten_structure=False, cp_p
547547
#It is often the case that there are more error generators than physical degrees of freedom in the POVM
548548
#We define a function which finds linear comb. of errgens that span these degrees of freedom.
549549
#This has been called "the trivial gauge", and this function is meant to avoid it
550-
def calc_physical_subspace(dense_ideal_povm, epsilon = 1e-9):
550+
def calc_physical_subspace(dense_ideal_povm, epsilon = 1e-4):
551551

552552
degrees_of_freedom = (dense_ideal_povm.shape[0] - 1) * dense_ideal_povm.shape[1]
553553
errgen = _LindbladErrorgen.from_error_generator(povm.state_space.dim, parameterization=to_type)
@@ -578,11 +578,14 @@ def calc_physical_subspace(dense_ideal_povm, epsilon = 1e-9):
578578
J[:,i] = vectorized_povm
579579

580580
_,S,Vt = _np.linalg.svd(J)
581+
581582
#Only return nontrivial singular vectors
582-
non_zero_mask = _np.where(_np.abs(S) > 1e-13)
583+
#non_zero_mask = _np.where(_np.ones(len(S)))
584+
non_zero_mask = _np.where(_np.abs(S) > 1e-63)
583585
non_trivial_vecs = Vt[non_zero_mask]
584586
non_trivial_vecs = non_trivial_vecs.reshape(-1, Vt.shape[1]) # Reshape to ensure it's 2D
585587
return non_trivial_vecs
588+
#return Vt[:len(S),]
586589

587590
phys_directions = calc_physical_subspace(dense_ideal_povm)
588591

pygsti/modelmembers/states/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def convert(state, to_type, basis, ideal_state=None, flatten_structure=False, cp
270270

271271
#GLND for states suffers from "trivial gauge" freedom. This function identifies
272272
#the physical directions to avoid this gauge.
273-
def calc_physical_subspace(ideal_prep, epsilon = 1e-9):
273+
def calc_physical_subspace(ideal_prep, epsilon = 1e-4):
274274
errgen = _LindbladErrorgen.from_error_generator(2**(2*num_qubits), parameterization=to_type)
275275
num_errgens = errgen.num_params
276276

@@ -289,9 +289,10 @@ def calc_physical_subspace(ideal_prep, epsilon = 1e-9):
289289
_,S,Vt = _np.linalg.svd(J)
290290

291291
#Only return nontrivial singular vectors
292-
non_zero_mask = _np.where(_np.abs(S) > 1e-13)
292+
non_zero_mask = _np.where(_np.ones(len(S)))
293293
non_trivial_vecs = Vt[non_zero_mask]
294294
non_trivial_vecs = non_trivial_vecs.reshape(-1, Vt.shape[1]) # Reshape to ensure it's 2D
295+
#return Vt[:len(S),]
295296
return non_trivial_vecs
296297

297298
phys_directions = calc_physical_subspace(dense_state)

0 commit comments

Comments
 (0)