HighDimensionalEconLab / DifferentiableStateSpaceModels.jl

MIT License
46 stars 1 forks source link

Track difference between finite-differences and test_rrule with the cache #130

Closed jlperla closed 2 years ago

jlperla commented 2 years ago

In first_order_gradients.jl if we use the test_rrule with the cache in the test_first_order then it fails the CRTU tests (and passes if the cache not passed in). However, if we manually test with finite-differences it passes the tests.

Also note that if we reset the cache internally to the rrule for generate_perturbation it seems to pass the unit tests with CRTU. Not sure why this would have any impact since we we call the gradient twice with zygote directly it doesn't have any problems. So there is either some odd behavior with CRTU+Zygote (e.g. the closure with the cache is doing someethig weird) or there could be some bizzaro bug. No evidence that it effects anything outside of just the test_rrule though.

jlperla commented 2 years ago

Trying with manual FiniteDiff usage seems to pass the tests.

May just be a quirk in CRTU. usage with this model Part of it may just be that the random projections that are made bring things into areas where the modl is not solvable. In those cases, there is limited error handling in the primals which coudl cause grief and differences.