Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GeeeekExplorer/transformers-patch

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transformers-Patch 🛠️

Memory optimization patches for HuggingFace Transformers.

Features ✨

  • Memory Reduction - Significantly lowers memory usage in Transformers models

  • Zero Configuration - Works automatically after import

Installation ⚡

pip install git+https://github.com/GeeeekExplorer/transformers-patch.git

Quick Start 🚀

Just import the patch before loading any Transformers models:

import transformers_patch
from transformers import AutoModel

Benchmark 📊

Test Configuration:

  • 8x GPU machine
  • Micro batch size: 1
  • Sequence length: 4096
  • Gradient checkpointing: Disabled
  • Model: Qwen3-8B
Memory Component Fixed Allocation Before Patch After Patch
Model + Gradients 30.5 GB - -
ZeRO Optimizer States 11.4 GB - -
Activations - 35.4 GB 17.8 GB

50% reduction in activation memory!

Example Usage 📋

See complete example in train.py.

Acknowledgements 🙏

About

patches for huggingface transformers to save memory

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.