{"record":{"id":"2817b0bde8b1d704","repo":"huggingface/transformers","slug":"param-name-is-on-the-meta-device-because-it-was","errorCode":null,"errorMessage":"{param_name} is on the meta device because it was offloaded, but we could not find the corresponding hook for it","messagePattern":"(.+?) is on the meta device because it was offloaded, but we could not find the corresponding hook for it","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/integrations/accelerate.py","lineNumber":534,"sourceCode":"\n\ndef load_offloaded_parameter(model: \"PreTrainedModel\", param_name: str) -> torch.Tensor:\n    \"\"\"Load `param_name` from disk, if it was offloaded due to the device_map, and thus lives as a meta parameter\n    inside `model`.\n    This is needed when resaving a model, when some parameters were offloaded (we need to load them from disk, to\n    then resave them to disk in the correct shard...).\"\"\"\n    # Start from the most inner module, and try to find the hook that was used for offloading the param\n    module_parts = param_name.split(\".\")\n    modules_to_check = [\".\".join(module_parts[:-idx]) for idx in range(1, len(module_parts))] + [\"\"]\n    for parent_name in modules_to_check:\n        parent = model.get_submodule(parent_name)\n        if hasattr(parent, \"_hf_hook\"):\n            weights_map = parent._hf_hook.weights_map\n            truncated_param_name = param_name.replace(f\"{parent_name}.\" if parent_name != \"\" else parent_name, \"\")\n            break\n    # If we did not break the loop, something is wrong\n    else:\n        raise ValueError(\n            f\"{param_name} is on the meta device because it was offloaded, but we could not find \"\n            \"the corresponding hook for it\"\n        )\n\n    # This call loads it from disk\n    tensor = weights_map[truncated_param_name]\n    return tensor\n\n\ndef _init_infer_auto_device_map(\n    model: nn.Module,\n    max_memory: dict[int | str, int | str] | None = None,\n    no_split_module_classes: set[str] | None = None,\n    tied_parameters: list[list[str]] | None = None,\n    hf_quantizer: \"HfQuantizer | None\" = None,\n) -> tuple[\n    list[int | str],\n    dict[int | str, int | str],","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/integrations/accelerate.py#L516-L552","documentation":"Error \"{param_name} is on the meta device because it was offloaded, but we could not find the corresponding hook for it\" thrown in huggingface/transformers.","triggerScenarios":"Raised when a parameter is on the meta device due to offload but its align_devices hook cannot be found.","commonSituations":"Model dispatched with hooks partially removed or manually moved after accelerate dispatch, breaking offloaded weight lookup.","solutions":["Re-dispatch the model with `dispatch_model` so hooks are attached for offloaded params.","Avoid manually moving offloaded parameters to the meta device."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}