Precisión mixta: FP16, BF16 y TF32
Intercambiar precisión por rendimiento
Precisión mixta: FP16, BF16 y TF32 es una lección gratuita de CUDA Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de CUDA Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de CUDA Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
Trading Bits for Speed
Tensor Cores get their speed from mixed precision: feeding smaller number formats in so the hardware can push far more math per cycle. ⚡
What FP32 Costs
Standard FP32 uses 32 bits per value. It is accurate but heavy, so moving and multiplying many FP32 numbers eats bandwidth and time.
Meet FP16
FP16 uses just 16 bits: a smaller exponent and fewer mantissa bits. Half the size means more values move and multiply at once.
FP16 Has a Small Range
FP16 saves space but its narrow exponent gives a tiny dynamic range. Very large or very small values can overflow or vanish to zero.
Meet BF16
BF16 is also 16 bits but keeps FP32's full exponent, trading mantissa bits instead. It matches FP32's range with less precision.
Why BF16 Wins for Training
Because BF16 shares FP32's wide range, gradients rarely overflow. That makes BF16 a favorite for training large neural networks safely.
Meet TF32
TF32 is a 19-bit Tensor Core format: FP32's exponent with a trimmed mantissa. It speeds up math while looking like FP32 to your code.
The Accumulator Stays Wide
No matter the input format, Tensor Cores usually accumulate partial sums in FP32. The speed is in the inputs; the safety is in the running total.
Range vs Precision
The big idea: FP16 and BF16 cost the same 16 bits but split them differently. One favors precision, the other favors range.
Picking a Format
Use BF16 or TF32 when range matters, FP16 when you can manage scaling. The right format depends on your data, not just on speed.
Declaring Half Precision
In CUDA C++ the FP16 type has a short name. This line declares one half value ready for Tensor Core math.
__half x = __float2half(1.5f);Quick Check
Which format keeps FP32's full exponent range in only 16 bits?
Recap
You saw how mixed precision trades bits for throughput: FP16 favors precision, BF16 favors range, and TF32 speeds FP32-style math. Wide accumulation keeps results safe. ✨
Preguntas frecuentes
¿La lección «Precisión mixta: FP16, BF16 y TF32» es gratis?
Sí — el texto completo de «Precisión mixta: FP16, BF16 y TF32» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de CUDA Academy, actualiza a CoddyKit PRO. El curso de CUDA Academy incluye 4 lecciones en total.
¿Qué aprenderé en «Precisión mixta: FP16, BF16 y TF32»?
Intercambiar precisión por rendimiento Practicas CUDA Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar CUDA Academy?
No se requiere experiencia previa. CUDA Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.
¿Cuánto tiempo toma la lección «Precisión mixta: FP16, BF16 y TF32»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de CUDA Academy?
Sí. Cada lección de CUDA Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Qué calculan los Tensor Cores
- Precisión mixta: FP16, BF16 y TF32
- API de fragmentos de WMMA
- Compromisos de estabilidad numérica