ต่อไปคำแนะนำต่อไป
การให้ยาที่แม่นยำและเภสัชจลนศาสตร์ของ AI
เทคนิค
คู่มือทางเทคนิค
Mixed precision uses lower-precision arithmetic for selected operations while retaining precision where needed.
ฟังคำแนะนำนี้บรรยายโดย AI · ~2 min
It can reduce memory use and improve throughput on supported hardware, but gains and numerical effects depend on the model, workload, hardware and training recipe.
Traditional training stores weights and runs math in 32-bit floating point (FP32). Mixed precision uses lower-precision FP16 or bfloat16 for eligible operations while retaining FP32 where needed. Some FP16 recipes maintain a separate FP32 master copy to accumulate small weight updates; autocast workflows may instead keep model parameters in FP32 while casting selected operation inputs. Using 16-bit tensors can reduce memory used by eligible operations. Supported accelerators may execute some low-precision operations faster, but end-to-end throughput depends on hardware, workload and which operations autocast selects. FP16 has a narrower range, so tiny gradients can underflow. Loss scaling multiplies the loss before backpropagation and reverses that scale before the optimizer update; tools such as torch.amp.GradScaler can manage this process. Bfloat16 has a wider exponent range than FP16 and often does not need the same loss-scaling strategy, though model and hardware behavior still need testing.
torch.cuda.amp.autocast ของ PyTorch ห่อลูปการฝึกอบรมเพื่อลดหน่วยความจำลงประมาณครึ่งหนึ่งและทรูพุตสองเท่าบน GPU ตัวเดียว
การฝึกอบรมโมเดลภาษาขนาดใหญ่ เช่น หม้อแปลงสไตล์ GPT ใน bfloat16 บน TPU เพื่อหลีกเลี่ยงการปรับลดการสูญเสียขนาด
ปรับขนาดแบตช์ที่ใหญ่ขึ้นบน RTX GPU สำหรับผู้บริโภคโดยเปลี่ยนการฝึกอิมเมจ ResNet จาก FP32 เป็น FP16
ความแม่นยำแบบผสม FP8 บน NVIDIA H100 GPU เพื่อลดต้นทุนในการฝึกโมเดลระดับแนวหน้าล่วงหน้า
ความแม่นยำลดลงเรื่อยๆ การฝึกอบรม FP8 ซึ่งได้รับการสนับสนุนบน NVIDIA Hopper และ Blackwell GPU กำลังกลายเป็นมาตรฐานสำหรับโมเดลระดับแนวหน้า และการวิจัยเกี่ยวกับ FP4 และรูปแบบไมโครสเกล (MXFP) จะผลักดันต่อไป คาดหวังว่าเฟรมเวิร์กจะเลือกความแม่นยำต่อเลเยอร์โดยอัตโนมัติ ฮาร์ดแวร์เพื่อจัดการรูปแบบที่แคบลงกว่าเดิม และการฝึกอบรมที่คำนึงถึงปริมาณเพื่อลดเส้นแบ่งระหว่างการฝึกอบรมและการอนุมานที่มีความแม่นยำต่ำ ซึ่งจะช่วยลดต้นทุนของการฝึกอบรมแบบจำลองล้านล้านพารามิเตอร์
จดหมายข่าวฟรี
เรื่องราว AI ที่ตรวจสอบแล้ว 3 เรื่องทุกวันทำงาน เช้า, เขียนเป็นภาษาอังกฤษธรรมดา ฟรีตลอดไป ไม่มีโฆษณา
อีเมลหนึ่งฉบับทุกวันทำงาน ยกเลิกการสมัครในคลิกเดียว เราไม่เคยขายหรือแชร์ที่อยู่อีเมลของคุณ
ทดสอบตัวเอง
ข้อเสนอแนะทันทีสำหรับทุกคำตอบ และใบรับรองที่สามารถแชร์ได้พร้อม ID ที่ตรวจสอบได้เมื่อคุณผ่านหลักสูตร
สนับสนุนการศึกษา AI ฟรี AI Understanding เป็นองค์กรไม่แสวงหาผลกำไร 501(c)(3) — ไม่มีโฆษณา ไม่มีกำแพงเงิน, ตลอดไป บริจาค
Mixed precision uses lower-precision arithmetic for selected operations while retaining precision where needed. It can reduce memory use and improve throughput on supported hardware, but gains and numerical effects depend on the model, workload, hardware and training recipe.
Some FP16 recipes keep an FP32 master weight so small optimizer updates are not lost to low-precision rounding; not every mixed-precision recipe uses a separate copy.
FP16 มีช่วงไดนามิกที่จำกัด ดังนั้นการไล่ระดับสีเล็กน้อยจึงสามารถปัดเศษให้เป็นศูนย์ได้ การคูณการสูญเสียก่อน backprop ช่วยให้สามารถแสดงได้
Bfloat16 เก็บบิตเลขชี้กำลัง 8 บิตเช่น FP32 ดังนั้นช่วงไดนามิกของมันจึงมีขนาดใหญ่และการไล่ระดับสีอันเดอร์โฟลว์นั้นหาได้ยาก
Many common Tensor Core operations accumulate in FP32 to reduce rounding error; this does not make the computation exact.
Lower precision can reduce memory and speed supported operations, but total results depend on the model, hardware, and kernels used.
เรียนรู้ต่อไป
คำแนะนำเพิ่มเติมที่เลือกสำหรับหัวข้อนี้
ต่อไปคำแนะนำต่อไป
การให้ยาที่แม่นยำและเภสัชจลนศาสตร์ของ AI
เทคนิค