google / qhbm-library

Quantum Hamiltonian-Based Models built on TensorFlow Quantum
https://qhbm-library.readthedocs.io/en/latest/
Apache License 2.0
40 stars 15 forks source link

Generalize persistence in EnergyInfer.expectation #157

Open zaqqwerty opened 2 years ago

zaqqwerty commented 2 years ago

Inside the expectation function in the EnergyInference class, I needed to add persistent=True to values_tape. This was to get persistence to work in gradient tapes that wrap calls to expectation. However, if persistence=False in the enclosing tape, might be more memory efficient to remove persistence here. So this issue is to find a way to detect the persistence of the enclosing tape and adjust accordingly.