huggingface/transformers · error · ValueError
No module matched pattern {parent_pattern!r} for fused kerne
Error message
No module matched pattern {parent_pattern!r} for fused kernel {kernel_cls.__name__!r}. Provide the full dotted path from the model root. What it means
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.
Source
Thrown at src/transformers/integrations/hub_kernels.py:984
meta_model = cls(config)
matched_any = False
for name, module in meta_model.named_modules():
if not re.fullmatch(parent_pattern, name):
continue
if not all(hasattr(module, child) for child in child_names):
raise ValueError(
f"Module {name!r} does not have the expected child modules {child_names} required for "
f"the fused kernel {kernel_cls.__name__!r}"
)
matched_any = True
module_cls = type(module)
patch_mapping[module_cls.__name__] = make_parent_class_for_kernel_fusion(
module_cls, child_names, layout_cls
)
if not matched_any:
raise ValueError(
f"No module matched pattern {parent_pattern!r} for fused kernel {kernel_cls.__name__!r}. "
f"Provide the full dotted path from the model root."
)
register_patch_mapping(patch_mapping, overwrite=True)
if hasattr(layout_cls, "conversion_mapping"):
existing = get_checkpoint_conversion_mapping(model_type)
transforms = list(layout_cls.conversion_mapping)
if existing is not None:
transforms = existing + transforms
register_checkpoint_conversion_mapping(model_type, transforms, overwrite=True)
new_mapping[kernel_cls.__name__] = final_repo
kernel_config.kernel_mapping = new_mapping
View on GitHub (pinned to a597f97485)
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.
Example fix
// before [[0, "layers.*.mlp.gate_proj"], [1, "layers.*.mlp.up_proj"]] // after [[0, "model.layers.*.mlp.gate_proj"], [1, "model.layers.*.mlp.up_proj"]]
Defensive patterns
Strategy: validation
Validate before calling
import re
def pattern_matches_any_module(model, parent_pattern: str) -> bool:
pat = parent_pattern.replace("*", r"\w+")
return any(re.fullmatch(pat, name) for name, _ in model.named_modules())
# with torch.device("meta"): probe = AutoModel.from_config(config) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Module {name!r} does not have the expected child modules {ch
- Fused kernel {kernel_cls.__name__!r} requires a companion la
- All patterns for a fused kernel must share the same parent m
- decompose_multimodal found no multi-modal submodules on {typ
- Model {cls.__name__} has no config class or model type
AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14).
Data as JSON: /api/errors/49b74894ea424650.
Report an issue: GitHub.