Commit 54332ac
committed
fix(path-c): Metal BACKWARD watchdog cap + row-chunk independent heavy bwd ops; isolate mamba3 compiler-crash blocker
Clears the FIRST full-scale direct-chain BACKWARD watchdog blocker (region
..._chain_7_10) and the m2rnn_bwd watchdog, and precisely isolates the remaining
deeper blocker (mamba3_mimo_bwd Metal pipeline-state compiler crash).
ROOT CAUSE (measured at full local_gb10_quarter: depth=13 hidden=3584 max_seq=4096,
each backward op ISOLATED in a FRESH process so a prior GPU error does not pollute):
seg op dispatch shader monolithic result
--- ------------------------------ -------------- ------- -----------------------------
4 sparse_mla_fp8_apply_bwd grid_chunks 88 KB ~12s -> WATCHDOG TIMEOUT
(+attn_qkv_bwd+rmsnorm_bwd grid_chunks 115 KB ~10-25s -> WATCHDOG (chain_7_10)
fused as 3-op ..._chain_7_10)
5 attention_qkv_projection_bwd grid_chunks 40 KB ~10s -> WATCHDOG TIMEOUT
7 m2rnn_bwd launcher_chunks 64 KB 512 launches x ~4.0s (near edge)
9 mamba3_mimo_bwd launcher_chunks 129 KB XPC COMPILER CRASH
9 mamba3_mimo_bwd grid_chunks 127 KB XPC COMPILER CRASH
Key findings:
* The watchdog at ..._chain_7_10 is NOT just "several ops summing in one command
buffer": BOTH sparse_mla_fp8_apply_bwd AND attention_qkv_projection_bwd time out
the ~5-6s macOS GPU watchdog even ISOLATED in a 1-op grid_chunks command buffer.
These ops are per-row-INDEPENDENT (each output row depends only on its own input
row + shared weights; NO carried reverse-time state).
* mamba3_mimo_bwd CRASHES MTLCompilerService at newComputePipelineState
(XPC_ERROR_CONNECTION_INTERRUPTED) in BOTH grid_chunks AND launcher_chunks at
full scale. The kernel is a fixed ~127 KB / 114-MSL-loop body INDEPENDENT of
hidden_size (tested 896/1792/3584) and sequence_length (tested 512/2048/4096) --
only runtime loop bounds change, never the emitted code. The metallib build
succeeds; the crash is the lazy AIR->GPU-ISA pipeline-state stage. fix (d)'s
premise ("mamba3 monolithic is watchdog-safe at production S") is FALSE at full
hidden=3584: mamba3 backward does not compile to a pipeline state in any
dispatch mode. Splitting that single op's 114-loop emitter into multiple
pipeline states is a codegen restructure (cppmega Python descriptor fragment
emitter) with gradient-correctness risk -- left as the documented deeper blocker.
FIX (Metal-gated; CUDA unchanged; explicit by target/op; RULE #1: route RAISES on
failure, no silent fallback):
* METAL_BACKWARD_MAX_SEGMENT_NODES = 1 (resolve-from-target sentinel; CUDA=None) --
sibling of METAL_FORWARD_MAX_SEGMENT_NODES. Splits the 3-op ..._chain_7_10
backward mega-kernel into one segment per op. New planner param
backward_max_segment_nodes on plan_path_c_direct_fusion_chain_for_region /
plan_path_c_direct_fusion_chains_for_model.
* _ROW_CHUNKED_INDEPENDENT_BACKWARD_OPS = {sparse_mla_fp8_apply_bwd,
attention_qkv_projection_bwd} -- these per-row-independent heavy ops now take the
SAME launcher_chunks row-windowing as the recurrent reverse-scan ops, splitting
each into K=512 command buffers of 8 rows. No carry buffers are added for them
(_row_phased_launcher_carry_buffers_for_nodes adds carries ONLY for mamba3/m2rnn);
path_c_first_row_launch zeroes owner grads once on (chunk 0, subchunk 0).
VERIFIED (full local_gb10_quarter scale, real measurements):
* sparse_mla_fp8_apply_bwd row-chunked: ran END-TO-END status=ok, 512 launches,
~1.3s/launch, total wall 676.9s -- NO watchdog timeout (was ~12s monolithic kill).
* attention_qkv_projection_bwd row-chunked: ~0.42s/launch -- watchdog-safe.
* Determinism: the 12 (sparse_mla: 9) DIRECT-WRITE grad buffers are BIT-EXACT
(max_abs_diff = 0.0) across two independent row-windowed runs on identical
inputs; only the relaxed-T.atomic_add reductions (rope_inv_freq_grad,
residual_norm_hidden_grad) vary by ~5e-6 float-reassociation noise, which is
dispatch-independent and inherent to the op -- NOT a row-chunking bug.
* Full-scale chain now plans + native-compiles all 11 segments (forward 4 + backward
7). New grouping: bwd seg4 sparse_mla(launcher), seg5 attn_qkv(launcher),
seg6 rmsnorm(grid), seg7 m2rnn(launcher), seg8 rmsnorm(grid),
seg9 mamba3(launcher, COMPILER-CRASHES at pipeline state), seg10 entry_rmsnorm(grid).
* Smoke-scale executor test runs the FULL route end-to-end status=ok with the new
11-segment grouping (mamba3 compiles at hidden=16).
REMAINING BLOCKER: the full backward cannot complete end-to-end at full scale
because mamba3_mimo_bwd does not compile to a Metal pipeline state (127 KB / 114
loops) in any dispatch mode. This is the next deeper fix (split the mamba3 backward
emitter into multiple pipeline states), not a watchdog/grouping issue.
Tests: test_path_c_fusion_ir.py 119 passed (was 116/3-fail: fixed 3 stale
"blocked"->"ready" mamba3-no-longer-blocked-in-planner assertions). Updated 6
m04 tests for the legitimately-changed Metal backward grouping (11 segments;
+5 cross-segment backward grads exposed by the split: qkv q/kv fp8+scale grads +
R residual_norm_hidden_grad). Remaining m04 failures are pre-existing on baseline
(CLI/data/JSONDecodeError/tokens), unrelated to this change.
Probe scripts (full-scale reproducers): scripts/_bwdgate_per_segment_probe.py,
_bwdgate_launch_probe.py, _bwdgate_rowchunk_probe.py, _bwdgate_granularity_probe.py,
_bwdgate_determinism_probe.py.1 parent 154ce8f commit 54332ac
8 files changed
Lines changed: 874 additions & 89 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
164 | 197 | | |
165 | 198 | | |
166 | 199 | | |
| |||
231 | 264 | | |
232 | 265 | | |
233 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
234 | 292 | | |
235 | 293 | | |
236 | 294 | | |
| |||
246 | 304 | | |
247 | 305 | | |
248 | 306 | | |
| 307 | + | |
249 | 308 | | |
250 | 309 | | |
251 | 310 | | |
| |||
14230 | 14289 | | |
14231 | 14290 | | |
14232 | 14291 | | |
| 14292 | + | |
| 14293 | + | |
| 14294 | + | |
14233 | 14295 | | |
14234 | 14296 | | |
14235 | 14297 | | |
| |||
14249 | 14311 | | |
14250 | 14312 | | |
14251 | 14313 | | |
14252 | | - | |
14253 | | - | |
14254 | | - | |
14255 | | - | |
14256 | | - | |
| 14314 | + | |
| 14315 | + | |
| 14316 | + | |
| 14317 | + | |
| 14318 | + | |
| 14319 | + | |
| 14320 | + | |
| 14321 | + | |
| 14322 | + | |
| 14323 | + | |
| 14324 | + | |
| 14325 | + | |
| 14326 | + | |
| 14327 | + | |
| 14328 | + | |
| 14329 | + | |
14257 | 14330 | | |
14258 | 14331 | | |
14259 | 14332 | | |
| |||
14279 | 14352 | | |
14280 | 14353 | | |
14281 | 14354 | | |
| 14355 | + | |
| 14356 | + | |
| 14357 | + | |
| 14358 | + | |
| 14359 | + | |
| 14360 | + | |
| 14361 | + | |
| 14362 | + | |
| 14363 | + | |
| 14364 | + | |
| 14365 | + | |
| 14366 | + | |
| 14367 | + | |
| 14368 | + | |
| 14369 | + | |
| 14370 | + | |
| 14371 | + | |
14282 | 14372 | | |
14283 | 14373 | | |
14284 | 14374 | | |
| |||
14335 | 14425 | | |
14336 | 14426 | | |
14337 | 14427 | | |
| 14428 | + | |
| 14429 | + | |
| 14430 | + | |
| 14431 | + | |
| 14432 | + | |
| 14433 | + | |
| 14434 | + | |
| 14435 | + | |
| 14436 | + | |
| 14437 | + | |
| 14438 | + | |
| 14439 | + | |
| 14440 | + | |
| 14441 | + | |
| 14442 | + | |
| 14443 | + | |
| 14444 | + | |
| 14445 | + | |
| 14446 | + | |
14338 | 14447 | | |
14339 | 14448 | | |
14340 | 14449 | | |
| |||
14372 | 14481 | | |
14373 | 14482 | | |
14374 | 14483 | | |
| 14484 | + | |
| 14485 | + | |
| 14486 | + | |
| 14487 | + | |
| 14488 | + | |
| 14489 | + | |
| 14490 | + | |
| 14491 | + | |
| 14492 | + | |
| 14493 | + | |
| 14494 | + | |
| 14495 | + | |
| 14496 | + | |
| 14497 | + | |
| 14498 | + | |
14375 | 14499 | | |
14376 | 14500 | | |
14377 | 14501 | | |
14378 | 14502 | | |
14379 | 14503 | | |
14380 | | - | |
| 14504 | + | |
| 14505 | + | |
| 14506 | + | |
| 14507 | + | |
14381 | 14508 | | |
14382 | 14509 | | |
14383 | 14510 | | |
| |||
14480 | 14607 | | |
14481 | 14608 | | |
14482 | 14609 | | |
| 14610 | + | |
| 14611 | + | |
| 14612 | + | |
14483 | 14613 | | |
14484 | 14614 | | |
14485 | 14615 | | |
| |||
14490 | 14620 | | |
14491 | 14621 | | |
14492 | 14622 | | |
14493 | | - | |
14494 | | - | |
14495 | | - | |
| 14623 | + | |
| 14624 | + | |
| 14625 | + | |
14496 | 14626 | | |
14497 | 14627 | | |
14498 | 14628 | | |
| |||
14509 | 14639 | | |
14510 | 14640 | | |
14511 | 14641 | | |
| 14642 | + | |
14512 | 14643 | | |
14513 | 14644 | | |
14514 | 14645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
0 commit comments