Md. Asif Uddin
    I.10.X10

    What backpropagation through time keeps

    complexity▲▲△

    A batch of N=32N=32 sequences of length T=1000T=1000 trains a layer of width H=512H=512 in float32. Under the storage scheme of I.10.B05, how many bytes of activations does a plain tanh layer keep for the backward pass, and how many does an LSTM layer keep? How do both scale with TT, and what does inference need instead?

    Hint

    The plain cell stores one HH-vector per step and sequence; the LSTM stores six.

    Solution

    The plain layer stores 4NTH=65,536,0004NTH=65{,}536{,}000 bytes, 62.562.5 MiB. The LSTM stores six times as much, 393,216,000393{,}216{,}000 bytes, 375375 MiB. Both grow linearly in TT: doubling the sequence doubles the storage.

    Streaming inference keeps only the current state: ht\vec h_t for the plain cell, ht\vec h_t and ct\vec c_t for the LSTM, about 2NH2NH numbers, independent of TT. The distinction of I.9 holds for gated cells too: constant inference memory says nothing about training memory. Truncated backpropagation or checkpointing reduces the training figure at the costs I.9 described.

    Draws on