Reduce function building overhead in wrappedCircuit#332
Open
k-vijayaraghavan wants to merge 16 commits into
Open
Reduce function building overhead in wrappedCircuit#332k-vijayaraghavan wants to merge 16 commits into
k-vijayaraghavan wants to merge 16 commits into
Conversation
In models/circuits/fittings.py, buildCircuit no longer substitutes parameters; rather it returns a string that can be used to construct a lambda function. Subsequently wrapCircuit returns a lambda function that only needs to be generated once. This offers ~80% improvement.
We can pass optimizations={"algorithm":algo,...} to circuit_fit.
Here algo can be 'pygad' or 'scipy_minimize' or a callable. We can also pass optimizations=[optimizations1,optimizations2], where optimizations1={"algorithm":algo,...} ... to perform sequential optimization.
To improve scaling, we can pass scale=[..] with the expected relative magnitude of the different parameters.
Modified elements for robust tanh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In models/circuits/fittings.py, it is rather inefficient to create/evaluate a new function for each call (i.e. currently, each call involves string conversions and exec). The proposed buildCircuit no longer substitutes parameters; rather it returns a string with variable-names that can be used to construct a lambda function. Subsequently wrapCircuit returns a lambda function that only needs to be generated once. This offers ~80% improvement. (tests/test_fitting.py::test_buildCircuit() has been correspondingly modified for compatibility)
PS: A new file tests/compare_newfitting.py was created (and subsequently deleted) to compare new buildCircuit with original buildCircuit. The file showed significant speed-up
R0-p(R1-Wo1,CPE1) : 82.97% faster
R0-p(C1,R1,R2) : 79.30% faster
R0-p(p(R1, C1)-R2, C2) : 82.17% faster
p(C1,R1)-p(C2,R2) : 81.10% faster
R1 : 85.55% faster