Skip to content

v2.2.4 - Clear the autocast cache after profiling (#187)

Choose a tag to compare

@github-actions github-actions released this 01 Nov 13:25
· 2 commits to main since this release
16757c4

🌟 Summary

THOP 2.2.4 fixes an AMP/autocast issue that could break gradient-based work after profiling.

📊 Key Changes

  • 🧹 profile() and profile_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

  • Clear the autocast cache after profiling by @Y-T-G in #187

New Contributors

Full Changelog: v2.2.3...v2.2.4