sgl-project/sglang · error · ImportError

Please install diso via `pip install diso`, or set mc_algo t

Error message

Please install diso via `pip install diso`, or set mc_algo to 'mc'

What it means

DMCSurfaceExtractor.run lazily imports the diso package (DiffDMC, differentiable marching cubes) on first use. If diso is not installed in the environment, the ImportError is caught and re-raised with this actionable message. The marching-cubes-alternative is the pure-Python skimage-based MCSurfaceExtractor, selectable via mc_algo='mc'.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/vaes/hunyuan3d_vae.py:1084

        grid_size, bbox_min, bbox_size = self._compute_box_stat(
            bounds, octree_resolution
        )
        vertices = vertices / grid_size * bbox_size + bbox_min
        return vertices, faces


class DMCSurfaceExtractor(SurfaceExtractor):
    """Differentiable Marching Cubes surface extractor."""

    def run(self, grid_logit, *, octree_resolution, **kwargs):
        device = grid_logit.device
        if not hasattr(self, "dmc"):
            try:
                from diso import DiffDMC

                self.dmc = DiffDMC(dtype=torch.float32).to(device)
            except ImportError:
                raise ImportError(
                    "Please install diso via `pip install diso`, or set mc_algo to 'mc'"
                )
        sdf = -grid_logit / octree_resolution
        sdf = sdf.to(torch.float32).contiguous()
        verts, faces = self.dmc(sdf, deform=None, return_quads=False, normalize=True)
        verts = center_vertices(verts)
        vertices = verts.detach().cpu().numpy()
        faces = faces.detach().cpu().numpy()[:, ::-1]
        return vertices, faces


SurfaceExtractors = {
    "mc": MCSurfaceExtractor,
    "dmc": DMCSurfaceExtractor,
}


class VectsetVAE(nn.Module, LayerwiseOffloadableModuleMixin):

View on GitHub (pinned to 0132848349)

Solutions

  1. pip install diso (needs a CUDA toolchain and matching torch version to compile the extension)
  2. Or switch to marching cubes: pass mc_algo='mc' when enabling the decoder so MCSurfaceExtractor (scikit-image) is used
  3. Verify the install with `python -c "from diso import DiffDMC"` and check the torch/CUDA version match if it still fails
  4. Ensure scikit-image is installed if you fall back to mc

Example fix

// before
extractor = DMCSurfaceExtractor()
mesh = extractor(grid_logits)  # ImportError

// after
extractor = MCSurfaceExtractor()
mesh = extractor(grid_logits, mc_level=0.0, bounds=bounds, octree_resolution=resolution)
Defensive patterns

Strategy: fallback

Validate before calling

try:
    from diso import DiffDMC  # noqa: F401
    mc_algo = 'dmc'
except ImportError:
    mc_algo = 'mc'  # skimage-based fallback, requires scikit-image
import skimage  # ensure fallback dependency present

Try / catch

try:
    mesh = dmc_extractor(grid_logits, octree_resolution=res)
except ImportError as e:
    if 'diso' in str(e):
        mesh = mc_extractor(grid_logits, mc_level=0.0, bounds=bounds, octree_resolution=res)
    else:
        raise

Prevention

When it happens

Trigger: Constructing or calling DMCSurfaceExtractor (mc_algo='dmc' / default when FlashVDM decoding is enabled via enable_flashvdm_decoder) in an environment where `import diso` fails — either the package is missing or its CUDA extension failed to build/load.

Common situations: Running Hunyuan3D VAE mesh extraction without installing the diso dependency; diso installed for a different torch/CUDA version so the import raises ImportError on extension load; lightweight CPU-only deployments that never needed diso before enabling FlashVDM.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/b845a9ed102f8048. Report an issue: GitHub.