unstale

pypi / ultralytics-thop

ultralytics-thop

What changed in ultralytics-thop 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-19.

2 breaking1 deprecations3 new APIs and options4 performance7 behavior and defaults1 tooling33 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli 0.2.0 on npm

ultralytics-thop 251 changes

Breaking changes 2

  • Rejects modules that already use total_ops for parameters, child modules, or class-level properties, preventing profiling from silently corrupting module structure or reported totals.

    2.1.6release notes

  • The broken, unused fx_profile implementation was removed; code that depends on it must migrate to the standard profile API.

    2.1.0release notes

Deprecations 1

  • Embedding layers using max_norm emit a warning because their data-dependent renormalization is not counted.

    2.1.6release notes

New APIs and options 3

  • Adds the min_cells argument to start proxy measurements at a larger size, which can help when model costs change behavior below a certain input size.

    2.2.0release notes

  • Custom counting rules can be callable objects or functools.partial instances and receive arguments from keyword, positional, or mixed module calls.

    2.1.3release notes

  • Adds an optional stride argument for image models, enabling smaller stride-aligned inputs and more accurate estimates when fixed-cost layers are present.

    2.1.1release notes

Performance 4

  • Explicitly registered as a zero-MAC operation, reducing missing-rule warnings and profiling overhead.

    2.1.3release notes

  • Explicitly registered as a zero-MAC operation, reducing missing-rule warnings and profiling overhead.

    2.1.3release notes

  • Explicitly registered as a zero-MAC operation, reducing missing-rule warnings and profiling overhead.

    2.1.3release notes

  • Profiling overhead is reduced by up to 2.4× while preserving bit-exact results; get_flops is approximately 1.31× faster overall across the tested Ultralytics model configurations.

    2.1.0release notes

Behavior and default changes 7

  • THOP now counts two-operand einsum operations in FLOPs estimates; one-operand calls and calls with more than two operands remain uncounted by this rule.

    2.2.2release notes

  • On PyTorch 1.13 and later, profile() counts functional matrix products and scaled_dot_product_attention when available, without recounting products inside modules with their own counting rule.

    2.2.0release notes

  • For models that may have quadratic costs, profile() uses measurements at several smaller sizes, validates a quadratic estimate, and profiles at the target size if the measurements do not support it.

    2.2.0release notes

  • Adds support for ModuleList, ModuleDict, ParameterList, and ParameterDict containers during profiling.

    2.1.6release notes

  • Stride-based shortcut estimation is disabled for models containing attention; they use exact target-size profiling instead.

    2.1.3release notes

  • THOP counts projection layers, attention matrix operations, and softmax processing for batched and unbatched, cross-attention, and other supported calls.

    2.1.3release notes

  • Rules resolve through a module type’s inheritance hierarchy, allowing custom subclasses, parametrized layers, and many lazy modules to inherit the nearest supported rule.

    2.1.2release notes

Tooling 1

  • Publish runs are queued and failed PyPI uploads retried; workflows can recover partially completed releases, reuse existing tags, and replace incomplete SBOM files.

    2.0.21release notes

Fixes and other changes 33

  • Adaptive max pools and nn.Bilinear are treated as fixed-size operations during extrapolation, preventing FLOPs from being overcounted for affected models.

    2.2.1release notes

  • Custom operations that may have nonlinear computational costs use direct profiling instead of inaccurate linear extrapolation.

    2.1.6release notes

  • Embedding lookups are treated as data gathering rather than arithmetic computation.

    2.1.6release notes

  • Profiling accounts for projection work and reduced recurrent width in LSTM layers with proj_size.

    2.1.6release notes

  • Recognized as performing no arithmetic operations during profiling.

    2.1.6release notes

  • Packed RNN, GRU, and LSTM inputs are counted using their actual processed sequence steps instead of the larger padded shape.

    2.1.6release notes

  • Applies custom profiling rules to composite modules, matching the behavior of profile().

    2.1.6release notes

  • Attention profiling skips MAC counting when older PyTorch versions cannot expose hook keyword arguments, avoiding unsafe calls while preserving accurate counts on PyTorch 2.x.

    2.1.5release notes

  • THOP now counts operations for nn.Bilinear layers instead of treating them as free, improving FLOPs/MACs estimates.

    2.1.4release notes

  • Fixed and adaptive average-pooling counts account for window sizes, padding, boundary behavior, ceil_mode, and count_include_pad.

    2.1.3release notes

  • Now counted, including additional elementwise work and correct handling of empty normalization dimensions.

    2.1.3release notes

  • Now counted, including additional elementwise work and correct handling of empty normalization dimensions.

    2.1.3release notes

  • Now counted, including additional elementwise work and correct handling of empty normalization dimensions.

    2.1.3release notes

  • Explicitly registered as a zero-MAC operation, reducing missing-rule warnings and profiling overhead.

    2.1.3release notes

  • Both profiler entry points count the forward pass that actually executed, including when inference replaces or detaches submodules.

    2.1.3release notes

  • Existing total_ops attributes and buffers are preserved during profiling and restored afterward, preventing model state from being overwritten.

    2.1.3release notes

  • Convolution and RNN/GRU/LSTM profilers correctly interpret channel, batch, and sequence dimensions for batched and unbatched layouts.

    2.1.3release notes

  • Counts follow the integer pooling windows PyTorch uses, improving MAC estimates when output sizes do not evenly divide the input.

    2.1.2release notes

  • Exact powers of 1,000 and negative values receive the correct units.

    2.1.2release notes

  • These module families are handled through shared base classes.

    2.1.2release notes

  • LeakyReLU is explicitly treated as a zero-MAC operation.

    2.1.2release notes

  • Nearest and nearest-exact upsampling are counted as requiring zero arithmetic operations.

    2.1.2release notes

  • GroupNorm and RMSNorm use the existing normalization rule, and lazy normalization modules receive more reliable rule resolution.

    2.1.2release notes

  • Parameter totals come from the model’s parameter tree rather than profiling hooks, correctly handling shared weights, unused branches, unsupported module types, and parent-owned parameters.

    2.1.2release notes

  • ReLU is explicitly treated as a zero-MAC operation.

    2.1.2release notes

  • Model training modes are restored more reliably after profiling.

    2.1.2release notesrelease notes

  • Profiling restores the model’s previous training or evaluation mode after profiling completes or fails.

    2.0.22release notes

  • Temporary hooks and operation-counting buffers are removed even when the model’s forward pass raises an error, preventing profiling state from remaining attached to the model.

    2.0.22release notes

  • The profiler avoids duplicate operation and parameter totals when the same module is reached through multiple paths.

    2.0.22release notes

  • Modules referenced by multiple parent layers are hooked only once, avoiding orphaned hook handles.

    2.0.22release notes

  • profile() removes temporary hooks and total_ops/total_params buffers from every module it touches, preventing profiling metadata from affecting state_dict() or shared modules while preserving results.

    2.0.21release notes

  • The package now declares Python 3.14 compatibility in its metadata, helping users and tools recognize support for that version.

    2.0.20release notes

  • Profiling now counts a module’s own parameters and avoids double-counting child parameters, improving totals for nested module structures.

    2.0.19release notes