mudler/LocalAI · error · ValueError
Could not find base class '{base_class_name}' in diffusers
Error message
Could not find base class '{base_class_name}' in diffusers What it means
Raised by the diffusers dynamic loader when building the pipeline registry: the requested base class name cannot be found on the top-level diffusers module nor in the 'schedulers', 'models', 'pipelines' submodules. The loader then cannot enumerate subclasses to populate the registry.
Source
Thrown at backend/python/diffusers/diffusers_dynamic_loader.py:180
import diffusers
# Try to get the base class from diffusers
base_class = None
try:
base_class = getattr(diffusers, base_class_name)
except AttributeError:
# Try to find in submodules
for submodule in ['schedulers', 'models', 'pipelines']:
try:
module = importlib.import_module(f'diffusers.{submodule}')
if hasattr(module, base_class_name):
base_class = getattr(module, base_class_name)
break
except (ImportError, ModuleNotFoundError):
continue
if base_class is None:
raise ValueError(f"Could not find base class '{base_class_name}' in diffusers")
registry: Dict[str, Type] = {}
# Include base class if requested
if include_base:
registry[base_class_name] = base_class
# Scan diffusers module for subclasses
for attr_name in dir(diffusers):
try:
attr = getattr(diffusers, attr_name)
if (isinstance(attr, type) and
issubclass(attr, base_class) and
(include_base or attr is not base_class)):
registry[attr_name] = attr
except (ImportError, AttributeError, TypeError, RuntimeError, ModuleNotFoundError):
continue
View on GitHub (pinned to 44413a9d06)
Solutions
- Print [c for c in dir(diffusers) if 'Pipeline' in c] against the installed diffusers to find the current class name.
- Upgrade/downgrade diffusers to the version the backend code was written against (check the backend image's requirements pin).
- Use the canonical base class 'DiffusionPipeline' unless a specific subclass registry is required.
- Fix the typo/case of base_class_name at the call site.
Defensive patterns
Strategy: validation
Validate before calling
import diffusers
assert hasattr(diffusers, base_class_name) or any(
hasattr(importlib.import_module(f'diffusers.{m}'), base_class_name)
for m in ('schedulers', 'models', 'pipelines')
), f"base class {base_class_name} absent from diffusers {diffusers.__version__}" Type guard
def base_class_exists(name: str) -> bool:
import diffusers
if hasattr(diffusers, name):
return True
return any(
hasattr(importlib.import_module(f'diffusers.{m}'), name)
for m in ('schedulers', 'models', 'pipelines')
) Try / catch
try:
registry = _discover_pipelines(base_class_name)
except ValueError as e:
logger.error("%s (diffusers %s)", e, diffusers.__version__)
registry = _discover_pipelines("DiffusionPipeline") # only if fallback acceptable Prevention
- Pin the diffusers version the backend was built against.
- Prefer the canonical 'DiffusionPipeline' base for generic registries.
- Smoke-test registry discovery at backend startup, not on first request.
When it happens
Trigger: get_pipeline_registry (or a caller) requests a base class name that does not exist in the installed diffusers version — e.g. a renamed or removed class, or a typo in the base_class_name argument.
Common situations: diffusers version drift (class renamed upstream, e.g. scheduler refactorings), a backend image pinned to an older diffusers while the code expects a newer class, or custom pipeline loading paths passing an arbitrary string as base class.
Related errors
- Unknown pipeline: {class_name}
- No job ID returned from server
- Invalid scheduler '{'k_' if is_karras else ''}{name}'
- Failed to load pipeline '{effective_pipeline_type}': {e}\nAv
- Unknown pipeline class '{class_name}'. Available pipelines:
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/0d1f41e9bc111dee.
Report an issue: GitHub.