Memory optimization patches for HuggingFace Transformers.
-
Memory Reduction - Significantly lowers memory usage in Transformers models
-
Zero Configuration - Works automatically after import
pip install git+https://github.com/GeeeekExplorer/transformers-patch.gitJust import the patch before loading any Transformers models:
import transformers_patch
from transformers import AutoModelTest Configuration:
- 8x GPU machine
- Micro batch size: 1
- Sequence length: 4096
- Gradient checkpointing: Disabled
- Model: Qwen3-8B
50% reduction in activation memory!
See complete example in train.py.
