Skip to content

Conversation

rileyjmurray
Copy link
Contributor

@rileyjmurray rileyjmurray commented Sep 10, 2025

Notes to self (updated sporadically):

  • There should be a way of adding custom objectives to pygsti without changing its source code. I should have a unit test that does this.
  • At some point I needed to make changes to copalayout.py to resolve an error in running an example notebook. The changes and notebook were first introduced in the commit with this comment. I've since reverted the changes to copalayout.py because it seems they aren't needed anymore.

rileyjmurray and others added 30 commits December 16, 2024 12:56
…me a file in test/performance so that it doesnt get discovered by testing frameworks like pytest
…t commit will simpify further, which may have consequences from the perspective of floating point arithmetic. Checking in NOW in case we want to revert to this version for numerical reasons.
…eparately, modify docstring for run_long_sequence_gst to be consistent with its implementation (including leaving notes for later).
…uge_group. Having the casting occur here makes sense, since a model has access to the associated StateSpace, Basis, and Evotype.
…tchboard.objfn_builder was used when switchboard.objfn_builder_modvi should have been used
…ectiveFunction with an implementation that works for five of its eight derived classes. Removed the separate implementations for those five derived classes. Introduce a templated docstring for TimeIndependentMDCObjectiveFunction and a decorator to reduce duplication among the nine total __init__ functions of this class and its eight derived classes .
…option of preserving parameterization. I set the default to False, since this seems to be needed for existing germ selection tests.
… if the model is serialized then it can be deserialized correctly.
…be near zero for correctness. Tests now pass even when optools.py.__SCALAR_TOL_EXPONENT__ = -1, which is reasonable to set when trying to suppress warnings or certain errors
…when (de)serializing a model with gate labels like `GCNOT` and `GIX`"
interp_weights[interp_weights < p] = 0.0
interp_weights[interp_weights > 0] = 1.0
else:
interp_weights = p * _np.ones(num_circuits)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we allowing p to be a arraylike here, so that one can fully specify the distribution of weights?

Comment on lines +770 to 771
objective : {'logl', 'chi2', 'tvd'}, optional
Whether to create builders for maximum-likelihood or minimum-chi-squared GST.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment needs to be updated to include total variational distance GST.

import warnings
warnings.warn(f'Trying to create an objective function from non-string specification, "{objective}". \
\nSupport for this kind of specification is experimental!')
iteration_builders = [chi2_builder]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not need line 796.

switchboard.modvi_ds, switchboard.mdl_final_modvi,
switchboard.objfn_builder_modvi,
switchboard.circuits_final,
switchboard.modvi_ds, switchboard.mdl_current_modvi,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switchboard.mdl_current_modvi seems inaccurate. This function is for the final_model_fit. Thus, shouldn't the appropriate model be switchboard.mdl_final_modvi?

@@ -99,6 +110,18 @@ def assert_hermitian(mat):
assert_hermitian(a)
assert_hermitian(b)

def check_unit_trace(mat):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want check_unit_trace to be only callable within _flat_mut_blks?

that we never reference in the code (truncScheme, estimate_label, and
missingDataAction).

- objective = typically, a string in {'chi2', 'logl', 'tvd'}. But this can
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the Literal typing to the parameter objective.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These arguments are only passed in the advanced_options dict. I can add the type annotation that advanced_options is dict[str,Any]. I'll leave other type annotations of this function to later work.

def create_from(cls, objective='logl', freq_weighted_chi2=False):
# This was a classmethod, but I made it static because this class has no derived classes.
@staticmethod
def create_from(objective='logl', freq_weighted_chi2=False, callable_penalty=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objective should be typed as a Literal.

Copy link
Contributor

@nkoskelo nkoskelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some items for consideration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to make these changes to resolve exceptions that were getting raised. I need to find an example showing how to trigger the error without these changes.

…of a TypeError from CircuitOutcomeProbabilityArrayLayout.indices_and_outcomes_for_index)
…ityArrayLayout.__iter__ (needed to convert slice to iterable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants