NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #2021 most downloaded on PyPI
Ultralytics THOP package for fast computation of PyTorch model FLOPs and parameters.
Last release 3 days ago
01 Oct 2026
Release timing varies
gaps range from 2 weeks to 7 months
Most releases are documented
notes for 31 of 43 stable releases
Nothing withdrawn
no release was ever pulled
2 years old
43 releases · first in 2024
THOP 2.2.2 improves FLOPs estimates for models that use two-operand torch.einsum , including open-vocabulary models such as YOLO-World and YOLOE.
THOP 2.2.2 improves FLOPs estimates for models that use two-operand torch.einsum, including open-vocabulary models such as YOLO-World and YOLOE.
torch.einsum, alongside the other functional matrix-product operations already counted.Full Changelog: v2.2.1...v2.2.2
v2.2.2 - Count two-operand einsum as a functional product (#183) Latest
Latest
Compare
One column per month.
THOP 2.2.1 improves operation-count estimates for models with adaptive max pooling or bilinear layers, without changing reported counts for Ultralytic
THOP 2.2.1 improves operation-count estimates for models with adaptive max pooling or bilinear layers, without changing reported counts for Ultralytics’ buildable model configurations.
nn.Bilinear are now treated as fixed-size operations during extrapolation.ultralytics-thop 2.2.1: Publishes the profiling fix from PR #181.Full Changelog: v2.2.0...v2.2.1
THOP 2.2.0 improves profile() so it can count more attention-related operations and estimate model cost from smaller inputs more reliably—reducing the
THOP 2.2.0 improves profile() so it can count more attention-related operations and estimate model cost from smaller inputs more reliably—reducing the need for custom counting rules or full-size profiling runs.
profile() now detects operations such as @, torch.matmul, torch.bmm, and—when available—scaled_dot_product_attention. Products inside a module with its own counting rule are not counted again.min_cells: This new profile() argument lets users start proxy measurements at a larger size, which can help with models whose costs change behavior below a certain input size.Full Changelog: v2.1.6...v2.2.0
v2.2.0 - Count functional products and extrapolate quadratic costs from stride proxies (#180)
Compare
🚀 THOP 2.1.6 is a patch release that improves model-operation profiling accuracy and robustness while preserving the existing API and behavior for typ
🚀 THOP 2.1.6 is a patch release that improves model-operation profiling accuracy and robustness while preserving the existing API and behavior for typical users.
📦 Released THOP 2.1.6
2.1.5 to 2.1.6.🧮 More accurate recurrent-layer profiling
proj_size, including the additional projection work and reduced recurrent width.🧩 Improved custom operation support
profile_origin() now applies custom profiling rules to composite modules, matching the behavior of the standard profile() function.🧱 Better handling of container and zero-operation modules
ModuleList, ModuleDict, ParameterList, and ParameterDict.max_norm emit a warning because their data-dependent renormalization is not counted.EmbeddingBag remains unregistered because its reduction cost depends on the input contents.🛡️ Safer total_ops handling
total_ops for parameters, child modules, or class-level properties.✅ Validation
total_ops bookkeeping.Full Changelog: v2.1.5...v2.1.6
THOP 2.1.5 improves PyTorch compatibility by making attention-operation profiling safe across both PyTorch 1.x and 2.x versions. 🛠️
THOP 2.1.5 improves PyTorch compatibility by making attention-operation profiling safe across both PyTorch 1.x and 2.x versions. 🛠️
Fixed nn.MultiheadAttention profiling on PyTorch 1.x
Attention profiling is now enabled only when PyTorch forward hooks can expose keyword arguments.
Preserved accurate attention counting on PyTorch 2.x
Newer PyTorch versions continue to report attention MACs correctly, including mixed cross-attention scenarios.
Avoided crashes on older PyTorch versions
When hook inputs cannot be reconstructed, THOP now skips attention MAC counting rather than attempting an unsafe call.
Updated the package version
The release version was bumped from 2.1.4 to 2.1.5.
Validated across profiling APIs ✅
Tests confirmed accurate results on PyTorch 2.x and safe zero-count behavior under PyTorch 1.x compatibility conditions.
Full Changelog: v2.1.4...v2.1.5
v2.1.5 - Keep attention profiling compatible with torch 1.x (#159)
Compare
THOP 2.1.4 now accurately counts nn.Bilinear operations instead of treating them as free, improving model complexity and compute reporting. 🎯
THOP 2.1.4 now accurately counts nn.Bilinear operations instead of treating them as free, improving model complexity and compute reporting. 🎯
nn.Bilinear support to THOP’s operation-counting registry.count_bilinear hook that accounts for both contractions performed by PyTorch.Full Changelog: v2.1.3...v2.1.4
v2.1.4 - Count nn.Bilinear instead of charging it nothing (#158)
Compare
🚀 THOP 2.1.3 delivers more accurate PyTorch operation profiling, especially for attention-based models, while improving pooling, recurrent layers, cus
🚀 THOP 2.1.3 delivers more accurate PyTorch operation profiling, especially for attention-based models, while improving pooling, recurrent layers, custom rules, and profiler reliability.
🧠 Accurate nn.MultiheadAttention counting (PR #157)
Attention is no longer reported as free. THOP now counts its projection layers, attention matrix operations, and softmax processing, including support for:
📈 More realistic attention-model estimates
Because attention cost does not scale linearly with image area, stride-based shortcut estimation is disabled for models containing attention. These models now use the exact target-size profiling path. For example, measured RT-DETR estimates increased by roughly 1.5–1.8%, reflecting previously uncounted work.
🧮 Improved average-pooling operation counts (PR #150)
Fixed and adaptive average pooling now account for actual window sizes, padding, boundary behavior, ceil_mode, and count_include_pad. This avoids assuming every output uses a full pooling window.
🧱 Better support for unbatched and recurrent inputs (PR #150)
Convolution and RNN/GRU/LSTM profilers now correctly interpret channel, batch, and sequence dimensions for both batched and unbatched layouts.
⚡ Expanded zero-operation layer coverage (PR #152)
Data movement and selection layers such as Flatten, Unflatten, Identity, PixelUnshuffle, additional padding layers, and fractional max pooling are explicitly registered as zero-MAC operations. This reduces unnecessary missing-rule warnings and improves profiling speed.
🔥 Complete softmax-family support (PR #153)
LogSoftmax, Softmin, and Softmax2d are now counted, including their additional elementwise work and correct handling of empty normalization dimensions.
🛡️ Safer handling of caller-owned total_ops values (PR #151)
Existing total_ops attributes and buffers are temporarily preserved during profiling and restored afterward, preventing THOP from overwriting model state.
🌳 Profiler results now reflect the modules that actually ran (PR #154)
Both profiler entry points consistently count the forward pass that executed, even when a model replaces or detaches submodules during inference. Training modes are also restored more reliably.
🧩 More flexible custom operation rules (PRs #155–#156)
Custom counting rules can now be callable objects or functools.partial instances, and they receive arguments supplied through keyword, positional, or mixed calls.
📦 Version updated to 2.1.3
total_ops data or model training states.Full Changelog: v2.1.2...v2.1.3
v2.1.3 - Count what an attention layer computes instead of reporting it as free (#157)
Compare
THOP 2.1.2 improves PyTorch model profiling accuracy, expands module-rule coverage, fixes parameter and formatting edge cases, and adds automated test
THOP 2.1.2 improves PyTorch model profiling accuracy, expands module-rule coverage, fixes parameter and formatting edge cases, and adds automated testing across supported environments. 🎯
Corrected adaptive average pooling counts 🧮
Counts now follow the integer pooling windows PyTorch actually uses, producing more accurate and consistent MAC estimates for output sizes that do not evenly divide the input.
Fixed upsampling operation rules 🚀
Nearest and nearest-exact upsampling are now correctly treated as requiring zero arithmetic operations. Costs for other interpolation modes remain assigned to their owning hook.
Expanded normalization and zero-operation coverage 🧩
Improved counting-rule inheritance 🧬
Rules are now resolved through a module type’s inheritance hierarchy. Custom subclasses, parametrized layers, and many lazy modules can inherit the nearest supported rule instead of being incorrectly reported as unsupported.
Improved parameter counting 📊
Parameter totals now come directly from the model’s parameter tree rather than profiling hooks. This correctly handles shared weights, unused branches, unsupported module types, and parameters owned by parent modules.
Preserved model state during profiling 🛡️
Profiling now restores each module’s original training or evaluation mode, avoiding unintended changes in models with mixed training states.
Fixed clever_format() edge cases ✨
Exact powers of 1,000 and negative values now receive the correct units—for example, 1000 becomes 1.00K and -1e9 becomes -1.00G.
Added continuous integration testing ✅
A new GitHub Actions workflow runs the test suite on pull requests, pushes, and nightly schedules across the supported Python and PyTorch range, including Python 3.8 with PyTorch 1.8.0 and Python 3.14 with the latest PyTorch.
Updated documentation and benchmarks 📚
README badges, custom-rule guidance, Chinese documentation, and model benchmark rows—including YOLO11 and YOLO26 entries—now reflect the corrected counts.
Version updated to 2.1.2 📦
This patch release packages the profiling, reliability, documentation, and testing improvements together.
Full Changelog: v2.1.1...v2.1.2
v2.1.2 - Correct adaptive pooling and zero-op counting rules (#148)
Compare
🚀 THOP v2.1.1 adds stride-aware image profiling, enabling faster and more reliable MAC estimates for image models while modernizing benchmarks and doc
🚀 THOP v2.1.1 adds stride-aware image profiling, enabling faster and more reliable MAC estimates for image models while modernizing benchmarks and documentation.
profile() support by @glenn-jocher:
stride argument for image models.profile(model, inputs=...) remain unchanged.ultralytics-thop from 2.1.0 to 2.1.1.stride profiling workflow and custom operation rules.AGENTS.md with stronger guidance around minimal changes, solving problems in the owning code path, deleting duplication, and avoiding regressions.stride is omitted.Full Changelog: v2.1.0...v2.1.1
v2.1.1 - Add stride-aware image profiling (#149)
Compare
Removed deprecated calculation helpers and unnecessary NumPy, warning, and tensor dependencies.
THOP v2.1.0 makes PyTorch model profiling substantially faster and simpler, delivering up to 2.4× lower profiling overhead while preserving bit-exact results. ⚡
Faster profiling through optimized bookkeeping
Significant performance improvements
get_flops became approximately 1.31× faster overall.Removed the broken torch.fx profiler
fx_profile.py implementation.Improved compatibility for custom operation rules
float values.Cleaner and more efficient counting internals
get_flops, should complete faster without changing reported results.thop.fx_profile module will need to migrate to the standard profile() API.Full Changelog: v2.0.22...v2.1.0
v2.1.0 - Speed up profiling 2.4x and remove the broken fx profiler (#141)
Compare
THOP v2.0.22 makes model profiling safer and more reliable by ensuring temporary hooks and buffers are always cleaned up—even when profiling fails or
THOP v2.0.22 makes model profiling safer and more reliable by ensuring temporary hooks and buffers are always cleaned up—even when profiling fails or models contain shared modules. 🧹🛡️
Guaranteed cleanup with finally 🧼
Profiling now removes temporary hooks and operation-counting buffers if the model’s forward pass raises an error.
Prevented duplicate hooks on shared modules 🔗
Modules referenced by multiple parent layers are now hooked only once, avoiding orphaned hook handles.
Improved operation counting for shared modules 📊
The profiler tracks already-counted modules to prevent duplicate operation and parameter totals when the same module is reached through multiple paths.
Preserved the model’s original training state ⚙️
Models are still restored to their previous training or evaluation mode after profiling completes or fails.
Version updated to 2.0.22 📦
Prevents permanently corrupted models 🚨
Previously, failed profiling or shared-module architectures could leave hooks pointing to deleted buffers, making the model unusable afterward. This is especially important for models such as RT-DETR-L with heavily shared activation modules.
Makes profiling safer to run on live models ✅
Users can profile models without worrying that temporary profiling state will remain attached to the original model.
Improves profiling accuracy 🎯
Shared modules are no longer counted repeatedly, producing more dependable operation and parameter estimates.
Supports future simplification of FLOPs calculation 🚀
With profiling cleanup now reliable across success and failure paths, Ultralytics can eventually remove the defensive deepcopy(model) workaround used by get_flops().
No user-facing API changes are required 👍
Existing thop.profile() workflows should continue to work while benefiting from improved robustness.
Full Changelog: v2.0.21...v2.0.22
v2.0.22 - Leave no hooks or buffers behind when profiling fails or shares modules (#140)
Compare
🧹 THOP 2.0.21 makes model profiling side-effect-free while improving release reliability, documentation accuracy, and development workflows.
🧹 THOP 2.0.21 makes model profiling side-effect-free while improving release reliability, documentation accuracy, and development workflows.
Fixed leaked profiling buffers by @raimbekovm:
profile() now removes temporary hooks and total_ops/total_params buffers from every module it touches.state_dict() or spreading through shared PyTorch modules.Strengthened PyPI publishing reliability:
Modernized CI/CD actions:
setup-uv usage with the shared Ultralytics action for more consistent behavior.Improved notifications and contributor workflows:
AGENTS.md guidance for AI coding agents, with CLAUDE.md linked to it.Updated documentation and code quality:
2.0.21.Full Changelog: v2.0.20...v2.0.21
v2.0.21 - Remove leaked profiling buffers from all modules (#137)
Compare
v2.0.20 is a small but useful compatibility release for thop that officially adds Python 3.14 support 🐍✨, with a minor workflow maintenance update to
v2.0.20 is a small but useful compatibility release for thop that officially adds Python 3.14 support 🐍✨, with a minor workflow maintenance update to keep release notifications reliable 📣
Official Python 3.14 support added ✅
Version bumped to 2.0.20 🔖
2.0.19 to 2.0.20 to publish this compatibility update.No model or runtime feature changes ⚙️
thop.GitHub Actions Slack notification update 🔔
v3.0.2 to v3.0.3.Makes adoption of newer Python versions easier 🚀
thop, since the package now officially declares support.Improves package visibility for tools and indexes 🧰
Low-risk release for existing users 👍
2.0.19.Better release workflow reliability 📬
In short, v2.0.20 is a compatibility-focused maintenance release: the biggest takeaway is official Python 3.14 support, with no disruption to existing thop functionality 🎉
Full Changelog: v2.0.19...v2.0.20
v2.0.20 - Add Python 3.14 support (#124)
Compare
v2.0.19 is a maintenance-focused release: it officially bumps the package version, improves profiling correctness for parameter counting, and moderniz
v2.0.19 is a maintenance-focused release: it officially bumps the package version, improves profiling correctness for parameter counting, and modernizes CI/CD workflows—without introducing new model architectures or user-facing API changes. 📦✅
(Most immediate change, current PR #122) thop version updated from 2.0.18 → 2.0.19 by @glenn-jocher 🔢
Profiling correctness fix (important functional improvement) 🧠
thop/profile.py, recursive counting now starts with the module’s own parameter count (module.total_params.item()), improving total parameter accounting.thop/vision/basic_hooks.py, parameter counting now uses parameters(recurse=False) to avoid double-counting child-module parameters in hierarchical models.New tests to validate Conv2D parameter counting behavior 🧪
Conv2d modules counting their own params correctlySequential wrappers not double-counting child paramsGitHub Actions workflow upgrades ⚙️
checkout, setup-python, upload-artifact, download-artifact) and Slack action versions.Documentation and style cleanups 🧹
thop profiling: more reliable parameter totals, especially in nested module structures. 📈Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.18...v2.0.19
thop v2.0.18 is a maintenance-focused patch release: a version bump with code quality and CI workflow updates—no runtime or API changes. ✅
thop v2.0.18 is a maintenance-focused patch release: a version bump with code quality and CI workflow updates—no runtime or API changes. ✅
thop/__init__.py via PR #105: Bump thop to 2.0.18 🔖__all__, prefixed unused variables, minor f-string improvementNote for maintainers: actions/checkout v5 and setup-uv v7 use newer Node runtimes; ensure self-hosted runners meet the required versions for CI. 🧩
RUF refactor by @glenn-jocher in https://github.com/ultralytics/thop/pull/103thop to 2.0.18 by @glenn-jocher in https://github.com/ultralytics/thop/pull/105Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.17...v2.0.18
v2.0.17 focuses on cleaner, safer imports and internal refactors that make THOP more maintainable and reliable without changing its public API. 🧹✨
v2.0.17 focuses on cleaner, safer imports and internal refactors that make THOP more maintainable and reliable without changing its public API. 🧹✨
__all__ (e.g., profile, profile_origin, clever_format, default_dtype). ✅torch.fx imports and clearer logging/util usage; added short docstrings for readability. 🧠Top PR prioritized:
import * to explicit imports and clarifies module boundaries for safer, more maintainable code.Additional improvements:
profile still work as before. 👍Quick note for users:
from thop import profile, clever_format
For more details, see the PRs: Unpack star imports (PR #98) and Ultralytics Refactor (PR #94).
Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.16...v2.0.17
Improved MACs accounting for ConvTranspose layers and strengthened CI security with automated SBOMs, delivering more accurate profiling results and sa
Improved MACs accounting for ConvTranspose layers and strengthened CI security with automated SBOMs, delivering more accurate profiling results and safer releases. 🚀
Tip: Usage remains the same
Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.15...v2.0.16
This release introduces support for trilinear upsampling in model profiling, alongside several workflow and documentation improvements for better usab
This release introduces support for trilinear upsampling in model profiling, alongside several workflow and documentation improvements for better usability, security, and contributor experience. 🚀
Overall, this update makes THOP more robust, user-friendly, and ready for a wider range of deep learning projects! 🌐✨
format.yml by @glenn-jocher in https://github.com/ultralytics/thop/pull/85Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.14...v2.0.15
Minor updates to standardize license formatting across workflow and project files. 🛠️✨
Minor updates to standardize license formatting across workflow and project files. 🛠️✨
format.yml, publish.yml, and pyproject.toml to a consistent style:Ultralytics YOLO 🚀, AGPL-3.0 license to Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license.Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.13...v2.0.14
Release v2.0.13 introduces significant improvements to the CI/CD workflow for the Ultralytics thop repository, enhancing maintainability, automation,
Release v2.0.13 introduces significant improvements to the CI/CD workflow for the Ultralytics thop repository, enhancing maintainability, automation, and efficiency for package building and publishing. 🚀
check, build, publish, and notify.continue-on-error) for greater workflow resilience, reducing disruptions from non-critical issues.2.0.12 to 2.0.13.This update makes development workflows more efficient for contributors while ensuring smoother experiences for end-users through well-tested and efficiently published updates. 🎉
Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.12...v2.0.13
The release v2.0.12 enhances Slack integration for notifications and updates the project's version.
The release v2.0.12 enhances Slack integration for notifications and updates the project's version.
v1.26.0 to v2.0.0, changing the configuration syntax for more robust notifications.2.0.11 to 2.0.12, reflecting these updates.Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.11...v2.0.12
The v2.0.11 release for the ultralytics/thop project focuses on refining the deployment process through improved GitHub Actions workflows and enhanced
The v2.0.11 release for the ultralytics/thop project focuses on refining the deployment process through improved GitHub Actions workflows and enhanced notification clarity.
publish.yml with an environment section detailing deployment specifications, including environment name and URL for better tracking via GitHub's Deployments tab.2.0.10 to 2.0.11 to reflect these updates.2.0.11 signals minor improvements, assisting users in pinpointing updates and maintaining software consistency. 🆙Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.10...v2.0.11
The release of version 2.0.10 introduces support for Python 3.13 and improvements in release automation processes.
The release of version 2.0.10 introduces support for Python 3.13 and improvements in release automation processes.
requests library with ultralytics-actions to simplify dependencies.check_pypi_version() for version management.ultralytics-actions-summarize-release for release note automation.Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.9...v2.0.10
The release v2.0.9 primarily enhances the publishing workflow for the Ultralytics THOP repository, focusing on improving security and streamlining pro
The release v2.0.9 primarily enhances the publishing workflow for the Ultralytics THOP repository, focusing on improving security and streamlining processes.
Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.8...v2.0.9
New version release for thop: updated from v2.0.7 to v2.0.8 🎉
New version release for thop: updated from v2.0.7 to v2.0.8 🎉
__init__.py, marking the new release.pyproject.toml.ultralytics-thop 2.0.8 by @glenn-jocher in https://github.com/ultralytics/thop/pull/59Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.7...v2.0.8
v2.0.7 enhances the project by improving metadata accessibility and ensuring clarity through focused code updates.
v2.0.7 enhances the project by improving metadata accessibility and ensuring clarity through focused code updates.
pyproject.toml to include new links for Homepage, Source, Documentation, and Changelog.thop/profile.py.count_convNd_ver2 function.Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.6...v2.0.7
This release (v2.0.6) focuses on enhancing performance, improving workflow efficiency, and ensuring clearer and more consistent version handling. Addi
This release (v2.0.6) focuses on enhancing performance, improving workflow efficiency, and ensuring clearer and more consistent version handling. Additionally, a Reddit badge has been added to increase community engagement visibility.
thop library version from 2.0.5 to 2.0.6 for minor updates.Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.5...v2.0.6
Version 2.0.5 includes improvements to the GitHub workflow for processing pull requests and a version bump in the THOP library.
Version 2.0.5 includes improvements to the GitHub workflow for processing pull requests and a version bump in the THOP library.
pull_request and pull_request_target. This ensures that the right information is captured, which simplifies release procedures and enhances automation reliability.Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.4...v2.0.5
The v2.0.4 update introduces enhancements in the automation of GitHub workflows and a version bump for the package.
The v2.0.4 update introduces enhancements in the automation of GitHub workflows and a version bump for the package.
thop library from 2.0.3 to 2.0.4.pull_request_target) are correctly processed along with standard pull requests, leading to more robust and versatile workflow automation. This change can improve the efficiency of release processes and ensure accurate extraction of pull request details, minimizing manual intervention. ⚙️thop library, signaling reliability and improved functionality to its users. 📦Overall, these changes streamline developer operations and ensure consistency in processing updates and version control. 🌐
Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.3...v2.0.4
The v2.0.3 release features improvements in the release automation process and provides detailed test documentation for better understanding and usage
The v2.0.3 release features improvements in the release automation process and provides detailed test documentation for better understanding and usage of THOP components.
Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.2...v2.0.3
Version 2.0.2 brings critical updates for GitHub Actions and versioning improvements.
Version 2.0.2 brings critical updates for GitHub Actions and versioning improvements.
PERSONAL_ACCESS_TOKEN or fallback to GITHUB_TOKEN for authentication.💼 Improved Workflow: By allowing the use of PERSONAL_ACCESS_TOKEN or GITHUB_TOKEN, it ensures more flexible and reliable authentication in GitHub Actions.
🆙 Versioning Update: Updating the version number to 2.0.2 reflects the latest changes and fixes.
Full Changelog: https://github.com/ultralytics/thop/compare/v2.0.1...v2.0.2
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →