-
Notifications
You must be signed in to change notification settings - Fork 118
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
Add cached evaluation of tensor networks #224
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @DNA386 thank you for your work! 🙌🏼 I just came back so I can only do a surface-level review at the moment - kindly take a look at my initial notes. I'll have a closer look soon.
One thing we would like to have are tests specific to the classes/functions implemented in the `lambeq/training/saved_tn_optimizer.py'.
We can make this configurable (i.e. enable/disable storing the paths in the checkpoints somehow).
|
d6e6035
to
e45d4b4
Compare
@neiljdo Let's run our benchmarks on this PR and compare speeds with current branch. |
includes merging PytorchQuantumModel with PytorchModel so they can share the cached tn eval.
add explicit opt-einsum dependency in workflow
Add caching option by default for models that evaluate tensor networks, as per #185
Also bonus include the Sim9 and Sim9Cx ansatze from the inTask repo.
A non-cached option is also included in case the circuits are small enough that caching introduces unnecessary overhead, but must be actively selected by the user. By default this will reproduce the previous behaviour.
The user can select this as a kwarg when initialising the model. Note: the pathfinder must also be provided as a kwarg if resuming from a checkpoint - the checkpoint currently will contain the saved paths, but not the information required to re-build the same fallback path finding algorithm.
By default, the paths will only be cached in memory. The user can chose to either save them to the checkpoint, or to a separate file by supplying a configured
CachedTnPathOptimizer
instance.