-
Notifications
You must be signed in to change notification settings - Fork 25.5k
[CUDA][cuBLAS][TF32] Skip checking TF32 options and setting cuBLAS handle TF32 modes for other dtypes #161823
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
base: main
Are you sure you want to change the base?
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/161823
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit b0b4c4b with merge base 93c5112 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
aten/src/ATen/cuda/CUDABlas.cpp
Outdated
// See Note [Writing Nondeterministic Operations] | ||
globalContext().alertCuBLASConfigNotDeterministic(); | ||
cublasHandle_t handle = at::cuda::getCurrentCUDABlasHandle(); | ||
if (!NoTF32Guard::should_disable_tf32() && |
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.
Why not just delegate this to an inline function instead of copy paste
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.
This feels mildly wrong... I.e. replacing one check with 30+ in different places are bound to cause errors. Where overhead is coming from? String comparison? Than it should be replaced by enum
I brought this up in the original PR, there's multiple reasons string comparison is used rather than I think with the changes to inline it would be cleaner. |
Should we revert #125888 until we come up with better design? It seems like it created a lot of problems without solving any |
Also I've looked at discussion on #125888 and it seems there were no serious arguments for strings - they want strings at python level, fine, but it's no reason to have string comparison for every cublas call |
For #161822
Basically #125888 appears to introduce measurable CPU overhead due to TF32 precision setting checks. Unfortunately one of the checks is in
getCurrentCUDABlasHandle
, which is called preceding every cuBLAS matmul (and in a few other places such as workspace setup). We don't need to do this for non-float32
matmuls so this PR is to alleviate the performance hit where it hurts the most (smaller dtypes that have faster matmuls) at the cost of some copypasta.Some microbenchmark runs with this PR (microseconds):
and without
script:
Longer term we'd prefer making
float32Precision
faster (better data structures, less validation, etc.?)cc @ptrblck @msaroufim @jerryzh168 @csarofeen @xwang233 @zasdfgbnm