Repository navigation
Commit 3535c92
authored
Honor norm_zero_centered_gamma in RMSNormWithInputScale (pytorch#22444)
Summary:
rlformers stores gamma offset by -1 when `norm_zero_centered_gamma` is set, so its `RMSNormWithInputScale` computes `rms_norm((weight + 1.0) * x)` (`core/model/transformer.py:208-211`). ET computed `rms_norm(weight * x)` unconditionally, and `norm_zero_centered_gamma` appeared in zero lines of ET — not on `ModelArgs`, not in `model_args_conversion.py`, not in `norm.py`. The flag was silently dropped, so a checkpoint carrying it loaded without error and produced systematically wrong activations from the first block onward.
Add `zero_centered_gamma` to `RMSNormWithInputScale` and `RMSNormWithInputScaleCoreML`, add `norm_zero_centered_gamma` to `ModelArgs`, plumb it through `get_et_model_args_from_genai_model_args`, and pass it where `post_ffn_norm` is built. It defaults to False, so no checkpoint without the flag changes behavior.
Reviewed By: Zhiwen-Owen-Jiang
Differential Revision: D117233461
Pull Request resolved: pytorch#224441 parent ade181b commit 3535c92
3 files changed
Lines changed: 34 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
248 | 252 | | |
249 | 253 | | |
250 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
190 | 194 | | |
191 | 195 | | |
192 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
107 | 114 | | |
108 | 115 | | |
109 | 116 | | |
| 117 | + | |
110 | 118 | | |
111 | 119 | | |
112 | 120 | | |
113 | | - | |
| 121 | + | |
| 122 | + | |
114 | 123 | | |
115 | 124 | | |
116 | 125 | | |
117 | 126 | | |
118 | | - | |
| 127 | + | |
119 | 128 | | |
120 | 129 | | |
121 | 130 | | |
| |||
139 | 148 | | |
140 | 149 | | |
141 | 150 | | |
| 151 | + | |
142 | 152 | | |
143 | 153 | | |
144 | 154 | | |
| |||
153 | 163 | | |
154 | 164 | | |
155 | 165 | | |
156 | | - | |
| 166 | + | |
| 167 | + | |
157 | 168 | | |
158 | 169 | | |
159 | 170 | | |
| |||
197 | 208 | | |
198 | 209 | | |
199 | 210 | | |
200 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
201 | 221 | | |
202 | 222 | | |
203 | 223 | | |
| |||
0 commit comments