exo-explore/exo · error · ValueError

Model must have either a 'layers' or 'h' attribute

Error message

Model must have either a 'layers' or 'h' attribute

What it means

Error "Model must have either a 'layers' or 'h' attribute" thrown in exo-explore/exo.

Source

Thrown at src/exo/worker/engines/mlx/auto_parallel.py:241

    inner = getattr(model, "backbone", None)
    if isinstance(inner, nn.Module):
        return inner

    raise ValueError(
        "Model must either have a 'model', 'transformer', or 'backbone' attribute"
    )


def get_layers(inner_model_instance: nn.Module) -> list[_LayerCallable]:
    # Handle both model.layers and model.h cases
    layers: list[_LayerCallable]
    if hasattr(inner_model_instance, "layers"):
        layers = cast(list[_LayerCallable], inner_model_instance.layers)
    elif hasattr(inner_model_instance, "h"):
        layers = cast(list[_LayerCallable], inner_model_instance.h)
    else:
        raise ValueError("Model must have either a 'layers' or 'h' attribute")

    return layers


def _patch_hybrid_cache(
    model: Qwen3_5TextModel | Qwen3NextModel | NemotronHModel,
    fa_idx: int,
    has_full_attn: bool,
    ssm_idx: int,
    has_linear: bool,
) -> None:
    # Hacks to make make_mask happy.
    original = model.make_cache

    def patched() -> list[ArraysCache | KVCache]:
        cache = original()
        if not has_full_attn:
            entry = cache[fa_idx]

View on GitHub (pinned to 21a54c5ea0)

When it happens

Trigger: Thrown at src/exo/worker/engines/mlx/auto_parallel.py:241 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of exo-explore/exo@21a54c5ea0 (2026-08-26). Data as JSON: /api/errors/06915248b0bc768b. Report an issue: GitHub.