Close Menu
techwavedispatch.com

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Welcome aMUSEd: Efficient Text-to-Image Generation

    November 12, 2026

    Jensen Huang Is Out. Will Nvidia’s Rivals Cash In?

    November 12, 2026

    Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL

    November 12, 2026
    Facebook X (Twitter) Instagram
    Trending
    • Welcome aMUSEd: Efficient Text-to-Image Generation
    • Jensen Huang Is Out. Will Nvidia’s Rivals Cash In?
    • Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL
    • Mint Mobile Will Give You $500 off Select New Phones When You Sign Up for a Year
    • Democrats launch Nvidia investigation, write scathing letter on Huang’s ‘scheme’ with Trump
    • an end-to-end example with Vectara’s hallucination leaderboard
    • The 10 Best Early Black Friday TV Deals (2026)
    • FAA expands AI advice to manage air traffic congestion across entire US airspace
    Facebook X (Twitter) Instagram
    techwavedispatch.com
    Subscribe
    Thursday, November 12
    • Home
    • AI Tools & Software
    • Machine Learning
    • Generative AI
    • Robotics & Automation
    • Future Tech & Hardware
    • AI in Business
    • Ethics & Regulations
    • More
      • Gadgets & Smart Devices
      • Cybersecurity & AI
      • Tech Breakthroughs
    techwavedispatch.com
    Home»AI Tools & Software»Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL
    AI Tools & Software

    Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL

    adminBy adminNovember 12, 2026No Comments5 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Pulling your hair out because LLM fine-tuning is taking forever? In this post, we introduce a lightweight tool developed by the community to make LLM fine-tuning go super fast!

    Before diving into Unsloth, it may be helpful to read our QLoRA blog post, or be familiar with LLM fine-tuning using the 🤗 PEFT library.



    Unsloth – 2x faster, -40% memory usage, 0% accuracy degradation

    Unsloth is a lightweight library for faster LLM fine-tuning which is fully compatible with the Hugging Face ecosystem (Hub, transformers, PEFT, TRL). The library is actively developed by the Unsloth team (Daniel and Michael) and the open source community. The library supports most NVIDIA GPUs –from GTX 1070 all the way up to H100s–, and can be used with the entire trainer suite from the TRL library (SFTTrainer, DPOTrainer, PPOTrainer). At the time of writing, Unsloth supports the Llama (CodeLlama, Yi, etc) and Mistral architectures.

    Unsloth works by overwriting some parts of the modeling code with optimized operations. By manually deriving backpropagation steps and rewriting all Pytorch modules into Triton kernels, Unsloth can both reduce memory usage and make fine-tuning faster. Crucially, accuracy degradation is 0% with respect to normal QLoRA, because no approximations are made in the optimized code.



    Benchmarking

    1 A100 40GB Dataset 🤗 Hugging Face 🤗 + Flash Attention 2 🦥 Unsloth 🦥 VRAM reduction
    Code Llama 34b Slim Orca 1x 1.01x 1.94x -22.7%
    Llama-2 7b Slim Orca 1x 0.96x 1.87x -39.3%
    Mistral 7b Slim Orca 1x 1.17x 1.88x -65.9%
    Tiny Llama 1.1b Alpaca 1x 1.55x 2.74x -57.8%
    DPO with Zephyr Ultra Chat 1x 1.24x 1.88x -11.6%
    Free Colab T4 Dataset 🤗 Hugging Face 🤗 + Pytorch 2.1.1 🦥 Unsloth 🦥 VRAM reduction
    Llama-2 7b OASST 1x 1.19x 1.95x -43.3%
    Mistral 7b Alpaca 1x 1.07x 1.56x -13.7%
    Tiny Llama 1.1b Alpaca 1x 2.06x 3.87x -73.8%
    DPO with Zephyr Ultra Chat 1x 1.09x 1.55x -18.6%

    Unsloth was benchmarked across 59 runs using 4 datasets on Tesla T4 and A100 Google Colab instances. QLoRA was applied to all linear layers (attention and MLP) with a rank of 16, and gradient checkpointing was on. By testing against the latest Transformers version (4.36), which has SDPA natively integrated if you have Pytorch 2.1.1, Unsloth is up to 2.7x faster and uses up to 74% less memory. We also tested Unsloth on a free Google Colab instance (low RAM, 1 T4 GPU, Pytorch 2.1.0 CUDA 12.1). All 59 notebooks are provided for full reproducibility, and more details are in Unsloth’s benchmarking details here



    How do I use Unsloth?

    Just load your model with FastLanguageModel.from_pretrained! Currently, Unsloth supports Llama and Mistral type architectures (Yi, Deepseek, TinyLlama, Llamafied Qwen). Please, open a Github issue if you want others! Also, on the latest Transformers main branch, you can now load pre-quantized 4bit models directly! This makes downloading models 4x faster, and reduces memory fragmentation by around 500MB, which allows you to fit larger batches! We have a few pre-quantized models for your convenience, including unsloth/llama-2-7b-bnb-4bit, unsloth/llama-2-13b-bnb-4bit, unsloth/mistral-7b-bnb-4bit and unsloth/codellama-34b-bnb-4bit.

    You will need to provide your intended maximum sequence length to from_pretrained. Unsloth internally performs RoPE Scaling, so larger maximum sequence lengths are automatically supported. Otherwise the API is pretty much the same as transformers’ from_pretrained, except that FastLanguageModel.from_pretrained also returns the model tokenizer for convenience.

    from unsloth import FastLanguageModel
    
    model, tokenizer = FastLanguageModel.from_pretrained(
        model_name = "unsloth/mistral-7b-bnb-4bit", 
        max_seq_length = 2048, 
        load_in_4bit = True,
    )
    

    Once the model has been loaded, use FastLanguageModel.get_peft_model to attach adapters in order to perform QLoRA fine-tuning.

    
    model = FastLanguageModel.get_peft_model(
        model,
        r = 16,
        target_modules = ["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
        lora_alpha = 16,
        lora_dropout = 0, 
        bias = "none",    
        use_gradient_checkpointing = True,
    )
    

    Once adapters are attached, you can use the model directly within any class from the HF ecosystem, such as the SFTTrainer from TRL!



    Unsloth + TRL integration

    To use Unsloth with the TRL library, simply pass the Unsloth model into SFTTrainer or DPOTrainer! The trained model is fully compatible with the Hugging Face ecosystem, so you can push the final model to the Hub and use transformers for inference out of the box!

    import torch
    
    from trl import SFTTrainer
    from transformers import TrainingArguments
    from datasets import load_dataset
    
    from unsloth import FastLanguageModel
    
    max_seq_length = 2048 
    
    dataset = load_dataset("imdb", split="train")
    
    
    model, tokenizer = FastLanguageModel.from_pretrained(
        model_name = "unsloth/mistral-7b-bnb-4bit", 
        max_seq_length = max_seq_length,
        dtype = None,
        load_in_4bit = True,
    )
    
    
    model = FastLanguageModel.get_peft_model(
        model,
        r = 16,
        target_modules = ["q_proj", "k_proj", "v_proj", "o_proj",
                          "gate_proj", "up_proj", "down_proj",],
        lora_alpha = 16,
        lora_dropout = 0, 
        bias = "none",    
        use_gradient_checkpointing = True,
        random_state = 3407,
        max_seq_length = max_seq_length,
    )
    
    trainer = SFTTrainer(
        model = model,
        train_dataset = dataset,
        dataset_text_field = "text",
        max_seq_length = max_seq_length,
        tokenizer = tokenizer,
        args = TrainingArguments(
          per_device_train_batch_size = 2,
          gradient_accumulation_steps = 4,
          warmup_steps = 10,
          max_steps = 60,
          fp16 = not torch.cuda.is_bf16_supported(),
          bf16 = torch.cuda.is_bf16_supported(),
          logging_steps = 1,
          output_dir = "outputs",
          optim = "adamw_8bit",
          seed = 3407,
      ),
    )
    trainer.train()
    



    Reproducible notebooks

    We are sharing below fully reproducible notebooks for anyone that wants to try out Unsloth with SFTTrainer on a free-tier Google Colab instance.

    Llama 7b Free Tesla T4 colab example here

    Mistral 7b Free Tesla T4 colab example here

    CodeLlama 34b A100 colab example here

    Zephyr DPO replication T4 colab example here

    Faster Finetuning LLM TRL Unsloth
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    admin
    • Website

    Related Posts

    Welcome aMUSEd: Efficient Text-to-Image Generation

    November 12, 2026

    an end-to-end example with Vectara’s hallucination leaderboard

    November 12, 2026

    Run ComfyUI workflows for free with Gradio on Hugging Face Spaces

    November 12, 2026
    Leave A Reply Cancel Reply

    Top Posts

    NVIDIA Is Investigating Reports That CEO Jensen Huang Was The Target Of Chinese Spy Efforts

    November 8, 202619 Views

    ADIndex: Layer-Adaptive Sparse Attention Indexing via Group-Level Distillation

    November 11, 20265 Views

    Anthropic releases new Mythos and Fable models amid RSI concerns

    November 9, 20265 Views

    Anthropic says AI is eroding Nvidia’s CUDA lead, cutting an AMD chip switch from months to three days

    November 11, 20264 Views
    Don't Miss

    Welcome aMUSEd: Efficient Text-to-Image Generation

    By adminNovember 12, 20260

    We’re excited to present an efficient non-diffusion text-to-image model named aMUSEd. It’s called so because…

    Jensen Huang Is Out. Will Nvidia’s Rivals Cash In?

    November 12, 2026

    Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL

    November 12, 2026

    Mint Mobile Will Give You $500 off Select New Phones When You Sign Up for a Year

    November 12, 2026
    About Us

    Welcome to TechWave Dispatch

    At TechWave Dispatch, we bring you the latest news, insights, and developments from the ever-evolving world of technology. Our mission is to keep readers informed about the innovations shaping our digital future.

    From artificial intelligence and machine learning to cybersecurity, robotics, smart devices, and groundbreaking technologies, we cover the topics that matter in today's fast-moving tech landscape.

    Our Picks

    Welcome aMUSEd: Efficient Text-to-Image Generation

    November 12, 2026

    Jensen Huang Is Out. Will Nvidia’s Rivals Cash In?

    November 12, 2026

    Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL

    November 12, 2026
    Most Popular

    Who Controls Scientific Discovery? – O’Reilly

    November 6, 20260 Views

    After blocking Muse, Amazon now lets users text Alexa to help them shop

    November 6, 20260 Views

    A controlled world for robot learning and evaluation

    November 6, 20260 Views
    Facebook X (Twitter) Instagram Pinterest
    • Terms and Conditions
    • Privacy Policy
    • Contact Us
    • About Us
    © 2026 TechWave Dispatch. All Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.