Commit 7753e39
committed
fix(path-c): flatten+contiguify 4-D arrays to blockscaled sparse-MLA's flat-1D ABI (RULE #1 FIRE)
blockscaled_sparse_mla_apply_kernel declares a flat 1-D ABI for every buffer, but both wrappers
passed raw 4-D/3-D arrays straight through -> 4-D-vs-1-D mismatch -> tvm-ffi returns NULL
(SystemError: ffi.Function returned NULL), correctly re-raised by the force_path_c guard. Broken
clear path = missing flatten.
Fix: add a contiguity-correct helper `_flat_1d_view(a) = mx.contiguous(a.reshape((a.size,)))`; wrap
every kernel buffer at both call sites (graph-output apply + _direct), incl. the _direct out_buf/
lse_buf owner outputs (flattened in, reshaped back after the in-place write).
Metal: blockscaled-prepared-small parity PASSED; graph + _direct routes max_abs 0.0 vs reference;
13->14 passed (updated the owner-output ABI test that encoded the buggy raw-4D pass-through; +new
_direct owner-output regression). No ffi-NULL, no fallback (fail-fast raises untouched).1 parent 8f90919 commit 7753e39
2 files changed
Lines changed: 118 additions & 23 deletions
File tree
- cppmega_mlx/nn/_tilelang
- tests
Lines changed: 36 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
141 | 154 | | |
142 | 155 | | |
143 | 156 | | |
| |||
1365 | 1378 | | |
1366 | 1379 | | |
1367 | 1380 | | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
1368 | 1387 | | |
1369 | 1388 | | |
1370 | | - | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
1374 | | - | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
1375 | 1394 | | |
1376 | | - | |
| 1395 | + | |
1377 | 1396 | | |
1378 | 1397 | | |
1379 | 1398 | | |
| |||
1386 | 1405 | | |
1387 | 1406 | | |
1388 | 1407 | | |
1389 | | - | |
| 1408 | + | |
1390 | 1409 | | |
1391 | | - | |
| 1410 | + | |
1392 | 1411 | | |
1393 | 1412 | | |
1394 | | - | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
1395 | 1417 | | |
1396 | 1418 | | |
1397 | 1419 | | |
| |||
1476 | 1498 | | |
1477 | 1499 | | |
1478 | 1500 | | |
1479 | | - | |
1480 | | - | |
1481 | | - | |
1482 | | - | |
1483 | | - | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
1484 | 1506 | | |
1485 | 1507 | | |
1486 | 1508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
249 | 252 | | |
250 | 253 | | |
251 | 254 | | |
| |||
277 | 280 | | |
278 | 281 | | |
279 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
280 | 286 | | |
281 | | - | |
282 | | - | |
| 287 | + | |
| 288 | + | |
283 | 289 | | |
284 | 290 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
292 | 302 | | |
293 | 303 | | |
294 | 304 | | |
| |||
385 | 395 | | |
386 | 396 | | |
387 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
0 commit comments