Commit 6969a64
committed
feat(path_c): device-resident gridded BACKWARD (B0/B1/B2) — CUDA pass_configs + delegation wire + RULE #1 no-numpy-fallback + gb10 probe
Make the MR region's backward device-resident gridded (mirrors the forward
77cb4a6+b961c6d), removing the abstract numpy host backward (the §15 79.6%@8l /
91.4%@28l wall) as a SILENT fallback.
1. CUDA pass_configs (mamba3_chunked_backward_core.py): thread
pass_configs={tl.disable_tma_lower:True, tl.disable_warp_specialized:True} into
each of build_chunk_scan_combine_bwd_metal / build_inter_chunk_recur_bwd_metal /
build_chunk_precompute_bwd_metal ONLY on the resolved CUDA branch, mirroring
compile_chunk_scan_fwd_metal exactly. The B0/B1/B2 prim BODIES have ZERO T.gemm /
shared.dyn / make_swizzled_layout (grep-confirmed) so NO new CUDA sibling prim is
needed. Metal default path is byte-identical (else branch unchanged).
2. Backward delegation: the existing interpose already routes the 3 bwd ops
(_MAMBA3_CHUNKED_GRID_DELEGATION_OPS, descriptors, production_source,
fragment_emitters, BWD handoff ABI buffers) via the direct-chain region path with
the flag ON. Added register_real_backward_driver + make_real_bank_backward_driver
(path_c_relax_train_step.py), symmetric to register_real_forward_driver, to drive
the real gridded backward MR kernel (run_backward=1) over the bank ABI for the
bank-SSA train_step path (device-resident, no host bounce).
3. RULE #1 (no silent numpy fallback): register_bank_drivers
(path_c_relax_step_banks.py) now RAISES with WHERE+WHAT when the chunked flag is
ON and the real gridded bank backward is NOT installed — instead of silently
binding pathc.bank_bwd_* to the numpy _region_bwd_driver. set_real_bank_bwd_installed
clears the guard once register_real_backward_driver runs (and stops the numpy bwd
from clobbering the real binding). Explicit CPU self-check escape:
CPPMEGA_PATH_C_ALLOW_NUMPY_BANK_BWD=1. Flag OFF (default) = byte-identical to before.
4. Probe scratch/probe_chunked_backward_cuda_gb10.py: prod shape (b=1,S=4096,c=64,
G=8,H=112,P=64,N=64); seeds deterministic inputs + cotangent; builds the gridded
forward cache (F0/F1, target=cuda) + serial y; runs B2->B1->B0 (pre-zeroed fp32
out, dx accumulated B2 D-skip then B0 inp-path); reference = MLX-free torch.autograd
VJP of OUR exact serial recurrence (GOLD oracle); asserts all 8 model-facing grads
max|abs|<1e-3 over ALL elements + NaN/inf guard; times B0/B1/B2 per-call; prints a
machine-parseable RESULT json. RULE #1: any grad over gate or NaN RAISES.
NO GPU on this Mac: edits + py_compile/AST + cross-module symbol checks only;
gb10 compile/run is the Profile agent's single-run step.1 parent 820c25e commit 6969a64
4 files changed
Lines changed: 819 additions & 5 deletions
File tree
- cppmega_mlx
- nn/_tilelang
- runtime
- scratch
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
422 | 443 | | |
423 | 444 | | |
424 | 445 | | |
425 | | - | |
| 446 | + | |
426 | 447 | | |
427 | 448 | | |
428 | 449 | | |
| |||
596 | 617 | | |
597 | 618 | | |
598 | 619 | | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
599 | 641 | | |
600 | 642 | | |
601 | 643 | | |
602 | | - | |
| 644 | + | |
603 | 645 | | |
604 | 646 | | |
605 | 647 | | |
| |||
852 | 894 | | |
853 | 895 | | |
854 | 896 | | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
855 | 918 | | |
856 | 919 | | |
857 | 920 | | |
858 | | - | |
| 921 | + | |
859 | 922 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
298 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
299 | 374 | | |
300 | 375 | | |
301 | 376 | | |
302 | | - | |
303 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
304 | 381 | | |
305 | 382 | | |
306 | 383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
246 | 247 | | |
247 | 248 | | |
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 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
249 | 393 | | |
250 | 394 | | |
251 | 395 | | |
| |||
0 commit comments