trellis-2-mrp-mlx/trellis2/modules
Pedro Augusto 2780bc459a sparse/config: probe flex_gemm on MPS, soft-fall-back to pytorch backend
The default Darwin path used to be a try/except ImportError, which only
catches build failures. With the mtlgemm round 1 fixes shipped, the more
common failure mode for end users will be running an *older* mtlgemm that
still returns CPU tensors from MPS calls — that doesn't fail import, it
fails with a cryptic LayerNorm crash inside the model on the first conv.

The new probe runs a tiny SparseConv3d on MPS and checks the output
device. If anything breaks (import, build, dispatch, return-device), fall
back to the pure-PyTorch backend rather than crashing inside the model.

Tensors in the probe are built on CPU then moved to MPS because some
PyTorch builds lack int/fp16 torch.zeros kernels on MPS — that's a
PyTorch issue, separate from anything we control here.

Plus: end-to-end smoke test (test_flex_gemm_integration.py) that
exercises both Algorithm.IMPLICIT_GEMM and Algorithm.MASKED_IMPLICIT_GEMM
through a real SparseConv3d → F.layer_norm chain on MPS. Confirms both
algorithms return MPS tensors of the right dtype and produce equivalent
output.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-17 07:51:05 +03:00
..
attention Init Release 2025-12-16 19:00:42 +00:00
sparse sparse/config: probe flex_gemm on MPS, soft-fall-back to pytorch backend 2026-07-17 07:51:05 +03:00
transformer Init Release 2025-12-16 19:00:42 +00:00
image_feature_extractor.py add mlx backend for apple silicon with metal gpu acceleration 2026-07-17 07:51:05 +03:00
norm.py Init Release 2025-12-16 19:00:42 +00:00
spatial.py Init Release 2025-12-16 19:00:42 +00:00
utils.py Init Release 2025-12-16 19:00:42 +00:00