New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AutoDiff] Fix forward-mode crashes related to tangent buffers #33633
Conversation
@@ -85,10 +85,8 @@ func activeInoutParamControlFlow(_ array: [Float]) -> Float { | |||
return result | |||
} | |||
|
|||
// FIXME(TF-984): Forward-mode crash due to unset tangent buffer. |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Function-local allocations" were introduced in pullback generation so that adjoint buffers would dominate all subsequent use sites in the reverse CFG. I don't see how they are needed in differential generation since the CFG is almost the same as the original function, so all tangent values we emit should have the same scope as their corresponding original value.
To me there seems to be a simpler, spot-on fix: For any non-wrt |
ea1a722
to
5c47a53
Compare
inout
parametersFixes TF-984, SR-13447. Fixes foward-mode crashed related to: - Missing tangent buffers for non-wrt `inout` parameters - Tangent buffers not being initialized due to the corresponding original buffer intialization instructions being non-active - Non-varied indirect results not being initialized - `emitDestroyValue` crashes due to `TangentVector` value category mismatch
…BufferInitializationInfo`, make `initInfo` non-optional in `setTangentBuffer`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this and addressing the comments!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great fixes!
@swift-ci Please test |
Build failed |
Build failed |
f94f1a0
to
8b750ab
Compare
…isiting all (un)initializing instructions where at least one parameter is active We found out that it is very untrivial to correctly check initializedness of code with aggregate projections (e.g. nested structs with multiple `struct_element_addr` referring to the same element). Instead of checking initializedness, we can rely on correctness of the original function SIL and reproduce (un)initializing instructions based on the original SIL.
Stylistic edits. Fix test by removing invalid `@_silgen_name` usage.
08e0fb1
to
9f08f5c
Compare
End-to-end forward-mode tests should be put in test/AutoDiff/validation-test. The forward-mode differentiation changes do not fix all crashers.
Iterate over original differentiability result indices instead of directly iterating over original indirect results and non-wrt `inout` parameters, which may include results that are not relevant for differentiation. Other cleanup included.
@swift-ci Please test |
Fixes TF-984, SR-13447.
Fixes foward-mode crashed related to:
inout
parametersoriginal buffer intialization instructions being non-active
emitDestroyValue
crashes due toTangentVector
value category mismatch