Extracted from lato.2_mrp_mlx. The same sparse module underlies LATO.2, Pixal3D and the rest of the TRELLIS.2 family, and all of them are blocked on Apple Silicon by the same single op - submanifold conv - so it belongs in one tested package rather than vendored per port. 13/13 tests: 7 for the conv against a hand-written reference (spconv is uninstallable here so there is no upstream oracle), 6 for the remaining layers against torch. SubMConv3d runs 13.8ms at 128^3/128ch on m3ultra, 5.9x faster than the obvious per-offset loop.
39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
"""MLX implementation of the TRELLIS-lineage sparse module.
|
|
|
|
Microsoft's TRELLIS.2 sparse stack has been inherited, near-verbatim, by a growing
|
|
family of 3D generation models — LATO.2 and TencentARC's Pixal3D among them. All of
|
|
them hard-require spconv or torchsparse, neither of which has a Metal build, and that
|
|
single dependency is what keeps the whole lineage off Apple Silicon.
|
|
|
|
The blocker is one operation: submanifold 3x3x3 convolution. Every SparseConv3d in
|
|
these models is constructed `stride=1, padding=None`, which spconv dispatches to
|
|
SubMConv3d. Implement that in MLX and the rest is ordinary linear/norm/attention work.
|
|
|
|
Packaged separately from any one model so each port depends on a tested core rather
|
|
than vendoring its own copy.
|
|
"""
|
|
|
|
from .conv import SubMConv3d, build_indice_map
|
|
from .tensor import SparseTensor, downsample, subdivide
|
|
from .ops import (
|
|
LayerNorm32,
|
|
SparseFeedForwardNet,
|
|
SparseGELU,
|
|
SparseGroupNorm32,
|
|
SparseLinear,
|
|
SparseMultiHeadAttention,
|
|
SparseResBlock,
|
|
SparseSiLU,
|
|
SparseTransformerBlock,
|
|
SparseTransformerCrossBlock,
|
|
)
|
|
|
|
__all__ = [
|
|
"SparseTensor", "subdivide", "downsample",
|
|
"SubMConv3d", "build_indice_map",
|
|
"SparseLinear", "LayerNorm32", "SparseGroupNorm32", "SparseSiLU", "SparseGELU",
|
|
"SparseResBlock", "SparseFeedForwardNet", "SparseMultiHeadAttention",
|
|
"SparseTransformerBlock", "SparseTransformerCrossBlock",
|
|
]
|
|
__version__ = "0.1.0"
|