Commit 9169e81
Fix PyTorch 2.3.1 compatibility: add version guard for torch.library.… (#12206)
* Fix PyTorch 2.3.1 compatibility: add version guard for torch.library.custom_op
- Add hasattr() check for torch.library.custom_op and register_fake
- These functions were added in PyTorch 2.4, causing import failures in 2.3.1
- Both decorators and functions are now properly guarded with version checks
- Maintains backward compatibility while preserving functionality
Fixes #12195
* Use dummy decorators approach for PyTorch version compatibility
- Replace hasattr check with version string comparison
- Add no-op decorator functions for PyTorch < 2.4.0
- Follows pattern from #11941 as suggested by reviewer
- Maintains cleaner code structure without indentation changes
* Update src/diffusers/models/attention_dispatch.py
Update all the decorator usages
Co-authored-by: Aryan <[email protected]>
* Update src/diffusers/models/attention_dispatch.py
Co-authored-by: Aryan <[email protected]>
* Update src/diffusers/models/attention_dispatch.py
Co-authored-by: Aryan <[email protected]>
* Update src/diffusers/models/attention_dispatch.py
Co-authored-by: Aryan <[email protected]>
* Move version check to top of file and use private naming as requested
* Apply style fixes
---------
Co-authored-by: Aryan <[email protected]>
Co-authored-by: Aryan <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>1 parent 8160289 commit 9169e81
1 file changed
+25
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
113 | 134 | | |
114 | 135 | | |
115 | 136 | | |
| |||
473 | 494 | | |
474 | 495 | | |
475 | 496 | | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | 497 | | |
480 | 498 | | |
481 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
482 | 502 | | |
483 | 503 | | |
484 | 504 | | |
| |||
487 | 507 | | |
488 | 508 | | |
489 | 509 | | |
490 | | - | |
| 510 | + | |
491 | 511 | | |
492 | 512 | | |
493 | 513 | | |
| |||
0 commit comments