huggingface/transformers · error · ValueError

The `device_map` does not contain the module {param}.

Error message

The `device_map` does not contain the module {param}.

What it means

Error "The `device_map` does not contain the module {param}." thrown in huggingface/transformers.

Source

Thrown at src/transformers/integrations/accelerate.py:895

        )
        logger.info(
            f"Based on the current allocation process, no modules could be assigned to the following devices due to "
            f"insufficient memory:\n"
            f"{devices_info}\n"
            f"These minimum requirements are specific to this allocation attempt and may vary. Consider increasing "
            f"the available memory for these devices to at least the specified minimum, or adjusting the model config."
        )

    check_tied_parameters_on_same_device(tied_parameters, device_map)
    return device_map


def _get_param_device(param, device_map):
    if param in device_map:
        return device_map[param]
    parent_param = ".".join(param.split(".")[:-1])
    if parent_param == param:
        raise ValueError(f"The `device_map` does not contain the module {param}.")
    else:
        return _get_param_device(parent_param, device_map)


def check_tied_parameters_on_same_device(tied_params, device_map):
    """
    Check if tied parameters are on the same device

    Args:
        tied_params (`List[List[str]]`):
            A list of lists of parameter names being all tied together.

        device_map (`Dict[str, Union[int, str, torch.device]]`):
            A map that specifies where each submodule should go.

    """
    for tie_param in tied_params:
        tie_param_devices = {}

View on GitHub (pinned to a597f97485)

Solutions

  1. Add the missing module to the device_map, or use device_map='auto' to cover all modules.

When it happens

Trigger: Raised in get_module_from_name / device lookup when a parameter's module is absent from the device_map.

Common situations: A custom or incomplete device_map dict that omits modules present in the model.


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