{"record":{"id":"9d5750d2d63942b9","repo":"huggingface/transformers","slug":"the-following-attributes-are-missing-sorted-miss","errorCode":null,"errorMessage":"The following attributes are missing: {sorted(missing_required_global_attributes)}\nPlease define them globally, or provide them for every layer in `per_layer_config`","messagePattern":"The following attributes are missing: (.+?)\nPlease define them globally, or provide them for every layer in `per_layer_config`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/integrations/heterogeneity/configuration_utils.py","lineNumber":133,"sourceCode":"    config: PreTrainedConfig, per_layer_overrides: dict[int, dict[str, Any]]\n) -> _HeterogeneitySpec:\n    explicit_per_layer_attributes = _get_per_layer_attributes(per_layer_overrides)\n\n    # Ensure all required global attributes are defined\n    missing_required_global_attributes = set()\n    for attr in explicit_per_layer_attributes:\n        if len(per_layer_overrides) != config.num_hidden_layers:\n            if not config._hasattr_without_heterogeneous_validation(attr):\n                missing_required_global_attributes.add(attr)\n        else:\n            for layer_overrides in per_layer_overrides.values():\n                if attr not in layer_overrides:\n                    if not config._hasattr_without_heterogeneous_validation(attr):\n                        missing_required_global_attributes.add(attr)\n                    break\n\n    if missing_required_global_attributes:\n        raise ValueError(\n            f\"The following attributes are missing: {sorted(missing_required_global_attributes)}\\nPlease define them globally, or provide them for every layer in `per_layer_config`\"\n        )\n\n    # Remove per-layer overrides that match the global value\n    for attr in explicit_per_layer_attributes:\n        if not config._hasattr_without_heterogeneous_validation(attr):\n            continue\n\n        global_value = config._getattr_without_heterogeneous_validation(attr)\n        for layer_overrides in per_layer_overrides.values():\n            if attr in layer_overrides and layer_overrides[attr] == global_value:\n                del layer_overrides[attr]\n\n    # Delete all empty layer configs\n    for layer_idx, layer_overrides in list(per_layer_overrides.items()):\n        if not layer_overrides:\n            del per_layer_overrides[layer_idx]\n","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/integrations/heterogeneity/configuration_utils.py#L115-L151","documentation":"For every attribute that appears in some (but not necessarily all) per_layer_config entries, the attribute must be resolvable everywhere: either defined globally on the config, or present in every layer's override (and if per-layer coverage is partial — fewer entries than num_hidden_layers — only the global route works). Attributes failing this are collected and reported as missing, because a middle layer with no override and no global value would have an undefined attribute.","triggerScenarios":"per_layer_config covering a subset of layers (len(per_layer_overrides) != num_hidden_layers) that introduces a new attribute not present on the global config; or full coverage where one layer omits an attribute that others set and the global config lacks it.","commonSituations":"Adding per-layer knobs like rope scaling or head counts for a few layers without defining a global default in the PretrainedConfig; partial recipes copied from heterogeneous model implementations (mix'n'match layers) missing the base attribute.","solutions":["Define the listed attributes globally on the config (e.g. config.sliding_window = 512) as a safe default","Or add the attribute to every layer's per_layer_config entry so no layer is left without a value","If coverage is partial, prefer the global-default route — per-layer-only attributes require full coverage"],"exampleFix":"# before: attribute only on some layers, no global default\nconfig.per_layer_config = {0: {\"rope_local_base_freq\": 10000.0}}\n# ValueError: The following attributes are missing: ['rope_local_base_freq']\n\n# after: define a global default\nconfig.rope_local_base_freq = 10000.0\nconfig.per_layer_config = {0: {\"rope_local_base_freq\": 10000.0}}","handlingStrategy":"validation","validationCode":"def validate_per_layer_attrs(config, per_layer):\n    attrs = {a for ov in per_layer.values() for a in ov}\n    missing = [\n        a for a in sorted(attrs)\n        if not hasattr(config, a)\n        and (len(per_layer) != config.num_hidden_layers or any(a not in ov for ov in per_layer.values()))\n    ]\n    assert not missing, f\"define these globally or per-layer everywhere: {missing}\"\n\nvalidate_per_layer_attrs(config, per_layer_config)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always give new per-layer attributes a global default on the config","When adding an attribute to only some layers, add it to all layer entries if there is no global default"],"tags":["heterogeneity","config","missing-attribute","per-layer","validation"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}