JavaScriptを有効にしてください

bfloatとは何か

 ·  ☕ 1 min read

double vs fp32 vs fp16 vs bfp16

  • double (64bit)
    • 1/11/52 = 64
  • fp32 -> float (32bit)
    • 1 / 8 / 23 = 32
  • fp16 -> float (16bit)
    • 1 / 5 / 10 = 16
    • IEEEで規格化
  • bfloat16
    • 1 / 8 / 7 = 16
      • 指数部をfp32に合わせている
      • 仮数部は実質的な有効数字 (粒度) を決めて,指数部は値のrangeを決めるので,仮数部を減らして指数部を増やすことで,取りうる値のrangeを最大化してあげる
        • (仮数部) x 2^(指数部)
          • 2^()部分は桁のようなものなので,
          • fp16だと0.00000001Xが表現できなかったのが,指数部が増えることで表現できる桁数が伸びるイメージ
    • Google Brainが考案
    • Automatic Mixed Precisionが割りと不安定でnanが出る場合,bfloat使えばマシになるケースがあるらしい



BFloat16 offers better stability during training than FP16. Most google models are BFloat16 due to using TPUs, where BF16 is native. We’re seeing more LLMs trained in BFloat16 out of superior stability (see the BigScience project by HuggingFace who noted better stability).
引用: https://www.reddit.com/r/MachineLearning/comments/vndtn8/d_mixed_precision_training_difference_between/

共有

YuWd (Yuiga Wada)
著者
YuWd (Yuiga Wada)
機械学習・競プロ・iOS・Web