torchprofile
Count the MACs / FLOPs of PyTorch models
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a real need for PyTorch developers who want to profile model efficiency. The MIT license is permissive. Main caveat: your model must be traceable with torch.jit.trace, which excludes models with dynamic control flow.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python >= 3.9 and torch installed; models must be traceable with torch.jit.trace.
- Low friction: pure Python wheel with only torch as a runtime dependency.
- Active maintenance with recent commits and a moderate user base.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions.
last release 2026-03-10 (157 days) · last repo commit 2026-03-11 · 645 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 297,561 downloads/mo, #7,882 on PyPI
Alternatives
Verify before relying
pip install torchprofile
import torch
from torchprofile import profile_macs
model = torch.nn.Linear(10, 10)
inputs = torch.randn(1, 10)
macs = profile_macs(model, inputs)
print(macs)- Whether the tracing approach handles dynamic control flow or models with conditional branches accurately.
- Performance characteristics when profiling very large models or batches.
- Compatibility with torch.jit.trace limitations across different PyTorch versions.
What it is and what it does
TorchProfile is a lightweight profiler that measures the computational cost of PyTorch models by counting multiply-accumulate operations (MACs). It works by tracing the model's computation graph using torch.jit.trace, which is more accurate than hook-based profilers and more general than ONNX-based approaches. The package outputs either a single aggregate MAC count or a per-operator breakdown showing which layers consume the most computation.
You pass a model and sample input tensors to the profile_macs function, and it returns the total MACs or a dictionary mapping operation nodes to their individual MAC counts. This is useful for understanding model efficiency, comparing architectures, and identifying computational bottlenecks without running the model on actual hardware.
Use it for
- Estimate computational cost of a model before deploying to resource-constrained devices.
- Compare MAC efficiency across different model architectures or hyperparameter choices.
- Identify which layers in a model consume the most computation for optimization targeting.
- Profile models during development to catch unexpectedly expensive operations early.
- Generate per-operator breakdowns for detailed performance analysis and model auditing.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a real need for PyTorch developers who want to profile model efficiency. The MIT license is permissive. Main caveat: your model must be traceable with torch.jit.trace, which excludes models with dynamic control flow.
Install
torchprofile on PyPI
Before you install
Low friction: pure Python wheel with only torch as a runtime dependency. Active maintenance with recent commits and a moderate user base.
Requires Python >= 3.9 and torch installed; models must be traceable with torch.jit.trace.
License in practice
MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions.
Quickstart
pip install torchprofile
import torch
from torchprofile import profile_macs
model = torch.nn.Linear(10, 10)
inputs = torch.randn(1, 10)
macs = profile_macs(model, inputs)
print(macs)
Verify before relying
- Whether the tracing approach handles dynamic control flow or models with conditional branches accurately.
- Performance characteristics when profiling very large models or batches.
- Compatibility with torch.jit.trace limitations across different PyTorch versions.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagetorch |
| Maintenance | Actively maintained 157 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 297,561 / month, #7,882 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 :: Science/ResearchLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: Artificial Intelligence |
Evidence: torchprofile-0.1.0-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 mac counter”
- torchprofileCounts multiply-accumulate operations (MACs) in PyTorch models by…
- thopCounts floating-point operations (MACs) and parameters in PyTorch…
- ultralytics-thopProfiles PyTorch models by counting Multiply-Accumulate Operations…
Give your agent the search over MCP, or paste the wish link into any chat.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also ultralytics-thop · thop · torch-tb-profiler · HolisticTraceAnalysis · torch · onnx2torch · fvcore · torcheval · torchviz