{"record":{"id":"49b74894ea424650","repo":"huggingface/transformers","slug":"no-module-matched-pattern-parent-pattern-r-for-f","errorCode":null,"errorMessage":"No module matched pattern {parent_pattern!r} for fused kernel {kernel_cls.__name__!r}. Provide the full dotted path from the model root.","messagePattern":"No module matched pattern (.+?) for fused kernel (.+?)\\. Provide the full dotted path from the model root\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/integrations/hub_kernels.py","lineNumber":984,"sourceCode":"                    meta_model = cls(config)\n\n            matched_any = False\n            for name, module in meta_model.named_modules():\n                if not re.fullmatch(parent_pattern, name):\n                    continue\n                if not all(hasattr(module, child) for child in child_names):\n                    raise ValueError(\n                        f\"Module {name!r} does not have the expected child modules {child_names} required for \"\n                        f\"the fused kernel {kernel_cls.__name__!r}\"\n                    )\n                matched_any = True\n                module_cls = type(module)\n                patch_mapping[module_cls.__name__] = make_parent_class_for_kernel_fusion(\n                    module_cls, child_names, layout_cls\n                )\n\n            if not matched_any:\n                raise ValueError(\n                    f\"No module matched pattern {parent_pattern!r} for fused kernel {kernel_cls.__name__!r}. \"\n                    f\"Provide the full dotted path from the model root.\"\n                )\n\n        register_patch_mapping(patch_mapping, overwrite=True)\n\n        if hasattr(layout_cls, \"conversion_mapping\"):\n            existing = get_checkpoint_conversion_mapping(model_type)\n            transforms = list(layout_cls.conversion_mapping)\n            if existing is not None:\n                transforms = existing + transforms\n            register_checkpoint_conversion_mapping(model_type, transforms, overwrite=True)\n\n        new_mapping[kernel_cls.__name__] = final_repo\n\n    kernel_config.kernel_mapping = new_mapping\n\n","sourceCodeStart":966,"sourceCodeEnd":1002,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/integrations/hub_kernels.py#L966-L1002","documentation":"The fusion branch requires at least one module in the meta-instantiated model to fullmatch the parent pattern; if none does, this ValueError tells you the pattern did not correspond to any module path. The pattern is derived by taking the shared parent prefix of the fusion tuple's patterns and replacing '*' with \\w+ before fullmatch, so it must be the exact dotted path (with wildcards) from the model root.","triggerScenarios":"A fusion key like [(0, 'layers.0.mlp.gate_proj'), ...] where real module names are 'model.layers.0.mlp.gate_proj' (missing the 'model.' root); a wildcard pattern that matches no layer indices; patterns written for a different architecture.","commonSituations":"Copying patterns from the kernel hub card of a different model; omitting the 'model.' prefix typical of most transformers models; version changes that renamed root modules; wrong config so meta instantiation produces a different tree.","solutions":["Print the model's module names (print(dict(model.named_modules()).keys()) or [n for n,_ in model.named_modules()]) and rewrite the pattern to the exact dotted path from the root, e.g. 'model.layers.*.mlp'.","Keep '*' only where names vary (layer indices), not as a multi-segment glob — it maps to \\w+ per segment under fullmatch.","Verify the kernel catalog you loaded targets your model_type."],"exampleFix":"// before\n[[0, \"layers.*.mlp.gate_proj\"], [1, \"layers.*.mlp.up_proj\"]]\n\n// after\n[[0, \"model.layers.*.mlp.gate_proj\"], [1, \"model.layers.*.mlp.up_proj\"]]","handlingStrategy":"validation","validationCode":"import re\n\ndef pattern_matches_any_module(model, parent_pattern: str) -> bool:\n    pat = parent_pattern.replace(\"*\", r\"\\w+\")\n    return any(re.fullmatch(pat, name) for name, _ in model.named_modules())\n\n# with torch.device(\"meta\"): probe = AutoModel.from_config(config)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always derive patterns from print([n for n, _ in model.named_modules()]) of the target model, including the 'model.' root.","Remember '*' matches one segment (\\w+), not multiple — spell out intermediate segments explicitly.","Test kernel catalogs against the exact model_type they claim to support."],"tags":["hub-kernels","fusion","pattern-matching","model-structure"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}