Skip to content

v2.1.5 - Keep attention profiling compatible with torch 1.x (#159)

Choose a tag to compare

@github-actions github-actions released this 29 Jul 19:11
· 16 commits to main since this release
8269c6e

🌟 Summary

THOP 2.1.5 improves PyTorch compatibility by making attention-operation profiling safe across both PyTorch 1.x and 2.x versions. πŸ› οΈ

πŸ“Š Key Changes

  • Fixed nn.MultiheadAttention profiling on PyTorch 1.x
    Attention profiling is now enabled only when PyTorch forward hooks can expose keyword arguments.

  • Preserved accurate attention counting on PyTorch 2.x
    Newer PyTorch versions continue to report attention MACs correctly, including mixed cross-attention scenarios.

  • Avoided crashes on older PyTorch versions
    When hook inputs cannot be reconstructed, THOP now skips attention MAC counting rather than attempting an unsafe call.

  • Updated the package version
    The release version was bumped from 2.1.4 to 2.1.5.

  • Validated across profiling APIs βœ…
    Tests confirmed accurate results on PyTorch 2.x and safe zero-count behavior under PyTorch 1.x compatibility conditions.

🎯 Purpose & Impact

  • Improves backward compatibility for users running models with PyTorch 1.x.
  • Prevents profiling-related runtime errors without changing model execution.
  • Maintains modern profiling accuracy for PyTorch 2.x users.
  • Users should receive a more reliable experience when using THOP to estimate model complexity, especially for models containing multi-head or cross-attention layers. πŸ“ˆ

What's Changed

Full Changelog: v2.1.4...v2.1.5