Add cached evaluation of tensor networks#224
Conversation
There was a problem hiding this comment.
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
There was a problem hiding this comment.
This is great work, the only change at this point (@neiljdo can do this) would be to make the old behaviour the default, so users can opt-in for the caching if they want.
We ultimately stuck with the caching path optimizer as the default.
* main: Fix no-, multiple-root prediction for parent predictions (Quantinuum#239) Add Oncilla to CLI (Quantinuum#238) Make SplitTensorAnsatz to deal with boxes with domains (Quantinuum#228) Fix bug with untokenised input sentences for `OncillaParser` (Quantinuum#235) Make `DisCoCircReader` compatible with `OncillaParser` (Quantinuum#234)
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
CachedTnPathOptimizerinstance.