Commit f443aaf
committed
feat(v3-1): stage_train honors OptimKind + extras.optimizer_kind + model_summary
Closes V3-1 / cppmega-mlx-wly. Fixes 3 confirmed UI→API→training bugs:
B1: stage_train hardcoded optim.AdamW. Lion/Lion8bit/Adam8bit/Muon/
Muon_AdamW_Hybrid/SGD selected in UI OptimTab were silently ignored
at train. Now _build_optimizer(spec_optim, lr) dispatches every
OptimKind through cppmega_mlx.training.optimizers factories.
B1-bis: build_model raised "unsupported optimizer kind" for Lion/Lion8bit/
Adam8bit. Pipeline orchestrator swallowed the BuildError and marked
train "skipped" — UI showed superficial green. Now build_model wires
these three through the same factories.
B1-tris: _make_optim dropped ns_steps and schedule when converting wire
payload to OptimSpec. Muon-from-UI failed validation; scheduled groups
silently lost their lr curve. Now both fields thread through with
kind-aware defaults.
V3-3 (model_summary helper) lands alongside: _summarize_model surfaces
mlp_activation, attention pre/post_norm, mlp pre/post_norm, optimizer_kind,
schedule_kind, num_brick_kinds — enables UI-side assertions that a brick
context change reached training.
Also fixed: stage_train's forward chain silently zeroed gradients for
every q/k/v after attention because attention's zero-init-out (o_proj=
zeros for identity-at-init) killed downstream gradient flow. Real
transformer blocks have residuals; now stage_train adds residual when
shapes match so gradients propagate as in production.
19 new pytest in tests/v4/test_stage_train_optimizers.py. Regression
92/92 across pipeline + schedules + jsonrpc_methods + new file.1 parent d71c482 commit f443aaf
4 files changed
Lines changed: 410 additions & 48 deletions
File tree
- cppmega_v4
- buildspec
- jsonrpc
- runner
- tests/v4
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
| |||
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
| 78 | + | |
70 | 79 | | |
| 80 | + | |
| 81 | + | |
71 | 82 | | |
72 | | - | |
| 83 | + | |
73 | 84 | | |
74 | 85 | | |
75 | 86 | | |
| |||
235 | 246 | | |
236 | 247 | | |
237 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
238 | 274 | | |
239 | | - | |
| 275 | + | |
240 | 276 | | |
241 | 277 | | |
242 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 47 | | |
59 | 48 | | |
60 | 49 | | |
| |||
94 | 83 | | |
95 | 84 | | |
96 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
126 | 151 | | |
127 | 152 | | |
128 | 153 | | |
129 | 154 | | |
130 | 155 | | |
131 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
132 | 163 | | |
133 | 164 | | |
134 | 165 | | |
135 | | - | |
| 166 | + | |
136 | 167 | | |
137 | 168 | | |
138 | 169 | | |
| |||
0 commit comments