unslothai/unsloth · error · RuntimeError

Could not install mamba-ssm, required by this Mamba model.

Error message

Could not install mamba-ssm, required by this Mamba model.

What it means

Raised by the SSM runtime bootstrap when a Mamba model is selected but _install_kernel() could not make the 'mamba_ssm' import available — the helper tried the configured install path (pinned PyPI version MAMBA_SSM_PACKAGE_VERSION or the release artifacts at MAMBA_SSM_RELEASE_BASE_URL/MAMBA_SSM_RELEASE_TAG) and it failed. Note causal-conv1d failure is tolerated (torch fallback), but mamba-ssm itself is mandatory, hence the hard RuntimeError.

Source

Thrown at studio/backend/utils/ssm_runtime.py:446

        package_version = CAUSAL_CONV1D_PACKAGE_VERSION,
        release_tag = CAUSAL_CONV1D_RELEASE_TAG,
        release_base_url = CAUSAL_CONV1D_RELEASE_BASE_URL,
        status_cb = status_cb,
        run = run,
    ):
        logger.warning("causal-conv1d unavailable; continuing on the model's torch fallback")

    if is_ssm and not _install_kernel(
        import_name = "mamba_ssm",
        display_name = "mamba-ssm",
        pypi_name = "mamba-ssm",
        package_version = MAMBA_SSM_PACKAGE_VERSION,
        release_tag = MAMBA_SSM_RELEASE_TAG,
        release_base_url = MAMBA_SSM_RELEASE_BASE_URL,
        status_cb = status_cb,
        run = run,
    ):
        raise RuntimeError("Could not install mamba-ssm, required by this Mamba model.")

View on GitHub (pinned to 203007d190)

Solutions

  1. Check the installer status output (status_cb messages) for the concrete sub-failure — wheel download error vs build failure.
  2. Verify torch/CUDA versions and install a mamba-ssm build matching them (pip install mamba-ssm==<MAMBA_SSM_PACKAGE_VERSION> with the right --index-url for your CUDA).
  3. On a restricted network, pre-download the wheel from the release tag at MAMBA_SSM_RELEASE_BASE_URL and install it manually, then restart so the import check passes.
  4. If no compatible build exists for your stack, use a non-Mamba model or an environment where the pinned combination is known to work.
Defensive patterns

Strategy: try-catch

Validate before calling

def mamba_deps_ready() -> bool:
    try:
        import mamba_ssm  # noqa: F401
        return True
    except ImportError:
        return False

if model_arch == 'mamba' and not mamba_deps_ready():
    warn_user('mamba-ssm will be installed on first Mamba load; ensure network + matching torch/CUDA')

Try / catch

try:
    load_model(model_id)  # Mamba model triggers kernel bootstrap
except RuntimeError as e:
    if 'Could not install mamba-ssm' in str(e):
        surface_to_user('mamba-ssm install failed; check network/torch-CUDA pairing, '
                        'or pip install mamba-ssm manually and retry')
    else:
        raise

Prevention

When it happens

Trigger: Loading a Mamba-architecture model when mamba_ssm is not installed and the bootstrap installer fails — unsupported torch/CUDA combination for the pinned wheels, offline machine with no cached artifacts, build-from-source failure (no compiler/CUDA toolkit), or a version mismatch between the pinned mamba-ssm release and the installed torch.

Common situations: New environment without mamba-ssm preinstalled; torch upgraded to a version with no matching prebuilt mamba-ssm wheel; air-gapped or proxy-restricted network blocking PyPI/GitHub release downloads; Windows where mamba-ssm builds routinely fail.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/532258048986b7a5. Report an issue: GitHub.