Skip to content
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

How to enable TF32 for CUDA GEMM? #916

Open
ajz34 opened this issue Dec 3, 2024 · 0 comments
Open

How to enable TF32 for CUDA GEMM? #916

ajz34 opened this issue Dec 3, 2024 · 0 comments

Comments

@ajz34
Copy link

ajz34 commented Dec 3, 2024

Hi tch-rs community!

I wish to ask a short question. How to enable TF32 in tch (for CUDA)? This option can make recent NVidia GPUs extremely fast when precision accuracy is not significant. I tried to search TF32 or precision in code of this crate, but could not find this option.
My workaround is using TF32 for GEMM, but not CUDNN.


For other tools, in candle-core of rust, this is done by

candle_core::cuda::set_gemm_reduced_precision_f32(true);

In cudarc, it seems that TF32 is not available for cublas wrapper, and TF32 is enforced (hardcoded) in cublaslt wrapper. So suing cudarc::cublaslt::safe will automatically call GEMM with TF32.

In pytorch of python, this is done by (https://pytorch.org/docs/stable/notes/cuda.html)

torch.backends.cuda.matmul.allow_tf32 = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant