unslothai/unsloth · error · ValueError

'{family_name}' needs diffusers ({pipeline_class}), but this

Error message

'{family_name}' needs diffusers ({pipeline_class}), but this diffusers exports it as a placeholder, which it does when a backend it requires is unavailable. That class requires: {', '.join(dummy_backends)}. Check which of those this environment is missing and install it.

What it means

diffusers imports and exports the family's pipeline class, but as a placeholder ('dummy') object — the class diffusers substitutes when an optional backend it requires (torch, transformers, etc.) is unavailable at diffusers' own import time. Strict mode refuses before training, because the trainer child would import the same placeholder and its from_pretrained would fail only after the GPU residents were freed. The message lists exactly which backends that class requires.

Source

Thrown at studio/backend/core/inference/diffusion_families.py:1160

        # The attribute probe is inside the try for the same reason. diffusers' top level is a lazy module, so
        # ``hasattr`` is what actually imports the pipeline's submodule, and when that submodule's own dependencies
        # are unsatisfiable it raises RuntimeError ("Failed to import diffusers.pipelines...") -- which hasattr does
        # NOT swallow, since it only absorbs AttributeError. A partially usable diffusers install therefore escaped
        # this guard exactly the way a missing one used to.
        if strict:
            raise ValueError(
                f"'{family_name}' needs diffusers ({pipeline_class}), which this environment "
                f"cannot import: {exc}. Install or repair it with: pip install -U diffusers."
            ) from None
        return

    if present and dummy_backends:
        # A placeholder, not the pipeline. Under the default this is left alone like every other
        # unusable install; strict refuses, because the trainer child imports the same placeholder
        # and its from_pretrained raises only after the GPU residents are gone.
        if not strict:
            return
        raise ValueError(
            f"'{family_name}' needs diffusers ({pipeline_class}), but this diffusers exports it as "
            f"a placeholder, which it does when a backend it requires is unavailable. That class "
            f"requires: {', '.join(dummy_backends)}. Check which of those this environment is "
            f"missing and install it."
        )

    if present:
        return
    raise ValueError(
        _too_old_message(
            pipeline_class, family_name, str(getattr(diffusers, "__version__", "unknown"))
        )
    )


def family_probe_class(fam: Any) -> str:
    """The class whose presence in the installed diffusers actually proves ``fam`` is loadable.

View on GitHub (pinned to 203007d190)

Solutions

  1. Read the message's required-backends list and install/upgrade the named one(s), usually: pip install -U torch transformers
  2. Then verify the placeholder is gone: python -c "import diffusers; print(type(diffusers.<PipelineClass>))" — it must not be a DummyObject
  3. If constraints force the old backend, downgrade diffusers to a version whose requirements match, and drop the new-family pick
  4. Re-run the training request after repairing the environment

Example fix

# before
# torch too old for installed diffusers -> dummy pipeline class -> ValueError

# after
pip install -U torch transformers   # the backends named in the message
python -c "import diffusers, torch; print(type(diffusers.FluxPipeline))"  # real class, not DummyObject
Defensive patterns

Strategy: validation

Validate before calling

def pipeline_class_real(pipeline_class: str) -> bool:
    try:
        import diffusers
        from diffusers.utils.dummy_pt_objects import DummyObject  # or equivalent dummy base
        cls = getattr(diffusers, pipeline_class, None)
        return cls is not None and not isinstance(cls, type) or (
            isinstance(cls, type) and not issubclass(cls, DummyObject)
        )
    except Exception:
        return False

Try / catch

try:
    validate_family_pipeline(pipeline_class, family_name, strict=True)
except ValueError as e:
    # message names the exact missing backends; install them before retrying training
    return bad_request(str(e))

Prevention

When it happens

Trigger: Training a family whose pipeline_class exists on diffusers but _dummy_required_backends() reports non-empty backends — typically an incompatible/downgraded torch or transformers relative to the installed diffusers, so diffusers could not construct the real pipeline class.

Common situations: Downgrading torch for another component leaves diffusers' backend check unsatisfied; a fresh venv where transformers is missing or too old; mixing pip and conda installs so diffusers sees a different torch; environments pinned to older backends than the new families (Flux2Klein, Z-Image, LTX-2, ...) require.

Related errors


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