Enjoying this issue?
Get tomorrow's AI & engineering digest in your inbox — hand-picked, summarized, and always spam-free.
TLDR
Unsloth achieves roughly 2x speed and 70% less memory on single-GPU fine-tuning by hand-deriving matrix differentials for the specific shape of LoRA adapters, bypassing PyTorch's general-purpose Autograd. The real advantage is a curve, not a fixed multiplier: modest at small context lengths, growing until the baseline runs out of memory. Multi-GPU support remains incomplete and inconsistently documented, making Unsloth a clear win for single-GPU workflows but not yet a replacement for Axolotl or LLaMA-Factory in distributed settings.
Key points
- Unsloth is an open-source library (Apache 2.0) that runs on top of PyTorch and provides custom Triton kernels for fine-tuning large language models.
- The speed gain comes from hand-deriving the six matrix differentials needed for the attention block when using a frozen weight matrix with a small trainable adapter (LoRA), and from reordering matrix multiplications to avoid building large intermediate matrices.
- Memory savings are largely due to implementing 'cut cross entropy' (based on an Apple paper), which computes the loss in slices on the fly instead of materializing the full logit matrix, reducing loss computation memory from 24 GB to 1 MB in the cited example.
- On an 8 GB GPU, Unsloth fine-tunes an 8B parameter Llama model at ~3,000 tokens context, while the Hugging Face path with Flash Attention runs out of memory. On an 80 GB GPU, Unsloth achieves 342,000 tokens context vs. 28,000 for the baseline.
- Using tiled feed-forward layers (with Stas Bekman), Unsloth pushed a 20B parameter model past 500,000 tokens context on a single 80 GB GPU, up from 80,000.
- Unsloth's published benchmarks show the speedup varies with context length: 1.4x at 1,000 tokens, 7.3x at 8,000 tokens, and the baseline runs out of memory at 16,000 tokens.
- Multi-GPU support is inconsistently documented: the multi-GPU page says it's complex and 'coming soon,' the README says it's available now, and the pricing page lists it as 'coming soon' for free tiers while paid tiers require contacting sales.
- In October 2024, Unsloth discovered and helped fix a bug in gradient accumulation that caused higher training losses than mathematically expected, which was present in nearly every open-source trainer.
- Unsloth released a desktop application on August 11 that runs and trains models locally on Mac, Windows, and Linux, merging over 200 pull requests nine days later.
- Unsloth was added to the PyTorch ecosystem landscape in April 2025.
Tools mentioned
Techniques
- Hand-derived matrix differentials for LoRA adapter shape
- Reordering matrix multiplications to avoid large intermediate matrices
- Cut cross entropy (loss computation in slices)
- Tiled feed-forward layers
- Gradient accumulation bug fix (cross-entropy denominator averaging)
Stop scrolling. Start reading smarter.
Receive the day's most important AI & engineering updates in one concise email. No spam.
Transcript (captions)
two times faster, 70% less memory, and zero loss in accuracy, which is the part that should not be possible. Normally, you buy speed with precision. You approximate something, you round
something off, and the model comes out a little worse. This one does not do that. Same gradients, same loss curve, same final weights. The library is called Unsloth. Free, open- source, Apache
licensed, and it runs on top of PyTorch, which makes the fight in the title a strange one. Unsloth is not competing with PyTorch. It is built out of it. So the real question is narrower and
better. Where does the two times actually come from? Speed is never free. Something in that training loop is being paid for. And you are about to see exactly what. The answer starts with one
sentence written by Daniel Han on the day he and Michael Han launch the thing. His words, PyTorch's Autograd is reasonably efficient for most tasks, but if you want extreme performance, you
have to derive the matrix differentials yourself. He is not saying PyTorch is slow. He is saying PyTorch is general and general has a price. Autograd will differentiate anything you write which
means it can optimize for nothing you wrote. Autograd is one of the great pieces of software engineering. You write the forward pass and it hands you the backward pass for free. It has to
work for any graph anybody can build. So it is not allowed to assume anything about yours. Han's bet was that for one specific shape, a frozen weight matrix with a small trainable adapter bolted
onto it, you can beat that by hand. In that shape, the attention block needs six matrix derivatives, and he sat down and worked out all six. Then comes the part that sounds too small to matter.
Matrix multiplication is associative. A * B * C gives the same answer whichever pair you multiply first. The cost of getting there is not the same at all. The adapter matrices are skinny. ranks
of eight, 16, maybe 128. The model's weight matrices are 4,096 wide or wider. Bracket the multiplication one way and you build an enormous intermediate matrix. Use it once and throw it away.
Bracket it the other way and you do not build it at all. Same answer, wildly different bill. Autograd cannot make that call for you. It does not know your rank is eight. It sees two matrices and
multiplies them in the order you type them. So he rewrote the hot paths as kernels in Triton, OpenAI's language for writing GPU code in Python. The rotary embeddings, the feed forward blocks, the
layer norms, the language model head, handwritten, fused in place, and it worked immediately. On a free collab card in December, the Alpaca data set took the hugging face implementation 23
hours and 15 minutes. Their build finished the same job in 2 hours and 34 minutes, which raises the obvious objection. If the maths is identical, why does PyTorch not just ship it?
Because a framework that ships that trade has to ship it for everyone, and it stops being true the moment your rank is large or your model is not a transformer or your adapter is somewhere
else. Generality is PyTorch's product. Unsloth is allowed to be narrow, and narrow is where the speed lives. The speed is only half the story anyway. The memory half is stranger because it
starts with a tensor most people have not thought about once. At the end of every forward pass, the model turns its hidden state into a score for every single token in the vocabulary. Long
sequence, big vocabulary, and that one array of numbers becomes the largest object on the card. In November, a team at Apple published a paper about exactly that. Eric Weidman's and four co-authors
called it cut cross entropy, and the numbers they published are worth stopping on. The memory used by the loss computation on the model they measured fell from 24 GB to 1 megab. The
classifier head as a whole went from 28 GB down to one. The trick is to skip the array entirely. You compute the loss in slices on the fly and throw each slice away as you go. The gradient that comes
out the other end is identical. Unsloth ships that plus its own chunked version that picks the slice size at runtime from whatever memory you have left, plus a checkpointer from April 2024 that
pushes activations out to system RAM and now costs about a tenth of 1% in overhead. Add it all up and the numbers stop looking like a speed story. On an 8 gigabyte card, Unslaught's published
benchmarks fine-tune an 8 billion parameter llama at just under 3,000 tokens of context. The hugging face path with flash attention runs out of memory before it starts. Go up to 80 GB and it
is 342,000 tokens against 28,000. 12 times the context, same card, same model, same four-bit weights and the ceiling moved again. Working with Stas Beckman on a
technique called tiled feed forward layers, they pushed a 20 billion parameter model past 500,000 tokens of context on one 80 GB card. The previous number was 80,000. So the two times is
real. But two times against what? Because that missing word is the most misleading thing in this entire field. And Unsloth is one of the very few projects that tells you the answer. Take
their mixture of experts kernels shipped in February. The headline is 12 times faster. read the blog and that 12 is measured against transformers version 4 against version 5 which already uses
PyTorch's own grouped matrix multiply the same kernels are about twice as fast both numbers are correct they answer different questions and only one is the question you are asking their published
table makes it planer fine-tuning the same model on the same blackwell card at a thousand tokens of context unsloth is 1.4 times faster at 22.4 at 44.8 8 at 8,000 7.3 and at 16,000 the
comparison stops because the baseline runs out of memory and posts no number at all. That is a curve, not a speed up. The advantage is modest when the work is small and it keeps growing until the
alternative simply stops working. Which means the useful form of the sentence has an object attached to it. They do the same thing with their packing work. The headline says three times faster.
The blog then deres the formula out loud and says the gain depends on how many short rows your data set has and that it collapses toward two if your rows are all long. Two times faster than what at
what context length on which card measured after the compiler finished warming up. Four questions. Unsloth answers all four on its own pages. The ecosystem quoting Unslo answers none of
them. It takes the biggest cell in the table and prints it on a badge. There is a second thing that badge hides and this one is a real limit rather than a framing problem. It is multiple GPUs.
Read Unsloth's own multiGPU page today and it says the process is complex, requires manual setup and that official multiGPU support is being announced soon. Read the read me on the same day
and it says multiGPU is available now. Read the pricing page on that same day and the free columns still list multiGPU under coming soon while the paid tiers sit behind a contact form with no price
printed anywhere on the page. Three of their own pages, one afternoon, three different answers. So if your training plan needs tensor, context, or expert parallelism as a thing you configure
rather than a thing you route around, Axelottle and Llamaactory document that matrix and Unsloth does not and a smaller trap that will confuse you on day one. Unslaught's own benchmark page
warns that torch compile takes about five minutes to warm up and tells you to measure throughput only after it finishes. Measure a short run and you will conclude the whole thing is
oversold. Measure a full apic and you get the number they published. It is not only unsloth making the claim either. Nvidia's own developer blog last December put the figure at two and a
half times the hugging face transformers library on Nvidia hardware and called Unsloth one of the world's most widely used open-source fine-tuning frameworks which brings us back to the verses in
the title in April this year the PyTorch ecosystem working group announced four new projects joining its landscape unsloth was one of them pietorch's own sentence about it reads utilizes PyTorch
to enable training of models and Torch compile for optimizations. The library built by deriving its way around Autograd is now formally part of the thing it derived its way around and it
runs both directions. Unsloth's newest mixture of experts path is built on PyTorch's own grouped matrix multiply and Han's release post thanked PyTorch, Torcho, and Hugging Face by name. The
project itself has grown into that. 74,000 stars, an Apache license, a Y Combinator batch, and a team of eight people. the last time the page was updated. There is a cleaner example of
what that relationship actually buys the rest of us. In October 2024, Benjamin Marie reported that gradient accumulation was producing higher training losses than plain full batch
training, which should be mathematically impossible. Unsloth found it. The cross entropy denominator was being averaged inside each mini batch instead of derived across the whole batch, which
made the final loss come out G* too large, where G is the number of accumulation steps. That bug was sitting in nearly every trainer in open source, including multiGPU runs that were not
using accumulation at all. Two people with a Triton habit found it, wrote the proof out in public, and HuggingFace patched it upstream. They are not only shipping kernels now either. On the 11th
of August, they released a desktop application that runs and trains models locally on Mac, Windows, and Linux. And the announcement has been seen about 3/4 of a million times. the release after it
merged more than 200 poll requests nine days later. Whatever else is true about the marketing, the pace is not a marketing artifact. So, here's the call. If you are fine-tuning on one GPU, and
almost every tutorial you will ever read assumes you are, Unsloth wins, and it is not close. Same weights, roughly half the wall clock, a fraction of the memory, and the receipts are published
with their baselines attached. The 5% it loses is real, though. multi-node shops and anyone who needs parallelism as configuration instead of as a workaround. Those people should be
running axelottle or llama and unsloaf's own documentation will tell you the same thing if you read past the readme. The thing worth being annoyed at here is not a company. It is the multiplier with
nothing attached to it. Two times faster is a sentence with a missing object and a field that repeats it without the object teaches people to shop for numbers instead of measurements. Which
leaves the one question I would carry out of this. Unsloth exists because the two people who built it looked at a default that had not been rederived in years and did the calculus by hand
anyway. So, what is still sitting in your stack that nobody has checked?