ultralytics-thop
Ultralytics THOP package for fast computation of PyTorch model FLOPs and parameters.
Decision gist · record as of 2026-08-14
Yes. THOP is actively maintained, has no known vulnerabilities, installs with minimal friction (two common dependencies), and solves a concrete problem in model development. The AGPL-3.0 license is a consideration only if you plan to distribute proprietary modifications; for research, internal tools, or open-source projects, it poses no barrier. Install it if you need to profile PyTorch model efficiency.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires PyTorch and a compatible model instance; the profile() call executes a forward pass so the model must be in a state ready to accept the provided input tensor shape.
- Low friction installation with only numpy and torch as runtime dependencies.
- Actively maintained by Ultralytics with a recent release (15 days old) and ongoing repository activity.
License · maintenance · safety
AGPL-3.0 (agpl) — Licensed under AGPL-3.0, which requires derivative works and modifications to remain open-source. An enterprise license is available from Ultralytics for proprietary use without open-source obligations.
last release 2026-07-30 (15 days) · last repo commit 2026-08-02 · 151 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 6,458,146 downloads/mo, #1,907 on PyPI
Alternatives
Verify before relying
pip install ultralytics-thop
import torch
from thop import profile
model = torch.nn.Sequential(torch.nn.Conv2d(3, 64, 3, padding=1))
inputs = (torch.randn(1, 3, 224, 224),)
macs, params = profile(model, inputs=inputs)
print(f"MACs: {macs}, Parameters: {params}")- Whether custom counting rules for third-party modules are extensible enough for all common modern architectures beyond the built-in layer types.
- Performance overhead of profiling on very large models or when profiling is called repeatedly during training.
- Accuracy of MAC estimates when using the stride parameter for spatial-only models versus actual deployment compute.
What it is and what it does
THOP is a PyTorch operation counter that measures model complexity by counting Multiply-Accumulate Operations and parameters. It runs a single forward pass through your model with example inputs and returns MAC and parameter counts, making it useful for comparing architecture efficiency before training or deployment. The package includes built-in counting rules for common layer types (convolutional, normalization, pooling, activation, linear, recurrent) and allows you to define custom counting rules for unsupported modules via forward hooks.
The package is lightweight and maintained by Ultralytics, with support for modern Python versions (3.8 through 3.14) across Linux, macOS, and Windows. It depends only on numpy and torch, keeping installation friction minimal. For image models, you can pass a stride parameter to estimate MACs from smaller stride-aligned profiles, or omit it for exact single-pass profiling. A helper function (clever_format) converts raw counts into human-readable notation.
Use it for
- Compare computational complexity of different neural network architectures before training to choose the most efficient design.
- Estimate deployment requirements by profiling model MACs and parameters to predict inference latency and memory usage.
- Analyze custom or third-party layer implementations by registering custom counting rules to understand their computational cost.
- Profile models with variable input sizes using the stride parameter to estimate MACs across different spatial dimensions.
- Convert raw operation counts into human-readable format using clever_format for reporting and documentation.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
THOP is actively maintained, has no known vulnerabilities, installs with minimal friction (two common dependencies), and solves a concrete problem in model development. The AGPL-3.0 license is a consideration only if you plan to distribute proprietary modifications; for research, internal tools, or open-source projects, it poses no barrier. Install it if you need to profile PyTorch model efficiency.
Install
ultralytics-thop on PyPI
Before you install
Low friction installation with only numpy and torch as runtime dependencies. Actively maintained by Ultralytics with a recent release (15 days old) and ongoing repository activity.
Requires PyTorch and a compatible model instance; the profile() call executes a forward pass so the model must be in a state ready to accept the provided input tensor shape.
License in practice
Licensed under AGPL-3.0, which requires derivative works and modifications to remain open-source. An enterprise license is available from Ultralytics for proprietary use without open-source obligations.
Quickstart
pip install ultralytics-thop
import torch
from thop import profile
model = torch.nn.Sequential(torch.nn.Conv2d(3, 64, 3, padding=1))
inputs = (torch.randn(1, 3, 224, 224),)
macs, params = profile(model, inputs=inputs)
print(f"MACs: {macs}, Parameters: {params}")
Verify before relying
- Whether custom counting rules for third-party modules are extensible enough for all common modern architectures beyond the built-in layer types.
- Performance overhead of profiling on very large models or when profiling is called repeatedly during training.
- Accuracy of MAC estimates when using the stride parameter for spatial-only models versus actual deployment compute.
Package facts
| License | AGPL-3.0 agpl |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesnumpytorch |
| Maintenance | Actively maintained 15 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,458,146 / month, #1,907 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchLicense :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)Operating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/EngineeringTopic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Scientific/Engineering :: Image RecognitionTopic :: Software Development |
Evidence: ultralytics_thop-2.1.6-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pytorch model flops counter”
- ultralytics-thopProfiles PyTorch models by counting Multiply-Accumulate Operations…
- fvcorefvcore provides shared computer vision utilities for PyTorch,…
- thopCounts floating-point operations (MACs) and parameters in PyTorch…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also thop · torchprofile · torchsummary · effdet · torch · ultralytics · pytorchcv · opt-einsum-fx · onnx-tool · torchinfo