Skip to content

Commit fb09ba2

Browse files
Revert "Revert "these are changes from the bugfix reparam branch, not sure what is going on here""
This reverts commit 5ea4c6f.
1 parent 5ea4c6f commit fb09ba2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: pygsti/modelmembers/states/__init__.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def state_type_from_op_type(op_type):
187187
return state_type_preferences
188188

189189

190-
def convert(state, to_type, basis, cp_penalty=1e-7, ideal_state=None, flatten_structure=False):
190+
def convert(state, to_type, basis, cptp_penalty=1e-7, ideal_state=None, flatten_structure=False):
191191
"""
192192
TODO: update docstring
193193
Convert SPAM vector to a new type of parameterization.
@@ -220,7 +220,7 @@ def convert(state, to_type, basis, cp_penalty=1e-7, ideal_state=None, flatten_st
220220
unchanged. When `True`, composed and embedded operations are "flattened"
221221
into a single state of the requested `to_type`.
222222
223-
cp_penalty : float, optional
223+
cptp_penalty : float, optional
224224
CPTP penalty that gets factored into the optimization to find the resulting model
225225
when converting to an error-generator type.
226226
@@ -269,7 +269,7 @@ def convert(state, to_type, basis, cp_penalty=1e-7, ideal_state=None, flatten_st
269269
errgen = _LindbladErrorgen.from_error_generator(2**(2*num_qubits), parameterization=to_type)
270270
num_errgens = errgen.num_params
271271

272-
#GLND for states suffers from "trivial gauge" freedom. This function identifies
272+
#GLND for states suffers from "dumb gauge" freedom. This function identifies
273273
#the physical directions to avoid this gauge.
274274
def calc_physical_subspace(ideal_prep, epsilon = 1e-9):
275275

@@ -293,13 +293,16 @@ def calc_physical_subspace(ideal_prep, epsilon = 1e-9):
293293

294294
#We use optimization to find the best error generator representation
295295
#we only vary physical directions, not independent error generators
296+
296297
def _objfn(v):
297298
L_vec = _np.zeros(len(phys_directions[0]))
298299
for coeff, phys_direction in zip(v,phys_directions):
299300
L_vec += coeff * phys_direction
300301
errorgen.from_vector(L_vec)
301302
proc_matrix = _spl.expm(errorgen.to_dense())
302-
return _np.linalg.norm(proc_matrix @ dense_st - dense_state) + cp_penalty * sum_of_negative_choi_eigenvalues_gate(proc_matrix, basis)
303+
#basis of to_dense() CHECK if always pp
304+
dense_basis = Basis.cast('pp', (2**num_qubits)**2)
305+
return _np.linalg.norm(proc_matrix @ dense_st - dense_state) + cptp_penalty * sum_of_negative_choi_eigenvalues_gate(proc_matrix, dense_basis)
303306

304307
soln = _spo.minimize(_objfn, _np.zeros(len(phys_directions), 'd'), method="Nelder-Mead", options={},
305308
tol=1e-13) # , callback=callback)

0 commit comments

Comments
 (0)