Skip to content

Commit b961c6d

Browse files
committed
test(path_c): e2e probe — MR delegation interpose builds CUDA grid scan on gb10
scratch/probe_mr_chunked_delegation_cuda_gb10.py exercises the ONE wiring site the flag-ON region build calls to replace the MR serial scan (_mamba3_chunked_grid_delegation_prim) with a production local_gb10_quarter shape_env on a real CUDA host. MEASURED on gb10 (path_c default target = cuda): [mamba3_chunk_precompute] delegation -> JITKernel OK (CUDA grid kernel) [mamba3_inter_chunk_recur] delegation -> JITKernel OK (CUDA grid kernel) [mamba3_chunk_scan_combine] delegation -> JITKernel OK (CUDA grid kernel) === DELEGATION: PASS === Confirms the MR mamba sub-region is driven by the gridded chunked SSD scan through the REAL path_c plumbing (not just isolated builders): the interpose passes target=cuda + block_Dstate=dstate and returns compiled CUDA JITKernels, never the serial T.Kernel(1) recurrence.
1 parent 77cb4a6 commit b961c6d

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""End-to-end check: the path_c delegation interpose builds the CUDA grid scan.
2+
3+
Exercises ``_mamba3_chunked_grid_delegation_prim`` (the ONE wiring site that the
4+
flag-ON region build calls to replace the MR serial scan) with a production
5+
``local_gb10_quarter`` shape_env, on a CUDA host. Confirms it returns a COMPILED
6+
CUDA JITKernel for the F0/F1/F2 forward ops (not the Metal default, not the serial
7+
T.Kernel(1)). This proves the MR mamba sub-region is driven by the gridded scan.
8+
"""
9+
10+
import sys
11+
import traceback
12+
13+
from cppmega_mlx.runtime import path_c_fusion_schedules as S
14+
from cppmega_mlx.runtime import path_c_fusion as F
15+
16+
17+
class _ShapeEnv:
18+
sequence_length = 4096
19+
mamba_num_heads = 112
20+
mamba_head_dim = 64
21+
mamba_state_dim = 64
22+
mamba_groups = 8
23+
24+
25+
OPS = {
26+
"mamba3_chunk_precompute":
27+
"cppmega_mlx.nn._tilelang.mamba3_chunked_precompute_core:"
28+
"build_chunk_precompute_metal/chunk_precompute_fwd_metal_prim",
29+
"mamba3_inter_chunk_recur":
30+
"cppmega_mlx.nn._tilelang.mamba3_chunked_precompute_core:"
31+
"build_inter_chunk_recur_metal/inter_chunk_recur_fwd_metal_prim",
32+
"mamba3_chunk_scan_combine":
33+
"cppmega_mlx.nn._tilelang.mamba3_chunked_scan_core:"
34+
"build_chunk_scan_combine_metal/chunk_scan_fwd_metal_prim",
35+
}
36+
37+
38+
def main():
39+
tgt = F._path_c_default_target()
40+
print("=== MR chunked-scan delegation interpose probe ===")
41+
print("path_c default target:", tgt)
42+
if tgt != "cuda":
43+
print("NOT a CUDA host; this probe must run on gb10")
44+
sys.exit(2)
45+
se = _ShapeEnv()
46+
ok = True
47+
for op_name, src in OPS.items():
48+
try:
49+
k = S._mamba3_chunked_grid_delegation_prim(
50+
op_name=op_name, production_source=src, shape_env=se, batch=1)
51+
kt = type(k).__name__
52+
# The compiled JITKernel carries the compiled artifact; a serial
53+
# T.Kernel(1) would never reach here (different code path).
54+
print(f"[{op_name}] delegation -> {kt} OK (CUDA grid kernel)")
55+
except Exception:
56+
print(f"[{op_name}] delegation FAILED:")
57+
traceback.print_exc()
58+
ok = False
59+
print("\n=== DELEGATION:", "PASS" if ok else "FAIL", "===")
60+
sys.exit(0 if ok else 1)
61+
62+
63+
if __name__ == "__main__":
64+
main()

0 commit comments

Comments
 (0)