april-tools / cirkit

a python framework to build, learn and reason about probabilistic circuits and tensor networks
https://cirkit-docs.readthedocs.io/en/latest/
GNU General Public License v3.0
71 stars 1 forks source link

Find another way to disable grad in tests #172

Open lkct opened 10 months ago

lkct commented 10 months ago

Ref:

I'm now against the solution to #87 by #126 on no_grad, as partially reverted here.

Reason: globally disabling grad is counter-intuitive and can waste time in debugging tests to look for missing grad, especially now when we have differential functionals.

Alternative: if a model does not need grad in unit tests, we can use nn.Module.requires_grad_(False) to disable grad for this module's params.

loreloc commented 4 months ago

I think more than 90% of tests will not require computing gradients. So, I still think a good default setting is gradients in tests turned off. Keeping this for now as we have still to write many tests, but it might be closed.

lkct commented 3 weeks ago

Just to note that I encountered this again 😢, though it quickly came to me to check if gradient is enabled (because it's not the first time).

Perhaps even if we're keeping the behaviour, we should add smth to docs/faqs/dev notes to remind people.

PS: currently we lack tests for circuit training which also needs grad