huggingface/transformers · error · ValueError

The model's config file has neither `hidden_size` nor `hidde

Error message

The model's config file has neither `hidden_size` nor `hidden_sizes` entry, therefore it's not possible to automatically fill out the following `auto` entries in the DeepSpeed config file: {hidden_size_auto_keys}. You can fix that by replacing `auto` values for these keys with an integer value of your choice.

What it means

Error "The model's config file has neither `hidden_size` nor `hidden_sizes` entry, therefore it's not possible to automatically fill out the following `auto` entries in the DeepSpeed config file: {hidden_size_auto_keys}. You can fix that by replacing `auto` values for these keys with an integer value of your choice." thrown in huggingface/transformers.

Source

Thrown at src/transformers/integrations/deepspeed.py:222

        ]
        hidden_size_auto_keys = [x for x in hidden_size_based_keys if self.is_auto(x)]

        if len(hidden_size_auto_keys) > 0:
            hidden_size = None
            if hasattr(model, "config"):
                if hasattr(model.config, "hidden_size"):
                    hidden_size = model.config.hidden_size
                elif hasattr(model.config, "hidden_sizes"):
                    # if there are many hidden sizes pick the largest one
                    hidden_size = max(model.config.hidden_sizes)
                elif hasattr(model.config, "text_config") and hasattr(model.config.text_config, "hidden_size"):
                    hidden_size = model.config.text_config.hidden_size
                elif hasattr(model.config, "text_config") and hasattr(model.config.text_config, "hidden_sizes"):
                    # if there are many hidden sizes pick the largest one
                    hidden_size = max(model.config.text_config.hidden_sizes)

            if hidden_size is None:
                raise ValueError(
                    "The model's config file has neither `hidden_size` nor `hidden_sizes` entry, "
                    "therefore it's not possible to automatically fill out the following `auto` entries "
                    f"in the DeepSpeed config file: {hidden_size_auto_keys}. You can fix that by replacing "
                    "`auto` values for these keys with an integer value of your choice."
                )

            self.fill_only("zero_optimization.reduce_bucket_size", hidden_size * hidden_size)
            if self.is_zero3():
                # automatically assign the optimal config values based on model config
                self.fill_only(
                    "zero_optimization.stage3_prefetch_bucket_size",
                    int(0.9 * hidden_size * hidden_size),
                )
                self.fill_only(
                    "zero_optimization.stage3_param_persistence_threshold",
                    10 * hidden_size,
                )

View on GitHub (pinned to a597f97485)

Solutions

  1. Replace the 'auto' entries in the DeepSpeed config with explicit integers.
  2. Add `hidden_size` to the model config so auto-fill can work.

When it happens

Trigger: Raised in DeepSpeed config auto-fill when the model config has neither hidden_size nor hidden_sizes for 'auto' entries.

Common situations: DeepSpeed config with 'auto' hidden-size keys on a model whose config lacks any hidden size attribute.


AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14). Data as JSON: /api/errors/665f9707ccf97ce3. Report an issue: GitHub.