optimize=True crashes on the first generate() when no C compiler is installed (fallback in optimize() never triggers)
What happens
With the default optimize=True, on a machine that has Triton but no C compiler (for example a pytorch/pytorch:2.9.1-cuda12.8-cudnn9-runtime based image), optimize() returns without any warning and the first generation fails:
torch._inductor.exc.InductorError: RuntimeError: Failed to find C compiler. Please specify via CC environment variable or set triton.knobs.build.impl.
With VoxCPM.from_pretrained(...) this happens during the warm-up generate() in __init__.
Why
optimize() in src/voxcpm/model/voxcpm.py and voxcpm2.py wraps torch.compile(...) in try/except and falls back to eager mode on error. torch.compile does not compile at that point, though; Triton builds its launcher (and looks for $CC / gcc / clang) on the first call of the compiled function, which is outside the try block, so the fallback never runs.
Reproduction (torch 2.9.1+cu128, triton 3.5.1, voxcpm 2.0.3, PATH without gcc/clang and no CC):
import types, torch, torch.nn as nn
from voxcpm.model.voxcpm2 import VoxCPM2Model
class Lm(nn.Module):
def __init__(self):
super().__init__(); self.l = nn.Linear(16, 16)
def forward_step(self, x):
return torch.relu(self.l(x))
m = types.SimpleNamespace(device="cuda", base_lm=Lm().cuda(), residual_lm=Lm().cuda(),
feat_encoder=nn.Linear(16, 16).cuda(),
feat_decoder=types.SimpleNamespace(estimator=nn.Linear(16, 16).cuda()))
VoxCPM2Model.optimize(m) # no warning printed
m.feat_encoder(torch.randn(4, 16, device="cuda"))
# InductorError: RuntimeError: Failed to find C compiler. ...
With gcc on PATH the same code runs. Workarounds today are installing a compiler or passing optimize=False; neither is mentioned in the FAQ's torch.compile section.
Suggested fix
Check for a compiler next to the existing import triton check in optimize(), so the existing fallback path prints a warning and runs eager. I have a small PR ready for this.
Environment: Linux, Python 3.11, torch 2.9.1+cu128, triton 3.5.1, voxcpm 2.0.3 (the optimize() code is the same on main).
This report was drafted with AI assistance and reviewed by me.