Checkpointing.jl
Checkpointing.jl copied to clipboard
Correctness issue
https://github.com/Argonne-National-Laboratory/Checkpointing.jl/blob/5cacc30d614963def9c78f1d152f6caaff576fc9/src/Rules/EnzymeRules.jl#L15
@michel2323 this line seems to have a correctness issue. It's not necessarily the cause of a different issue @swilliamson7 and I were debugging, but seems sufficiently bad that it could be the culprit.
In essence you're only running the body of the loop (func.val) if the return is needed. However, if, for example, the return is nothing and the body of the fnuction updates something in place, your rule will tell Enzyme to not execute the original body of the function which is wrong.
cc @vchuravy
The fix should basically just be moving func.val before the if statement
Same thing for the while loop, presumably
Should be fixed https://github.com/Argonne-National-Laboratory/Checkpointing.jl/pull/45 . Though when doing multilevel checkpointing I still have an issue with the primal. Gotta look into it.
Hopefully okay now, thank you Michel! I need to check derivatives, but they aren't zero anymore which is good 😊
Fingers crossed. Ping me if not! @swilliamson7
We should move to https://github.com/Argonne-National-Laboratory/Checkpointing.jl/pull/72.