LLVM ERROR: Failed to compute parent layout for slice layout.
Hi I trying to perform example.py on V100, But I get an error LLVM ERROR: Failed to compute parent layout for slice layout.
I use ATTN_BACKEND=xformers, and casting model to float32:
The error occurs on hr_coords = self.models['shape_slat_decoder'].upsample(slat, upsample_times=4) in /trellis2/pipelines/trellis2_image_to_3d.py
What do I need to do to resolve this error?
Hi there! Just wondering how you eventually resolved this issue?
Fix: LLVM ERROR: Failed to compute parent layout for slice layout on pre-Ampere GPUs (V100 / sm_70)
TL;DR
One line, in trellis2/modules/sparse/conv/config.py:
-FLEX_GEMM_ALGO = 'masked_implicit_gemm_splitk'
+FLEX_GEMM_ALGO = 'explicit_gemm'
That is the whole fix. TRELLIS.2 then runs to completion on a V100 and produces a clean, watertight, correctly-textured GLB.
Do not work around this with SPARSE_CONV_BACKEND=spconv. See the warning below —
it stops the crash and silently corrupts the output instead.
Why this is hard to find
Three things conspire to hide it.
1. There is no traceback. LLVM ERROR: ... comes from
llvm::report_fatal_error() inside Triton's TritonGPU backend, which calls
abort(). The process dies on SIGABRT with no Python stack, so you learn that a
kernel failed but never which one, or from where.
You can recover the stack — faulthandler installs a SIGABRT handler:
import faulthandler
faulthandler.enable(all_threads=True)
That alone turns this from a mystery into a five-minute diagnosis. It prints the full Python stack at the moment of the abort:
flex_gemm/kernels/triton/spconv/sparse_submanifold_conv_fwd_masked_implicit_gemm_splitk.py:153
flex_gemm/utils/autotuner.py:277 _benchmark
flex_gemm/ops/spconv/submanifold_conv3d.py:202 _sparse_submanifold_conv_forward
trellis2/modules/sparse/conv/conv_flex_gemm.py:46 sparse_conv3d_forward
trellis2/models/sc_vaes/sparse_unet_vae.py:521 upsample
trellis2/pipelines/trellis2_image_to_3d.py:328 sample_shape_slat_cascade
This matches the report in #89 exactly — the OP identified
self.models['shape_slat_decoder'].upsample(...) as the failure point.
Note where it dies: inside the autotuner. FlexGEMM benchmarks candidate configs,
and compiling one of them is what aborts. This is consistent with #12, where a V100
user hits No autotune configuration found for the current platform and device from
the same flex_gemm.kernels.triton.spconv package — pre-Ampere simply is not covered.
2. Setting the algorithm from outside does not work. The obvious fix is:
import flex_gemm.ops.spconv as s
s.set_algorithm(s.Algorithm.EXPLICIT_GEMM) # appears to work, then aborts anyway
It appears to apply — printing ALGORITHM confirms it — and then aborts regardless,
because of trellis2/modules/sparse/conv/conv_flex_gemm.py:38:
def sparse_conv3d_forward(self, x: SparseTensor) -> SparseTensor:
flex_gemm.ops.spconv.set_algorithm(config.FLEX_GEMM_ALGO) # every forward pass
TRELLIS.2 re-asserts its own value on every single forward pass, so anything set from outside the library is overwritten microseconds later.
3. There are two modules named config. This is the part that cost the most time:
trellis2/modules/sparse/config.py— has a__from_env(), but it only readsSPARSE_CONV_BACKEND,SPARSE_DEBUG, andSPARSE_ATTN_BACKEND/ATTN_BACKEND.trellis2/modules/sparse/conv/config.py— whereFLEX_GEMM_ALGOactually lives. It reads no environment at all.
conv_flex_gemm.py does from . import config, so it is the second one. If you go
looking for FLEX_GEMM_ALGO in the file that has the env-var plumbing, it is not there.
There is no environment variable for it anywhere in the codebase.
Why explicit_gemm
FlexGEMM offers five algorithms. Only explicit_gemm runs through torch ops instead of
Triton — submanifold_conv3d.py:115 is explicit about it:
assert spconv.ALGORITHM == Algorithm.EXPLICIT_GEMM, \
"Only explicit_gemm is supported for torch implementation"
So it cannot reach the Triton compiler, and therefore cannot hit the abort. The
trade-off is memory: explicit GEMM materialises the gather rather than fusing it.
Peak VRAM measured 14.09 GiB for a 2K-texture single-object run, which fits
comfortably on a 32 GB V100. On a 16 GB card you may need to lower texture_size.
A version that does not need editing on every machine
If you would rather not hand-edit a vendored file, append this to
trellis2/modules/sparse/conv/config.py. It makes the value selectable and picks a
safe default on any pre-Ampere card:
def __from_env():
"""FLEX_GEMM_ALGO is hardcoded upstream and its Triton kernel aborts the whole
process on sm_70. Only explicit_gemm avoids Triton entirely."""
import os
global FLEX_GEMM_ALGO
valid = ('explicit_gemm', 'implicit_gemm', 'implicit_gemm_splitk',
'masked_implicit_gemm', 'masked_implicit_gemm_splitk')
env = os.environ.get('TRELLIS2_FLEX_GEMM_ALGO')
if env in valid:
FLEX_GEMM_ALGO = env
return
try:
import torch
if torch.cuda.is_available() and torch.cuda.get_device_capability()[0] < 8:
FLEX_GEMM_ALGO = 'explicit_gemm'
except Exception:
pass
__from_env()
WARNING: SPARSE_CONV_BACKEND=spconv is not a safe workaround
This is the natural thing to try, and it does stop the crash. It also silently produces broken geometry.
Same input image, same model, same weights, same everything except
SPARSE_CONV_BACKEND. Both runs completed without error:
flex_gemm + explicit_gemm |
spconv |
|
|---|---|---|
| Crashes | no | no |
| Connected components | 64 | 12,500 |
| Largest component | 99.10% of faces | 0.09% of faces |
| Faces left after removing islands | 982,226 | 814 |
| Peak VRAM | 14.09 GiB | 2.67 GiB |
| GLB size | 35.0 MiB | 20.3 MiB |
The spconv output is not a surface. It is ~12,500 disconnected specks arranged in a roughly humanoid cloud — it renders like a point cloud, and removing the islands from a 910,403-face mesh leaves 814 faces, because there is no body in there to keep.
If that symptom sounds familiar, it may be worth a look from anyone on #99 ("outputs point cloud / voxel samples instead of a surface mesh"), though that report is on Blackwell and I have only verified this on sm_70.
A useful smell test: peak VRAM. Explicit GEMM materialises the gather, so a real 2K-texture run sits around 14 GiB. If a TRELLIS.2 run peaks at 2-4 GiB, you are probably on the spconv path and your mesh is confetti. That number is what finally told me an earlier run I had recorded as "working" had never been working at all.
A crash you can debug. Output that looks plausible but is shattered into thousands of disconnected components — with a texture whose channels run outside [0, 1] — will cost you far more. If you have been using the spconv fallback on a pre-Ampere card, re-check your meshes.
Verification
Same input image, V100 32 GB, explicit_gemm. Connectivity is measured after welding
vertices by position — UV unwrapping duplicates a vertex on every atlas seam (247,871
of them here), and counting connected components without collapsing those reports
fragmentation that is an artifact of the atlas, not the geometry.
| Measure | Broken | Fixed | Expected |
|---|---|---|---|
| Connected components | 11,990 | 62 | few |
| Largest component | 0.07% | 99.10% | ~100% |
| V/F ratio (welded) | 9.72 – 14.15 | 0.495 | ~0.5 |
| Boundary edges | — | 4 of 1,481,786 (0.0003%) | 0 |
| base_color range | −1.77 … +2.42 | 0.004 … 0.906 | 0 … 1 |
| alpha range | −1.01 … +2.19 | 0.992 … 1.000 | 0 … 1 |
| Saturation (steel armour) | 0.60 | 0.012 | < 0.12 |
| Metallic | — | 0.99 | ~1.0 |
base_color R/G/B average 0.383 / 0.381 / 0.380 — neutral grey to three decimals, at metallic 0.99, which is what a suit of plate armour should bake to.
Environment this was verified on
GPU Tesla V100 32 GB (sm_70, compute capability 7.0)
torch 2.6.0+cu124
triton 3.2.0
xformers ATTN_BACKEND=xformers (flash-attn is sm_80+)
spconv spconv-cu124 2.3.8 (installed, but NOT used as the conv backend)
model microsoft/TRELLIS.2-4B
OS Ubuntu 22.04, CUDA 12.4
TORCH_CUDA_ARCH_LIST=7.0
Two other pre-Ampere fixes needed alongside this
These are separate problems; you will likely hit them on the way.
bf16 (issue #23). The flow models are configured bf16, and bf16 hardware arrived
with Ampere — xformers' only pre-Ampere backend (cutlassF) rejects it outright.
Converting after construction leaves weights and self.dtype inconsistent, because
convert_module_to only touches selected submodules. Rewrite the config before the
model is built, in trellis2/models/__init__.py:
with open(config_file, 'r') as f:
config = json.load(f)
_args = config.get('args', {})
if _args.get('dtype') in ('bf16', 'bfloat16') and torch.cuda.is_available():
if torch.cuda.get_device_capability()[0] < 8:
_args['dtype'] = 'float16'
model = __getattr__(config['name'])(**config['args'], **kwargs)
The model is then constructed fp16, so buffers, submodule selection, and the
manual_cast(h, self.dtype) calls in forward all agree. Credit to NiklasVoigt in #23
for the approach; the maintainer confirms in that thread that casting to fp16 or fp32
is expected to work.
DINOv3 .layer (issue #147). On recent transformers, DINOv3ViTModel no longer
exposes .layer directly — it is .model.layer. Resolve whichever exists at runtime
rather than pinning transformers:
layers = getattr(m, 'layer', None)
if layers is None:
layers = m.model.layer
Suggested upstream change
FLEX_GEMM_ALGO is the only one of the three sparse-conv settings with no environment
variable, and it is the one whose wrong value kills the process. Two small changes would
have saved everyone in #89, #23 and #12 a lot of time:
- Read
FLEX_GEMM_ALGOin__from_env()like the other settings, and default it toexplicit_gemmwhentorch.cuda.get_device_capability()[0] < 8. - Have
conv_flex_gemm.py:38set the algorithm once at init instead of on every forward pass, so an externalset_algorithm()is not silently undone.