Torch Lattice
torch-lattice is the Torch/CUDA training-side companion to
mlx-lattice. It keeps the sparse
model authoring and CUDA provenance workflow on the Torch side, then exports
portable lattice MLIR artifacts for MLX/Metal deployment.
torch-lattice is a project-owned fork of MIT HAN Lab's TorchSparse. The public
semantics are aligned to mlx-lattice and the lattice MLIR contract rather than
to historical TorchSparse API quirks.
Documentation | MLX Lattice | PyPI | Acknowledgements
Install
For normal use, install the published package from PyPI:
uv add torch-lattice --torch-backend cu128
If you are installing into an existing environment instead of adding a project dependency, use:
uv pip install --torch-backend cu128 torch-lattice
The published wheel targets Python 3.14 and the PyTorch CUDA 12.8 wheel stack. At runtime, the important requirement is a Linux system with a compatible NVIDIA driver for the CUDA runtime provided by PyTorch. A local CUDA toolkit is only needed when building from source or developing the native extension.
For development from a checkout:
uv sync --all-packages --extra test
The repository also provides a CUDA Linux GitHub workflow that builds and smoke checks the native CUDA wheel on an Ubuntu runner.
Relationship to MLX Lattice
The two packages are intentionally split by runtime role:
torch-latticeis the CUDA training and artifact-production side.mlx-latticeis the Apple Silicon inference and deployment side.lattice-contractdefines the shared artifact constants and MLIR contract metadata used by both sides.
Portable artifacts use graph.mlir plus weights.safetensors. Torch-side
exporters write those files; MLX-side artifact loading compiles them into an
executable MLX program.
Convolution semantics
Convolution classes are explicit:
torch_lattice.nn.Conv3dis forward support-generating sparse convolution and exports tolattice.conv3d, includingstride=1. Calling the same module asconv(x, coordinates=target)exports target-aligned convolution without a separate module class.torch_lattice.nn.SubmConv3dis support-preserving submanifold convolution and exports tolattice.subm_conv3d.torch_lattice.nn.ConvTranspose3dexports tolattice.conv_transpose3d.torch_lattice.nn.GenerativeConvTranspose3dexports tolattice.generative_conv_transpose3d.
Artifact builders lower module identity directly. They do not infer submanifold semantics from stride, padding, or legacy indice-key conventions.
Tooling
After uv sync --all-packages, use the workspace scripts from the repository
root:
uv run bench --preset smoke
uv run fuzz --cases 32 --device cuda --archive /tmp/torch_lattice_fuzz.tar.gz
uv run conformance fuzz --cases 32 --device cuda
uv run migration all --device cuda
The corresponding MLX-side replay command is:
uv run conformance replay /tmp/torch_lattice_fuzz.tar.gz \
--report /tmp/torch_lattice_fuzz_report.json
Migration compatibility checks
Original TorchSparse and torch-lattice are not assumed to have identical class
semantics. The supported migration rule is explicit:
- original
torchsparse.nn.Conv3d(kernel_size > 1, stride = 1)maps totorch_lattice.nn.SubmConv3d; - original pointwise
Conv3d(kernel_size = 1)maps totorch_lattice.nn.Conv3d; - original strided forward convolutions map to
torch_lattice.nn.Conv3dwith the same stride.
The migration CLI verifies the covered subset against a kept original
TorchSparse package/worktree in separate subprocesses.
Documentation
The full documentation is hosted at torch-lattice.iki.moe:
The source for the documentation lives in docs/. Build it locally
with:
uv sync --group docs --no-install-workspace
uv run --no-sync sphinx-build -W -b html docs docs/_build/html
Development
Common local checks:
uv run --all-packages --extra test pytest tests -q
uv run bench --list
Build CUDA Linux distributions locally with:
export CUDA_PATH=/usr/local/cuda-12.8
uv build \
--sdist \
--wheel \
--config-setting=cmake.define.CMAKE_CUDA_COMPILER="$CUDA_PATH/bin/nvcc" \
--config-setting=cmake.define.CUDAToolkit_ROOT="$CUDA_PATH"
Acknowledgements
torch-lattice is based on MIT HAN Lab's original
TorchSparse project.
It is developed together with
mlx-lattice, which provides the
MLX/Metal deployment runtime for the same artifact contract.
License
Open sourced under the MIT license.
Metadata
Release files for torch-lattice 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torch_lattice-0.5.0.tar.gz | 240.8 kB | Without provenance | Details for torch_lattice-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torch_lattice-0.5.0-cp314-cp314-manylinux_2_34_x86_64.whl | CPython 3.14 | CPython 3.14 | Linux glibc 2.34+ x86-64 | Details for torch_lattice-0.5.0-cp314-cp314-manylinux_2_34_x86_64.whl |
Total release size: 7.4 MB
Release files / torch_lattice-0.5.0.tar.gz
| Download URL | torch_lattice-0.5.0.tar.gz |
|---|---|
| Size | 240.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c300927cd8b99b7014c8b619349e2b36e52738711b7d1cb95d246e6d04dcf0a6
|
|
BLAKE2b-256 checksum How to use checksums |
980e61741219721abbdf53ff672f00461ea430953cd5be15a84c057d2dc9b9fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / torch_lattice-0.5.0-cp314-cp314-manylinux_2_34_x86_64.whl
| Download URL | torch_lattice-0.5.0-cp314-cp314-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 7.1 MB |
| Tags | CPython 3.14 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
0f09e7d5e61c4ed04d915a3e08df097a76efd01d55344af321020e53cafb40a5
|
|
BLAKE2b-256 checksum How to use checksums |
ea69570cc85e72ffdec9c2657e3d49ddecbfb0e8aa06220ebbe211dfc113e160
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for torch-lattice 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.