Error: bf16 is only supported on A100+ GPUs
When running in V100, I got errors below:
File "/root/miniconda3/envs/trellis2/lib/python3.10/site-packages/xformers/ops/fmha/dispatch.py", line 76, in _run_priority_list
raise NotImplementedError(msg)
NotImplementedError: No operator found for memory_efficient_attention_forward with inputs:
query : shape=(1, 4096, 12, 128) (torch.bfloat16)
key : shape=(1, 4096, 12, 128) (torch.bfloat16)
value : shape=(1, 4096, 12, 128) (torch.bfloat16)
attn_bias : <class 'NoneType'>
p : 0.0
[email protected] is not supported because:
requires device with capability > (9, 0) but your GPU has capability (7, 0) (too old)
bf16 is only supported on A100+ GPUs
[email protected] is not supported because:
requires device with capability > (8, 0) but your GPU has capability (7, 0) (too old)
bf16 is only supported on A100+ GPUs
cutlassF-pt is not supported because:
bf16 is only supported on A100+ GPUs
The flow-matching models are trained with BF16 precision. Manually casting them to Float16 or Float32 may resolve this issue, although I have not tested it. Using Float16 could potentially introduce numerical instability and cause the model to crash.
The flow-matching models are trained with BF16 precision. Manually casting them to Float16 or Float32 may resolve this issue, although I have not tested it. Using Float16 could potentially introduce numerical instability and cause the model to crash.
hi, when will the training code to be released?
Have you solved this problem and successfully deployed it on the V100?
The flow-matching models are trained with BF16 precision. Manually casting them to Float16 or Float32 may resolve this issue, although I have not tested it. Using Float16 could potentially introduce numerical instability and cause the model to crash.
Hi, I am casting model to Float32, but now i have error LLVM ERROR: Failed to compute parent layout for slice layout
There are any example for casting model to float32?
i had to downcast bf16 to fp16 for my quadro rtx 6000. simply add a little check for this into trellis2/models/init.py
49 + import torch
64 with open(config_file, 'r') as f:
65 config = json.load(f)
66 +
67 + # Auto-downcast bf16 to fp16 on GPUs that don't support bfloat16 (CC < 8.0)
68 + if config['args'].get('dtype') in ('bf16', 'bfloat16'):
69 + if torch.cuda.is_available():
70 + cap = torch.cuda.get_device_capability()
71 + if cap[0] < 8:
72 + config['args']['dtype'] = 'float16'
73 +
i also used os.environ['ATTN_BACKEND'] = 'xformers' in app.py
I hit this on a V100 (sm_70) and got all the way through to working output. Posting the full sequence because bf16 is only the first of three walls on pre-Ampere, and the second one is much harder to diagnose.
1. bf16 (this issue)
The flow models are configured bf16, and bf16 hardware arrived with Ampere — xformers'
only pre-Ampere backend (cutlassF) rejects it outright, which is the error above.
Converting the models after construction does not fully work: convert_module_to only
touches selected submodules, so weights and self.dtype end up inconsistent (I saw
flow-model weights still reporting float32 while self.dtype had flipped). 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 earlier
in this thread for the approach.
Pair it with ATTN_BACKEND=xformers (flash-attn is sm_80+).
2. LLVM ERROR: Failed to compute parent layout for slice layout
Once bf16 is sorted you will very likely hit this, which is #89 — closed, with the
question still unanswered. It is a hard abort() from inside Triton, so there is no
Python traceback at all.
Short version: trellis2/modules/sparse/conv/config.py hardcodes
FLEX_GEMM_ALGO = 'masked_implicit_gemm_splitk', whose Triton kernel cannot compile on
sm_70. Change it to 'explicit_gemm' — the only one of the five that runs through torch
ops instead of Triton.
Two traps: setting it via flex_gemm.ops.spconv.set_algorithm() does not work,
because conv_flex_gemm.py:38 re-asserts TRELLIS.2's own value on every forward pass;
and there are two modules named config, only one of which has the __from_env()
plumbing — FLEX_GEMM_ALGO lives in the other one and has no environment variable at all.
I have written that up in full detail on #89.
3. Do NOT reach for SPARSE_CONV_BACKEND=spconv
This is the natural way to dodge #89 and it is a trap. It does not crash — it silently produces a shattered mesh. Controlled A/B, same input image, both runs exiting 0:
| flex_gemm + explicit_gemm | spconv | |
|---|---|---|
| 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 |
The spconv output renders as a point cloud rather than a surface.
Useful smell test: peak VRAM. Explicit GEMM materialises the gather, so a real 2K-texture run sits near 14 GiB. If your run peaks at 2–4 GiB you are on the spconv path and your mesh is confetti — that number is what finally told me a run I had recorded as "working" had never worked.
Result on a V100 32 GB
With all three sorted: 62 connected components with the largest holding 99.10% of faces (one body plus a few dozen small islands), V/F 0.495 after welding, 4 boundary edges out of 1.48M, base_color in [0.004, 0.906], alpha in [0.992, 1.000], metallic 0.99. Peak VRAM 14.09 GiB.
GPU Tesla V100 32 GB (sm_70)
torch 2.6.0+cu124
triton 3.2.0
model microsoft/TRELLIS.2-4B
OS Ubuntu 22.04, CUDA 12.4
TORCH_CUDA_ARCH_LIST=7.0
I hit this on a V100 (sm_70) and got all the way through to working output. Posting the full sequence because bf16 is only the first of three walls on pre-Ampere, and the second one is much harder to diagnose.
1. bf16 (this issue)
The flow models are configured
bf16, and bf16 hardware arrived with Ampere — xformers' only pre-Ampere backend (cutlassF) rejects it outright, which is the error above.Converting the models after construction does not fully work:
convert_module_toonly touches selected submodules, so weights andself.dtypeend up inconsistent (I saw flow-model weights still reportingfloat32whileself.dtypehad flipped). Rewrite the config before the model is built, intrellis2/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 inforwardall agree. Credit to NiklasVoigt earlier in this thread for the approach.Pair it with
ATTN_BACKEND=xformers(flash-attn is sm_80+).2.
LLVM ERROR: Failed to compute parent layout for slice layoutOnce bf16 is sorted you will very likely hit this, which is #89 — closed, with the question still unanswered. It is a hard
abort()from inside Triton, so there is no Python traceback at all.Short version:
trellis2/modules/sparse/conv/config.pyhardcodesFLEX_GEMM_ALGO = 'masked_implicit_gemm_splitk', whose Triton kernel cannot compile on sm_70. Change it to'explicit_gemm'— the only one of the five that runs through torch ops instead of Triton.Two traps: setting it via
flex_gemm.ops.spconv.set_algorithm()does not work, becauseconv_flex_gemm.py:38re-asserts TRELLIS.2's own value on every forward pass; and there are two modules namedconfig, only one of which has the__from_env()plumbing —FLEX_GEMM_ALGOlives in the other one and has no environment variable at all.I have written that up in full detail on #89.
3. Do NOT reach for
SPARSE_CONV_BACKEND=spconvThis is the natural way to dodge #89 and it is a trap. It does not crash — it silently produces a shattered mesh. Controlled A/B, same input image, both runs exiting 0:
flex_gemm + explicit_gemm spconv 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 The spconv output renders as a point cloud rather than a surface.
Useful smell test: peak VRAM. Explicit GEMM materialises the gather, so a real 2K-texture run sits near 14 GiB. If your run peaks at 2–4 GiB you are on the spconv path and your mesh is confetti — that number is what finally told me a run I had recorded as "working" had never worked.
Result on a V100 32 GB
With all three sorted: 62 connected components with the largest holding 99.10% of faces (one body plus a few dozen small islands), V/F 0.495 after welding, 4 boundary edges out of 1.48M, base_color in [0.004, 0.906], alpha in [0.992, 1.000], metallic 0.99. Peak VRAM 14.09 GiB.
GPU Tesla V100 32 GB (sm_70) torch 2.6.0+cu124 triton 3.2.0 model microsoft/TRELLIS.2-4B OS Ubuntu 22.04, CUDA 12.4 TORCH_CUDA_ARCH_LIST=7.0
wow! Bravo
Adding to @Maulth's walkthrough from a second V100 32 GB (PCIe), with two more walls and some fp16 numbers:
explicit_gemmcan run a 32 GB card out of memory on a detailed input. It materialises the whole im2col (27× the input for a 3×3×3 kernel). The turret example (assets/example_image/0f168a4b…webp,1024_cascade) ran out at 31.6 GiB insubmanifold_conv3d. I opened JeffreyXiang/FlexGEMM#34, which builds the im2col in 512 MB row blocks (same result: fp32 relative error 2.6e-7 against a brute-force reference). With it the turret completes in 137 s, peaks at 15.4 GiB, and gives the same mesh on two runs.- fp16 headroom (re @JeffreyXiang's concern above): on that run the largest block output in the fp16 flow models was 14,336, against fp16's 65,504 limit, with no inf or NaN. One shape, so a data point rather than a guarantee.
- Two version pins: transformers 5.x renamed
DINOv3ViTModel's.layer(pin 4.57.6), and OpenCV 5.0 would not read the.exrenvironment map (pinopencv-python<5). - On 16 GB of system RAM, loading every sub-model on the CPU first used 16 GB plus 11 GB of swap; moving each to the GPU as it loads keeps host memory small.
torch 2.6.0+cu124, xformers 0.0.29.post3, triton 3.2.0, TORCH_CUDA_ARCH_LIST=7.0.
from_pretrained passed the checkpoint's configured dtype directly to the model constructor without checking the current CUDA device's compute capability.
For checkpoints configured as bf16 or bfloat16, from_pretrained now substitutes float16 before model construction when CUDA is available and the current device has compute capability below 8.0. The fallback emits a warning about FP16 overflow and numerical instability.
https://github.com/microsoft/TRELLIS.2/pull/200