Commit 55d878e
committed
feat(mamba3-pathc): runtime ABI-binder wiring for chunked delegation + unlock verification (verified partial)
Wire the flag-ON (CPPMEGA_PATH_C_MAMBA3_CHUNKED_SCAN, DEFAULT OFF) chunked
mamba3 F0/F1/F2 + B0/B1/B2 grid segments into the LIVE m04 direct-fusion-chain
runtime route. All edits are gated on the delegated-prim attr
_cppmega_path_c_mamba3_chunked_grid_delegation (None when flag OFF) -> flag-OFF
is byte-for-byte unchanged (diff is purely additive, 0 deletions).
Five binder sites reconciled so the 6 delegated COMPILED tilelang JITKernels
(unnamed positional KernelParam ABI) bind into the by-name direct-chain route:
1. _kernel_parameter_count_for_target: count device-buffer params via
KernelParam.is_scalar() instead of the unhashable buffer_map.get(param)
(was: TypeError unhashable KernelParam -> all 6 segs blocked -> chain blocked).
2. delegation interpose: attach _delegated_kernel_buffer_order (= region surface
node.inputs+node.outputs, VERIFIED 1:1 with kernel param slots for all 6 ops)
+ _shapes/_dtypes from the compiled slots; soft-skip on a partial/stub surface
so kernel-only unit tests are unaffected (real model surface reconciles -> ABI
attached on all 6).
3. path_c_kernel_buffer_order + _path_c_kernel_buffer_shapes: return the delegated
ordered names/shapes so the route arg-assembly binds positionally by name.
4. _path_c_direct_chain_required_logical_buffer_specs: register every delegated
buffer so the pre-step owner allocates the handoff buffers.
5. compile_path_c_direct_fusion_chain_artifacts: use the delegated JITKernel
DIRECTLY as the artifact (it is already the callable Metal kernel), skipping
compile_path_c_region/_module_from_template which RAISE on a non-PrimFunc.
UNLOCK VERIFICATION (scratch/verify_mamba3_chunked_runtime_unlock.py + RESULTS.md):
- Flag OFF (serial): m04 direct-chain route runs end-to-end -> chain ready,
14 segs, 0 chunked, install ok, loss=5.7134 FINITE, 163 grads, fwd+bwd 6.106s.
- Flag ON (chunked): chain now PLANS + COMPILES as `ready` with all 6 chunked
segments ok (was: blocked); ABI attached to all 6; pre-step owner allocation
REACHED. Route then RAISES (loud, RULE #1) at the ONE remaining gap: the
handoff/IO DTYPE BRIDGE (chunked kernels bind fp16 I/O vs fp32 owner policy;
prev_states has a genuine F1-fp32-write / F2-fp16-read split that the validated
kernel test bridges with an explicit .half() cast a single-owner buffer cannot
replicate). NOT yet end-to-end. Precise fix directions in RESULTS.md.
Merge-safety (flag default OFF), all GREEN: test_path_c_fusion_ir (119),
test_mamba3_chunked_backward_b0b1b2 + chained_forward_f0f1f2 (26, flag-ON kernel
parity bwd worst 3.84e-4), test_mamba3_pathc_chunked_forward_gate + dispatch (22),
test_path_c_autosplit_metal_parity (124). The 3 pre-existing m04 direct-chain test
failures pre-date this change (verified via git stash; unrelated JSON fixtures).
NOT pushed. Flag default OFF = merge-safe.1 parent 7945625 commit 55d878e
5 files changed
Lines changed: 533 additions & 0 deletions
File tree
- cppmega_mlx/runtime
- scratch
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2388 | 2388 | | |
2389 | 2389 | | |
2390 | 2390 | | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
2391 | 2450 | | |
2392 | 2451 | | |
2393 | 2452 | | |
| |||
16508 | 16567 | | |
16509 | 16568 | | |
16510 | 16569 | | |
| 16570 | + | |
| 16571 | + | |
| 16572 | + | |
| 16573 | + | |
| 16574 | + | |
| 16575 | + | |
| 16576 | + | |
| 16577 | + | |
| 16578 | + | |
| 16579 | + | |
| 16580 | + | |
| 16581 | + | |
| 16582 | + | |
| 16583 | + | |
| 16584 | + | |
| 16585 | + | |
| 16586 | + | |
| 16587 | + | |
| 16588 | + | |
| 16589 | + | |
| 16590 | + | |
| 16591 | + | |
16511 | 16592 | | |
16512 | 16593 | | |
16513 | 16594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
419 | 431 | | |
420 | 432 | | |
421 | 433 | | |
| |||
| 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 | + | |
0 commit comments