Answers for LLM inference engineers

ImportError: cannot import name 'X' from 'timm.models.layers', No module named 'timm.layers' or 'timm.models.layers.norm': which timm versions have it

Almost all of these come from timm 0.9.0 (2023-05-12), which moved timm.models.layers to timm.layers and removed 65 modules. No module named 'timm.layers' means your timm is older than 0.9.0: upgrade. No module named 'timm.models.layers.norm' (or .helpers, .drop, ...) means code or a pickled model from timm 0.6.13 or older: the file is now timm.layers.norm, or pin pip install "timm<0.9.0". from timm.models.layers import X still works for the names that existed in 0.9.0, with a FutureWarning, but not for the 127 names added to timm.layers since. For any other module or name, paste the error below.

Published 2026-11-18 · Data as of 2026-11-18 · every timm release with a git tag, 0.1.1 to 1.0.31 (51 releases), and the untagged ones where they differ · read from the source of each release tag, nothing was installed or run (how, limits) · Corrected 2026-12-05

Corrected on 2026-12-05: this page read only the releases with a git tag. The releases on PyPI without one (the even 0.1.x releases and 0.3.0 to 0.3.2) were taken to have the names of the tagged release before them, which is not always so: from timm import list_models works from 0.1.2 (2019-06-24), not only from 0.2.1. Those releases were then read from their PyPI wheels: 8 top-level names (and 2,320 module-and-name pairs in all) differ from the tagged release before them. The lookup now gives them.

Examples:

Runs in your browser on timm.json (427 KB); nothing you paste is sent anywhere. Covers 12,776 module-and-name pairs in 382 modules.

Which modules did timm 0.9.0 remove, and where are they now?

65 modules left in 0.9.0; for 61 of them a module with the same file exists in 1.0.31, under timm.layers for the old layer files and with a leading underscore for the builders and helpers under timm.models. An import that names one of these modules fails on 0.9.0 and later, and so does loading a model pickled with timm 0.6.13 or older that used them.

Removed in 0.9.0Same file in 1.0.31
timm.data.parserstimm.data.readers
timm.data.parsers.class_maptimm.data.readers.class_map
timm.data.parsers.img_extensionstimm.data.readers.img_extensions
timm.data.parsers.parsertimm.data.readers.reader
timm.data.parsers.parser_factorytimm.data.readers.reader_factory
timm.data.parsers.parser_image_foldertimm.data.readers.reader_image_folder
timm.data.parsers.parser_image_in_tartimm.data.readers.reader_image_in_tar
timm.data.parsers.parser_image_tartimm.data.readers.reader_image_tar
timm.data.parsers.parser_tfdstimm.data.readers.reader_tfds
timm.models.efficientnet_blockstimm.models._efficientnet_blocks
timm.models.efficientnet_buildertimm.models._efficientnet_builder
timm.models.gluon_resnetnone with the same file name
timm.models.gluon_xceptionnone with the same file name
timm.models.layers.activationstimm.layers.activations
timm.models.layers.activations_jitnone with the same file name
timm.models.layers.activations_metimm.layers.activations_me
timm.models.layers.adaptive_avgmax_pooltimm.layers.adaptive_avgmax_pool
timm.models.layers.attention_pool2dtimm.layers.attention_pool2d
timm.models.layers.blur_pooltimm.layers.blur_pool
timm.models.layers.bottleneck_attntimm.layers.bottleneck_attn
timm.models.layers.cbamtimm.layers.cbam
timm.models.layers.classifiertimm.layers.classifier
timm.models.layers.cond_conv2dtimm.layers.cond_conv2d
timm.models.layers.configtimm.layers.config
timm.models.layers.conv2d_sametimm.layers.conv2d_same
timm.models.layers.conv_bn_acttimm.layers.conv_bn_act
timm.models.layers.create_acttimm.layers.create_act
timm.models.layers.create_attntimm.layers.create_attn
timm.models.layers.create_conv2dtimm.layers.create_conv2d
timm.models.layers.create_normtimm.layers.create_norm
timm.models.layers.create_norm_acttimm.layers.create_norm_act
timm.models.layers.droptimm.layers.drop
timm.models.layers.ecatimm.layers.eca
timm.models.layers.evo_normtimm.layers.evo_norm
timm.models.layers.fast_normtimm.layers.fast_norm
timm.models.layers.filter_response_normtimm.layers.filter_response_norm
timm.models.layers.gather_excitetimm.layers.gather_excite
timm.models.layers.global_contexttimm.layers.global_context
timm.models.layers.halo_attntimm.layers.halo_attn
timm.models.layers.helperstimm.layers.helpers
timm.models.layers.inplace_abntimm.layers.inplace_abn
timm.models.layers.lambda_layertimm.layers.lambda_layer
timm.models.layers.lineartimm.layers.linear
timm.models.layers.median_pooltimm.layers.median_pool
timm.models.layers.mixed_conv2dtimm.layers.mixed_conv2d
timm.models.layers.ml_decodertimm.layers.ml_decoder
timm.models.layers.mlptimm.layers.mlp
timm.models.layers.non_local_attntimm.layers.non_local_attn
timm.models.layers.normtimm.layers.norm
timm.models.layers.norm_acttimm.layers.norm_act
timm.models.layers.paddingtimm.layers.padding
timm.models.layers.patch_embedtimm.layers.patch_embed
timm.models.layers.pool2d_sametimm.layers.pool2d_same
timm.models.layers.pos_embedtimm.layers.pos_embed
timm.models.layers.selective_kerneltimm.layers.selective_kernel
timm.models.layers.separable_convtimm.layers.separable_conv
timm.models.layers.space_to_depthtimm.layers.space_to_depth
timm.models.layers.split_attntimm.layers.split_attn
timm.models.layers.split_batchnormtimm.layers.split_batchnorm
timm.models.layers.squeeze_excitetimm.layers.squeeze_excite
timm.models.layers.std_convtimm.layers.std_conv
timm.models.layers.test_time_pooltimm.layers.test_time_pool
timm.models.layers.trace_utilstimm.layers.trace_utils
timm.models.layers.weight_inittimm.layers.weight_init
timm.models.poolformernone with the same file name

Modules removed in other releases

ModuleGone inSame file in 1.0.31
timm.layers.activations_jit1.0.3none with the same file name
timm.data.parsers.constants0.6.5timm.data.constants
timm.models.layers.involution0.5.4none with the same file name
timm.models.layers.swin_attn0.5.4none with the same file name
timm.optim.novograd0.5.4none with the same file name
timm.models.layers.create_self_attn0.4.12none with the same file name
timm.models.layers.se0.4.12none with the same file name
timm.models.layers.anti_aliasing0.4.9none with the same file name
timm.models.adaptive_avgmax_pool0.2.1timm.layers.adaptive_avgmax_pool
timm.models.conv2d_same0.2.1timm.layers.conv2d_same
timm.models.gen_efficientnet0.2.1none with the same file name
timm.models.median_pool0.2.1timm.layers.median_pool
timm.models.model_factory0.2.1none with the same file name
timm.models.test_time_pool0.2.1timm.layers.test_time_pool

79 of the 382 modules that have existed are gone from 1.0.31. Old paths such as timm.models.helpers and timm.models.registry still exist as mapping files that re-export the underscored modules.

The error appears when I load a saved model. What then?

A model saved whole with torch.save(model, path) stores the module path of every class, and loading it imports those paths. A model saved under timm 0.6.13 or older names modules such as timm.models.layers.norm, so loading it with timm 0.9.0 or later raises ModuleNotFoundError from inside pickle (the traceback shows find_class). Load it once with pip install "timm<0.9.0", save model.state_dict(), and from then on build the model with timm.create_model and load the state dict.

How was this read, and how was it checked?

From the source of each release tag, with Python's ast module; no release was installed or imported. timm imports eagerly, so a module's names are everything it binds at module level, including what from timm.layers.x import * brings in. Dates come from PyPI.

Checks, by a second reading: (1) each of the 28 top-level names is found as plain text in __init__.py (or the modules it star-imports) in every release of its range (1,090 name-and-release pairs). (2) A regular expression finds 43,256 definitions in 2,351 file versions; all are among the names read. (3) timm.models.layers was read a second time with regular expressions in all 38 releases where it is a mapping; the names match, apart from torch, nn and F, which a star import without __all__ also passes along. (4) 8 known facts hold, among them the reports under Sources.

Limits

Questions

How do I fix "No module named 'timm.models.layers.norm'"?

timm 0.9.0 (2023-05-12) removed the submodules of timm.models.layers; the files moved to timm.layers (timm.layers.norm). The error usually comes from loading a model that was saved whole with torch.save(model) under timm 0.6.13 or older: pickle stores the old module path. Either install pip install "timm<0.9.0" to load it, or load it once there and save model.state_dict() instead, which does not depend on module paths.

How do I fix "No module named 'timm.layers'"?

Your timm is older than 0.9.0. Upgrade with pip install -U "timm>=0.9.0", or, if you must stay on 0.6, import the same names from timm.models.layers.

How do I fix "ModuleNotFoundError: No module named 'timm'"?

That exact message, with nothing after timm, means the Python that runs your code has no timm installed at all; no release removed the top-level package. Install it into that same interpreter with python -m pip install timm (the PyPI package and the import name are both timm). In a notebook, ComfyUI or another program that ships its own Python, run pip with that program's python executable, because the pip on your PATH can belong to a different environment. If the message names a submodule, such as timm.layers or timm.models.layers.norm, timm is installed and the two questions above apply.

Does "from timm.models.layers import X" still work?

For the names that existed when timm.models.layers was moved, yes: timm keeps it as a mapping that warns "Importing from timm.models.layers is deprecated, please import via timm.layers". 127 public names added to timm.layers since then are not in the mapping, so for those the old path fails; import them from timm.layers.

Why does this page read every timm release and not one per minor version?

timm has stayed at 1.0 since 2024 and ships its changes in patch releases (1.0.3 to 1.0.31), so a module or name can appear or go in any of them.

Sources

The same data as JSON: timm.json, licensed CC BY 4.0.

Related: "cannot import name ... from 'transformers'" · "... from 'huggingface_hub'" · "... from 'datasets'" · "... from 'diffusers'".