385 points · by danielhanchen · 2y ago · 119 comments
1. Manual autograd engine - hand derived backprop steps.
2. QLoRA / LoRA 80% faster, 50% less memory.
3. All kernels written in OpenAI's Triton language.
4. 0% loss in accuracy - no approximation methods - all exact.
5. No change of hardware necessary. Supports NVIDIA GPUs since 2018+. CUDA 7.5+.
6. Flash Attention support via Xformers.
7. Supports 4bit and 16bit LoRA finetuning.
8. Train Slim Orca fully locally in 260 hours from 1301 hours (5x faster).
9. Open source version trains 5x faster or you can check out Unsloth Pro and Max codepaths for 30x faster training!
https://www.reddit.com/r/LocalLLaMA/comments/188197j/80_fast... has more info about Unsloth!
Hopefully you can try it out! Wrote a blog post at https://unsloth.ai/introducing if you want to learn more about our manual hand derived backprop or Triton kernels and stuff! Thanks once again!
Whatever advantage they have I don’t see how they would be able to to keep it for long as part of their closed source “pro” version.
If it’s low hanging fruit the open source equivalents are bound to snipe them before long.
Best of luck and all success to you!
So in GPUs the goal is to saturate the GPU with matrix multiplies instead of data movement. I'll write a more detailed blog but approximately:
1. Flash Attention v2 reduces the time taken by 17% or so
2. RoPE Triton kernels: -7.1%
3. RMS Layernorm in Triton: -3.1%
4. Cross Entropy in Triton: -1%
5. Manual autograd for MLP: -4%
6. Manual QKV autograd: -2%
7. Manual O autograd: -2%
8. Smart cache evictions and reduced data duplications etc: -30%
9. And other tricks in the Max and Pro versions makes it 30x faster
You can see it's just tricks in each step, which accumulate together to make to go faster.
I'll write up a blog post to detail it all in the future!!!
If you don't believe the timings, I was the author of Hyperlearn https://github.com/danielhanchen/hyperlearn which makes ML faster - I also listed the papers which cite the algos.
I also used to work at NVIDIA making TSNE 2000x faster on GPUs and some other algos like Randomized SVD, sparse matrix multiplies etc.
If you have any suggestions on a more appropriate pricing strategy - I'm all ears!!
I really don't know much about pricing and the open core model, so I'm making stuff up literally.
B2B deals at 200-300k+ are your best bet at selling this IMO.
question on the perf benchmarks: why do all the results with 2 GPUs & DDP take longer than the single GPU case? Both benchmarks do the same amount of work, one training epoch, so this negative scaling is surprising.
1. DDP itself has an overhead since it has to synchronize gradients at each training step since GPU0 and GPU1 has to give gradients to GPU0.
2. Huggingface seems to not be optimized well for DDP mainly due to inefficient data movement - we fixed that - interestingly - even on 1 GPU it's faster.
In other words, every benchmark, in either HF or Unsloth, is slower in absolute terms when going from 1 to 2 GPUs. That makes me think something is wrong with the test.
Could you share your benchmark code?
It'd be quite a lift unless we're just willing to just accept the self reported metrics as golden. And even then, they're always qualified by hardware and usage scope. Making it good enough to be useful is the hard part. CI/CD pipeline with a bunch of machine configurations and benchmarks along with a reasonable way to communicate them...
If anyone's up for it you'd legitimately become indispensable.
I'll post it once its completed if you're interested!
For instance, are any of your prompting tests in say, Korean? What about winograd schema challenges in languages other than English? Japanese for instance, comes with its own unique set of context ambiguities that do not appear in English. I'm sure dozens of languages are similar. It'd be nice to have user contributable tests to cover the breadth of use cases here.
A great optimization that moves a score let's say from 95% -> 5% on "winograd-persian" may be fine or may be a show stopper, depends on what you care about.
That's why it's gotta be normalized, future-proof, and crowdsourced.
So technically the code can run, but I'll have to edit it to remove the Triton changes.
I'm all very new to this, so I'm literally making stuff as I go along!!
Apologies!
Given the current state of AI performance, I’d imagine that those without 100s of GPUs but looking to maximise the performance of what they do have, would be a great demographic for the Paid plan.
Would someone be able to tell me more about this?
The main reason is because from Turing, Tensor Cores got provided, and so the matrix matmuls are all different in Tensor Cores
Not to mention that other than beyond 7B models, your options drastically taper off. Mistral and most open base model projects only have models available up to 7 billion parameters or so, which is quite tiny if you are used to the relative ease of using un-finetuned GPT-4 to carry out your tasks of choice.
So what options are there? Falcon 40B and MPT-30B - sure, the weights license is all right, but many in the community have reservations about those models' underperformance, as you can get much more bang for your buck with newer models, in an equal number of weights in a newer base model. Subjectively speaking, it could be a waste of time.
Falcon 180B and Yi 34B weights are both issued under non-free licenses, just like Llama 2.
Is Llama 2 proprietary? For the vast majority of people, for the vast majority of purposes, no. I'm not a lawyer, but I think that Meta would be quite unlikely to do more than cut off your HuggingFace access to the repo where new models will be distributed.
All thanks to Llama - the LLM community is now vibrant and alive!
It's mainly trying to reduce data movement, maximize FLOP utilization via matrix multiplies, and reducing FLOPs via manually deriving backpropagation equations + more!
This is a pretty good overview paper: https://arxiv.org/pdf/2108.02692.pdf (they claim to be better than the rest -- I haven't evaluated their claims in practice yet)
The techniques are mostly about ordering and common subexpression elimination for XOR operations and choosing "better" matrices to do the computation with. CRS codes can be used with many different matrices, but it turns out some are better than others for effiency (XOR operations are encoded by 1s in the CRS matrix, so if you choose a CRS matrix with fewer of them while meeting the requirements, you can do less operations and get the same results).
Yep so the OSS version does have the reordering of operations - I'll write a blog post about it in the coming days!! We also have other tricks up our sleeve to make it go even faster!!
Edit: it seems like http://unsloth.ai works - we're talking with our web hosting people to fix it
I think there are a few Redditors from /r/localllama who also requested this, but for now first priority is getting Mistral support!!
I OSSed all the code to the community - I'm actually an extremely open person and I love contributing to the OSS community.
The issue was the package got gobbled up by other startups and big tech companies with no credit - I didn't want any cash from it, but it stung and hurt really bad hearing other startups and companies claim it was them who made it faster, whilst it was actually my work. It hurt really bad - as an OSS person, I don't want money, but just some recognition for the work.
I also used to accept and help everyone with coding up their startup's software, but I never got paid or even any thanks - sadly I didn't expect the world to be such a hostile place.
So after a sad awakening, I decided with my brother instead of OSSing everything, we would first OSS something which is still very good - 5X faster training is already very reasonable.
I'm all open to other suggestions on how we should approach this though! There are no evil intentions - in fact I insisted we OSS EVERYTHING even the 30x faster algos, but after a level headed discussion with my brother - we still have to pay life expenses no?
If you have other ways we can go about this - I'm all ears!! We're literally making stuff up as we go along!
true. saw this myself too for my projects. big tech / startups would use your project internally and give you nothing back. sadly happens often.
This also incentives contributing to open source, because you'd potentially get compensated if the code was used by some big corporation.
Why isn't this a thing?
> The issue was the package got gobbled up by other startups and big tech companies with no credit
I understand that this is frustrating, but are you open sourcing things for recognition? The fact is companies are going to use 100s of open source packages and aren't going to credit them all, or even any.
At any rate, I appreciate how difficult your position must be, and wish you luck.
I agree, but generally as a researcher / OSS even a nice citation is nice :) There are some cool people who do just that, but some do not.
But thanks once again!
I still haven't figured out how to open source algorithms which don't have an UI or database - maybe a training or inference platform?
But if we made a training / inference platform, then there won't be any OSS code.
We're currently stuck in the middle - do you have any suggestions on this?
The company here does seem less sinister however - don't think they've accepted VC investment yet? Could be wrong.
We're open to VC investment now, except we truly believe in bootstrapping it - we have tonnes of other products in the pipeline like a Recession predictor, a Data Science Consultant, our own trained chatbot via DPO and our fully cleaned datasets and more!
The paid version just makes it train 30x faster on multi GPU platforms - it's more of an open core approach.
But thanks a lot again!