{"title": "BPPSA: Scaling Back-propagation by Parallel Scan Algorithm", "book": "Proceedings of Machine Learning and Systems", "page_first": 451, "page_last": 469, "abstract": "In an era when the performance of a single compute device plateaus, software must be designed to scale on a massively parallel system for better runtime performance. However, in the context of training deep learning models, the commonly used back-propagation (BP) algorithm imposes a strong sequential dependency in the process of gradient computation. Under model parallelism, BP has a theoretical step complexity of Theta(n) which hinders its scalability in a parallel computing environment, where n represents the number of compute devices into which a model is partitioned.\n\nScan is a primitive operation that performs an in-order aggregation on a sequence of values and returns the partial result at each step. Parallel algorithms (e.g., Blelloch scan) have been developed to scale the scan operation on massively parallel systems. In this work, in order to improve the scalability of BP, we reformulate BP into a scan operation which is then scaled by our modified version of the Blelloch scan algorithm with a theoretical step complexity of Theta(log n). We evaluate our approach on a vanilla Recurrent Neural Network training with synthetic datasets, and demonstrate up to 2.75x speedup in terms of the overall training time and 8.8x speedup on the backward pass alone.", "full_text": "                BPPSA:SCALINGBACK-PROPAGATIONBYPARALLELSCANALGORITHM\r\n                                                ShangWang1 YifanBai2 GennadyPekhimenko1\r\n                                                                   ABSTRACT\r\n                   In an era when the performance of a single compute device plateaus, software must be designed to scale on\r\n                   massively parallel systems for better runtime performance. However, in the context of training deep learning\r\n                   models, the popular back-propagation (BP) algorithm imposes a strong sequential dependency in the process of\r\n                   gradient computation. Under model parallelism, BP takes \u0398(n) steps to complete which hinders its scalability on\r\n                   parallel systems (n represents the number of compute devices into which a model is partitioned).\r\n                   In this work, in order to improve the scalability of BP, we reformulate BP into a scan operation which is a primitive\r\n                   that performs an in-order aggregation on a sequence of values and returns the partial result at each step. We can\r\n                   then scale such reformulation of BP on parallel systems by our modi\ufb01ed version of the Blelloch scan algorithm\r\n                   whichtheoretically takes \u0398(logn) steps. We evaluate our approach on a vanilla Recurrent Neural Network (RNN)\r\n                   training with synthetic datasets and a RNN with Gated Recurrent Units (GRU) training with the IRMAS dataset,\r\n                   and demonstrate up to 2.75\u00d7 speedup on the overall training time and 108\u00d7 speedup on the backward pass. We\r\n                   also demonstrate that the retraining of pruned networks can be a practical use case of our method.\r\n              1    INTRODUCTION                                              Lastly, data parallelism cannot be applied when a model\r\n              The training of deep learning models demands more and          does not \ufb01t into one device due to memory constraints (e.g.,\r\n              morecomputeresources(Amodeietal.,2018)asthemodels              caused by deep network architecture, large batch size, or\r\n              become more powerful and complex with an increasing            high input resolution (Rhu et al., 2016; Zhu et al., 2018)).\r\n              number of layers in recent years (Krizhevsky et al., 2012;     Modelparallelism (Krizhevsky, 2014; Huang et al., 2018;\r\n              Szegedy et al., 2015; Simonyan & Zisserman, 2015; He           Shazeer et al., 2018; Narayanan et al., 2019) is another\r\n              et al., 2015; Huang et al., 2016). For example, ResNet         approach to distributed training which partitions a model\r\n              can have more than a thousand layers (He et al., 2016),        and distributes its parts among devices. It covers a wide\r\n              and ResNet-152 takes days to train on eight state-of-the-art   spectrum of training deep learning models where data par-\r\n              GPUs(Coleman et al., 2017). Now that the performance           allelism does not suf\ufb01ce. Na\u00efve training under model par-\r\n              of a single compute device plateaus (Esmaeilzadeh et al.,      allelism does not scale well with the number of devices\r\n              2011; Arunkumar et al., 2017), training has to be designed     due to under-utilization of the hardware resources, since\r\n              to scale on massively parallel systems.                        at most one device can be utilized at any given point in\r\n              Data parallelism (Shallue et al., 2018) is the most popular    time (Narayanan et al., 2019). To address the aforemen-\r\n              waytoscaletraining by partitioning the training data among     tioned issue, prior works on pipeline parallelism, including\r\n              multiple devices, where each device contains a full replica    PipeDream(Narayananetal.,2019)andGPipe(Huangetal.,\r\n              of the model. As the number of devices increases, data         2018), propose pipelining across devices for better resource\r\n              parallelism faces the trade-off between synchronization cost   utilization; however, as the number of layers and devices in-\r\n              in synchronous parameter updates and staleness in asyn-        creases, pipeline parallelism still faces the trade-off between\r\n              chronous parameter updates (Ben-Nun & Hoe\ufb02er, 2018).           resource utilization in synchronous parameter updates and\r\n              Furthermore, recent studies demonstrate the scaling limit of   staleness in asynchronous parameter updates (Narayanan\r\n              data parallelism even when assuming perfect implementa-        et al., 2019). Moreover, to fully \ufb01ll the pipeline with useful\r\n              tions and zero synchronization cost (Shallue et al., 2018).    computation, each device needs to store the activations at\r\n                                                                             the partition boundaries for all mini-batches that enter the\r\n                  1Department of Computer Science, University of Toronto     pipeline. Therefore, the maximum number of devices that\r\n              2Department of Electrical Engineering and Computer Sci-        pipeline parallelism can support is limited by the memory\r\n              ences, University of California, Berkeley; work done at the    capacity of a single device.\r\n              University of Toronto.   Correspondence to:   Shang Wang\r\n              <wangsh46@cs.toronto.edu>.                                     Algorithmically, the fundamental reason for this scalabil-\r\n                                                                             ity limitation observed from prior works is that the back-\r\n              Proceedings of the 3rd MLSys Conference, Austin, TX, USA,      propagation (BP) algorithm (Rumelhart et al., 1988) im-\r\n              2020. Copyright 2020 by the author(s).\r\n                                                BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                                                                                  (Saad, 2003) to reduce the runtime and storage costs; more\r\n                                                                                  importantly, the positions of input-independent zeros in this\r\n                                                                                  case are deterministic, which leads to potentially more op-\r\n                                                                                  timized implementations of sparse matrix libraries. Based\r\n                                                                                  on these observations, we develop routines to ef\ufb01ciently\r\n                                                                                  generate sparse transposed Jacobians for various operators.\r\n                                                                                  \u2022Asaproofofconcept,weevaluateBPPSAonavanillaRe-\r\n               Figure 1: BP as a scan operation, scaled by our modi\ufb01ed            current Neural Network (RNN) (Elman, 1990) training with\r\n               version of the Blelloch scan algorithm.                            synthetic datasets, as well as a RNN with Gated Recurrent\r\n                                                                                  Units (GRU) (Cho et al., 2014) training with the IRMAS\r\n                                                                                  dataset (Bosch et al., 2012). Our method achieves a max-\r\n               poses a strong sequential dependency between layers during         imum2.75\u00d7speedup in terms of the overall (end-to-end)\r\n               the gradient computation. Since computing systems evolve           training time, and up to 108\u00d7 speeduponthebackwardpass,\r\n               to have more and more parallel nodes (Esmaeilzadeh et al.,         compared to the baseline BP approach which under-utilizes\r\n               2011; Arunkumar et al., 2017), in this work, we aim at ex-         the GPU. Moreover, we demonstrate that the retraining of\r\n               ploring the following question: How can BP scale ef\ufb01ciently        pruned networks (Han et al., 2015; See et al., 2016; He\r\n               whenthenumberoflayersanddeviceskeepsincreasinginto                 et al., 2017) (e.g., pruned VGG-11 (Simonyan & Zisserman,\r\n               the foreseeable future?                                            2015)) can also be a practical use case of BPPSA.\r\n               To answer this question, we utilize a primitive operation          2    BACKGROUNDANDMOTIVATION\r\n               called Scan (Blelloch, 1990) that performs an in-order ag-\r\n               gregation on a sequence of values and returns the partial          2.1   ProblemFormulation\r\n               result at each step. Parallel algorithms (Hillis & Steele,         Weconceptualizeadeeplearningmodelasavectorfunction\r\n               1986; Blelloch, 1990) have been developed to scale the scan                                                        ~\r\n                                                                                  f composed of sub-functions ~x = f (~x        ; \u03b8 ):\r\n               operation on massively parallel systems. We observe that                                            i     i  i\u22121    i\r\n               BPismathematicallysimilartoascanoperationonthetrans-                            ~      ~            ~                 ~\r\n                                                                                         f(.; \u03b8 ,...,\u03b8 ) = f (.; \u03b8 ) \u25e6 ... \u25e6 f (.; \u03b8 )       (1)\r\n               posed Jacobian matrix (Weisstein, 2019) of each layer and                        1      n      1      1         n      n\r\n               the gradient vector of the output from the last layer. Inspired            ~\r\n               by this key observation, we restructure the strong sequen-         where \u03b8i,i     \u2208 {1,...,n} are the parameters of the\r\n                                                                                  model. The model is evaluated by an objective function\r\n               tial dependency of BP, and present a new method to scale                    ~\r\n                                                                                  l(f(~x ; \u03b8 ,i \u2208 {1,...,n})), where ~x is the initial input\r\n                                                                                        0   i                             0\r\n               Back-propagation by Parallel Scan Algorithm (BPPSA).               to the model. Figure 2 visualizes a convolutional neural\r\n               Ourmajorcontributions are summarized below.                        network conceptualized in this formulation.\r\n               \u2022 We reformulate BP as a scan operation and modify the             To train the model f, a \ufb01rst-order optimizer requires the\r\n               Blelloch scan algorithm (Blelloch, 1990) to ef\ufb01ciently scale       gradients \u2207 l, which are derived from the gradients \u2207 l:\r\n                                                                                              ~                                            ~x\r\n                                                                                              \u03b8                                             i\r\n               BPinaparallel computing environment. Our method has                             i\r\n                                              1                                                            \u2202~x               \u2202~x\r\n               a theoretical step complexity of \u0398(logn), where n repre-             [\u2207 l,...,\u2207 l] \u2190 [(        1)T\u2207 l,...,(      n)T\u2207 l] (2)\r\n                                                                                       ~        ~                   ~x                 ~x\r\n                                                                                       \u03b8        \u03b8                    1                  n\r\n               sents the number of devices into which a model is parti-                 1        n          ~                  ~\r\n                                                                                                           \u2202\u03b8                \u2202\u03b8\r\n                                                                                                             1                  n\r\n               tioned, compared to \u0398(n) of the na\u00efve implementation of                   \u2202~x\r\n                                                                                  where    i is the Jacobian matrix of the output ~xi of fi to its\r\n               modelparallelism. Moreover, our algorithm does not have                    ~\r\n                                                                                         \u2202\u03b8\r\n                                                                                           i\r\n               the theoretical scalability limit by the memory capacity of a                  ~\r\n                                                                                  parameters \u03b8i. To derive \u2207 l given \u2207        l, BP (Rumelhart\r\n                                                                                                               ~x          ~x\r\n               single device as pipeline parallelism does. As an example,                                       i           n\r\n                                                                                  et al., 1988) solves the following recursive equation, from\r\n               Figure 1 shows how BP for training a network composed of           i = n\u22121toi=1:\r\n               7 layers (blue cubes) can be reformulated into a scan opera-                        \u2202~x\r\n               tion on the transposed Jacobian matrices (blue squares) of               \u2207 l\u2190( i+1)T\u2207               l, \u2200i \u2208 {n \u2212 1,...,1}     (3)\r\n                                                                                          ~x                   ~x\r\n                                                                                            i       \u2202~x         i+1\r\n               this network and the \ufb01nal gradient vector (yellow squares),                             i\r\n                                                                                         \u2202~x\r\n               as well as how this scan operation can be scaled by BPPSA.         where     i+1 is the Jacobian matrix of the output ~x       of\r\n                                                                                           \u2202~xi                                          i+1\r\n                                                                                  f     to its input ~x . Equation 2 itself does not have de-\r\n               \u2022 Generating, storing and processing full Jacobian matri-           i+1                i\r\n               ces are usually considered to be prohibitively expensive.          pendency along i; therefore, the computation of \u2207~ l can\r\n                                                                                                                                         \u03b8\r\n                                                                                                                                          i\r\n                                                                                  be parallelized if \u2207   l are available. However, Equation 3\r\n               However, we observe that the Jacobians of many types of                                 ~xi\r\n               layers (e.g., convolution, activation, max-pooling) can be ex-     imposes a strong sequential dependency along i where the\r\n                                                                                  computation of \u2207 l can not begin until the computation of\r\n                                                                                                    ~x\r\n               tremely sparse where we can leverage sparse matrix format                              i\r\n                                                                                  \u2207     l \ufb01nishes, and therefore, hinders the scalability when\r\n                                                                                    ~x\r\n                   1Step complexity (detailed in Section 3.6) quanti\ufb01es the run-     i+1\r\n               time of a parallel algorithm.                                      multiple workers (de\ufb01ned as instances of execution; e.g., a\r\n                                                                                  core in a multi-core CPU) are available.\r\n                                                              BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                    Figure 2: A visualization of the formulation in Section 2.1 on convolutional neural networks. Different parts of the model\r\n                    can be distributed to different devices (workers).\r\n                    2.2    Prior Works                                                                    2.3     De\ufb01nition of the Scan Operation\r\n                    Toincrease the utilization of hardware resources in model                             For a binary and associative operator \u2295 with an iden-\r\n                    parallelism, prior works, e.g., PipeDream (Narayanan et al.,                          tity value I, the exclusive scan (a.k.a., prescan) on an\r\n                    2019) and GPipe (Huang et al., 2018), propose to pipeline                             input array [a ,a ,a ,...,a                 ] produces an output array\r\n                                                                                                                              0    1   2         n\u22121\r\n                    the computation in the forward and backward passes across                             [I,a ,a \u2295a ,a \u2295a \u2295a ,...,a \u2295...\u2295a                                 ] (Blelloch,\r\n                                                                                                                 0   0       1    0      1      2        0             n\u22122\r\n                    devices. However, these solutions are not \u201csilver bullets\u201d to                         1990). Parallel scan algorithms have been developed due to\r\n                    scalability due to the following reasons.                                             the importance of the scan operation and the need to lever-\r\n                    First, both PipeDream (Narayanan et al., 2019) and GPipe                              age the computing power of emerging parallel hardware\r\n                    (Huanget al., 2018) require storing activations and/or multi-                         systems (Hillis & Steele, 1986; Blelloch, 1990).\r\n                    ple versions of weights for all batches that enter the pipeline.                       3     PROPOSEDMETHOD: BPPSA\r\n                   Although GPipe\u2019s re-materialization (Chen et al., 2016) can\r\n                    mitigate memory usage, the theoretical per-device space                               3.1     Back-propagation as a Scan Operation\r\n                    complexity grows linearly with the length of the pipeline                             Wede\ufb01neabinary,associative, and non-commutative op-\r\n                                                           2\r\n                    (i.e., the number of devices). Thus, the maximum number                               erator A \u22c4 B = BA, whose identity value is the identity\r\n                    of devices that pipeline parallelism can support is limited                           matrixI,whereAcanbeeitheramatrixoravectorandB is\r\n                    by the memory capacity of a single device (e.g., the GPU                              a matrix. Using operator \u22c4, we can reformulate Equation 3\r\n                    global memory), and such memory capacity is not expected                              as calculation of the following array:\r\n                    to grow signi\ufb01cantly in the foreseeable future (Mutlu, 2013).                                                  \u2202~x                    \u2202~x           \u2202~x\r\n                                                                                                              [\u2207    l, \u2207    l \u22c4 (     n )T,\u2207 l\u22c4(             n )T \u22c4(       n\u22121)T,\r\n                                                                                                                 ~xn     ~xn     \u2202~x            ~xn     \u2202~x             \u2202~x\r\n                    Second, if the parameter updates are partially asynchronous                                                     n\u22121                    n\u22121             n\u22122         (4)\r\n                    as proposed in PipeDream (Narayanan et al., 2019), the re-                                 ..., \u2207   l \u22c4 (  \u2202~xn )T \u22c4... \u22c4 (\u2202~x2)T]\r\n                                                                                                                     ~xn     \u2202~x                  \u2202~x\r\n                    sulting staleness may effect the convergence for adaptive op-                                               n\u22121                  1\r\n                    timizers such as Adam (Kingma & Ba, 2015) (Appendix C).                               Equation 4 can be interpreted as an exclusive scan operation\r\n                    If the gradient updates are fully synchronized as proposed                            of \u22c4 on the following input array:\r\n                                                                                                                          \u2202~x            \u2202~x                  \u2202~x          \u2202~x\r\n                    in GPipe (Huang et al., 2018), the \u201cbubble of idleness\u201d be-                                               n    T         n\u22121 T                2 T          1 T\r\n                                                                                                             [\u2207 l,(               ) ,(             ) ,...,(         ) ,(        ) ] (5)\r\n                                                                                                                 ~x\r\n                                                                                                                  n     \u2202~x              \u2202~x                  \u2202~x          \u2202~x\r\n                    tween the forward and backward passes increases linearly                                                n\u22121              n\u22122                  1            0\r\n                   with the length of the pipeline, which linearly reduces the                            3.2     Scaling Back-propagation with the Blelloch Scan\r\n                    hardware utilization and leads to diminishing returns.                                        Algorithm\r\n                    Our approach fundamentally differs from these key prior                               Weparallelize the computation of Equation 4 on multiple\r\n                   works (Narayanan et al., 2019; Huang et al., 2018) in the                              workers with the Blelloch scan algorithm (Blelloch, 1990),\r\n                    following ways. First, instead of following the dependency                            formally described in Algorithm 1. The algorithm contains\r\n                    of BP, we reformulate BP so that scaling is achieved via the                          twophases: up-sweepanddown-sweep. Asanexample,Fig-\r\n                    Blelloch scan algorithm (Blelloch, 1990) which is designed                            ure 3 visualizes this algorithm applied on the convolutional\r\n                    for parallelism. Second, the original BP is reconstructed                             layers of VGG-11 (Simonyan & Zisserman, 2015) with lev-\r\n                    exactly without introducing new sources of errors (e.g., stal-                        els L0-L4 as the up-sweep and levels L5-L10 as the down-\r\n                    eness); therefore, our method is agnostic to the exact \ufb01rst-                          sweep. Only the up-sweep phase contains matrix-matrix\r\n                    order optimizer being used. Third, our approach becomes                               multiplications. Due to the non-commutative property of the\r\n                    moreadvantageous as the number of devices increases, in-                              operator \u22c4, we have to reverse the order of operands for \u22c4\r\n                    stead of diminishing returns or hitting scalability limits due                        during the down-sweepphase. This modi\ufb01cation is re\ufb02ected\r\n                    to linear per-device space complexity.                                                online 13 of Algorithm 1 and visualized in Figure 4b.\r\n                        2Appendix B includes a detailed space complexity analysis.                        3.3     Jacobian Matrices in Sparse Format\r\n                                                                                                                                            \u2202~xi+1                  ~\r\n                                                                                                          Afull Jacobian matrix                      of f      (.; \u03b8      ) can be too\r\n                                                                                                                                             \u2202~x          i+1        i+1\r\n                                                                                                                                                i\r\n                                                                                                          expensive to generate, store, and process. In fact, the Jaco-\r\n                                                                                                          bian of the \ufb01rst convolution operator in VGG-11 (Simonyan\r\n                                                                             BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                        Figure 3: Applying our algorithm on the convolutional layers of VGG-11 (Simonyan & Zisserman, 2015). Blue, orange, and\r\n                        green squares represent transposed Jacobian matrices, gradient vectors, and symbolic identity matrices respectively. Blue\r\n                        solid lines, orange solid lines, and yellow dash lines represent matrix-matrix multiplications, matrix-vector multiplications,\r\n                        and logical data movements (that do not always have to be performed explicitly) respectively.\r\n                        Algorithm 1 Modi\ufb01ed Blelloch Scan Algorithm                                                                 cobian: guaranteed zeros that are input (~x0) invariant (e.g.,\r\n                        Input: a = [\u2207           l, (  \u2202~xn )T,...,(\u2202~x1 )T]                \u22b2Input array of Equation 5               zeros that are not on the diagonal of ReLU\u2019s Jacobian) and\r\n                                            ~x\r\n                                              n     \u2202~xn\u22121                \u2202~x0                                                      related to the model\u2019s architecture; and possible zeros that\r\n                        Output: a = [I,\u2207             l, ..., \u2207     l]   \u22b2\u2207 lforEquation2;computedin-place\r\n                                                 ~xn           ~x1            ~xi\r\n                          1: for d \u2190 0 to \u2308log(n + 1)\u2309 \u2212 2 do                                         \u22b2Up-sweepPhase                depend on the input (e.g., zeros on the diagonal of ReLU\u2019s\r\n                                                               d         d+1\r\n                          2:      for all i \u2190 0 to (n \u2212 2 ) by 2               doinparallel                                         Jacobian). For any operator, the positions of guaranteed\r\n                          3:          (l, r) \u2190 (i + 2d \u2212 1,min(i + 2d+1 \u2212 1,n))\r\n                          4:          a[r] \u2190 a[l] \u22c4 a[r]                                                                            zeros (named as the sparsity pattern for brevity) in the Jaco-\r\n                          5:      endfor                                                                                            bian is deterministic with the model architecture and known\r\n                          6: end for                                                                                                aheadoftraining time. Thus, mapping non-zero elements in\r\n                          7: a[n] \u2190 I\r\n                          8: for d \u2190 \u2308log(n + 1)\u2309 \u2212 1 to 0 do                                     \u22b2Down-sweepPhase                  the input matrices to each non-zero element in the product\r\n                                                               d         d+1\r\n                          9:      for all i \u2190 0 to (n \u2212 2 ) by 2               doinparallel                                         matrix (e.g., calculating the number of non-zeros and index\r\n                        10:           (l, r) \u2190 (i + 2d \u2212 1,min(i + 2d+1 \u2212 1,n))\r\n                        11:           T \u2190a[l]                                                                                       merging in CSR matrix-matrix multiplication (Kunchum\r\n                        12:           a[l] \u2190 a[r]                                                                                   et al., 2017)) can be performed prior to training and re-\r\n                        13:           a[r] \u2190 a[r] \u22c4 T                   \u22b2Modi\ufb01cation: Reverse the operands of \u22c4.                    movedfromagenericsparsematrix multiplication routine\r\n                        14:       endfor\r\n                        15: end for                                                                                                (e.g., cuSPARSE (NVIDIA, 2018)) to achieve signi\ufb01cantly\r\n                                                                                                                                    better performance during the training phase. As an exam-\r\n                                                                                                                                    ple, the second last column of Table 1 shows the extremely\r\n                                                                                                                                    high sparsity of guaranteed zeros (de\ufb01ned as the fraction\r\n                                                                                                                                    over all elements in a matrix) for various operators in VGG-\r\n                          (a) Up-sweep: B \u2190 A\u22c4B.                             (b) Down-sweep: A,B \u2190                                 11(Simonyan&Zisserman,2015). In our implementation,\r\n                                                                             B,B\u22c4A.                                                 the transposed Jacobian matrices are represented in the CSR\r\n                        Figure 4: Visualizations of the primitive operations per-                                                   format since it is the most straightforward and commonly\r\n                        formed in the up-sweep and the down-sweep phases.                                                           used sparse matrix format; however, any other sparse matrix\r\n                                                                                                                                    format can be used as an alternative, including a potentially\r\n                        &Zisserman,2015)processing a 32\u00d732 image occupies                                                           moreef\ufb01cient customized sparse matrix format that utilizes\r\n                        768 MB of memory if stored as a full matrix, which is                                                       the deterministic property of the current sparsity pattern,\r\n                        prohibitively large. Fortunately, Jacobian matrices of major                                               which we leave to investigate as part of our future work.\r\n                        operators (such as convolution, ReLU, and max-pooling) are                                                  3.4      Generating Jacobian Matrix in CSR Analytically\r\n                        usually extremely sparse as shown in Figure 5. In compari-\r\n                        son, representing the data contained in the same Jacobian of                                               To practically generate the Jacobian for an operator, in-\r\n                        the aforementioned convolution operator in the Compressed                                                   stead of generating one column at a time either numerically\r\n                        Sparse Row (CSR) (Saad, 2003) format shrinks the memory                                                    (Mahaffy, 2019) or via automatic differentiation (Paszke\r\n                        consumption down to only 6.5 MB. We can observe that                                                        et al., 2017; PyTorch Forums, 2019), we develop analyti-\r\n                        there are two reasons for zeros to appear in an operator\u2019s Ja-\r\n                                                      BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                                             Table 1: The sparsity expressions of guaranteed zeros for various operators.\r\n                   Operator          Filter/Kernel Size      Input Size        Output Size        Sparsity        Examples \u2020     Analytical Generation Speedup \u00a7\r\n                                                                                                       h w \u2021                               3\r\n                   Convolution       c \u00d7c \u00d7h \u00d7w              c \u00d7h \u00d7w           c \u00d7h \u00d7w            1\u2212 f f          0.99157        8.3 \u00d710 \u00d7\r\n                                      o     i     f     f      i     i     i     o     o     o          hiwi\r\n                                                                                                         1                                 6\r\n                   ReLU              N/A                     c \u00d7h\u00d7w            c \u00d7h\u00d7w             1\u2212chw           0.99998        1.2 \u00d710 \u00d7\r\n                                                                                                        hfwf                               5\r\n                   Max-pooling       h \u00d7w                    c \u00d7h \u00d7w           c \u00d7h \u00d7w            1\u2212              0.99994        1.5 \u00d710 \u00d7\r\n                                      f      f                 i     i     i     o     o     o         c h w\r\n                                                                                                        i i i\r\n                   \u2020 The examples of sparsity for the \ufb01rst convolution, ReLU and max-pooling operators of VGG-11 (Simonyan & Zisserman, 2015)\r\n                   \u2021 operating on 32 \u00d7 32 images are shown in the second last column of the table.\r\n                     Approximation when hi and wi are much greater than the padding size.\r\n                   \u00a7 Over generating the transposed Jacobian through PyTorch\u2019s Autograd (Paszke et al., 2017) one column at a time; measured on a Ryzen\r\n                     Threadripper 1950X (AMD, 2019b) machine; averaged across 1000 trials.\r\n                                                                                               252.                   Benilsea    22.                   Benilsea\r\n                                                                                               200.                   BASPP       20.                   BASPP\r\n                                                                                              Lsso157.                            Lsso18.\r\n                                                                                               105.                               16.\r\n                                                                                               152.                               14.\r\n                                                                                                     0Is)ehctab fo #(s noitaret20055000700502005   5000   7005\r\n                                                                                                                                        Is)ehctab fo #(s noitaret\r\n                                                                                              (a) Training loss per iteration.     (b) Test loss per iteration.\r\n                                                                       (c) ReLU.             Figure 6: Training and test loss per iteration for training\r\n                                                                                             LeNet-5 on CIFAR-10. Baseline represents training via the\r\n                                                                                             PyTorch Autograd, while BPPSA represents our method.\r\n                       (a) Convolution         (b) Max-pooling.                              with the same constant. Figure 6 shows that the orange lines\r\n                 Figure 5: Transposed Jacobians for various operators. Yel-                  overlap with the blue lines for both training and test losses,\r\n                 low, cyan and purple dots represents locations of non-zero                  which means our algorithm has negligible impact on the\r\n                 elements, possible zeros and guaranteed zeros in the matrix.                convergence compared to the original BP.\r\n                 cal routines to generate the transposed Jacobian directly                   3.6    Complexity Analysis\r\n                 into the CSR format. Appendix D demonstrates such an-                       Runtime Complexity            Weleverage the following de\ufb01ni-\r\n                 alytical routines in detail for the convolution, ReLU and                   tions to quantify the complexity of a parallel algorithm: (1)\r\n                 max-pooling operators. As proofs of concept for the poten-                  step complexity (S) which evaluates the minimum number\r\n                 tial performance bene\ufb01ts, the last column of Table 1 shows                  of steps to \ufb01nish the execution on the critical path (end-\r\n                 the speedup on analytical generation of the transposed Ja-                  to-end) given the number of parallel workers; (2) per-step\r\n                 cobians for the aforementioned operators in VGG-11 (Si-                     complexity (P) which evaluates the runtime of a single step;\r\n                 monyan & Zisserman, 2015). As part of our future work                       and(3)workcomplexity(W)whichevaluatesthenumberof\r\n                 to build a mature framework with automatic differentiation                  total steps executed by all workers. For brevity, we refer to\r\n                 capability that performs training via BPPSA, we aim to pro-                 performing the scan operation serially as linear scan, which\r\n                 vide a library that implements a \u201csparse transposed Jacobian                is essentially emulating BP by using the transposed Jacobian\r\n                 operator\" (replacing the backward operator in the case of                   andmultiplyingitwiththegradient(asshowninEquation3)\r\n                 cuDNN(NVIDIA,2019a))foreachforwardoperator.                                 explicitly. Assuming the system can be conceptualized as\r\n                 3.5    Convergence                                                          a parallel random-access machine (PRAM) (Kruskal et al.,\r\n                                                                                             1990), the number of workers is p and the size of the input\r\n                 Theoretically, our algorithm is a reconstruction of BP in-                  array in Equation 5 is n + 1, the step and work complexity\r\n                 stead of an approximation, and hence, expected to reproduce                 of our algorithm can be derived as:\r\n                 the exact same outputs. However, in practice, numerical dif-                                         (\r\n                 ferences could be introduced due to the change in the order                       S          (n) =      \u0398(logn)               p > n            (6)\r\n                                                                                                     Blelloch            \u0398(n/p+logp) otherwise\r\n                 of matrix multiplications. We apply our algorithm to train\r\n                 LeNet-5 (Lecun et al., 1998) on CIFAR-10 (Krizhevsky,                            W           (n) = \u0398(n)                                        (7)\r\n                 2009) to demonstrate that such numerical differences would                          Blelloch\r\n                 not affect model convergence. We use a mini-batch size of                   compared to S             (n) = \u0398(n),W              (n) = \u0398(n) of\r\n                                                                                                               Linear                    Linear\r\n                 256andtheSGD(Qian,1999)optimizerwithalearningrate                           the linear scan (which has the same step and work complex-\r\n                 of 0.001 and a momentum of 0.9. We seed the experiments                     ity as BP). Therefore, in an ideal scenario where there is an\r\n                                                                BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                    unbounded number of workers with unit per-step complex-                                        Table 2: Speci\ufb01cations of our experiment platforms.\r\n                    ity, our algorithm reduces the runtime of BP from \u0398(n)                                      GPU                                RTX2070                   RTX2080Ti\r\n                    to \u0398(logn). If, however, we consider the difference in                                      NumberofStreaming\r\n                    per-step complexity between our algorithm (PBlelloch) and                                   Multiprocessors (SMs)              36                        68\r\n                    the baseline (P                ) due to runtime difference between                          NVIDIAGPUDriver                    430.50                    440.33.01\r\n                                          Linear                                                                CUDA(Nickollsetal., 2008)          10.0.130                  10.0.130\r\n                    matrix-matrix and matrix-vector multiplications, our al-                                    cuDNN(Chetluretal., 2014)          7.5.1                     7.6.2\r\n                    gorithm has a runtime of \u0398(logn)P                                compared to                PyTorch (Paszke et al., 2017)      1.1.0                     1.2.0\r\n                                                                         Blelloch                                                                  RyzenThreadripper         EPYC\r\n                    \u0398(n)PLinear in the baseline. There are two approaches                                       CPU                                1950X(AMD,2019b)          7601 (AMD,2019a)\r\n                    to make our algorithm achieve a lower runtime and better                                    Host Memory                        32GB,2400MHz              128GB,2133MHz\r\n                    scaling than the baseline. First, we can reduce P                                  ,        Linux Kernel (Torvalds, 2019)      4.15.0-76                 4.19.49\r\n                                                                                            Blelloch\r\n                    whichisre\ufb02ectedinleveragingthesparsityinthetransposed                                     system-wide actual time spent on a process, (2) speedup\r\n                    Jacobian as analyzed in Section 4.3 and Section 5.3. Sec-                                 whichistheratioofthewall-clocktimespentonthebaseline\r\n                    ond, without lowering PBlelloch, our algorithm can still out-                             overourmethod,and(3)FLOPwhichrepresentsthenumber\r\n                    perform the baseline if P                       /P            <\u0398(n/logn).\r\n                                                         Blelloch       Linear                                of \ufb02oating-point operations executed.\r\n                    This can occur when n/logn grows larger than the dimen-\r\n                    sion of ~xi. The performance bene\ufb01t of such case is demon-                                Weleverage three types of benchmarks to empirically evalu-\r\n                    strated in Section 4.1 and Section 5.1.                                                   ate BPPSA: (1) an end-to-end benchmark of a vanilla RNN\r\n                                                                                                              training on synthesized datasets to demonstrate the scalabil-\r\n                    Space Complexity                Assuming space of storing a trans-                        ity bene\ufb01ts of BPPSA on long sequential dependency; (2)\r\n                    posed Jacobian matrix is bounded by M                              and storing            an end-to-end benchmark of a GRU training on the IRMAS\r\n                                                                               Jacob\r\n                    ~x   is bounded by M (note that M                           \u226aO(M 2)due                    dataset (Bosch et al., 2012) to demonstrate the potential\r\n                      i                           ~x                   Jacob                ~x\r\n                    to sparse matrix formats; both MJacob and M are not                                       of BPPSA on a more realistic workload; and (3) a micro-\r\n                                                                                          ~x\r\n                    functions of p), in our method, each worker requires the                                  benchmarkofaprunedVGG-11(Simonyan&Zisserman,\r\n                    space of M                 (n) = \u0398(max(n,1))M                         which re-           2015) to evaluate the feasibility of using sparse matrix for-\r\n                                     Blelloch                         p           Jacob\r\n                    duces as p increases until a constant MJacob, comparing to                                mattoreduce the per-step complexity of BPPSA.\r\n                    M               =\u0398(n+p)M forpipelineparallelismwhich\r\n                        Pipeline            p            ~x                                                   4.1     RNNEnd-to-endBenchmark\r\n                    increases linearly as p increases. Therefore, our method\r\n                    does not have the limitation of scalability on p, as long as                              WesetupexperimentsoftraininganRNN(Elman,1990)on\r\n                    each worker has the memory capacity of at least M                               .\r\n                                                                                             Jacob            sequential data, which is a classical example of workloads\r\n                    4      METHODOLOGY                                                                        where the runtime performance (in terms of the wall-clock\r\n                                                                                                              time) is limited due to the strong sequential dependency.\r\n                    Although training deep learning models on thousands of                                    Thelarge number of operators n is modeled through a large\r\n                    devices has been proven feasible in the industry (MLPerf,                                 sequence length T. The large number of workers p is re-\r\n                    2019; Goyal et al., 2017), setting up an experiment for                                   \ufb02ected in the total number of CUDA threads that can be\r\n                    such a large number of devices would require a data cen-                                  executed concurrently in all SMs of a single GPU, which\r\n                    ter of GPUs and re-implementing/optimizing our entire ex-                                 wemodelthroughthefraction of GPU per sample (derived\r\n                    periment framework, which requires both monetary and                                      as one over the mini-batch size B).\r\n                    engineering resources out of reach for a typical academic                                                                                                      (k)    (k)\r\n                    research group. Thus, we set up small-scale experiments                                   Datasets We synthesize the datasets X = {(x                              , c    )}\r\n                    that can re\ufb02ect the large-scale workloads to demonstrate the                              of 32000 training samples (i.e., k \u2208 {0,31999}) for the\r\n                                                                                                              task of bitstream classi\ufb01cation. Each sample consists of a\r\n                    potential performance bene\ufb01ts of our method.                                                               (k)             (k)                                            (k)\r\n                                                                                                              class label c         where c         \u2208{0,...,9} and a bitstream x\r\n                    Environment Setup Our experiments are performed on                                        where the value x(k) at each time step t \u2208 {0,...,T \u2212 1} is\r\n                                                                                                                                       t\r\n                    two platforms with RTX 2070 (NVIDIA, 2019b) and RTX                                       sampled from the Bernoulli distribution (Bernoulli, 1713;\r\n                    2080Ti (NVIDIA, 2019c) respectively (both are Turing ar-                                  Evans & Rosenthal, 2009):\r\n                                                                                                      3                        (k)                                   (k)\r\n                    chitecture GPUs) whose speci\ufb01cations are listed in Table 2 .                                             x      \u223cBernoulli(0.05+c                    \u00d70.1)               (8)\r\n                                                                                                                               t\r\n                    Baselines Weevaluate our method against PyTorch Auto-                                                                                  (k)\r\n                                                                                                              Equivalently, each bitstream x                    can be viewed as a bi-\r\n                    grad (Paszke et al., 2017) with cuDNN backend (NVIDIA,                                    nomial experiment (Bernoulli, 1713; Evans & Rosenthal,\r\n                    2019a) which is a widely adopted and state-of-the-art imple-                              2009) of class c(k). The objective of this task is to classify\r\n                    mentation of BP.                                                                                                   (k)                                             (k)\r\n                                                                                                              each bitstream x              into its corresponding class c                  cor-\r\n                    Metrics Weusethreemetrics to quantify the results from                                    rectly. We synthesize eight datasets with different T, where\r\n                    our evaluations: (1) wall-clock time which measures the                                   T increases up to 30000. In reality, long sequences of input\r\n                                                                                                              can often be found in audio signals such as speech (Nagrani\r\n                         3Appendix G includes results on V100 (NVIDIA, 2019d).                                et al., 2017; Baumann et al., 2018; Barker et al., 2018) or\r\n                                                            BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                   music (Bertin-Mahieux et al., 2011; Benzi et al., 2016).                           Table 3: MFCC con\ufb01gurations and the resulting feature\r\n                                                                                                      sizes (represented as the number of frames F multiplied by\r\n                   Model We leverage a vanilla RNN (Elman, 1990) (de-                                 the number of coef\ufb01cients C) for the S, M and L sets.\r\n                   scribed in Equation 9) to solve the aforementioned task,\r\n                   since RNNisanintuitive, yet classical, deep learning model                           Set Name                            S             M             L\r\n                   and often used to process sequential data:                                           MFCCCoef\ufb01cients                     20            13            7\r\n                                                                                                        FFTWindowLength                     4096          2048          1024\r\n                       ~(k)                      (k)    ~              ~(k)      ~                      HopLength                           512           256           128\r\n                       h      =tanh(Wihx             +bih+Whhh                +bhh)         (9)\r\n                         t                       t                       t\u22121                            Resulting Input Features (F \u00d7 C)    259\u00d738        517\u00d724        1034\u00d712\r\n                           ~(k) ~      ~           20\r\n                   whereh        , b  , b    \u2208R .Theoutputclassesarepredicted\r\n                             t      ih   hh\r\n                   via the softmax function (Bridle, 1990) applied on a linear                        Table 3, the preprocessing results in three sets (S, M and L),\r\n                                                                         ~(k)                         re\ufb02ecting the trade-off between the temporal and frequency\r\n                   transformation to the last hidden states hT\u22121. The cross\r\n                   entropy (Goodfellow et al., 2016) is used as the loss func-                        resolutions. For all samples, we normalize the values of\r\n                   tion which is optimized in training via the Adam optimizer                         each coef\ufb01cient across the frames to have zero mean and\r\n                                                                                            \u22125        unit variance. We remove the \ufb01rst coef\ufb01cient because it only\r\n                   (Kingma & Ba, 2015) with the learning rate of 1 \u00d7 10                         .     represents the average power of the audio signal.\r\n                   Thecomputationof\u2207 (k)l duringthebackwardpasscarries\r\n                                               ~\r\n                                               h\r\n                                                 t\r\n                   the strong sequential dependency which is the target for                           Model Sinceinstrument classi\ufb01cation is a more complex\r\n                   acceleration via BPPSA.                                                            task than the synthetic workloads in Section 4.1, a GRU\r\n                   Implementation Weimplementourmodi\ufb01edversionof                                      (Choetal., 2014) (described in Equations 10) is used in this\r\n                   the Blelloch scan algorithm as two custom CUDA kernels                             set of experiments.\r\n                   for the up-sweepanddown-sweepphasesrespectively,along                                                      ~             ~          ~\r\n                                                                                                        ~r =\u03c3(W ~x +b +W h                          +b )\r\n                   with a few other CUDA kernels for the preparation of the                              t           ir t       ir        hr t\u22121         hr\r\n                                                                                                                               ~             ~         ~\r\n                                                                                                        ~z  =\u03c3(W ~x +b +W h                         +b )\r\n                   input transposed Jacobian matrices. Each level during the                             t           iz t       iz        hz t\u22121         hz                   (10)\r\n                                                                                                                                    ~                     ~         ~\r\n                   up-/down-sweep is associated with a separate CUDA kernel                             ~n  =tanh(W ~x +b +~r \u25e6(W h                              +b ))\r\n                   launch (in the same CUDA stream); therefore, synchroniza-                              t                in t       in      t        hn t\u22121         hn\r\n                                                                                                        ~                                 ~\r\n                                                                                                        h =(1\u2212~z )\u25e6~n +~z \u25e6h\r\n                   tion is ensured between two consecutive levels. Each thread                            t             t      t      t     t\u22121\r\n                                                                                                               ~         20                                            C\r\n                   block is responsible for the \u22c4 operation (i.e. multiplication                      where h \u2208 R , t \u2208 {0,...,F \u2212 1} and ~x \u2208 R . Since\r\n                                                                                                                 t                                             t\r\n                   in reverse) of two matrices as well as moving the intermedi-                       cuDNN\u2019sGRUimplementation(Appleyardetal.,2016)is\r\n                   ate results, and the shared memory is leveraged for caching                        closed source, we are unable to generate the transposed\r\n                   input and output matrices. Our custom CUDA kernels are                             Jacobians ef\ufb01ciently (Appendix E), which leads to signi\ufb01-\r\n                   integrated into the Python front-end where the RNN and the                         cant overhead in the forward pass. However, such overhead\r\n                   training procedure are de\ufb01ned through PyTorch\u2019s Custom                             could potentially be reduced if cuDNN\u2019s source code be-\r\n                   C++andCUDAExtensions(Goldsborough,2019). Forthe                                    comes publicly available. Other settings are the same as\r\n                   forward pass and the baseline of PyTorch Autograd (Paszke                          Section 4.1 with the exception of a 3 \u00d7 10\u22124 learning rate.\r\n                   et al., 2017), we simply plug in the PyTorch\u2019s RNN mod-                            Implementation We directly use PyTorch\u2019s GRU mod-\r\n                   ule (PyTorch, 2019b) which calls into the cuDNN\u2019s RNN                              ule (PyTorch, 2019b) which calls into the cuDNN\u2019s\r\n                   implementations (cudnnRNNForwardTraining and                                       GRUimplementations(cudnnRNNForwardTraining\r\n                   cudnnRNNBackwardData) (NVIDIA, 2019a); there-                                      and cudnnRNNBackwardData with CUDNN_GRU)\r\n                   fore, our baseline is already much faster than implementing                        (NVIDIA,2019a). Wereuse the same CUDA implementa-\r\n                   RNNin Python using PyTorch\u2019s RNNCell module (Py-                                   tion of the Blelloch scan algorithm as in Section 4.1.\r\n                   Torch, 2019b) due to GEMM streaming and kernel fusions\r\n                   (Appleyard et al., 2016).                                                          4.3    PrunedVGG-11Micro-benchmark\r\n                   4.2    GRUEnd-to-endBenchmark                                                      Despite the recent advances in network pruning algorithms\r\n                   Toextend the aforementioned RNN end-to-end benchmark                               (Han et al., 2015; See et al., 2016; He et al., 2017), there\r\n                   to a more realistic setting, we evaluate the runtime perfor-                       is no existing widely adopted software or hardware plat-\r\n                   manceoftraining a GRU (Cho et al., 2014) on the IRMAS                              form that can exploit performance bene\ufb01ts from pruning, as\r\n                   (Bosch et al., 2012) dataset for the task of instrument classi-                    mosttechniquesareevaluatedthrough\u201cmaskingsimulation\u201d\r\n                   \ufb01cation based on audio signals.                                                    which leads to the same (if not worse) runtime and mem-\r\n                                                                                                      ory usage. In contrast, in this work, we discover that the\r\n                   Datasets Wepreprocess the IRMAS dataset and compute                                retraining of pruned networks could bene\ufb01t from BPPSA\r\n                   the mel-frequency cepstral coef\ufb01cients (MFCC) (Davis &                             duetothefollowingreason: SincethevaluesintheJacobian\r\n                   Mermelstein, 1980) for each waveform audio sample via                              of a convolution operator only depend on the \ufb01lter weights\r\n                   LibROSA\u2019s (Brian McFee et al., 2015) MFCC implemen-                                (Appendix D.1), pruning the weights can lead to a higher\r\n                   tation. With different MFCC con\ufb01gurations as listed in                             sparsity in the Jacobian, which then reduces the per-step\r\n                                              BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                                                                               sequential data such as audio signals. We observe that the\r\n                                                                               blue curve (BPPSA) is roughly equivalent to the red curve\r\n                                                                               (PyTorch/cuDNNbaseline) scaled down by 63% along the\r\n                                                                               horizontal (time) axis. We conclude that, in this setting,\r\n                                                                               training the RNN through BPPSA reconstructs the origi-\r\n                                                                               nal BP algorithm while achieving a 2.73\u00d7 speedup on the\r\n                                                                               overall training time and 16\u00d7 on the BP runtime.\r\n                                                                               Sensitivity Analysis We measure the performance varia-\r\n               Figure 7: Training loss across wall-clock time when the         tion as the sequence length T and the fraction of GPU per\r\n               RNNistrained via BPPSA (blue curve) and the PyTorch             sample (1/B) vary, since those two parameters represent\r\n               AutogradbaselinewithcuDNN\u2019sRNNbackend(redcurve).                the total number of operators n and the number of workers\r\n                                                                               prespectively \u2014 key variables in the theoretical runtime of\r\n               complexity of sparse matrix-matrix multiplications.             our method. To estimate the speedups, we measure the wall-\r\n               Toevaluate the feasibility of leveraging the sparsity in the    clock time of training via BPPSA for a single epoch, and\r\n               transposedJacobianofeachoperator,wesetupabenchmark              take the average of 20 measurements from different epochs.\r\n               with VGG-11(Simonyan&Zisserman,2015): training on               Wethencompareagainsttraining via the PyTorch/cuDNN\r\n               CIFAR-10 (Krizhevsky, 2009), pruning away 97% of the            baseline measured in the same way. We can also derive the\r\n               weights in all convolution and linear operators using the       backward pass runtime by measuring the wall-clock time of\r\n               technique proposed by See et al. (See et al., 2016), and        the training procedure without actually performing the back-\r\n               retraining the pruned network. We choose this pruning           wardpass, and subtracting from the total runtime (including\r\n               percentage so that a similar validation accuracy is reached     the overhead of preparing the input transposed Jacobians).\r\n               (90.1% v.s. 88.9%) after retraining for the same number         Figure 8a, Figure 8b and Figure 8c show how changing\r\n               of epochs (100) as training. We then apply BPPSA on the         the sequence length T affects the backward pass and over-\r\n               convolutional layers of VGG-11 to compute Equation 3.           all training time. We make three observations from these\r\n               Since the sparsity pattern of the transposed Jacobian can       \ufb01gures. First, our method scales as n increases when n\r\n               be determined ahead of training time from the model archi-      is relatively in the same range as p. Second, when n in-\r\n               tecture (as we show in Section 3.3), existing sparse matrix     creases to be much larger than p, the performance starts to\r\n               libraries which target generic cases are sub-optimal for our    be bounded by p. Third, even in the range of overly large\r\n               method. For example, cuSPARSE (NVIDIA, 2018) calcu-             n, our method still achieves better utilization on massively\r\n               lates the number of non-zeros in the product matrix and         parallel hardware than the baseline.\r\n               merges the indices of the input matrices before it can per-     Figure 8d, Figure 8e and Figure 8f show how changing\r\n               form the multiplication. Such preparations do not need to       the fraction of GPU per sample (1/B) affects the backward\r\n               repeat across iterations in BPPSA\u2019s case and could be per-      pass and overall training time. We can conclude that BPPSA\r\n               formed ahead of time due to the deterministic nature of the     scales as the \u201ceffective\" number of workers p per sample\r\n               sparsity pattern. This, in turn, saves considerable amount      increases (equivalently, as the batch size B decreases, since\r\n               of execution time. Therefore, due to the lack of a fair im-     the total number of SMs in the GPU is constant). In re-\r\n               plementation, we perform the evaluation by calculating the      ality, determining the appropriate mini-batch size can be\r\n               FLOPsneededforeachstepinourmethodandthebaseline                 nontrivial: training with large batch can lead to \u201cgeneraliza-\r\n               implementations through static analysis.                        tion gap\" (Keskar et al., 2016), while training with small\r\n                                                                               batch would under-utilize the hardware resources and lead\r\n               5    EVALUATION                                                 to longer training time. Here, BPPSA can be viewed as of-\r\n               In this section, we present the results from the RNN            fering an alternative to train with smaller mini-batch while\r\n               end-to-end benchmark (Section 4.1), the GRU end-to-end          utilizing the hardware resources more ef\ufb01ciently than BP.\r\n               benchmark (Section 4.2) and the pruned VGG-11 micro-            Bycomparingthe speedup in Figure 8b and Figure 8e be-\r\n               benchmark (Section 4.3).                                        tween RTX 2070 and RTX 2080Ti (RTX 2080Ti has a\r\n                                                                               higher number of SMs than RTX 2070; 68 vs. 36 (NVIDIA,\r\n               5.1  RNNEnd-to-endBenchmark                                     2019c;b)), we can observe that: (1) BPPSA achieves its\r\n               Figure 7 shows the training curves of loss values with re-      maximum speedup at a higher sequence length on RTX\r\n               spect to wall-clock time when we train the RNN for 80           2080Ti than RTX 2070; (2) as the batch size B increases,\r\n               epochs on the RTX 2070 GPU with the mini-batch size             the speedup of BPPSA on RTX 2080Ti drops at a slower\r\n               B = 16 and the sequence length T = 1000. This experi-           rate than RTX 2070. These two observations, together with\r\n               mentcanbeviewedasthesimplestmechanismtoprocess                  Figure 8a and Figure 8d where the BPPSA latency per itera-\r\n                                                   BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                  40       2070                                  102      Baenilse                              10.                          Baenilse\r\n                           2it080                                         2070                                                               2PF ,070\r\n                  30                                                      2it080                                08.                          2APPSB ,070\r\n                                                                                                                                             2PF ,it080\r\n                                                                                                                06.                          2APPSB ,it080\r\n                  20                                             101\r\n                                                                                                                04.\r\n                  10                                            SenilseBa revo pudeep\r\n                                                                                                                02.\r\n                 BnoitaretI rep s)m( emitnuR ASPP0               100                                           NnwodkaerB emitnuR dezilamro\r\n                       10   30  100  300  1k   3k  1k0  3k0           10   30  100  300  1k   3k  1k0 3k0       00.  10   30  100 300   1k  3k  1k0  3k0\r\n                                 Secneuqe  htgneL                                ShtgneL ecneuqe                               ShtgneL ecneuqe\r\n                (a) The BPPSA runtime per iteration as the     (b) The backward pass speedup as the se-       (c) The runtime breakdown as the sequence\r\n                sequence length T increases.                   quence length T increases.                     length T increases.\r\n                  30                                 2070                 Baenilse                              10.                          Baenilse\r\n                  25                                 2it080      101      2070                                                               2PF ,070\r\n                                                                          2it080                                08.                          2APPSB ,070\r\n                  20                                                                                                                         2PF ,it080\r\n                                                                                                                06.                          2APPSB ,it080\r\n                  15\r\n                  10                                                                                            04.\r\n                   5                                            SenilseaB revo pudeep                           02.\r\n                 BnoitaretI rep s)m( emitnuR APPS                100                                           NnwodkaeBr emitnuR dezilamro\r\n                   0  1652/1821/146/ 123/161/  18/ 14/  12/          1652/1821/146/ 123/161/  18/ 14/  12/      00. 1652/1821/146/123/ 161/ 18/  14/ 12/\r\n                             rnoitcaF elpmaS rep PUG fo                      relpmaS rep UPG fo noitcaF                    rnoitcaF elpmaS rep PUG fo\r\n                (d) The BPPSA runtime per iteration as the     (e) The backward pass speedup as the frac-     (f) The runtime breakdown as the fraction of\r\n                fraction of GPUpersample(1/B)increases.        tion of GPU per sample (1/B) increases.        GPUpersample(1/B)increases.\r\n                Figure 8: We report the BPPSA backward pass latency per iteration (Figure 8a and Figure 8d), the backward pass speedups\r\n                (Figure 8b and Figure 8e) of BPPSA over the baseline, as well as the runtime (normalized by the baseline) breakdowns to\r\n                demonstrate the overall speedups (Figure 8c and Figure 8f). The fraction of GPU per sample (which re\ufb02ects the number of\r\n                workers p) is computed as one over the batch size B. FP refers to the forward pass. The standard deviations of the BPPSA\r\n                latency are reported as black lines in Figure 8a and Figure 8d.\r\n                tion on RTX 2080Ti is lower than RTX 2070, are consistent              overhead by taking the difference in the runtime of the train-\r\n                with the aforementioned conclusions regarding the perfor-              ing procedures without actually performing the backward\r\n                mance variation with the number of workers p. We can                   pass between BPPSA and the PyTorch/cuDNN baseline.\r\n                observe a maximum of 108\u00d7 backward pass speedup on                     Themeasurementsare averaged across 100 epochs.\r\n                RTX2080Tiandamaximumof2.75\u00d7overallspeedupon                            Figure 9 shows how the sequence length T and batch size\r\n                RTX2070(thehighest backward pass speedup might not                     B affect the runtimes of the forward pass, the backward\r\n                lead to the highest overall speedup due to different forward           pass and the overhead. We make two observations from this\r\n                pass runtime on which BPPSA has no impact).                            \ufb01gure. First, our method achieves a higher speedup on the\r\n                5.2    GRUEnd-to-endBenchmark                                          backward pass as T increases (changing the preprocessed\r\n                Weinclude the training curves of loss values with respect              dataset from S to L), which reinforces the observation from\r\n                to the wall-clock time when we train the GRU with the                  Section 5.1 that our method scales well as the total num-\r\n                preprocessed datasets in Appendix F. They leads to the                 ber of operators n increases. Second, since the maximum\r\n                sameconclusions as the ones in Section 5.1.                            sequence length (1034) is not as extreme as in Section 5.1,\r\n                                                                                       the backward pass runtime of BPPSA is less affected than\r\n                Sensitivity Analysis       To perform an analysis similar to           the overhead by B and the GPU model, which means n is\r\n                Section 5.2, we only need to vary the batch size B since               still within the same range as the number of workers p in\r\n                the preprocessed dataset type (S, M, L) already re\ufb02ects the            this set of experiments. The maximum overall speedup and\r\n                sequence length T. However, since the overhead of comput-              backward pass speedup (excluding the overhead) are 2.36\u00d7\r\n                ing the transposed Jacobians during the forward pass can-              and 13.4\u00d7 respectively.\r\n                not be neglected (as mentioned in Section 4.2), to achieve             5.3    PrunedVGG-11Micro-benchmark\r\n                a deeper understanding of the performance variation, we\r\n                demonstrate the runtime breakdowns among the forward                   Since the sparsity of the product matrix might reduce after\r\n                pass, the backward pass and the overhead. We can derive the            each multiplication, the per-step complexity might increase\r\n                                                  BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                             FP          BASPP          FO          BenilseBaP \r\n                   100.  Ba61 = eziS hct    B23 = eziS hcta    B46 = eziS hcta                 10 7\r\n                   057.                                                                        10 5\r\n                 S 005.\r\n                   052.                                                                       FPOL103\r\n                   000.                                                                                    mv                  mlacitirc ,m\r\n                   100.                                                                        10 1        mm                  b)BP( enilsea\r\n                   057.                                                                                    mlacitirc ,v\r\n                 M 005.                                                                                 10 5     107      109     1011    10 13\r\n                   052.                                                                                               mk x n x \r\n                   000.                                                               Figure 10: Measuring FLOP for each step when retrain-\r\n                   100.                                                               ing pruned VGG-11 on CIFAR-10. mv and mm represent\r\n                   057.                                                               matrix-vector and matrix-matrix multiplications in BPPSA\r\n                 L                                                                    respectively. critical indicates that the step is on the critical\r\n                   005.                                                               path. The x-axis represents the theoretical runtime complex-\r\n                   052.                                                               ity of the step if the transposed Jacobian were not encoded\r\n                   000.   2070   2it080      2070   2it080      2070   2it080         in a sparse format. The green circles represent the FLOP\r\n                                                                                      estimated for each \u201cgradient operator\" in the BP baseline.\r\n                Figure 9: The runtime breakdowns in the GRU end-to-end\r\n                benchmark as the dataset type (S, M, L) and batch sizes B             tial dependency. We reformulate BP into a scan operation\r\n                vary. FP represents the forward pass; FO represents the for-          which is scaled by our modi\ufb01ed version of the Blelloch\r\n                ward pass overhead of computing the transposed Jacobians;             scan algorithm. Our proposed algorithm, BPPSA, achieves\r\n                BPrepresents the BP baseline; and BPPSA represents the                a logarithmic, rather than linear, step complexity. In addi-\r\n                backward pass via BPPSA. The measurements are normal-                 tion, BPPSA has a constant per-device space complexity;\r\n                ized by the total runtime of the baseline (FP + BP).                  hence, its scalability is not limited by the memory capacity\r\n                                                                                      of each device. In our detailed evaluations, we demonstrate\r\n                as the up-sweep phase progresses into deeper levels. For-             that performance bene\ufb01ts can be achieved in two impor-\r\n                tunately, we can adopt BPPSA to balance the number of                 tant use cases. First, for the case where there is a long\r\n                levels in the up-/down-sweep phases according to the spar-            dependency in BP, we evaluate BPPSA by training a RNN\r\n                sity of the products on each level to achieve an overall              with synthetic datasets and training a GRU with the IRMAS\r\n                speedup. Speci\ufb01cally, in this experiment, BPPSA performs              dataset (Bosch et al., 2012), where our method achieves up\r\n                the up-sweep from L0 to L2 (consistent with the notations             to 2.75\u00d7 speedup on the overall (end-to-end) training time\r\n                in Figure 3), calculates the partial results that are needed          and 108\u00d7 speedup on the backward pass runtime. Second,\r\n                for the down-sweep phase through linear scan, and then                we can reduce the per-step complexity by leveraging the\r\n                performs the down-sweep from L7 to L10.                               sparsity in the Jacobian itself. To this end, we develop ef-\r\n                                                                                      \ufb01cient routines to generate the transposed Jacobian in the\r\n                Assuming the sparse transposed Jacobian matrices are en-              CSRformat,anddemonstrate that the retraining of pruned\r\n                coded in the CSR format, Figure 10 shows the calculated               networks can potentially bene\ufb01t from BPPSA (as we show\r\n                FLOP of each step in BPPSA and each \u201cgradient opera-                  for a pruned VGG-11 benchmark when re-training on the\r\n                tor\" in the baseline (BP) for re-training pruned VGG-11 on            CIFAR-10 dataset). We hope that our work will inspire\r\n                CIFAR-10. Weobservethatthegreencircles(baseline)have                  radically new ideas and designs to improve distributed DNN\r\n                similar expected performance as the other circles (BPPSA).            training beyond the existing theoretical frameworks.\r\n                Thus, we can conclude that exploiting the sparsity in the             ACKNOWLEDGEMENTS\r\n                transposed Jacobian is an ef\ufb01cient strategy that reduces the\r\n                per-step complexity of our method P               to a level sim-\r\n                                                         Blelloch                     We want to thank Xiaodan (Serina) Tan, James Gleeson,\r\n                ilar with the baseline P           . This strategy makes the\r\n                                            Linear                                    Geoffrey Yu, Roger Grosse, Jimmy Ba, Andrew Pelegris,\r\n                overall scalability to be \u201censured\" algorithmically.                  BojianZheng,KazemCheshmiandMaryamMehriDehnavi\r\n                6    CONCLUSION                                                       for their constructive feedback during the development of\r\n                                                                                      this work. This work was supported in part by the NSERC\r\n                In this work, we explore a novel direction to scale BP by             Discovery grant, the Canada Foundation for Innovation\r\n                challenging its fundamental limitation: the strong sequen-            JELFgrant, the Connaught Fund, and Huawei grants.\r\n                                            BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n              REFERENCES                                                   Bertin-Mahieux, T., Ellis, D. P., Whitman, B., and Lamere,\r\n              Amazon. Amazon ec2 p3 instances. https://aws.                  P. The million song dataset. In Proceedings of the 12th\r\n                amazon.com/ec2/instance-types/p3/,2019.                      International Conference on Music Information Retrieval\r\n                Accessed: 2019-08-28.                                        (ISMIR 2011), 2011.\r\n              AMD.        Epyc 7601 dual amd server processors.            Blelloch, G. E. Pre\ufb01x sums and their applications. Technical\r\n                https://www.amd.com/en/products/cpu/                         Report CMU-CS-90-190, School of Computer Science,\r\n                amd-epyc-7601,2019a. Accessed: 2019-08-28.                   Carnegie Mellon University, Nov. 1990.\r\n              AMD.          Ryzen    threadripper   1950x    processor.    Bosch, J., Janer, J., Fuhrmann, F., and Herrera, P. A com-\r\n                https://www.amd.com/en/products/cpu/                         parison of sound segregation techniques for predominant\r\n                amd-ryzen-threadripper-1950x,                   2019b.       instrument recognition in musical audio signals. Proceed-\r\n                Accessed: 2019-08-28.                                        ings of the 13th International Society for Music Informa-\r\n                                                                             tion Retrieval Conference, ISMIR 2012, pp. 559\u2013564, 01\r\n              Amodei, D., Hernandez, D., Sastry, G., Clark, J., Brock-       2012.\r\n                man, G., and Sutskever, I. Ai and compute. https:\r\n                //openai.com/blog/ai-and-compute/,2018.                    BrianMcFee,ColinRaffel,DawenLiang,DanielP.W.Ellis,\r\n                Accessed: 2019-08-28.                                        Matt McVicar, Eric Battenberg, and Oriol Nieto. librosa:\r\n                                                                             Audio and Music Signal Analysis in Python. In Kathryn\r\n              Appleyard, J., Kocisk\u00fd, T., and Blunsom, P. Optimizing         Huff and James Bergstra (eds.), Proceedings of the 14th\r\n                performanceofrecurrentneuralnetworksongpus. CoRR,            Python in Science Conference, pp. 18 \u2013 24, 2015. doi:\r\n                abs/1604.01946, 2016. URL http://arxiv.org/                  10.25080/Majora-7b98e3ed-003.\r\n                abs/1604.01946.\r\n                                                                           Bridle, J. S. Probabilistic interpretation of feedforward clas-\r\n              Arunkumar, A., Bolotin, E., Cho, B., Milic, U., Ebrahimi,      si\ufb01cation network outputs, with relationships to statistical\r\n                E., Villa, O., Jaleel, A., Wu, C.-J., and Nellans, D. Mcm-   pattern recognition. In Souli\u00e9, F. F. and H\u00e9rault, J. (eds.),\r\n                gpu: Multi-chip-module gpus for continued performance        Neurocomputing, pp. 227\u2013236, Berlin, Heidelberg, 1990.\r\n                scalability. ACM SIGARCHComputerArchitectureNews,            Springer Berlin Heidelberg.\r\n                45(2):320\u2013332, 2017.\r\n              Barker, J., Watanabe, S., Vincent, E., and Trmal, J. The     Chen, T., Xu, B., Zhang, C., and Guestrin, C.      Train-\r\n                \ufb01fth \u2019chime\u2019 speech separation and recognition challenge:    ing deep nets with sublinear memory cost.       CoRR,\r\n                Dataset, task and baselines. CoRR, abs/1803.10609, 2018.     abs/1604.06174, 2016. URL http://arxiv.org/\r\n                URLhttp://arxiv.org/abs/1803.10609.                          abs/1604.06174.\r\n              Baumann, T., K\u00f6hn, A., and Hennig, F.        The spoken      Chetlur, S., Woolley, C., Vandermersch, P., Cohen, J., Tran,\r\n                wikipedia corpus collection:    Harvesting, alignment        J., Catanzaro, B., and Shelhamer, E. cudnn: Ef\ufb01cient\r\n                and an application to hyperlistening.    Language Re-        primitives for deep learning. CoRR, abs/1410.0759, 2014.\r\n                sources and Evaluation, Jan 2018.       doi:  10.1007/       URLhttp://arxiv.org/abs/1410.0759.\r\n                s10579-017-9410-y. URL https://doi.org/10.                 Cho, K., van Merrienboer, B., G\u00fcl\u00e7ehre, \u00c7., Bougares, F.,\r\n                1007/s10579-017-9410-y.                                      Schwenk, H., and Bengio, Y. Learning phrase represen-\r\n              Ben-Nun, T. and Hoe\ufb02er, T. Demystifying parallel and dis-      tations using RNN encoder-decoder for statistical ma-\r\n                tributed deep learning: An in-depth concurrency analysis.    chine translation. CoRR, abs/1406.1078, 2014. URL\r\n                CoRR, abs/1802.09941, 2018. URL http://arxiv.                http://arxiv.org/abs/1406.1078.\r\n                org/abs/1802.09941.                                        Coleman, C. A., Narayanan, D., Kang, D., Zhao, T. J.,\r\n              Benzi, K., Defferrard, M., Vandergheynst, P., and Bres-        Zhang, J., Nardi, L., Bailis, P., Olukotun, K., Re, C. B.,\r\n                son, X. FMA: A dataset for music analysis. CoRR,             and Zaharia, M. A. Dawnbench : An end-to-end deep\r\n                abs/1612.01840, 2016. URL http://arxiv.org/                  learning benchmark and competition. 2017.\r\n                abs/1612.01840.\r\n                                                                           Davis, S. and Mermelstein, P. Comparison of paramet-\r\n              Bernoulli, J. Jacobi Bernoulli, ... Ars conjectandi, opus      ric representations for monosyllabic word recognition in\r\n                posthumum. Accedit Tractatus de seriebus in\ufb01nitis, et        continuously spoken sentences. IEEE Transactions on\r\n                epistola Gallice scripta De ludo pilae reticularis. impen-   Acoustics, Speech, and Signal Processing, 28(4):357\u2013366,\r\n                sis Thurnisiorum, fratrum, 1713.                             August 1980. ISSN 0096-3518.\r\n                                                BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n               Deng,J., Dong, W., Socher, R., Li, L., Li, K., and Fei-Fei, L.       2016.       URL http://arxiv.org/abs/1608.\r\n                  Imagenet: A large-scale hierarchical image database. In           06993.\r\n                  2009IEEEConferenceonComputerVisionandPattern                   Huang, Y., Cheng, Y., Chen, D., Lee, H., Ngiam, J., Le,\r\n                  Recognition, pp. 248\u2013255, June 2009. doi: 10.1109/                Q. V., and Chen, Z. Gpipe: Ef\ufb01cient training of gi-\r\n                  CVPR.2009.5206848.                                                ant neural networks using pipeline parallelism. CoRR,\r\n               Elman,J.L. Findingstructureintime. CognitiveScience,14               abs/1811.06965, 2018. URL http://arxiv.org/\r\n                  (2):179\u2013211, 1990. doi: 10.1207/s15516709cog1402\\_1.              abs/1811.06965.\r\n               Esmaeilzadeh, H., Blem, E., St. Amant, R., Sankaralingam,         Keskar, N. S., Mudigere, D., Nocedal, J., Smelyanskiy,\r\n                  K., and Burger, D. Dark silicon and the end of multicore          M., and Tang, P. T. P. On large-batch training for deep\r\n                  scaling. In Proceedings of the 38th Annual International          learning: Generalization gap and sharp minima. CoRR,\r\n                  Symposium on Computer Architecture, ISCA \u201911, pp.                 abs/1609.04836, 2016. URL http://arxiv.org/\r\n                  365\u2013376. ACM, 2011.                                               abs/1609.04836.\r\n               Evans, M. and Rosenthal, J. Probability and Statistics: The       Kingma,D.P.andBa,J. Adam: Amethodforstochasticop-\r\n                  Science of Uncertainty. W. H. Freeman, 2009. ISBN                 timization. In 3rd International Conference on Learning\r\n                  9781429281270.                                                    Representations, ICLR 2015, 2015.\r\n               Goldsborough, P.          Custom c++ and cuda exten-              Krizhevsky, A. Learning multiple layers of features from\r\n                  sions.      https://pytorch.org/tutorials/                        tiny images. Technical report, 2009.\r\n                  advanced/cpp_extension.html, 2019.                     Ac-     Krizhevsky, A. One weird trick for parallelizing convo-\r\n                  cessed: 2019-08-28.                                               lutional neural networks. CoRR, abs/1404.5997, 2014.\r\n               Goodfellow, I., Bengio, Y., and Courville, A.           Deep         URLhttp://arxiv.org/abs/1404.5997.\r\n                  Learning.      MIT Press, 2016.           http://www.          Krizhevsky, A., Sutskever, I., and Hinton, G. E. Imagenet\r\n                  deeplearningbook.org.                                             classi\ufb01cation with deep convolutional neural networks. In\r\n               Goyal, P., Doll\u00e1r, P., Girshick, R. B., Noordhuis, P.,               Proceedings of the 25th International Conference on Neu-\r\n                  Wesolowski, L., Kyrola, A., Tulloch, A., Jia, Y., and             ral Information Processing Systems - Volume 1, NIPS\u201912,\r\n                  He, K. Accurate, large minibatch SGD: training ima-               pp. 1097\u20131105, 2012.\r\n                  genet in 1 hour. CoRR, abs/1706.02677, 2017. URL               Kruskal, C. P., Rudolph, L., and Snir, M. A complex-\r\n                  http://arxiv.org/abs/1706.02677.                                  ity theory of ef\ufb01cient parallel algorithms. Theoretical\r\n               Han, S., Pool, J., Tran, J., and Dally, W. Learning both             Computer Science, 71(1):95 \u2013 132, 1990. doi: https:\r\n                  weights and connections for ef\ufb01cient neural network. In           //doi.org/10.1016/0304-3975(90)90192-K.\r\n                  Cortes, C., Lawrence, N. D., Lee, D. D., Sugiyama, M.,         Kunchum, R., Chaudhry, A., Sukumaran-Rajam, A., Niu,\r\n                  and Garnett, R. (eds.), Advances in Neural Information            Q., Nisa, I., and Sadayappan, P. On improving perfor-\r\n                  Processing Systems 28, pp. 1135\u20131143. 2015.                       manceofsparse matrix-matrix multiplication on gpus. In\r\n               He, K., Zhang, X., Ren, S., and Sun, J. Deep residual learn-         Proceedings of the International Conference on Super-\r\n                  ing for image recognition. CoRR, abs/1512.03385, 2015.            computing, ICS \u201917, pp. 14:1\u201314:11, 2017.\r\n                  URLhttp://arxiv.org/abs/1512.03385.                            Lecun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradient-\r\n               He, K., Zhang, X., Ren, S., and Sun, J. Identity mappings            based learning applied to document recognition. In Pro-\r\n                  in deep residual networks. CoRR, abs/1603.05027, 2016.            ceedings of the IEEE, pp. 2278\u20132324, 1998.\r\n                  URLhttp://arxiv.org/abs/1603.05027.                            Mahaffy, J.     Numerical evaluation of jacobians - per-\r\n                                                                                    sonal.psu.edu.        http://www.personal.psu.\r\n               He, Y., Zhang, X., and Sun, J.             Channel pruning           edu/jhm/ME540/lectures/NumJacobian.\r\n                  for accelerating very deep neural networks.         CoRR,         html,2019. Accessed: 2019-08-28.\r\n                  abs/1707.06168, 2017. URL http://arxiv.org/\r\n                  abs/1707.06168.                                                MLPerf. Mlperftraining v0.6 results. https://mlperf.\r\n                                                                                    org/training-results-0-6/, 2019. Accessed:\r\n               Hillis, W. D. and Steele, Jr., G. L. Data parallel algorithms.       2019-08-28.\r\n                  Commun.ACM,29(12):1170\u20131183,December1986.                      Mutlu, O. Memory scaling: A systems architecture per-\r\n               Huang, G., Liu, Z., and Weinberger, K. Q. Densely con-               spective. pp. 21\u201325, 05 2013. doi: 10.1109/IMW.2013.\r\n                  nected convolutional networks. CoRR, abs/1608.06993,              6582088.\r\n                                              BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n               Nagrani, A., Chung, J. S., and Zisserman, A.          Vox-        abs/1602.08124, 2016. URL http://arxiv.org/\r\n                 celeb: a large-scale speaker identi\ufb01cation dataset. CoRR,       abs/1602.08124.\r\n                 abs/1706.08612, 2017. URL http://arxiv.org/\r\n                 abs/1706.08612.                                              Rumelhart, D. E., Hinton, G. E., and Williams, R. J. Neuro-\r\n                                                                                 computing: Foundations of research. chapter Learning\r\n               Narayanan, D., Harlap, A., Phanishayee, A., Seshadri, V.,         Representations by Back-propagating Errors, pp. 696\u2013\r\n                 Devanur, N., Granger, G., Gibbons, P., and Zaharia, M.          699. MIT Press, 1988.\r\n                 Pipedream: Generalized pipeline parallelism for dnn\r\n                 training. In SOSP 2019, October 2019.                        Saad, Y. Iterative Methods for Sparse Linear Systems. Soci-\r\n               Nickolls, J., Buck, I., Garland, M., and Skadron, K. Scalable     ety for Industrial and Applied Mathematics, Philadelphia,\r\n                 parallel programming with cuda. Queue, 6(2):40\u201353,              PA, USA, 2nd edition, 2003.\r\n                 March2008. ISSN1542-7730.                                    See, A., Luong, M., and Manning, C. D. Compression of\r\n               NVIDIA.      cusparse ::    Cuda toolkit documentation,           neural machine translation models via pruning. CoRR,\r\n                 2018. URL https://docs.nvidia.com/cuda/                         abs/1606.09274, 2016. URL http://arxiv.org/\r\n                 cusparse/index.html. [Accessed: 2018-11-06].                    abs/1606.09274.\r\n               NVIDIA.          cudnn    developer    guide   ::    Deep      Shallue, C. J., Lee, J., Antognini, J. M., Sohl-Dickstein,\r\n                 learning    sdk    documentation.            https://           J., Frostig, R., and Dahl, G. E. Measuring the effects\r\n                 docs.nvidia.com/deeplearning/sdk/                               of data parallelism on neural network training. CoRR,\r\n                 cudnn-developer-guide/index.html, 2019a.                        abs/1811.03600, 2018. URL http://arxiv.org/\r\n                 Accessed: 2019-08-28.                                           abs/1811.03600.\r\n               NVIDIA.      Geforce rtx 2070 graphics card | nvidia.          Shazeer, N., Cheng, Y., Parmar, N., Tran, D., Vaswani, A.,\r\n                 https://www.nvidia.com/en-us/geforce/                           Koanantakool, P., Hawkins, P., Lee, H., Hong, M., Young,\r\n                 graphics-cards/rtx-2070/, 2019b. Accessed:                      C., Sepassi, R., and Hechtman, B. Mesh-tensor\ufb02ow:\r\n                 2019-08-28.                                                     Deep learning for supercomputers. In Bengio, S., Wal-\r\n                                                                                 lach, H., Larochelle, H., Grauman, K., Cesa-Bianchi, N.,\r\n               NVIDIA.     Geforce rtx 2080 ti graphics card | nvidia.           and Garnett, R. (eds.), Advances in Neural Information\r\n                 https://www.nvidia.com/en-us/geforce/                           Processing Systems 31, pp. 10414\u201310423. Curran Asso-\r\n                 graphics-cards/rtx-2080-ti/, 2019c.                  Ac-        ciates, Inc., 2018.\r\n                 cessed: 2019-08-28.\r\n                                                                              Simonyan, K. and Zisserman, A. Very deep convolutional\r\n               NVIDIA. Nvidia v100 tensor core gpu. https://www.                 networks for large-scale image recognition. In 3rd Inter-\r\n                 nvidia.com/en-us/data-center/v100/,                             national Conference on Learning Representations, ICLR\r\n                 2019d. Accessed: 2019-08-28.                                    2015, 2015.\r\n               Paszke, A., Gross, S., Chintala, S., Chanan, G., Yang, E.,     Szegedy, C., Liu, W., Jia, Y., Sermanet, P., Reed, S.,\r\n                 DeVito, Z., Lin, Z., Desmaison, A., Antiga, L., and Lerer,      Anguelov, D., Erhan, D., Vanhoucke, V., and Rabinovich,\r\n                 A. AutomaticdifferentiationinPyTorch. InNIPSAutodiff            A. Going deeper with convolutions. In Computer Vision\r\n                 Workshop, 2017.                                                 andPattern Recognition (CVPR), 2015.\r\n               PyTorch. Torch.nn. https://pytorch.org/docs/                   PyTorch Forums.     How to compute jacobian matrix in\r\n                 stable/nn.html#torch.nn.MaxPool2d,                              pytorch?    https://discuss.pytorch.org/t/\r\n                 2019a. Accessed: 2019-05-23.                                    how-to-compute-jacobian-matrix-in-pytorch/\r\n               PyTorch.      torch.nn \u2014 pytorch master documenta-                14968,2019. Accessed: 2019-08-28.\r\n                 tion.    https://pytorch.org/docs/stable/                    Torvalds, L. Linux kernel source tree. https://github.\r\n                 nn.html,2019b. Accessed: 2019-08-28.                            com/torvalds/linux, 2019. Accessed: 2019-08-\r\n               Qian, N. On the momentum term in gradient descent learn-          28.\r\n                 ing algorithms. Neural Netw., 12(1):145\u2013151, January         Varoquaux, G., Gouillart, E., and Vahtras, O.         Com-\r\n                 1999.                                                           pressed sparse row format (csr), 2019.              URL\r\n               Rhu, M., Gimelshein, N., Clemons, J., Zul\ufb01qar, A., and            https://scipy-lectures.org/advanced/\r\n                 Keckler, S. W.      Virtualizing deep neural networks           scipy_sparse/csr_matrix.html.                  Accessed:\r\n                 for memory-ef\ufb01cient neural network design.        CoRR,         2019-05-23.\r\n                                           BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n              Weisstein, E. W.    \"jacobian.\" from mathworld\u2013a wol-       in Section 5 and Table 1. We require an x86-64 based ma-\r\n                fram web resource. http://mathworld.wolfram.              chine with at least one NVIDIA GPU to evaluate the artifact,\r\n                com/Jacobian.html,2019. Accessed: 2019-08-28.             and NVIDIAContainer Toolkit is the only software depen-\r\n                                                                          dency to prepare. After the installation, the entire work\ufb02ow\r\n              Zhu, H., Akrout, M., Zheng, B., Pelegris, A., Jayarajan,    (from building the needed Docker image to plotting the \ufb01-\r\n                A., Phanishayee, A., Schroeder, B., and Pekhimenko, G.    nal results) is automated by a single workflow.sh script.\r\n                Benchmarking and analyzing deep neural network train-     Although the the exact numerical results produced by the\r\n                ing. In 2018 IEEE International Symposium on Workload     artifact might vary across hardware platforms, the general\r\n                Characterization, IISWC 2018, pp. 88\u2013100, 2018. doi:      trends and conclusions should be similar to the results re-\r\n                10.1109/IISWC.2018.8573476.                               ported in this paper.\r\n              SUMMARYOFAPPENDICES                                         A.2   Artifact check-list (meta-information)\r\n                                                                            \u2022 Algorithm: Back-propagation by Parallel Scan Algorithm\r\n              Duetospaceconstraints, we are unable to include several          (BPPSA)\r\n              important details in the main text of this paper. We pro-     \u2022 Program: RNN and GRU end-to-end benchmarks (Sec-\r\n              vide these details in the appendix below that includes the       tion 4.1, 4.2); a VGG-11 micro-benchmark Section 4.3. All\r\n              following content:                                               benchmarks are public, included, and automated.\r\n                \u2022 Appendix A describes our open-sourced artifact and        \u2022 Compilation: GCC7.4.0andCUDA10.0arerecommended,\r\n                                                                               included, and tested, although other versions of GCC and\r\n                  explains how to reproduce all major experiments in           CUDAmightworkaswell.\r\n                  this work.                                                \u2022 Binary: Scripts included to build binaries from the source\r\n                \u2022 Appendix B performs an analysis on the space com-            code.\r\n                  plexity for one of the key prior works, GPipe (Huang      \u2022 Dataset: The synthetic datasets (Section 4.1) and IRMAS\r\n                  et al., 2018). Appendix C describes our initial attempts     are included; approximately 4.5 GB in total.\r\n                  to analyze PipeDream\u2019s (Narayanan et al., 2019) be-       \u2022 Run-time environment: The main software dependency\r\n                  havior on VGG-16 with the Adam optimizer (instead            is NVIDIAContainer Toolkit (https://github.com/\r\n                  of a vanilla SGD). We use these two appendices to            NVIDIA/nvidia-docker) which dictates the OS re-\r\n                  support our arguments in Section 2.2.                        quirements. We recommend and tested on Ubuntu 18.04.\r\n                \u2022 Appendix D lists the routines that we developed to        \u2022 Hardware: An x86-64 based machine with at least one\r\n                  generate the transposed Jacobians for various operators      NVIDIAGPUandinternetaccess. NoSUDOaccessneeded.\r\n                  directly into the CSR format. This is the complemen-      \u2022 Run-time state: No contentions on hardware resources\r\n                  tary material for Section 3.4.                               (CPU,GPU,RAM,PCIe)withotherprocesses.\r\n                \u2022 Appendix E shows how to derive the transposed Ja-         \u2022 Execution: Around 57 hours in total on the RTX 2080Ti\r\n                  cobians for GRU, and demonstrates the source of the          platform listed in Table 2.\r\n                  overhead in the forward pass for our GRU end-to-end       \u2022 Metrics: Wall-clock time, speedup, and FLOP (Section 4).\r\n                  benchmark (Section 4.2).                                  \u2022 Output: Figures that are similar to Figure 7, 8, 9, 10 and\r\n                \u2022 Appendix F includes the training curves for our GRU         13; Text that contains speedups similar to the last column of\r\n                                                                               Table 1.\r\n                  end-to-end benchmark, which serves as a complemen-\r\n                  tary material to Section 5.2.                             \u2022 Experiments: A single script is provided that automates the\r\n                                                                               entire work\ufb02ow.\r\n                \u2022 Appendix G reports the additional hardware sensitiv-      \u2022 How much disk space required (approximately)?: Ap-\r\n                  ity results on the Volta-based V100 GPU (NVIDIA,             proximately a total of 19.7 GB is needed.\r\n                  2019d) to validate BPPSA potential across different       \u2022 Howmuchtimeisneededtopreparework\ufb02ow(approx-\r\n                  GPUgenerations.                                              imately)?: Around one hour to install NVIDIA Container\r\n                                                                               Toolkit with its dependencies.\r\n              A ARTIFACTAPPENDIX                                            \u2022 How much time is needed to complete experiments (ap-\r\n              A.1   Abstract                                                   proximately)?: Refer to the Execution part above.\r\n              We provide the source code, scripts and data that corre-      \u2022 Publicly available?: Yes.\r\n              sponds to Section 4 as our artifact to reproduce the results  \u2022 Codelicenses (if publicly available)?: MIT.\r\n                                                BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                  \u2022 Datalicenses (if publicly available)?: MIT.                     2. Install a NVIDIA GPU driver that is compatible with\r\n                  \u2022 Work\ufb02owframeworkused?: No.                                         the GPU, the CUDA version (10.0 recommended) and\r\n                                                                                       the NVIDIAContainer Toolkit.\r\n                  \u2022 Archived (provide DOI)?: 10.5281/zenodo.3605368                 3. Install Docker Engine - Community (https://\r\n                                                                                       docs.docker.com/install/), then con\ufb01gure\r\n               A.3    Description                                                      the docker group to use Docker as a non-root\r\n               Thesource code is publicly available on GitHub (https:                  user. https://docs.docker.com/install/\r\n               //github.com/UofT-EcoSystem/BPPSA-open)                                 linux/linux-postinstall/).\r\n               and Zenodo (https://doi.org/10.5281/zenodo.                          4. Install  NVIDIA Container Toolkit (https://\r\n               3605368). Thesourcecodeandscripts only require 37.9                     github.com/NVIDIA/nvidia-docker).\r\n               kB of disk space. However, the workflow.sh script\r\n               builds a 7.7 GB Docker image, then downloads and unzips            Weprovide the install.sh script as a reference to the\r\n               12GBofdata.                                                        above steps 2 to 4.\r\n               A.3.1   Hardwaredependencies                                       A.5   Experimentwork\ufb02ow\r\n               The hardware speci\ufb01cations used are listed in Table 2. In          Weprovide the workflow.sh script that automates the\r\n               general, an x86-64 based machine with at least one NVIDIA          entire work\ufb02ow consisting of the following stages:\r\n               GPUandinternetaccess is required.\r\n               A.3.2   Software dependencies                                        1. Build the Docker image used across experiments.\r\n               Although it is possible to run the experiments natively              2. Download and unzip the synthetic datasets (Sec-\r\n               on the host machine (and, in fact, this is how our RTX                  tion 4.1) and IRMAS.\r\n               2070 platform was set up), we do not recommend this ap-              3. Execute the RNN (Section 4.1) and GRU (Section 4.2)\r\n               proach since installing the dependencies can be tedious,                end-to-end benchmarks.\r\n               non-portable, and unsafe (due to the SUDO access re-\r\n               quirements). Instead, we package all of the original de-             4. Plot the results for the RNN and GRU end-to-end\r\n               pendencies into a Docker image which can be built na-                   benchmarks.\r\n               tively by the workflow.sh script. Therefore, our ar-                 5. Evaluate the speedups for sparse transposed Jacobian\r\n               tifact only requires NVIDIA Container Toolkit (https:                   generation (Section 3.4).\r\n               //github.com/NVIDIA/nvidia-docker). Werec-\r\n               ommendandtestedonUbuntu18.04,however,itispossible                    6. Download the sparse transposed Jacobians of a regular\r\n               to evaluate the artifact on other Linux distributions that              and pruned VGG-11.\r\n               NVIDIAContainerToolkit supports as well.\r\n                                                                                    7. Execute the VGG-11 micro-benchmark (Section 4.3)\r\n               A.3.3   Datasets                                                        and plot the results.\r\n               The workflow.sh script downloads all the required                  After the installation in Section A.4, the user only need to\r\n               datasets automatically.                                            run the command \"./workflow.sh\"intheprojectroot\r\n               A.3.4   Models                                                     directory, which takes around 57 hours on our reference\r\n                                                                                  plarform with the RTX 2080Ti GPU (Table 2).\r\n               TheRNN(Section4.1)andGRU(Section4.2)areincluded.\r\n               The transposed Jacobians of VGG-11 are downloaded by               A.6   Evaluation and expected result\r\n               the workflow.shscript.                                             After ./workflow.sh\ufb01nishes, a results/ directory\r\n               A.4    Installation                                                is created to contain the following results:\r\n               Assumingthehardwarelisted in Section A.3.1 is available,              \u2022 fig_7.pngcorrespondingtoFigure7.\r\n               the following steps are needed to perform the installation:           \u2022 fig_8_a.png, fig_8_b.png, fig_8_c.png,\r\n                 1. Clone     the   project   by   git clone https:                    fig_8_d.png,                fig_8_e.png              and\r\n                    //github.com/UofT-EcoSystem/                                       fig_8_f.pngcorrespondingtoFigure8.\r\n                    BPPSA-open.git.                                                  \u2022 fig_9.pngcorrespondingtoFigure9.\r\n                                               BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                                                                                \u0398(L/K) space for re-computing the intermediate activa-\r\n                                                                                tions of each sample in a \u201cmicro-batch\", where L and K\r\n                                                                                are the length of the network and the number of devices in\r\n                                                                                the pipeline correspondingly. As we show in Figure 11, to\r\n                                                                                fully \ufb01ll the pipeline with useful computation, the number of\r\n                                                                                \u201cmicro-batches\" entering the pipeline (the solid black box)\r\n                                                                                should be equal to the length of the pipeline (the dashed\r\n                                                                                black box); thus, each device needs to store at least \u0398(K)\r\n                                                                                activations at the partition boundary for each sample, result-\r\n                                                                                ing in a \u0398(L/K +K)per-device space complexity.\r\n               Figure 11: Timing diagram of the forward pass when dis-\r\n               tributing a model via pipeline parallelism. Each color repre-    C AFFECTOFPIPEDREAM\u2019SSTALENESS\r\n               sents an individual batch.                                             ONADAM\r\n                 \u2022 fig_10.pngcorrespondingtoFigure10.                           Using the source code from https://github.com/\r\n                 \u2022 fig_13.pngcorrespondingtoFigure13.                           msr-fiddle/pipedream,wereproducePipeDream\u2019s\r\n                 \u2022 table_1_last_column.txt corresponding to                     results on VGG-16 with the same settings except the follow-\r\n                    the last column of Table 1.                                 ing:\r\n               Theexactnumericalresultsmightvaryacrosshardwareplat-                \u2022 4 RTX2080TiGPUs(insteadof16V100GPUs).\r\n               forms, but the general trends should be similar to the results      \u2022 Mini-batch size of 32 (instead of 64).\r\n               presented in this paper where we conducted the experiments          \u2022 Adamoptimizer with the learning rate of 0.00003 and\r\n               on platforms with the RTX 2070 and 2080Ti GPUs (Ta-                    zero weight decay (instead of SGD with the learning\r\n               ble 2). In addition, the speedups of BPPSA over BP should              rate of 0.01 and the weight decay of 0.0005).\r\n               beeasilyobservableintheRNNandGRUend-to-endbench-\r\n               marks.                                                              \u2022 90epochsintotal (instead of 60).\r\n               A.7   Experimentcustomization                                       \u2022 Step decay learning rate schedule (instead of polyno-\r\n                                                                                      mial decay).\r\n               Each stage of the work\ufb02ow can be turned off indepen-\r\n               dently by commenting out the corresponding lines in              For the baseline,      we use the source code from\r\n               workflow.sh. The software environment can be cus-                https://github.com/pytorch/examples/\r\n               tomized by modifying docker/Dockerfile and re-                   tree/master/imagenet (which is a plain VGG im-\r\n               building the Docker image. The parameters of the RNN             plementation used as one of PyTorch\u2019s of\ufb01cial examples for\r\n               and GRU end-to-end benchmarks can be customized                  ImageNet(Dengetal., 2009)) and the same aforementioned\r\n               by modifying the code/rnn_grid_run.sh and                        settings except using one GPU (instead of four). We choose\r\n               code/gru_grid_run.sh scripts which are launched                  these settings for the following purpose: (1) to \ufb01t in the\r\n               byworkflow.shthroughDockercontainers.                            hardware resources available to us; (2) to match with a\r\n                                                                                widely adopted baseline; and (3) to use the Adam optimizer\r\n               A.8   Methodology                                                instead of SGD. We run both experiments three times and\r\n                                                                                record the Top-1 and Top-5 validation accuracy across\r\n               Submission, reviewing and badging methodology:                   epochs. We present our results in Figure 12.\r\n                 \u2022 http://cTuning.org/ae/                                       Weobservea2.6%top-1and1.9%top-5accuracylossfrom\r\n                    submission-20200102.html                                    PipeDreamcomparedtothebaseline. Combining with the\r\n                                                                                observation that the error bars are negligible (i.e., negligible\r\n                 \u2022 http://cTuning.org/ae/                                       variance across runs), we conclude that at least in this case,\r\n                    reviewing-20200102.html                                     PipeDreamis not fully equivalent to the baseline for some\r\n                 \u2022 https://www.acm.org/publications/                            adaptive optimizers (e.g., Adam), which differs from the\r\n                    policies/artifact-review-badging                            optimizer-oblivious property of our work. It is important to\r\n                                                                                emphasizethatwedonotimplythatPipeDreamwillalways\r\n               B SPACECOMPLEXITYOFGPIPE                                         have a negative impact on the convergence. A deeper analy-\r\n                                                                                sis is needed on a much greater space of hyper-parameters\r\n               Using the notations consistent with GPipe (Huang et al.,         to understand how general is such an effect on convergence\r\n               2018), with re-materialization enabled, each device reserves     with PipeDream that is beyond the scope of our work.\r\n                                                BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                                                                                  Algorithm 3 Compute the CSR indices array for the\r\n                                                                                  transposed Jacobian of a 3 \u00d7 3 convolution.\r\n                                                                                  Input: input channels c , output channels c , input height h , input width w ,\r\n                                                                                                     i               o            i             i\r\n                                                                                      indptrcomputedfromAlgorithm2\r\n                                                                                  Output: indices \u2190 malloc(3w (3h \u22122)c c )\r\n                                                                                                               i   i     i o\r\n                                                                                   1: for all i \u2190 0 to (c h w \u2212 1) do in parallel\r\n                                                                                                    i i i\r\n                                                                                   2:   r \u2190imod(h w )\r\n                                                                                                     i i\r\n                                                                                   3:   base \u2190 malloc(9co)\r\n                                                                                   4:   for all j \u2190 0 to (co \u2212 1) do in parallel\r\n                                                                                   5:      for all k \u2190 0 to 2 do in parallel\r\n                                                                                   6:         base[9j +3k : 9j +3(k +1)] \u2190 (\r\n                                                                                                  [\u22121,0,1]+(jh +k\u22121)w +r)mod(c h w )\r\n                                                                                                                i          i           o i i\r\n                                                                                   7:      endfor\r\n                                                                                   8:   endfor\r\n                                                                                   9:   if r < w or r > w (h \u22121)then\r\n                                                                                               i        i  i\r\n                                                                                   10:     row \u2190malloc(6co)\r\n                                                                                   11:     (left,right) \u2190 (3,9)ifr < wi;(0,6)otherwise\r\n                                                                                   12:     for all j \u2190 0 to (co \u2212 1) do in parallel\r\n                                                                                   13:        row[6j : 6j + 6] \u2190 base[9j + left : 9j + right]\r\n                                                                                   14:     endfor\r\n                                                                                   15:  else\r\n                                                                                   16:     row \u2190base\r\n                                                                                   17:  endif\r\n                                                                                   18:  indices[indptr[i] : indptr[i +1]] \u2190 sorted(row)\r\n                                                                                   19: end for\r\n               Figure 12: Top-1 and Top-5 validation accuracy across              Algorithm 4 Compute the CSR data array for the trans-\r\n               epochs for both PipeDream and the baseline. We report              posed Jacobian of a 3 \u00d7 3 convolution.\r\n                                                                                  Input: inputchannelsc ,outputchannelsc ,inputheighth ,inputwidthw ,\ufb01lter\r\n               both the mean (as curves) and the range (as error bars).                             i              o           i            i\r\n                                                                                     weights,indptrcomputedfromAlgorithm2\r\n                                                                                  Output: data \u2190 malloc(3w (3h \u22122)c c )\r\n                                                                                                            i   i     i o\r\n                                                                                   1: for all i \u2190 0 to (c h w \u2212 1) do in parallel\r\n               D SPARSEJACOBIANGENERATION                                                           i i i\r\n                                                                                   2:   r \u2190imod(h w )\r\n                                                                                                     i i\r\n                                                                                   3:   m\u2190\u230ai/(h w )\u230b\r\n                     ROUTINES                                                                     i  i\r\n                                                                                        range \u2190(1::-1)if(r < wi);\r\n                                                                                   4:            (2:0:-1)if(r > w (h \u22121));\r\n               D.1    Convolution                                                                                i  i\r\n                                                                                                 (2::-1)otherwise\r\n               Algorithm 2, Algorithm 3 and Algorithm 4 show how to                5:   data[indptr[i] : indptr[i + 1]] \u2190 flatten(\r\n               generate the CSR indptr, indices and data arrays                              weights[:,m,range,::-1])\r\n                                                                                   6:   Fix corner cases when (i mod w ) = 0 or (i mod w ) = (w \u2212 1).\r\n               (Varoquaux et al., 2019) respectively for the transposed                                           i               i      i\r\n                                                                                   7: end for\r\n               Jacobian of a convolution operator that has a 3\u00d73 \ufb01lter and\r\n                                  4\r\n               padding size of 1.\r\n                                                                                  posed Jacobian of a ReLU operator are formally described\r\n               Algorithm2ComputetheCSRindptrarrayforthetrans-                     in Algorithm 5, Algorithm 6 and Algorithm 7 respectively.\r\n               posed Jacobian of a 3 \u00d7 3 convolution.\r\n               Input: input channels c , output channels c , input height h , input width w\r\n                                 i              o            i           i        Algorithm5ComputetheCSRindptrarrayforthetrans-\r\n               Output: indptr \u2190 malloc(c h w +1)\r\n                                         i i i\r\n                1: for all i \u2190 0 to (c h w ) do in parallel                       posed Jacobian of ReLU.\r\n                                 i i i\r\n                2:   a \u2190\u230ai/(h w )\u230b\r\n                               i i                                                Input: size d of the (\ufb02attened) input tensor x\r\n                3:   b \u2190imod(h w )\r\n                4:   if b 6 w then i i                                            Output: indptr \u2190 malloc(d+1)\r\n                            i                                                      1: for all i \u2190 0 to d do in parallel\r\n                5:      indptr[i] \u2190 ac (3w (3h \u22122))+6c b\r\n                                      o    i   i         o                         2:   indptr[i] \u2190 i\r\n                6:   else if b 6 w (h \u2212 1) then\r\n                               i  i                                                3: end for\r\n                7:      indptr[i] \u2190 ac (3w (3h \u22122))+6c w +9c (b\u2212w )\r\n                                      o    i   i         o i     o      i\r\n                8:   else\r\n                        indptr[i] \u2190ac (3w (3h \u22122))+6c w +9c (w (h \u22122))\r\n                9:                   o    i   i          o i     o  i  i\r\n                                    +6c (b\u2212w (h \u22121))\r\n                                        o      i  i\r\n               10:   endif                                                        D.3    Max-pooling\r\n               11: end for\r\n                                                                                  Assumingthestride size and the window size are the same,\r\n                                                                                  and we can access a tensor (named as pool_indices for\r\n               D.2    ReLU                                                        brevity) which speci\ufb01es the indices of the elements in the\r\n               Our methods of generating the CSR indptr, indices                  input tensor that are \u201cpooled\u201d for the output tensor (docu-\r\n               and data arrays (Varoquaux et al., 2019) for the trans-            mented in (PyTorch, 2019a)), our methods of generating\r\n                                                                                  the CSRindptr,indicesanddataarrays(Varoquaux\r\n                   4Although we assume a speci\ufb01c con\ufb01guration of the convolu-     et al., 2019) are formally described in Algorithm 8, Algo-\r\n               tion operator here, deriving a generic routine is doable.          rithm 9 and Algorithm 10 respectively.\r\n                                                                           BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n                       Algorithm 6 Compute the CSR indices array for the                                                         E OVERHEADANALYSISOFTHEGRU\r\n                        transposed Jacobian of ReLU.                                                                                     END-TO-END BENCHMARK\r\n                        Input: size d of the (\ufb02attened) input tensor x                                                          WecanrewritetheGPUinEquation10intothefollowing\r\n                        Output: indices \u2190 malloc(d)\r\n                         1: for all i \u2190 0 to (d \u2212 1) do in parallel                                                              form:\r\n                         2:      indices \u2190 i\r\n                         3: end for                                                                                                ~                        ~                 ~            ~\r\n                                                                                                                                  R =W ~x +b +W h                                      +b\r\n                                                                                                                                      t         ir t          ir          hr t\u22121             hr\r\n                                                                                                                                   ~                        ~                 ~            ~\r\n                                                                                                                                  Z =W ~x +b +W h                                      +b\r\n                       Algorithm 7 Compute the CSR data array for the trans-                                                         t          iz t          iz          hz t\u22121             hz\r\n                                                                                                                                    ~                ~            ~             ~                        ~                  ~\r\n                                                                                                                                  M =W h +b , N =W ~x +b +~r \u25e6M\r\n                        posed Jacobian of ReLU.                                                                                       t          hn t\u22121             hn            t          in t          in        t         t\r\n                        Input: the (\ufb02attened) input tensor x, and its size d                                                                    ~                        ~                               ~\r\n                                                                                                                                  ~r   =\u03c3(R ),              ~z  =\u03c3(Z ),             ~n    =tanh(N )\r\n                        Output: data \u2190 malloc(d)                                                                                    t              t          t             t          t                    t\r\n                         1: for all i \u2190 0 to (d \u2212 1) do in parallel                                                               ~                                           ~\r\n                                                                                                                                  h =(1\u2212~z )\u25e6~n +~z \u25e6h\r\n                         2:      if x[i] > 0 then                                                                                    t                t         t       t       t\u22121\r\n                         3:          data[i] \u2190 1\r\n                         4:      else                                                                                            Given the GRU expressed in the above form, the transposed\r\n                         5:          data[i] \u2190 0                                                                                                                                                                ~\r\n                         6:      endif                                                                                                                                                                        \u2202h\r\n                                                                                                                                 Jacobian between consecutive hidden states                                       t    can be\r\n                         7: end for                                                                                                                                                                           ~\r\n                                                                                                                                                                                                            \u2202h\r\n                                                                                                                                 computed analytically:                                                         t\u22121\r\n                       Algorithm8ComputetheCSRindptrarrayforthetrans-                                                                               ~\r\n                        posed Jacobian of max-pooling.                                                                             J =( \u2202Rt )T =WT\r\n                                                                                                                                     1           ~                     hr\r\n                                                                                                                                               \u2202h\r\n                        Input: pool_indices,inputheighth ,inputwidthw ,outputheighth ,output                                                        t\u22121\r\n                                                                        i                 i                    o                                          \u2202~r\r\n                            width w , output channels c\r\n                                      o                       o                                                                    ~                          t   T\r\n                        Output: indptr \u2190 malloc(c h w +1),mapping \u2190 malloc(c h w )                                                 j =Diag((                     ) ) =~r \u25e6(1\u2212~r )\r\n                                                                o i i                                           o i i                2                      ~                 t               t\r\n                         1: for all i \u2190 0 to c h w \u2212 1 do in parallel                                                                                    \u2202R\r\n                                                  o i i                                                                                                        t\r\n                         2:      mapping[i] \u2190 \u22121                                                                                                            ~\r\n                                                                                                                                                         \u2202N\r\n                         3: end for                                                                                                ~                           t T           ~\r\n                                                                                                                                   j =Diag((                     ) ) = M\r\n                         4: for all c \u2190 0 to c       \u22121doinparallel                                                                  3                                          t\r\n                                                  o                                                                                                       \u2202~r\r\n                         5:      for all h \u2190 0 to h \u2212 1 do in parallel                                                                                        t\r\n                                                        o\r\n                         6:          for all w \u2190 0 to w \u2212 1 do in parallel                                                                          ~\r\n                                                             o                                                                                  \u2202Mt T                   T\r\n                         7:               i \u2190 ch w +pool_indices[c,h,w]\r\n                                                   i   i                                                                           J =(                   )    =W\r\n                         8:               j \u2190(ch +h)w +w                                                                             4           ~                     hn\r\n                                                     o          o                                                                              \u2202h\r\n                         9:               mapping[i] \u2190 j                                                                                            t\u22121\r\n                        10:          endfor                                                                                                                  ~\r\n                                                                                                                                                         \u2202N\r\n                        11:      endfor                                                                                            ~                           t   T\r\n                                                                                                                                   j =Diag((                     ) ) =~r\r\n                        12: end for                                                                                                  5                       ~                 t\r\n                                                                                                                                                         \u2202M\r\n                        13: ptr \u2190 0                                                                                                                             t\r\n                        14: for i \u2190 0 to (c h w \u2212 1) do                                                                                                  \u2202~n\r\n                                               o i i                                                                               ~                          t   T\r\n                                                                                                                                   j =Diag((                     ) ) = 1\u2212~n \u25e6~n\r\n                        15:      indptr[i] \u2190 ptr                                                                                     6                      ~                         t       t\r\n                                                                                                                                                         \u2202N\r\n                        16:      if mapping[i] 6= \u22121 then                                                                                                      t\r\n                        17:          ptr \u2190ptr+1                                                                                                            ~\r\n                        18:      endif                                                                                             ~                     \u2202ht T                                                             (11)\r\n                                                                                                                                   j =Diag((                    ) ) = 1\u2212~z\r\n                        19: end for                                                                                                  7                   \u2202~n                        t\r\n                        20: indptr[\u22121] \u2190 ptr                                                                                                                  t\r\n                                                                                                                                                    ~\r\n                                                                                                                                   J =( \u2202Zt )T =WT\r\n                                                                                                                                     8           ~                     hz\r\n                                                                                                                                               \u2202h\r\n                       Algorithm 9 Compute the CSR indices array for the                                                                            t\u22121\r\n                                                                                                                                                          \u2202~z\r\n                        transposed Jacobian of max-pooling.                                                                        ~                          t   T\r\n                                                                                                                                   j =Diag((                    ) ) = ~z \u25e6 (1 \u2212~z )\r\n                                                                                                                                     9                      ~                 t               t\r\n                        Input: mapping computed from Algorithm 8, input height h , input width w ,                                                       \u2202Zt\r\n                                                                                                   i                   i\r\n                             output height h , output width w , output channels c\r\n                                               o                    o                      o                                                                 ~\r\n                        Output: indices \u2190 malloc(cohowo)                                                                           ~                       \u2202ht T             ~\r\n                                                                                                                                   j     =Diag((                  ) ) = h             \u2212~n\r\n                         1: indices_ptr \u2190 0                                                                                          10                    \u2202~z                 t\u22121           t\r\n                         2: for i \u2190 0 to (c h w \u2212 1) do                                                                                                        t\r\n                                               o i i                                                                                                 ~\r\n                         3:      if mapping[i] = \u22121then                                                                                            \u2202h\r\n                         4:          continue                                                                                      J      =(           t   )T        =I\u25e6~z\r\n                         5:      endif                                                                                               11            ~         direct\r\n                                                                                                                                                \u2202ht\u22121\r\n                         6:      indices[indices_ptr] \u2190 mapping[i]                                                                      ~\r\n                         7:      indices_ptr \u2190 indices_ptr+1                                                                          \u2202ht                     ~      ~ T                  ~T          ~      ~ T\r\n                         8: end for                                                                                                             =(J \u25e6(j \u25e6j ) +J \u25e6j )\u25e6(j \u25e6j ) +\r\n                                                                                                                                      ~                1        2      3             4      5           6       7\r\n                                                                                                                                   \u2202h\r\n                                                                                                                                        t\u22121\r\n                                                                                                                                                            ~       ~      T\r\n                                                                                                                                                   J \u25e6(j \u25e6j ) +J\r\n                       Algorithm 10 Compute the CSR data array for the trans-                                                                        8        9       10             11\r\n                        posed Jacobian of max-pooling.                                                                          where Diag(.) represents taking the diagonal of a square\r\n                        Input: output channels c , output height h , output width w\r\n                                                     o                     o                    o                                matrix, and \u25e6 represents the broadcasting element-wise\r\n                        Output: data \u2190 malloc(c h w )\r\n                                                            o o o                                                               (Hadamard) product. Since cuDNN\u2019s GRU implementa-\r\n                         1: for all i \u2190 0 to (c h w \u2212 1) do in parallel\r\n                                                   o o o\r\n                         2:      data \u2190 1                                                                                        tion (Appleyard et al., 2016) is closed source, we cannot\r\n                         3: end for                                                                                              access the values of the gates (~r , ~z , ~n ). Therefore, we\r\n                                                                                                                                                                                        t     t     t\r\n                                                BPPSA:ScalingBack-propagationbyParallelScanAlgorithm\r\n               have to recompute the gates (but in a more parallelized way)            method by subtracting the \u201cFP + Overhead\" row from\r\n                                                               ~\r\n                                                              \u2202h\r\n               during the forward pass in order to compute       t  as shown           the \"BPPSA\" row for each column (batch size).\r\n                                                              ~\r\n                                                             \u2202h\r\n                                                                t\u22121\r\n               in Equations 11. This engineering challenge results in signif-\r\n               icant overhead during the forward pass in our experiments,         From the aforementioned results, we can observe trends\r\n               however, can potentially be resolved if cuDNN\u2019s source             in both benchmarks similar to the ones in the results from\r\n               code were publicly available and modi\ufb01able.                        RTX2070andRTX2080Ti(Section5.1andSection5.2).\r\n               F GRUTRAININGCURVE                                                 Table 4: The wall-clock time (s) for running a single epoch\r\n                                                                                  of the RNN end-to-end benchmark (Section 4.1) as the\r\n                                                                                  sequence length T increases.\r\n                                                                                     Sequence   Forward         Baseline        BPPSA\r\n                                                                                     Length (T) Pass Only\r\n                                                                                     10         1.57 \u00b10.01      4.49 \u00b10.04      4.24 \u00b10.04\r\n                                                                                     30         2.13 \u00b10.01      5.5 \u00b10.06       4.91 \u00b10.06\r\n                                                                                     100        3.82 \u00b10.02      8.87 \u00b10.05      6.64 \u00b10.08\r\n                                                                                     300        8.79 \u00b10.03      18.49\u00b10.1       11.71\u00b10.07\r\n                                                                                     1000       25.86\u00b10.12      53.33\u00b10.39      29.29\u00b10.18\r\n                                                                                     3000       75.33\u00b10.36      157.11\u00b10.58     79.48\u00b10.45\r\n                                                                                     10000      250.28\u00b10.32     510.13\u00b11.11     265.02\u00b10.64\r\n               Figure 13: Training loss across wall-clock time when the              30000      748.99\u00b10.71     1557.94\u00b16.53    764.31\u00b10.63\r\n               GRUistrained via BPPSA (blue curve) and the PyTorch\r\n               AutogradbaselinewithcuDNN\u2019sRNNbackend(redcurve).                   Table 5: The wall-clock time (s) for running a single epoch\r\n                                                                                  of the RNN end-to-end benchmark (Section 4.1) as the\r\n               Figure 13 shows the training curves of loss values with re-        fraction of GPU per sample (1/B) increases.\r\n               spect to wall-clock time when we train the GRU with the (S,         Fraction of GPU   Forward\r\n               M,L)preprocesseddatasetsfor400epochsontheRTX2070                    per Sample (1/B)  Pass Only      Baseline        BPPSA\r\n               GPUwhenthemini-batch size B is 16. We observe that                  1/256             2.13 \u00b10.02     4.02 \u00b10.06      3.72 \u00b10.02\r\n               the blue curve (BPPSA), if horizontally-scaled, maintains a         1/128             3.87 \u00b10.02     7.96 \u00b10.11      5.49 \u00b10.01\r\n                                                                                   1/64              7.51 \u00b10.06     14.77\u00b10.2       9.27 \u00b10.02\r\n               similar shape as the red curve (PyTorch/cuDNN baseline),            1/32              13.62\u00b10.11     29.51\u00b10.34      15.0 \u00b10.12\r\n               which reinforces our observation in Section 5.1 that BPPSA          1/16              25.86\u00b10.12     53.33\u00b10.39      29.29\u00b10.18\r\n                                                                                   1/8               51.29\u00b10.18     102.77\u00b10.61     56.37\u00b10.35\r\n               reconstructs the original back-propagation algorithm but            1/4               100.55\u00b10.25    209.67\u00b10.66     112.23\u00b10.47\r\n               achieves a shorter training time.                                   1/2               200.65\u00b10.24    409.33\u00b10.67     227.13\u00b10.74\r\n               G ADDITIONALHARDWARESENSITIVITY                                    Table 6: The wall-clock time (s) of running one epoch in\r\n                     RESULTS                                                      the GRU end-to-end benchmark (Section 4.2) as the dataset\r\n                                                                                  type (S, M, L) and the batch size B varies. \u201cFP\" represents\r\n               Tofurther validate BPPSA on a different GPU architecture,          running the forward pass only; \u201cFP + Overhead\" represents\r\n               we repeat the experiments in Section 4.1 and Section 4.2           running the forward pass with GRU\u2019s Jacobian generation\r\n               on an NVIDIA V100 (Volta architecture) (NVIDIA, 2019d)             overhead; \u201cBaseline\" represents training normally via the\r\n               through an AWS p3.2xlarge instance (Amazon, 2019) with             BPbaseline; \u201cBPPSA\" represents training via our method.\r\n               the same software stack as our RTX 2080Ti platform (in                                   Batch Size    Batch Size   Batch Size\r\n               Table 2). The results are summarized in:                                                 B=16          B=32         B=64\r\n                                                                                         FP             1.66 \u00b10.01    0.91 \u00b10.01   0.52 \u00b10.0\r\n                                                                                    S    Baseline       3.71 \u00b10.02    1.9 \u00b10.01    1.0 \u00b10.0\r\n                  \u2022 Table4andTable5fortheRNNend-to-endbenchmark                          FP+Overhead    2.1 \u00b10.01     1.09 \u00b10.01   0.62 \u00b10.0\r\n                    (Section4.1). Wecanderivethebackwardpassruntime                      BPPSA          2.94 \u00b10.02    1.48 \u00b10.01   0.82 \u00b10.01\r\n                    of the baseline by subtracting the \u201cForward Pass Only\"               FP             3.21 \u00b10.01    1.73 \u00b10.01   0.86 \u00b10.01\r\n                                                                                    M    Baseline       6.19 \u00b10.04    3.3 \u00b10.02    1.82 \u00b10.02\r\n                    column from the \u201cBaseline\" column for each row (T                    FP+Overhead    3.52 \u00b10.02    1.83 \u00b10.01   1.18 \u00b10.01\r\n                    or 1/B); while we can also derive the backward pass                  BPPSA          4.2 \u00b10.03     2.22 \u00b10.01   1.2 \u00b10.01\r\n                    runtime of our method by subtracting the \u201cForward                    FP             5.78 \u00b10.03    3.04 \u00b10.02   1.64 \u00b10.01\r\n                                                                                    L    Baseline       11.43\u00b10.09    6.09 \u00b10.07   3.19 \u00b10.04\r\n                    Pass Only\" column from the \u201cBPPSA\" column for                        FP+Overhead    6.06 \u00b10.04    3.23 \u00b10.02   2.13 \u00b10.01\r\n                    each row (T or 1/B).                                                 BPPSA          6.91 \u00b10.05    3.57 \u00b10.04   2.33 \u00b10.01\r\n                  \u2022 Table 6 for the GRU end-to-end benchmark (Sec-\r\n                    tion 4.2). We can derive the backward pass runtime\r\n                    of the baseline by subtracting the \u201cFP\" row from the\r\n                    \u201cBaseline\" row for each column (batch size); while\r\n                    wecanalsoderive the backward pass runtime of our\r\n", "award": [], "sourceid": 177, "authors": [{"given_name": "Shang", "family_name": "Wang", "institution": "University of Toronto"}, {"given_name": "Yifan", "family_name": "Bai", "institution": "University of California, Berkeley"}, {"given_name": "Gennady", "family_name": "Pekhimenko", "institution": "University of Toronto"}]}