DaoyuanLi2816/can-i-finetune-this
Estimate whether a Hugging Face model fits and fine-tunes on your local GPU.
What it solves
It solves the problem of "Out of Memory" (OOM) errors when fine-tuning Large Language Models (LLMs) on consumer-grade GPUs. Instead of downloading massive model weights only to find the hardware cannot handle the training process, this tool allows users to estimate VRAM usage and determine feasibility before starting.
How it works
The tool uses a memory model that accounts for factors often missed by basic estimators, including:
- Weight Memory: Handles various precisions (fp32, fp16, bf16, int8, NF4) and accounts for the fp32 upcast of embeddings and norms in QLoRA.
- Training Buffers: Models the logits/cross-entropy chain, which is a significant memory consumer for models with large vocabularies.
- Parameter Tracking: Calculates memory for LoRA/QLoRA trainable parameters, gradients, and optimizer states (e.g., AdamW vs 8-bit AdamW).
- Activations: Estimates memory based on sequence length, batch size, and model architecture, with options for gradient checkpointing.
- Validation: Users can run local benchmarks (
bench) and calibrate the estimator (calibrate) to ground the static predictions in real-world measurements on their specific hardware.
Who it’s for
Developers and AI researchers using consumer NVIDIA GPUs (typically 12–24 GB VRAM) who want to fine-tune open-weight LLMs using LoRA or QLoRA without wasting time and disk space on failing configurations.
Highlights
- VRAM Estimation: Provides a detailed memory breakdown (static model, activations, logits, etc.) and a feasibility decision.
- Configuration Recommendations: Suggests optimal batch sizes, sequence lengths, and LoRA ranks to fit a model within available VRAM.
- Recipe Generation: Creates ready-to-run training scripts using the Hugging Face, PEFT, and TRL ecosystem.
- Hardware Grounding: Includes a benchmarking suite to verify estimates against actual peak memory usage on the user's machine.
Related
- Dispatch
- Project
- Project
- Project
- Project