{"record":{"id":"acbf6e705799bff0","repo":"huggingface/pytorch-image-models","slug":"invalid-local-mbconv-norm-local-mbconv-norm-r-e","errorCode":null,"errorMessage":"Invalid local_mbconv_norm={local_mbconv_norm!r}; expected one of {tuple(_LOCAL_MBCONV_NORM_MODES)}.","messagePattern":"Invalid local_mbconv_norm=(.+?); expected one of (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"timm/models/cpubone.py","lineNumber":39,"sourceCode":"from ._features import feature_take_indices\nfrom ._features_fx import register_notrace_module\nfrom ._manipulate import checkpoint_seq\nfrom ._registry import register_model, generate_default_cfgs\n\n__all__ = ['CPUBone']\n\n\n_LOCAL_MBCONV_NORM_MODES = {\n    # mode: (expand, depthwise, project)\n    'proj': (False, False, True),\n    'depth_proj': (False, True, True),\n    'all': (True, True, True),\n}\n\n\ndef _check_local_mbconv_norm(local_mbconv_norm: str) -> None:\n    if local_mbconv_norm not in _LOCAL_MBCONV_NORM_MODES:\n        raise ValueError(\n            f'Invalid local_mbconv_norm={local_mbconv_norm!r}; '\n            f'expected one of {tuple(_LOCAL_MBCONV_NORM_MODES)}.'\n        )\n\n\ndef _check_global_pool(global_pool: str) -> None:\n    assert global_pool in (\"\", \"avg\"), \"CPUBone only supports average or disabled pooling\"\n\n\ndef remap_legacy_state_dict(state_dict: Dict[str, torch.Tensor]) -> Dict[str, torch.Tensor]:\n    \"\"\"Remap keys from original CPUBone checkpoints to the current model layout.\"\"\"\n    remapped = {}\n    for k, v in state_dict.items():\n        # conv_proj was nn.Sequential([conv, bn]) → now ConvLayer with .conv / .bn\n        k = k.replace(\".conv_proj.0.\", \".conv_proj.conv.\")\n        k = k.replace(\".conv_proj.1.\", \".conv_proj.norm.\")\n        # pwise was a single-element nn.Sequential → now a plain nn.Conv2d\n        k = k.replace(\".pwise.0.\", \".pwise.\")","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/models/cpubone.py#L21-L57","documentation":"CPoTBone (cpubone.py) validates the local_mbconv_norm argument against a fixed set of modes (_LOCAL_MBCONV_NORM_MODES, e.g. 'none', 'first', 'last', 'all' style keys mapping to which MBConv sub-blocks get norm). Any string outside that tuple raises ValueError at construction time.","triggerScenarios":"Instantiating cputbone_s or CPoTBone with local_mbconv_norm set to an unrecognized string (e.g. 'first-last', 'norm', typo like 'fisrt').","commonSituations":"Hand-writing config YAML/JSON for backbone experiments; copying a norm-mode name from a different model family; version drift if valid mode names changed between timm releases.","solutions":["Print tuple(_LOCAL_MBCONV_NORM_MODES) from timm.models.cpubone and use one of those exact keys","Check the model's pretrained cfg / docs for the default value and revert to it","Update timm if the mode you want exists in a newer release"],"exampleFix":"# before\nmodel = timm.create_model('cputbone_s', local_mbconv_norm='first-last')\n# after\nfrom timm.models.cpubone import _LOCAL_MBCONV_NORM_MODES\nmodel = timm.create_model('cputbone_s', local_mbconv_norm=list(_LOCAL_MBCONV_NORM_MODES)[0])","handlingStrategy":"validation","validationCode":"from timm.models.cpubone import _LOCAL_MBCONV_NORM_MODES\nif cfg['local_mbconv_norm'] not in _LOCAL_MBCONV_NORM_MODES:\n    raise ValueError(f\"local_mbconv_norm must be one of {tuple(_LOCAL_MBCONV_NORM_MODES)}\")\nmodel = timm.create_model('cputbone_s', **cfg)","typeGuard":"def is_valid_local_mbconv_norm(v: str) -> bool:\n    from timm.models.cpubone import _LOCAL_MBCONV_NORM_MODES\n    return v in _LOCAL_MBCONV_NORM_MODES","tryCatchPattern":null,"preventionTips":["Import valid mode names from the module rather than hardcoding strings","Validate string-enum config fields at load time","Add schema validation for experiment configs"],"tags":["timm","cpubone","validation","constructor"],"backgroundTag":"invalid-enum-argument","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}