Spaces:
Runtime error
Runtime error
Commit
·
fd334d1
1
Parent(s):
50f8e45
Fix torch/transformers version incompatibility
Browse filesFix for: AttributeError: module 'torch.utils._pytree' has no attribute 'register_pytree_node'
Root Cause:
- torch==2.1.0 is too old for transformers>=4.46.0
- transformers 4.46+ uses register_pytree_node API
- This API only exists in torch 2.2+
Solution:
- Upgrade to torch>=2.2.0,<2.6.0
- Ensures compatibility with transformers 4.46+
- Still uses CPU-only torch from PyPI
- Cap at <2.6.0 for stability
Version Matrix:
✅ torch 2.2.0+ : transformers 4.46+ : Compatible
❌ torch 2.1.0 : transformers 4.46+ : Incompatible (pytree API missing)
This allows transformers to properly initialize with torch 2.2+.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
- requirements.txt +2 -2
requirements.txt
CHANGED
|
@@ -22,7 +22,7 @@ aiosqlite>=0.19.0
|
|
| 22 |
numpy>=1.24.3,<2.0.0
|
| 23 |
|
| 24 |
# HuggingFace dependencies (for Granite 4 local loading)
|
| 25 |
-
#
|
| 26 |
-
torch
|
| 27 |
transformers>=4.46.0
|
| 28 |
accelerate>=0.20.0 # For efficient model loading
|
|
|
|
| 22 |
numpy>=1.24.3,<2.0.0
|
| 23 |
|
| 24 |
# HuggingFace dependencies (for Granite 4 local loading)
|
| 25 |
+
# Torch 2.2+ required for transformers 4.46+
|
| 26 |
+
torch>=2.2.0,<2.6.0
|
| 27 |
transformers>=4.46.0
|
| 28 |
accelerate>=0.20.0 # For efficient model loading
|