Commit f23a673
committed
feat(mamba3-pathc): dtype-bridge fix + flag-ON chunked route runs END-TO-END on Metal
Resolve the handoff dtype/ABI bridge so the flag-ON chunked mamba3 direct-chain
route runs a full fwd+bwd Path-C step end-to-end on Metal (finite loss, all 6
chunked grid segments execute, ~2.8-3.5x faster than the 6.106s serial baseline).
All edits gated on the delegated-kernel ABI attrs -> flag default OFF is byte-
unchanged (merge-safe).
Fixes (RULE #1: no silent precision loss; every cast is an explicit graph op;
owner buffers keep model-policy dtype):
1. Producer/consumer dtype split: per-segment role map
(_cppmega_path_c_delegated_kernel_buffer_roles); owner allocates each handoff
buffer at its PRODUCER dtype, consumer slots cast-at-bind. A delegated OUTPUT
consumed by the serial graph (brick delta) keeps the serial model-ABI
dtype/shape (fp32) and the producer casts/reshapes on writeback.
2. _path_c_cast_kernel_buffer_dtype (consumer read cast) +
_path_c_torch_mps_to_mlx writeback of delegated out_idx returns.
3. _path_c_direct_chain_model_param_aliases: {brick}_D/_A -> _mamba3_D/_mamba3_A_log.
4. Delegated binding-readiness branch (bind compiled JITKernels by name; a
JITKernel has no TIR physical_abi_map).
5. _path_c_call_delegated_metal_artifact_with_mlx_bridge: the delegated grid
kernels are tilelang TORCH-MPS artifacts (reject MLX arrays) -> bridge MLX
owner buffers <-> torch MPS so the chunked segments actually execute.
UNLOCK PROOF (Metal, local_gb10_quarter, seq=128): flag-ON chunked route runs
end-to-end, loss=5.5452 FINITE, 6 chunked segs (F0/F1/F2+B2/B1/B0) execute,
fwd+bwd 1.75-2.21s vs 6.106s serial. Chunked backward kernels parity-verified at
kernel level (b0b1b2: 11 passed, worst 3.83e-4).
NOT YET full 163-grad parity: a SEPARATE downstream gap (the flag-ON chain omits
the non-mamba backward segments, so the mamba delta_grad cotangent is unseeded ->
chunked bwd runs with zero cotangent -> zero mamba grads; only 2 suffix grads
return). NEXT: emit non-mamba backward segments + map chunked grad-output names
into the model grad tree (chain/grad-tree assembly, not a dtype/ABI bridge).
Merge-safety (flag OFF): 124 fusion-IR/autosplit passed; 11 chunked-bwd kernel
parity passed; m04 direct-chain 82 passed / 3 pre-existing failures (verified
identical on clean base via git stash).
Doc: scratch/MAMBA3-RUNTIME-WIRING-RESULTS.md (RESOLUTION section).1 parent 55d878e commit f23a673
4 files changed
Lines changed: 654 additions & 13 deletions
File tree
- cppmega_mlx/runtime
- scratch
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2406 | 2406 | | |
2407 | 2407 | | |
2408 | 2408 | | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
2409 | 2424 | | |
2410 | 2425 | | |
2411 | 2426 | | |
| |||
2441 | 2456 | | |
2442 | 2457 | | |
2443 | 2458 | | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
2444 | 2462 | | |
2445 | 2463 | | |
2446 | 2464 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 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 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
172 | 184 | | |
173 | 185 | | |
174 | 186 | | |
| |||
179 | 191 | | |
180 | 192 | | |
181 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
182 | 216 | | |
183 | 217 | | |
184 | 218 | | |
| |||
0 commit comments