TF32 Explained: Checking Precision and Acceleration for FP32 Matrix Operations
Learn what NVIDIA TF32 changes in FP32 matrix operations, how cuBLAS selects the mode, and how to verify numerical quality and real workload speed.
TF32 Explained: Checking Precision and Acceleration for FP32 Matrix Operations
TF32 (TensorFloat-32) is an NVIDIA Tensor Core compute mode that can accelerate FP32 matrix multiplication and convolution. It keeps the FP32 exponent width while reducing input significand precision for multiplication, with FP32 accumulation and output in the documented path. Arrays usually remain stored as FP32, but the result need not match an FP32-input computation bit for bit.
TF32 is a compute mode, not a storage type
NVIDIA describes Ampere TF32 with one sign bit, eight exponent bits, and ten mantissa bits. Its exponent width matches FP32, so it retains a similarly wide value range, while its shorter mantissa distinguishes fewer nearby values. This bit layout describes the Ampere mode; do not assume every GPU generation or library call selects the same path. NVIDIA’s TF32 technical explanation describes conversion before matrix multiplication and FP32 accumulation/output.
| Property | FP32 path | TF32 Tensor Core path |
|---|---|---|
| Array storage | 32-bit floating point | Inputs and outputs usually remain FP32 |
| Multiplication inputs | FP32 precision | Inputs are rounded to TF32 precision |
| Accumulation/output | Requested FP32 path | The documented TF32 path uses FP32 accumulation/output |
| Potential benefit | Preserves FP32 input precision | Higher throughput for supported matrix operations |
| Cost | Matrix-heavy work can take longer | Input rounding can increase numerical error |
FP32 accumulation does not restore bits discarded when inputs are rounded. Conversely, saying an operation uses TF32 does not mean its stored arrays were converted into a smaller data type. Current cuBLAS documentation distinguishes input/output data types from compute types.
Rounding can matter for small residuals
Matching FP32’s exponent width preserves a broad value range, not FP32’s precision between neighboring values. Near 1, adjacent normal TF32 significands are spaced by 2^-10, or 0.0009765625. With round-to-nearest-even, the illustrative input 1.0007 rounds to 1.0009765625. These decimal values explain the format; they are not a GPU measurement.
| Illustrative input | FP32 input (decimal approximation) | Rounded TF32 value |
|---|---|---|
| 1.0007 | about 1.0007000 | 1.0009765625 |
The difference may be inconsequential when large terms dominate, but it can matter when large values cancel and the remaining residual is small, or when a threshold drives a decision. A matrix product combines many products and sums, so an input error does not guarantee a proportionally small output error. Check conditioning, sensitive iterations, loss values, convergence, and application-level results where relevant.
Compare range, storage, and precision separately
TF32 applies reduced significand precision to matrix multiplication while normally keeping FP32 arrays. That differs from converting data to FP16 or BF16 for storage and computation. NVIDIA describes TF32 and FP16 as having the same mantissa width, while TF32 uses the wider FP32 exponent. BF16 also has the FP32 exponent width but less mantissa precision. Choose based on dynamic range, tolerated error, memory traffic, and library support rather than a universal ranking.
| Choice | What mainly changes | Decision question |
|---|---|---|
| FP32 compute | Reference input and compute precision | Does the baseline meet the required accuracy? |
| TF32 mode | Matrix multiplication input precision | Is acceleration useful while keeping FP32 storage? |
| FP16/BF16 data | Storage and compute types may both be reduced | Can the workload tolerate the range/error limits, and will lower memory traffic help? |
TF32 is a reasonable first option to evaluate for supported, large matrix products or convolutions in an FP32 model. It does not shrink the input arrays, so it may not help when storage or memory bandwidth is the main bottleneck. Consider FP16/BF16 mixed precision separately if reducing memory traffic is the goal. NVIDIA describes TF32 as a compute mode for matrix multiplication and convolution, not as a general replacement for FP32 data.
Check the device and library path
Availability depends on device features, CUDA and cuBLAS versions, the API, matrix shape, and runtime settings. CUDA documentation says device features depend on compute capability and warns that specialized Tensor Core features are not automatically guaranteed on every later architecture. You can inspect the GPU name and capability with:
nvidia-smi --query-gpu=name,compute_capThis identifies the device; it does not prove a particular library call used a TF32 kernel. Check the compatibility information for your CUDA and library versions, then inspect the actual execution with a profiler. The CUDA Programming Guide documents the capability query and feature boundaries.
Select the compute type in cuBLAS
Current cuBLAS documentation uses cublasComputeType_t to select compute precision in cublasGemmEx() and cublasLtMatmul(). CUBLAS_COMPUTE_32F_FAST_TF32 allows TF32 Tensor Core compute with 32-bit floating-point input and output. The library rounds converted inputs to nearest, ties to even. “Allows” does not guarantee the same kernel is selected for every shape and device. See the cuBLAS 13.5 compute-type documentation.
| cuBLAS setting or state | Meaning |
|---|---|
| CUBLAS_COMPUTE_32F | Requests the standard 32-bit compute type |
| CUBLAS_COMPUTE_32F_FAST_TF32 | Allows TF32 Tensor Core compute for 32-bit floating-point input/output |
| NVIDIA_TF32_OVERRIDE=0 | Overrides defaults and programmatic settings to disable cuBLAS TF32 Tensor Core acceleration |
| Framework default | Check the documentation and runtime path for the specific framework, version, and operation |
Do not blindly copy the older CUBLAS_TENSOR_OP_MATH setting into new code: current cuBLAS documentation marks it deprecated and describes compute types as the way to select precision. NVIDIA_TF32_OVERRIDE=0 can override a programmatic setting, so check the environment and framework configuration if TF32 is not running. It can help isolate a numerical issue, but disabling TF32 is not a substitute for evaluating the output.
Validate precision and performance in five steps
**Fix the target and acceptance criteria.** Record the GPU and compute capability, driver/CUDA/cuBLAS or framework versions, input shapes and representative data. Decide acceptable output error, model quality, and convergence criteria.
**Create an FP32 reference.** Change only the TF32 setting; keep inputs, preprocessing, initialization, algorithm, and evaluation constant. Choose tolerances or task metrics in advance because floating-point results need not be bitwise identical. The [CUDA Best Practices Guide](https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/) recommends representative reference comparisons.
**Allow TF32 for the intended operation.** Use the library or framework’s documented compute setting and confirm device and input-type support. Record environment overrides and framework defaults, not just the setting’s name.
**Compare representative numerical results.** Check maximum absolute and relative error plus task metrics; for training, compare loss and convergence. Include cancellation and extreme-range cases. Do not approve the mode from one tiny matrix test.
**Profile the path and measure end-to-end time.** Confirm Tensor Core use and the selected kernel in a profiler. Repeat with warm-up and proper synchronization, separating data transfer from compute. Compare both matrix-operation time and total inference/training time; keep only settings that meet the accuracy criteria.
Troubleshoot unexpected error or no speedup
If error exceeds tolerance, first check whether another setting changed at the same time. Reproduce the case with TF32 disabled, compare against the reference, and identify which operation causes the difference. You may keep higher precision for only a sensitive matrix operation or review the algorithm’s numerical stability instead of reverting every operation.
If there is no speedup, check that the workload contains large matrix products or convolutions, uses FP32 inputs, runs on a compatible device/library path, and is not blocked by a global override. Small inputs, memory transfers, or other operations can dominate total time even when Tensor Core throughput is higher. Without profiling, do not treat “TF32 is enabled” as proof that a TF32 kernel ran.
Sources
[NVIDIA, Accelerating AI Training with NVIDIA TF32 Tensor Cores](https://developer.nvidia.com/blog/accelerating-ai-training-with-tf32-tensor-cores/)
[NVIDIA, cuBLAS 13.5 Documentation](https://docs.nvidia.com/cuda/cublas/)
[NVIDIA CUDA Programming Guide, Compute Capabilities](https://docs.nvidia.com/cuda/cuda-programming-guide/05-appendices/compute-capabilities.html)
[NVIDIA CUDA C++ Best Practices Guide, Verification and Numerical Accuracy](https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/)