v2.0.21 - Remove leaked profiling buffers from all modules (#137)
🌟 Summary
🧹 THOP 2.0.21 makes model profiling side-effect-free while improving release reliability, documentation accuracy, and development workflows.
📊 Key Changes
-
Fixed leaked profiling buffers by @raimbekovm:
profile()now removes temporary hooks andtotal_ops/total_paramsbuffers from every module it touches.- Prevents profiling metadata from remaining in
state_dict()or spreading through shared PyTorch modules. - FLOPs and parameter results remain unchanged.
-
Strengthened PyPI publishing reliability:
- Queues release workflows to avoid overlapping publish runs.
- Retries failed PyPI uploads, including transient Sigstore, Rekor, and network failures.
- Supports recovery of partially completed releases and safely reuses existing tags.
- Allows SBOM uploads to replace incomplete files.
-
Modernized CI/CD actions:
- Updated GitHub Actions checkout, Python setup, and Slack integrations.
- Replaced direct
setup-uvusage with the shared Ultralytics action for more consistent behavior.
-
Improved notifications and contributor workflows:
- Slack release messages are shorter, clearer, and include clickable release, run, and PR links.
- Replaced the third-party CLA action with the shared Ultralytics CLA workflow.
- Added
AGENTS.mdguidance for AI coding agents, withCLAUDE.mdlinked to it.
-
Updated documentation and code quality:
- Corrected benchmark outputs and README links.
- Standardized PyTorch imports and logging practices for Ruff 0.16.0 compatibility.
- Updated the version to
2.0.21.
🎯 Purpose & Impact
- ✅ More trustworthy profiling: Users can profile a model without unintentionally modifying its saved state or affecting models created later in the same process.
- 🧠 Safer repeated profiling: This is especially important for complex models with shared activation modules or custom containers.
- 🚀 More dependable releases: Queuing and retry behavior reduce failed PyPI releases caused by temporary infrastructure or network issues.
- 🔄 Better recovery: Maintainers can resume incomplete releases without manually recreating tags or release metadata.
- 📚 Clearer documentation: Correct benchmark values and contribution links make THOP easier to understand and use.
- 🛠️ No expected API disruption: The release preserves profiling results and existing functionality while improving cleanup, automation, and maintainability.
What's Changed
- Improve README accuracy and links by @glenn-jocher in #125
- Bump actions/checkout from v6 to v7 in /.github/workflows by @UltralyticsAssistant in #126
- Simplify Slack notification messages by @glenn-jocher in #127
- Linkify PR numbers in publish Slack notifications by @glenn-jocher in #128
- Add AGENTS.md agent guidance and fix README drift by @glenn-jocher in #129
- Harden publish workflow recovery, notifications, and dispatch guard by @glenn-jocher in #130
- Replace third-party CLA action by @glenn-jocher in #131
- Bump slackapi/slack-github-action from v3.0.3 to v3.0.5 in /.github/workflows by @UltralyticsAssistant in #132
- Bump slackapi/slack-github-action from v3.0.5 to v4.0.0 in /.github/workflows by @UltralyticsAssistant in #133
- Use shared setup-uv action everywhere by @glenn-jocher in #134
- Bump actions/setup-python from v6 to v7 in /.github/workflows by @UltralyticsAssistant in #135
- Queue publish runs and retry PyPI upload failures by @glenn-jocher in #136
- Ruff 0.16.0 compatibility changes by @glenn-jocher in #138
- Ruff 0.16.0 compatibility changes by @glenn-jocher in #139
- Remove leaked profiling buffers from all modules by @raimbekovm in #137
New Contributors
- @raimbekovm made their first contribution in #137
Full Changelog: v2.0.20...v2.0.21