Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove commented-out function definitions and delete files with no executable code #452

Open
wants to merge 47 commits into
base: develop
Choose a base branch
from

Conversation

rileyjmurray
Copy link
Contributor

@rileyjmurray rileyjmurray commented Jun 7, 2024

This PR aims to resolve #428.

At time of opening this PR, the changes might be over-zealous, so I'm happy to roll some changes back. That said, I suggest we be aggressive in removing this kind of unused text. Here's a proposal for how to decide what to actually keep and what to remove:

  • We can/should keep simple reference implementations of functions that are important but very complicated.
    • Example: there's an implementation of Levenberg-Marquardt from Wikipedia that I've kept. I think this is valuable because our actual LM code is very complicated, so having a reference is helpful for maintainability.
  • We could keep text that's related to memory profiling.
    • Rationale: The question of whether or not to bother trying to profile memory usage in a certain location requires a fair amount of expertise, so I think keeping this kind of text could serve as a flag for suspected hot code paths.
  • Commented-out pyx code should be removed unless we have a very good reason for keeping it.

Another source of criteria for figuring out what to keep is to look for a short note at the beginning of some commented-out code block. Often there are notes that say "FUTURE," "Removed," "unused," "REMOVE," "Debugging," etc...

Other, miscellaneous changes

  • Removed some unused imports.

rileyjmurray and others added 28 commits August 13, 2024 12:10
These changes address unexpected behavior that can occur when manually adding an operation without then manually rebuilding the parameter vector. When this happens it is possible for the Model's internal attributes to fall out of sync with those of it's child objects. Now we check for the need to rebuild the parameter vector every time.
Fixes a minor bug in circuit that was caught by unit tests.
This adds a warning for when rebuilds are performed on models with nontrivial parameter bounds, which may result in manually set bounds being overwritten.
This is relevant when attempting to use Dask outside of pyGSTi,
where signals cannot be set in the workers.
Setting the PYGSTI_NO_CUSTOMLM_SIGINT env variable
now skips this behavior.
Fix was a missing Label.is_simple() -> Label.IS_SIMPLE.
A bug in the parameter label handling code was causing parameter labels to explode exponentially in size when _rebuild_paramvec was caused, leading to major memory issues. This now makes it so that the value of _paramlbls is fixed to that of the underlying operations and adds a new version of the parameter_labels property that goes through the interposer (making the interposer labels something generated on demand). Also add a threshold for coefficients printing in the LinearInterposer to avoid obnoxious labels.
Serialization wasn't working correctly for GSTGaugeOptSuite with the trivial gauge optimization argument dict. This should fix that bug.
The creation of COPA layouts relies on a number of specialized circuit structures which require non-trivial time to construct. In the context of iterative GST estimation with nested circuit lists (i.e. the default) this results in unnecessarily repeat construction of these objects. This is an initial implementation of a caching scheme allowing for more efficient re-use of these circuit structures across iterations.
Cache the expanded SPAM-free circuits to reduce recomputing things unnecessarily.
Adds a new method to OpModel that allows for doing instrument expansion and povm expansion in bulk, speeding things up be avoiding recomputation of shared quantities. Also adds a pipeline for re-using completed or split circuits (as produced by the related OpModel methods) for more efficient re-use of done work.
Some minor performance oriented tweaks to the init for COPA layouts.
Refactor some of the ordered dictionaries in matrix layout creation into regular ones.
Start adding infrastructure for caching things used in MDC store creation and for plumbing in stuff from layout creation.
Performance optimization for the method for adding omitted frequencies to incorporate caching of the number of outcomes per circuit (which is somewhat expensive since it goes through the instrument/povm expansion code). Additionally refactor some other parts of this code for improved efficiency. Also makes a few minor tweaks to the method for adding counts to speed that up as well. Can probably make this a bit faster still by merging the two calls to reduce redundancy, but that is a future us problem. Additionally make a few microoptimizations to the dataset code for grabbing counts, and to slicetools adding a function for directly giving a numpy array for a slice (instead of needing to cast from a list).

Miscellaneous cleanup of old commented out code that doesn't appear needed any longer.
Fix a bug I introduced in dataset indexing into something that could be None.
Another minor bug caught by testing.
Improve the performance of __getitem__ when indexing into static circuits by making use of the _copy_init code path.
Implement caching of circuit structures tailored to the map forward simulator's requirements.
This finishes the process of refactoring expand_instruments_and_separate_povm from a circuit method to a method of OpModel.
Refactor expand_instruments_and_separate_povm to use the multi-circuit version under the hood to reduce code duplication.
Refactor cache creation functions into static methods of the corresponding forward simulator class. Also add an empty base version of this method, and clean up a few miscellaneous things caught by review.
Fix a few minor issues related to refactored code and updates made in this branch.
Add in support for data set key aliasing in COPA layout cache creation.
Rework some of the if statement branching in the layout creation to instead use fallback behavior of get more.
@rileyjmurray rileyjmurray marked this pull request as ready for review September 24, 2024 18:11
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