A FactorizationSpec describes how to factorize a parameter's gradient. Used by AdaFactor optimizer for memory-efficient second-moment estimation by factorizing the second-moment matrix into row and column statistics instead of storing the full matrix. Attributes: axes: A list o
| 129 | |
| 130 | @dataclasses.dataclass |
| 131 | class FactorizationSpec: |
| 132 | """A FactorizationSpec describes how to factorize a parameter's gradient. |
| 133 | |
| 134 | Used by AdaFactor optimizer for memory-efficient second-moment estimation by factorizing |
| 135 | the second-moment matrix into row and column statistics instead of storing the full matrix. |
| 136 | |
| 137 | Attributes: |
| 138 | axes: A list of None/str corresponding to the axes of the parameter shape. |
| 139 | Each element is either: |
| 140 | - None: no factorization along this axis. |
| 141 | - str: the factorization axis name (typically "row" or "col"). |
| 142 | |
| 143 | For AdaFactor, either: |
| 144 | - All axes are None (no factorization, used for small parameters) |
| 145 | - Exactly two axes are "row" and "col" (factorized, used for large matrices) |
| 146 | |
| 147 | Example: |
| 148 | For a weight matrix of shape [1024, 4096]: |
| 149 | axes=["row", "col"] enables factorization |
| 150 | |
| 151 | For a 3D tensor of shape [8, 1024, 4096]: |
| 152 | axes=[None, "row", "col"] factorizes only the last two dimensions |
| 153 | """ |
| 154 | |
| 155 | axes: Sequence[Optional[str]] |
| 156 | |
| 157 | |
| 158 | # Ideally this would be a recursive type: |
no outgoing calls