-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff] Speed up compile time by 3.5x by caching derivative function types. #29590
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
Conversation
@swift-ci please test tensorflow |
@swift-ci please test tensorflow linux gpu |
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.
Thank you for identifying and fixing the issue!
Linux GPU CI failures are temporarily expected. Merging now so new toolchains can be built with the compilation time fix. |
I believe that this change may have regressed the Windows builds: |
My apologies. I just sent PR #29592 your way. |
[AutoDiff] Fix windows build failure introduced in #29590.
Nice graph. This shows exactly when the slowdown occurred: It's when we switched to |
Upstream #29590: cache `SILFunctionType::getAutoDiffDerivativeFunctionType` results.
Compiling packages that use AutoDiff is currently extremely slow. For example, compiling tensorflow/swift-apis takes ~5 minutes on a slower machine. This is largely due to calls to
SILFunctionType::getAutoDiffDerivativeFunctionType
in SIL verifier, which spends a long time computing generic signatures with GSB.This PR improves this situation by caching computed derivative function types in
ASTContext
. This resulted in a 1.6x speedup in running the AutoDiff test suite, and a 3.5x speedup in compiling tensorflow/swift-apis.Future investigations:
getAutoDiffDerivativeFunctionGenericSignature
.SILFunctionType::getAutoDiffTransposeFunctionType()
.Here are the results building tensorflow/swift-apis with
-j56
.Before:
After:
Resolves TF-1133.