Commit ff98a05
authored
fix: eliminate 3rd forward pass in distillation (hidden state MSE) (#74)
The distillation loop was running 3 forward passes per chunk:
1. forward_gpu for logits (removed in PR #73)
2. forward_train for activations (kept)
3. forward_with_hidden_states for MSE loss ← REMOVED NOW
Now forward_train collects per-layer hidden states in TrainForwardOutput,
and the MSE loss uses those directly. One forward pass per chunk.
Impact: training step time drops by ~33% (was 2 forwards, now 1).
Estimated: ~100s/step → ~67s/step.1 parent cae68a0 commit ff98a05
2 files changed
Lines changed: 14 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1829 | 1829 | | |
1830 | 1830 | | |
1831 | 1831 | | |
1832 | | - | |
| 1832 | + | |
| 1833 | + | |
1833 | 1834 | | |
1834 | | - | |
1835 | | - | |
1836 | | - | |
| 1835 | + | |
| 1836 | + | |
1837 | 1837 | | |
1838 | 1838 | | |
1839 | | - | |
1840 | 1839 | | |
1841 | 1840 | | |
1842 | 1841 | | |
| |||
1851 | 1850 | | |
1852 | 1851 | | |
1853 | 1852 | | |
1854 | | - | |
1855 | | - | |
| 1853 | + | |
1856 | 1854 | | |
1857 | | - | |
| 1855 | + | |
1858 | 1856 | | |
1859 | 1857 | | |
1860 | 1858 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| 67 | + | |
| 68 | + | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
| |||
218 | 222 | | |
219 | 223 | | |
220 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
221 | 228 | | |
222 | 229 | | |
223 | 230 | | |
| |||
236 | 243 | | |
237 | 244 | | |
238 | 245 | | |
239 | | - | |
| 246 | + | |
240 | 247 | | |
241 | 248 | | |
242 | 249 | | |
| |||
0 commit comments