Repository navigation
v2.2.4 - Clear the autocast cache after profiling (#187)
🌟 Summary
THOP 2.2.4 fixes an AMP/autocast issue that could break gradient-based work after profiling.
📊 Key Changes
- 🧹
profile()andprofile_origin()now clear PyTorch’s autocast cache when profiling finishes, including when an error occurs. - The fix targets cached, detached half-precision casts that can affect a later forward pass under autocast, particularly with PyTorch 2.10 and older.
🎯 Purpose & Impact
- ✅ Prevents backward-pass errors such as “does not require grad” after profiling.
- 🚀 Improves reliability for Ultralytics AutoBatch and similar workflows that profile a model before running forward and backward passes under AMP.
- 🌿 Outside autocast, clearing the cache has no effect. No model behavior or model features changed.
What's Changed
New Contributors
Full Changelog: v2.2.3...v2.2.4