training rnns with 16 bit floa5ng point
play

Training RNNs with 16-bit Floa5ng Point Erich Elsen - PowerPoint PPT Presentation

Training RNNs with 16-bit Floa5ng Point Erich Elsen Research Scien5st Silicon Valley AI Lab @Baidu State of the Art Speech Recogni5on CTC


  1. Training ¡RNNs ¡with ¡16-­‑bit ¡ Floa5ng ¡Point ¡ Erich ¡Elsen ¡ Research ¡Scien5st ¡

  2. Silicon ¡Valley ¡AI ¡Lab ¡@Baidu ¡ • State ¡of ¡the ¡Art ¡Speech ¡Recogni5on ¡ CTC Systems ¡ Fully Connected – Deep ¡Speech ¡2 ¡(hJp://arxiv.org/abs/ 1512.02595) ¡ • Easily ¡Adaptable ¡for ¡a ¡variety ¡of ¡ Recurrent languages ¡ or GRU (Bidirectional) • Trained ¡on ¡up ¡to ¡40,000 ¡hours ¡of ¡speech ¡ Batch Normalization – 4.5 ¡years! ¡ • Each ¡Model ¡requires ¡over ¡20 ¡Exa-­‑Flops ¡to ¡ train ¡ 1D or 2D Invariant – Can ¡take ¡two ¡or ¡more ¡weeks ¡using ¡32 ¡GPUs ¡ Convolution • => ¡FP16 ¡is ¡one ¡tool ¡to ¡decrease ¡training ¡ Spectrogram 5me ¡ Erich ¡Elsen ¡

  3. Neural ¡Network ¡Op5miza5on ¡ • A ¡network ¡consists ¡of ¡parameters, ¡x, ¡and ¡we ¡try ¡to ¡ minimize ¡the ¡cost ¡J, ¡of ¡the ¡network ¡on ¡some ¡data ¡set ¡ • Everybody ¡uses ¡some ¡variant ¡of ¡Batch ¡Stochas5c ¡ Gradient ¡Descent ¡(SGD) ¡ – Batch ¡= ¡use ¡mul5ple ¡examples ¡per ¡gradient ¡calcula5on ¡ ¡ x n + 1 = x n − α ∂ J ∂ x – α ¡oden ¡between ¡.01 ¡and ¡.0001 ¡ • The ¡ra5o ¡of ¡the ¡two ¡terms ¡on ¡the ¡right ¡is ¡very ¡ important ¡ Erich ¡Elsen ¡

  4. Training ¡Recurrent ¡Neural ¡Networks ¡ (RNNs) ¡ • Parameters ¡are ¡W, ¡U ¡ • x, ¡h ¡are ¡the ¡network ¡ac5va5ons ¡ • Forward ¡pass ¡eqn: ¡ h t = σ ( Wx t + Uh t − 1 ) • Performance ¡of ¡GEMM ¡very ¡important ¡ Erich ¡Elsen ¡

  5. Training ¡RNNs ¡ Memory ¡Usage ¡ • Must ¡save ¡x, ¡h ¡for ¡the ¡backward ¡pass! ¡ • Most ¡memory ¡is ¡used ¡to ¡store ¡ac5va5ons ¡ • Weights ¡< ¡10% ¡allocated ¡memory ¡ • Standard ¡is ¡to ¡use ¡32-­‑bit ¡floa5ng ¡point ¡for ¡weights ¡and ¡ac5va5ons ¡ 2048 ¡ U ¡ h ¡ h ¡ h ¡ h ¡ h ¡ h ¡ h ¡ MB ¡= ¡32 ¡-­‑ ¡256 ¡ Timesteps ¡= ¡50 ¡-­‑ ¡800 ¡ Erich ¡Elsen ¡

  6. FP16 ¡ • By ¡using ¡only ¡16-­‑bits ¡per ¡number ¡we: ¡ – can ¡store ¡twice ¡as ¡many ¡numbers ¡ • Increase ¡mini-­‑batch ¡size! ¡ – can ¡move ¡twice ¡as ¡many ¡numbers ¡around ¡in ¡the ¡same ¡ amount ¡of ¡5me ¡ • All ¡bandwidth ¡bound ¡opera5ons ¡improve ¡ – Hardware ¡arithme5c ¡units ¡take ¡up ¡less ¡and ¡are ¡faster ¡ • New ¡hardware ¡will ¡have ¡twice ¡as ¡many ¡FP16 ¡flops ¡as ¡FP32 ¡ • All ¡compute ¡bound ¡opera5ons ¡will ¡improve ¡ • No ¡Free ¡Lunch ¡– ¡Op5miza5on ¡becomes ¡more ¡ difficult ¡ Erich ¡Elsen ¡

  7. FP32 ¡GEMM ¡Performance ¡ Erich ¡Elsen ¡

  8. Pseudo-­‑FP16 ¡GEMM ¡Performance ¡ Inputs/Outputs ¡FP16, ¡ • Internals ¡FP32 ¡ ¡ Use ¡Today ¡On ¡Maxwell: ¡ ¡ • CublasSgemmEx • Nervana GEMM 2-­‑3x ¡Faster! ¡ Erich ¡Elsen ¡

  9. True ¡FP16 ¡GEMM ¡Performance ¡ (es5mated) ¡ Inputs/Outputs/ Internals ¡FP16 ¡ ¡ Use ¡In ¡the ¡Future ¡ on ¡Pascal ¡ ¡ 4-­‑6x ¡Faster! ¡ ¡ Op5miza5on ¡ problem ¡even ¡more ¡ challenging ¡ Erich ¡Elsen ¡

  10. Number ¡Representa5on ¡ • Total ¡bits ¡= ¡1 ¡sign ¡bit ¡+ ¡bits ¡for ¡m ¡+ ¡bits ¡for ¡e ¡ N = ± m ∗ 2 e • Intui5on ¡– ¡2^m ¡values ¡between ¡each ¡power ¡of ¡2 ¡ • Imagine ¡2 ¡bits ¡for ¡m ¡and ¡2 ¡bits ¡for ¡e ¡ Erich ¡Elsen ¡

  11. FP16 ¡vs ¡FP32 ¡ FP16 ¡ FP32 ¡ Max. ¡Value ¡ ~61,000 ¡ ~1e38 ¡ Grid ¡points ¡between ¡each ¡ 2048 ¡ ~16,700,000 ¡ power ¡of ¡2 ¡ Smallest ¡number ¡you ¡can ¡ add ¡to ¡one ¡and ¡get ¡a ¡ ~.000489 ¡ ~.00000006 ¡ different ¡number ¡ (ULP ¡rela5ve ¡to ¡1) ¡ Erich ¡Elsen ¡

  12. Rounding ¡ • Generally ¡accepted ¡prac5ce ¡(implemented ¡in ¡ hardware) ¡is ¡round ¡to ¡nearest ¡even ¡(r2ne) ¡ • Go ¡to ¡the ¡nearest ¡point ¡and ¡if ¡you’re ¡exactly ¡halfway ¡ go ¡to ¡the ¡nearest ¡even ¡number ¡(in ¡binary) ¡ Erich ¡Elsen ¡

  13. Summa5on ¡and ¡Rounding ¡ • x ¡updated ¡by ¡adding ¡a ¡sequence ¡of ¡rela5vely ¡ small ¡numbers ¡ • if ¡the ¡updates ¡are ¡too ¡small, ¡we ¡will ¡never ¡ make ¡any ¡progress ¡with ¡round ¡to ¡nearest ¡even ¡ x n + 1 = x n − α ∂ J ∂ x = x n Erich ¡Elsen ¡

  14. Saddle ¡Points! ¡ • Local ¡minimum ¡not ¡a ¡problem ¡ • Saddle ¡points ¡are ¡what ¡make ¡op5miza5on ¡ hard ¡ – Flat ¡ – Small ¡Deriva5ve ¡ Image ¡from ¡wikipedia ¡ Erich ¡Elsen ¡

  15. In ¡1-­‑D ¡ J = − ( x − 3) 2 + 3 ∂ J ∂ x = − 2( x − 3) α ¡ ¡= ¡.01 ¡ Erich ¡Elsen ¡

  16. 1-­‑D ¡Op5miza5on ¡Problem ¡ Erich ¡Elsen ¡

  17. 1-­‑D ¡ra5os ¡of ¡updates ¡to ¡x ¡ Erich ¡Elsen ¡

  18. Solu5on ¡1 ¡ Stochas5c ¡Rounding ¡ • Round ¡up ¡or ¡down ¡with ¡probability ¡related ¡to ¡ the ¡distance ¡to ¡the ¡neighboring ¡grid ¡points ¡ • Example ¡– ¡if ¡the ¡closest ¡grid ¡points ¡are ¡100 ¡ and ¡101 ¡and ¡the ¡value ¡is ¡100.01 ¡ – We ¡round ¡up ¡1% ¡of ¡the ¡5me ¡ – Round ¡down ¡99% ¡of ¡the ¡5me ¡ Erich ¡Elsen ¡

  19. Stochas5c ¡Rounding ¡ • Ader ¡adding ¡.01, ¡100 ¡5mes ¡to ¡100 ¡ – With ¡r2ne ¡we ¡will ¡s5ll ¡have ¡100 ¡ – With ¡stochas5c ¡rounding ¡we ¡will ¡ expect ¡ to ¡have ¡ 101 ¡ • Allows ¡us ¡to ¡make ¡op5miza5on ¡progress ¡even ¡ when ¡the ¡updates ¡are ¡small ¡ Erich ¡Elsen ¡

  20. Solu5on ¡2 ¡ High ¡precision ¡accumula5on ¡ • Keep ¡two ¡copies ¡of ¡the ¡weights ¡ – One ¡in ¡high ¡precision ¡(fp32) ¡ – One ¡in ¡low ¡precision ¡(fp16) ¡ • Accumulate ¡updates ¡to ¡the ¡high ¡precision ¡ copy ¡ • Round ¡the ¡high ¡precision ¡copy ¡to ¡low ¡ precision ¡and ¡perform ¡computa5ons ¡ Erich ¡Elsen ¡

  21. High ¡precision ¡accumula5on ¡ • Ader ¡adding ¡.01, ¡100 ¡5mes ¡to ¡100 ¡ – We ¡will ¡have ¡exactly ¡101 ¡in ¡the ¡high ¡precision ¡ weights, ¡which ¡will ¡round ¡to ¡101 ¡in ¡the ¡low ¡ precision ¡weights ¡ • Allows ¡for ¡accurate ¡accumula5on ¡while ¡ maintaining ¡the ¡benefits ¡of ¡fp16 ¡computa5on ¡ • Requires ¡more ¡weight ¡storage, ¡but ¡weights ¡ are ¡usually ¡a ¡small ¡part ¡of ¡the ¡memory ¡ footprint ¡ Erich ¡Elsen ¡

  22. Batch ¡Normaliza5on ¡Helps ¡ Erich ¡Elsen ¡

  23. Results ¡ Erich ¡Elsen ¡

  24. Conclusion ¡ • Half ¡precision ¡enables ¡bigger, ¡deeper ¡ networks ¡ • Half ¡precision ¡enables ¡faster ¡training ¡and ¡ evalua5on ¡of ¡networks ¡ • Half ¡precision ¡enables ¡beJer ¡scaling ¡to ¡ mul5ple ¡GPUs ¡ • Training ¡can ¡be ¡tricky, ¡these ¡techniques ¡can ¡ help ¡ Erich ¡Elsen ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend