{"record":{"id":"51de8b57c325a4af","repo":"huggingface/pytorch-image-models","slug":"token-mixer-type-not-supported","errorCode":null,"errorMessage":"Token mixer type: {} not supported","messagePattern":"Token mixer type: (.+?) not supported","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"timm/models/fastvit.py","lineNumber":1157,"sourceCode":"                    proj_drop=proj_drop_rate,\n                    drop_path=drop_path_rate[block_idx],\n                    layer_scale_init_value=layer_scale_init_value,\n                    inference_mode=inference_mode,\n                    **dd,\n                ))\n            elif token_mixer_type == \"attention\":\n                blocks.append(AttentionBlock(\n                    dim_out,\n                    mlp_ratio=mlp_ratio,\n                    act_layer=act_layer,\n                    norm_layer=norm_layer,\n                    proj_drop=proj_drop_rate,\n                    drop_path=drop_path_rate[block_idx],\n                    layer_scale_init_value=layer_scale_init_value,\n                    **dd,\n                ))\n            else:\n                raise ValueError(\n                    \"Token mixer type: {} not supported\".format(token_mixer_type)\n                )\n        self.blocks = nn.Sequential(*blocks)\n\n    def forward(self, x):\n        x = self.downsample(x)\n        x = self.pos_emb(x)\n        if self.grad_checkpointing and not torch.jit.is_scripting():\n            x = checkpoint_seq(self.blocks, x)\n        else:\n            x = self.blocks(x)\n        return x\n\n\nclass FastVit(nn.Module):\n    fork_feat: torch.jit.Final[bool]\n\n    \"\"\"","sourceCodeStart":1139,"sourceCodeEnd":1175,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/models/fastvit.py#L1139-L1175","documentation":"FastViT's network constructor builds each stage block based on a token_mixer_type string (variants like 'conv', 'conv_rep', 'itpool', 'itp', 'attn', etc.). If a stage's token_mixer_type does not match any supported branch, ValueError('Token mixer type: {} not supported') is raised during model construction.","triggerScenarios":"Building FastViT (e.g. fastvit_t8 or the FastViT class directly) with a modified architecture config containing an unknown token_mixer_type, or passing custom stage definitions where a mixer name is misspelled.","commonSituations":"Editing FastViT arch strings to prototype new mixer types; merging configs across timm versions where mixer names changed; string parsing bugs in YAML/JSON config that truncate or alter the token_mixer_type token.","solutions":["Inspect the supported mixer branches in timm/models/fastvit.py above line 1157 and correct the token_mixer_type string","Use the stock fastvit_* factory functions instead of hand-editing architecture configs","Diff your config against the default architecture dict in the same timm version"],"exampleFix":"# before\nblocks.append(..., token_mixer_type='attention')  # typo\n# after\nblocks.append(..., token_mixer_type='attn')  # exact supported name","handlingStrategy":"validation","validationCode":"import inspect, timm.models.fastvit as fv\nsrc = inspect.getsource(fv)\n# safer: hard check against known mixers\nallowed = {'conv', 'conv_rep', 'itpool', 'itp', 'itp_rep', 'attn', 'attn_rep'}\nassert cfg['token_mixer_type'] in allowed, f\"unknown mixer {cfg['token_mixer_type']}\"","typeGuard":"def is_valid_fastvit_mixer(t: str) -> bool:\n    allowed = {'conv', 'conv_rep', 'itpool', 'itp', 'itp_rep', 'attn', 'attn_rep'}\n    return t in allowed","tryCatchPattern":"try:\n    model = timm.create_model('fastvit_t8', **cfg)\nexcept ValueError as e:\n    if 'not supported' in str(e):\n        cfg['token_mixer_type'] = 'conv'  # safe fallback\n        model = timm.create_model('fastvit_t8', **cfg)\n    else:\n        raise","preventionTips":["Keep architecture configs in code (not free-form YAML) where names can be linted","Diff custom arch defs against the stock ones per release","Use factory functions unless you intentionally modify the architecture"],"tags":["timm","fastvit","architecture","validation"],"backgroundTag":"invalid-enum-argument","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}