MCPcopy Create free account
hub / github.com/apple/axlearn / FactorizationSpec

Class FactorizationSpec

axlearn/common/base_layer.py:131–155  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

129
130@dataclasses.dataclass
131class 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:

Calls

no outgoing calls

Tested by 8

testParityMethod · 0.72
test_partition_fnMethod · 0.72
test_all_maskMethod · 0.72
test_learnerMethod · 0.72
test_learner_configMethod · 0.72
mock_updatesFunction · 0.72
test_param_specsMethod · 0.72