low latency rnn inference using cellular batching
play

Low-latency RNN inference using Cellular Batching Jinyang - PowerPoint PPT Presentation

Low-latency RNN inference using Cellular Batching Jinyang Li joint work with Pin Gao, Lingfan Yu, Yongwei Wu New York University


  1. Low-­‑latency ¡RNN ¡inference ¡using ¡ Cellular ¡Batching ¡ ¡ Jinyang ¡Li ¡ joint ¡work ¡with ¡Pin ¡Gao, ¡Lingfan ¡Yu, ¡Yongwei ¡Wu ¡ ¡ ¡ New ¡York ¡University ¡ ¡ ¡ ¡ ¡ ¡Tsinghua ¡University ¡

  2. Lifecycle ¡of ¡DNN ¡deployments ¡ opGmal ¡weights ¡θ opt ¡ Training: ¡ [0.1, ¡0.2, ¡...] ¡ IteraGvely ¡modify ¡ weights ¡θ ¡ Use ¡fixed ¡weights ¡ ¡θ opt ¡ predicGons ¡ Inference ¡

  3. DNN ¡Serving ¡must ¡provide ¡low ¡latency ¡ good ¡ throughput ¡ Goal ¡ Training: ¡ ¡ All ¡samples ¡are ¡ available ¡at ¡once ¡ Inference: ¡ good ¡throughput ¡ Goal ¡ & ¡low ¡latency ¡ Request ¡arrives ¡one ¡ at ¡a ¡Gme ¡

  4. The ¡hardware ¡reality: ¡batching ¡ improves ¡performance ¡ Throughput ¡(reqs/sec) ¡ 900000 ¡ 600000 ¡ 300000 ¡ 0 ¡ 6000 ¡ Latency ¡(us) ¡ 4000 ¡ 2000 ¡ 0 ¡ 2 ¡ 16 ¡ 32 ¡ 128 ¡ 256 ¡ 512 ¡ 1024 ¡ 2048 ¡ 4096 ¡ 4 ¡ 8 ¡ 64 ¡ Batch ¡size ¡ Nvidia ¡Tesla ¡v100, ¡one ¡LSTM ¡step ¡(hidden ¡state ¡size ¡1024) ¡

  5. Background ¡on ¡Recurrent ¡Neural ¡Network ¡ hidden ¡ ¡ state: ¡h ¡ h 2 ¡ h 1 ¡ h 0 ¡ unfold ¡ f θ f θ f θ f θ x 0 ¡ x 2 ¡ x 1 ¡ input: ¡x ¡

  6. RNN’s ¡batching ¡challenge: ¡ ¡ chain-­‑RNNs ¡ • How ¡to ¡batch ¡chains ¡of ¡different ¡lengths? ¡ LSTM ¡ LSTM ¡ LSTM ¡ “fast” ¡ Volta ¡CPU ¡is... ¡ cell ¡ cell ¡ cell ¡ “Volta” ¡ “is” ¡ “GPU” ¡ LSTM ¡ LSTM ¡ I ¡love ¡... ¡ “california” ¡ cell ¡ cell ¡ “I” ¡ “love” ¡

  7. State-­‑of-­‑the-­‑art ¡soluGon: ¡padding ¡ • TensorFlow, ¡MXNet, ¡PyTorch, ¡CNTK ¡batch ¡via ¡ padding ¡ LSTM ¡ LSTM ¡ LSTM ¡ “fast” ¡ Volta ¡CPU ¡is... ¡ cell ¡ cell ¡ cell ¡ “Volta” ¡ “is” ¡ “GPU” ¡ LSTM ¡ LSTM ¡ I ¡love ¡... ¡ “california” ¡ cell ¡ cell ¡ “I” ¡ “love” ¡

  8. State-­‑of-­‑the-­‑art ¡soluGon: ¡padding ¡ • TensorFlow, ¡MXNet, ¡PyTorch, ¡CNTK ¡batch ¡via ¡ padding ¡ LSTM ¡ LSTM ¡ LSTM ¡ “fast” ¡ Volta ¡CPU ¡is... ¡ cell ¡ cell ¡ cell ¡ “california” ¡ I ¡love ¡... ¡ “Volta” ¡ “is” ¡ “GPU” ¡ xxxx ¡ “love” ¡ “I” ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡

  9. RNN’s ¡batching ¡challenge: ¡ ¡ TreeLSTM ¡ • How ¡to ¡batch ¡trees ¡of ¡different ¡structures? ¡ LSTM ¡ LSTM ¡ cell ¡ cell ¡ LSTM ¡ LSTM ¡ LSTM ¡ LSTM ¡ leaf ¡ leaf ¡ leaf ¡ cell ¡ “cats” ¡ “sleep” ¡ LSTM ¡ LSTM ¡ “kids” ¡ leaf ¡ leaf ¡ “love” ¡ “dogs” ¡

  10. State-­‑of-­‑the-­‑art ¡soluGons: ¡graph ¡batching ¡ • TensorFlow-­‑Fold ¡and ¡DyNet ¡merge ¡dataflow ¡ graphs ¡ LSTM ¡ LSTM ¡ cell ¡ cell ¡ LSTM ¡ LSTM ¡ LSTM ¡ LSTM ¡ leaf ¡ leaf ¡ leaf ¡ cell ¡ “cats” ¡ “sleep” ¡ LSTM ¡ LSTM ¡ “kids” ¡ leaf ¡ leaf ¡ “love” ¡ “dogs” ¡

  11. State-­‑of-­‑the-­‑art ¡soluGons: ¡graph ¡batching ¡ • TensorFlow-­‑Fold ¡and ¡DyNet ¡merge ¡dataflow ¡ graphs ¡ LSTM ¡ cell ¡ LSTM ¡ LSTM ¡ leaf ¡ cell ¡ LSTM ¡ LSTM ¡ “kids” ¡ leaf ¡ leaf ¡ “love” ¡ “dogs” ¡ “sleep” ¡ “cats” ¡

  12. ExisGng ¡batching ¡techniques ¡do ¡not ¡ work ¡well ¡for ¡RNNs ¡ • Long ¡delay ¡ – New ¡request ¡has ¡to ¡wait ¡for ¡current ¡batch ¡to ¡finish ¡ • SubopGmal ¡Throughput ¡ – Padding ¡wastes ¡computaGon ¡ – Not ¡every ¡operator ¡is ¡batched ¡thoroughly ¡in ¡the ¡ merged ¡graph. ¡

  13. Talk ¡outline ¡ • MoGvaGon: ¡ ¡ – ExisGng ¡batching ¡techniques ¡incur ¡long ¡delay ¡for ¡RNNs ¡ • Our ¡approach: ¡cellular ¡batching ¡ • Batchmaker ¡RNN ¡inference ¡system ¡ • EvaluaGon ¡

  14. Our ¡approach: ¡cellular ¡batching ¡ • The ¡insight: ¡RNN ¡is ¡made ¡up ¡of ¡(a ¡few ¡types ¡of) ¡ cells ¡that ¡are ¡repeated ¡many ¡Gmes ¡ ü Cellular ¡batching: ¡make ¡batching ¡decisions ¡ before ¡execuGng ¡each ¡cell. ¡ X Graph ¡batching ¡or ¡padding: ¡make ¡batching ¡ decisions ¡before ¡execuGng ¡requests. ¡

  15. Graph ¡batching ¡wastes ¡batching ¡ opportunity ¡ execuGng ¡ finished ¡ Not ¡yet ¡executed ¡

  16. Graph ¡batching ¡wastes ¡batching ¡ opportunity ¡ execuGng ¡ finished ¡ Not ¡yet ¡executed ¡

  17. Graph ¡batching ¡wastes ¡batching ¡ opportunity ¡ execuGng ¡ finished ¡ Not ¡yet ¡executed ¡

  18. Graph ¡batching ¡wastes ¡batching ¡ opportunity ¡ execuGng ¡ finished ¡ Not ¡yet ¡executed ¡

  19. Graph ¡batching ¡wastes ¡batching ¡ opportunity ¡ execuGng ¡ finished ¡ Not ¡yet ¡executed ¡

  20. Cellular ¡batching ¡reduces ¡waiGng ¡ execuGng ¡ finished ¡ Not ¡yet ¡executed ¡

  21. Cellular ¡batching ¡reduces ¡waiGng ¡ execuGng ¡ finished ¡ Not ¡yet ¡executed ¡

  22. Cellular ¡batching ¡reduces ¡waiGng ¡ execuGng ¡ finished ¡ Not ¡yet ¡executed ¡

  23. Cellular ¡batching ¡reduces ¡waiGng ¡ execuGng ¡ finished ¡ Not ¡yet ¡executed ¡

  24. Cellular ¡batching ¡reduces ¡waiGng ¡ execuGng ¡ finished ¡ Not ¡yet ¡executed ¡

  25. Performance ¡challenges ¡in ¡realizing ¡ cellular ¡batching ¡ • Must ¡support ¡mulGple ¡types ¡of ¡cells ¡and ¡>1 ¡GPUs ¡ – Only ¡cells ¡of ¡the ¡same ¡type ¡can ¡be ¡batched ¡ ¡together ¡ – Different ¡cell ¡types ¡have ¡different ¡priority ¡ • Balance ¡batching ¡opportunity ¡and ¡overhead ¡ – Cost ¡of ¡scheduling ¡is ¡non-­‑trivial ¡ – Adding ¡new ¡requests ¡to ¡a ¡batch ¡incurs ¡memory ¡copy ¡ • Decisions ¡must ¡be ¡made ¡asynchronously ¡with ¡ execuGon ¡

  26. Talk ¡outline ¡ • MoGvaGon: ¡ ¡ – ExisGng ¡batching ¡techniques ¡incur ¡long ¡delay ¡for ¡RNNs ¡ • Our ¡approach: ¡cellular ¡batching ¡ • Batchmaker ¡RNN ¡inference ¡system ¡ • EvaluaGon ¡

  27. Batchmaker: ¡system ¡architecture ¡ User-­‑defined ¡ cell ¡definiGon ¡ unfolding ¡logic ¡ (saved ¡by ¡MXNet/TensorFlow) ¡ initalizaGon ¡ requests ¡ predicGons ¡

  28. How ¡the ¡scheduler ¡makes ¡decisions ¡ • Preserve ¡Locality ¡ – prefer ¡batching ¡cells ¡of ¡the ¡same ¡set ¡of ¡request ¡ – prefer ¡sGcking ¡to ¡the ¡same ¡GPU ¡for ¡the ¡same ¡ request ¡ • Allow ¡Priority ¡ – decoder ¡cells ¡> ¡encoder ¡cells ¡ – TreeLSTM ¡internal ¡cells ¡> ¡leaf ¡cell ¡ • Schedule ¡several ¡dependent ¡batches ¡at ¡a ¡Gme ¡

  29. Priority ¡and ¡locality ¡in ¡scheduling ¡

  30. Priority ¡and ¡locality ¡in ¡scheduling ¡

  31. Priority ¡and ¡locality ¡in ¡scheduling ¡

  32. Priority ¡and ¡locality ¡in ¡scheduling ¡

  33. Priority ¡and ¡locality ¡in ¡scheduling ¡

  34. Priority ¡and ¡locality ¡in ¡scheduling ¡

  35. Priority ¡and ¡locality ¡in ¡scheduling ¡

  36. ImplementaGon ¡opGmizaGons ¡ • Dynamically ¡adjust ¡the ¡batch ¡size ¡(up ¡to ¡the ¡ configured ¡maximum) ¡ – Form ¡and ¡execute ¡a ¡batch ¡whenever ¡GPU ¡is ¡idle ¡ • Asynchronously ¡wait ¡for ¡GPU ¡kernel ¡compleGon ¡ – GPU ¡driver’s ¡asynchronous ¡callback ¡is ¡too ¡slow ¡ – Add ¡a ¡signaling ¡kernel ¡at ¡the ¡end ¡of ¡all ¡cell ¡kernels ¡ • update ¡a ¡variable ¡in ¡host ¡memory ¡

  37. Talk ¡outline ¡ • MoGvaGon: ¡ ¡ – ExisGng ¡batching ¡techniques ¡incur ¡long ¡delay ¡for ¡RNNs ¡ • Our ¡approach: ¡cellular ¡batching ¡ • Batchmaker ¡RNN ¡inference ¡system ¡ • EvaluaGon ¡

  38. EvaluaGon ¡quesGons ¡ • How ¡does ¡Batchmaker ¡compare ¡against ¡ baseline ¡systems? ¡ • Where ¡does ¡Batchmaker’s ¡performance ¡ advantage ¡come ¡from? ¡

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