| 37 | |
| 38 | |
| 39 | class ActivationRecomputation(Enum): |
| 40 | NONE = 0 |
| 41 | """No activation recomputation; requires the most amount of memory.""" |
| 42 | |
| 43 | SELECTIVE = 1 |
| 44 | """Selectively checkpoints and recomputes only parts of each transformer layer that |
| 45 | take up a considerable amount of memory but are not computationally expensive to |
| 46 | recompute, i.e. QK^T matrix multiply, softmax, softmax dropout, and attention over |
| 47 | V.""" |
| 48 | |
| 49 | FULL = 2 |
| 50 | """Full activation recomputation stores the input to EVERY transformer layer, which |
| 51 | is sharded across the tensor parallel group, thus requiring an extra all-gather |
| 52 | (ignored for now) per layer and add communication overhead; requires the lease |
| 53 | amount of memory; requires an extra forward pass.""" |
| 54 | |
| 55 | |
| 56 | @total_ordering |
no outgoing calls