909 points · by jph00 · 2y ago · 206 comments
It's the #1 most requested thing I've been hearing from open source model builders: the ability to use multiple GPUs with QLoRA training. So that's why we decided to make it our first project.
Huge thanks to Tim Dettmers for helping us get started to this -- and of course for creating QLoRA in the first place!
Let me know if you have any questions or thoughts.
I think that is a great example of how important and useful QLoRA is. Maybe we should run a dual-GPU challenge next time not that multi-GPU is working...
One thing I've wondered about: what are the drawbacks to using QLoRA? For example if compute is not a limit, I'm guessing one should not use QLoRA and finetune in full precision instead?
Afaik when a model is first quantized to nf4 (before finetuning begins), model performance is degraded from baseline (see https://x.com/Tim_Dettmers/status/1661482614811918338?s=20).
Dettmers shows that after finetuning wrt the dataset, the result is as good as full precision. But afaik never explored the effects outside the finetuning data. Assuming the finetuning dataset is small, the model will just be the degraded nf4 version, right? Or perhaps finetuning will even skew the model in weird ways (trying to fix quantization errors).
Anecdotally models finetuned wth QLoRA perform well. Does anyone have any papers or a careful analysis of this?
On Twitter someone asked you if you would provide any risk assessment reflection, and you replied that the risk would be similar to the release of a new model of pen or pencil.
That reply, while cute, isn’t accurate. A new pencil does not mean new capabilities for humanity, while the whole point of your release is that it does afford new capabilities and therefore new risks.
The woman, a professor working on the societal impacts of AI, asked a straightforward question in apparent good faith [1]. Your reply did not seem to me to be in good faith.
Can you explain the apparent disconnect? I’m less concerned as to whether or not you would release an assessment and more concerned at the dismissive attitude, especially towards a female professor studying societal impacts of AI, a fellow researcher.
By way of background: I studied the philosophy of ethics at university, I co-authored a book chapter on AI/ML ethics, my wife and I quit our jobs and worked for free for years entirely focused on trying to help society adapt to and benefit from AI, I wrote the actual article we're commenting on, and the article is about LLM fine-tuning -- a field I to some extent created by developing the ULMFiT algorithm.
The person in question is, IIRC, at Governance AI, a group whose work I spent months studying in depth -- work which I believe is more likely to cause harm to society than to benefit it, as I explained here:
> especially towards a professor studying societal impacts of AI
I can't help but feel like you're trying to load this question with some expectation that sex/gender should change how people react and respond. It shouldn't, at all, positively or negatively. Everyone is human (for now).
Stepping back, this is the kind of discourse that Twitter can sometimes reinforce: short responses that, lacking context, can be interpreted in polarizing ways. After a bit of reading on the participants (because both of them are working in interesting areas), my belief is that the "pencil" response is actually shorthand for a whole set of beliefs that provide a lot of context and nuance to the discussion, but if you don't know that, it sounds like saying "AI is as dangerous as a new brand of chewing gum".
In addition, without defining what risks we're talking about, it's really hard to know the scope the answer is addressing. E.g., societal risk due to AI in general? vs. say, the risks of affecting the quality an existing model with fine-tuning?
So, I am chalking this up to a misunderstanding due to the limitations of the platform as well as the short-hand used in the response. And I could be completely wrong :)
If I were a consumer I would be interested in the final price of fine tuning, for example a table with model size, training size, cost of training, and expected loss of quality with this technology.
One obvious question: Can you apply your technology with the recent (-1,0,1) encoding?, I think you will answers that the (-1,0,1) model is not available and you can't try it, but my question is whether once/if that model is available answer.ai will be able to use the same technology that this post to fine tune a big model in two very small GPUs, and then I should ask for a new table with cost/benefits analysis.
Edited: I should add that I find this kind of work very useful for enhancing individual users like me to be able to compete in the applications of LLM market, this is great work and along the lines of the book "from zero to one" (not that I like or dislike the author) to solve the kind of problem that nobody is trying to solve.
Edited: Now that I have a total of 23 points in HN, I will change my password to some random one, just to cure my desire to look for votes, and try to make some work, and again some tomorrow create a new presence in HN.
If you use Stylus (or any similar browser extension), I actually wrote a style to hide points for that very reason, replacing karma and scores with `•••`
This is actually the second time I see someone mentioning this need, so I've made it into a gist and published it to userstyles, but here's it is also since it's pretty short:
@-moz-document domain("news.ycombinator.com") {
/* Hide karma and points on replies */
span.pagetop #karma, span.comhead span.score {
visibility: hidden;
position: relative;
display: inline-block;
height: 10px !important;
overflow: hidden;
}
span.pagetop #karma {
width: 0.8rem !important;
}
span.comhead span.score {
width: 0.8rem !important;
}
span.pagetop #karma::before, span.comhead span.score::before {
content: "•••";
visibility: visible;
overflow: hidden;
opacity: 0.8;
font-family: Helvetica, Arial, sans-serif !important;
}
}
https://gist.github.com/airstrike/62584e6ffb6104791c0ae48a8e...https://userstyles.world/style/15164/hackernews-hide-karma-a...
On the 1.58bit paper, from what I understand, this requires a total retraining from scratch. Hopefully the researchers will open source their weights :)
On the technicals, weights are encoded in (-1, 0, 1), whilst QLoRA uses a 4bit dynamic mapping of 16 numbers. The only change required would be the torch.matmul(X, W) step, where it'll be torch.bitlinear_matmul(X, W). Before with QLoRA, one has to do torch.matmul(X, dequantize(W)). So one has to implement torch.bitlinear_matmul. The backward is torch.bitlinear_matmul(dY, W.T).
[-1, 0, 1]
[0, 1, -1]
[10, 20, 30] x [1, 1, 0]
Instead of doing 10(-1) + 20(0) + 30(1) + 10(0) + ..., since we know beforehand the weights are simply (-1, 0, 1), we easily flip the sign and do addition, or force the hardware to do addition ie if (-1) do subtraction. If (0) do addition. If (1) do addition.Floating point multiplication does addition of the exponents and multiplying of the mantissa. So just simplifying:
Float16 has E=5, M=10. Ie around 5 + 10^2 space needed = 105.
Bfloat16 has E=8, M=7. So 8 + 7^2 = 57 space.
Float8(143) E=4, M=3. So 4 + 3^2 = 13 space.
1.58(16bit) E=5, M=10. Addition only, so shift E say 5 + 10 addition = 15.
1.58(8bit) E=4, M=3. Addition only, so shift E say 4 + 3 addition = 7.
Obviously I'm simplifying, but with only additions, 1.58 uses say 7 space, whilst FP8 uses 13 space, so in theory 2x more transistors can be crammed, ie 2x more FLOPs than FP8.
So if you train your models with that in mind you're weighs can be reduced to -1,0,1 reducing the space complexity.
I don't think the costs in expressiveness are captured quite yet, but as perplexity doesn't care about correctness, if that is the metric that is important for you it will probably reduce memory requirements for inference.
The irony of making an unnecessary edit like this to virtue signal for implicit social currency by shitting on the explicit form.
A side point, but this "recent" encoding goes back to a 2017 paper from the Allen Institute. These days a seven year old paper is ancient.
They went further and showed you could could get away with binary, you don't even need trinary!
You are probably referring to XNOR net, and the novel piece there was also using binary activations (which bitnet is not).
So as far as I can tell, bitnet is basically BinaryConnect applied to LLMs.
P.S. I thought one was suppose to spend the HN points on mocking north-americans, shameless self-promotion, unpopular facts, general trolling and complaints about topics existing. I could go on but I haven't the points.
Great job!
After that, the larger flagship AI models were then closed up again and used as an server only offering.
I was curious about the choice of FSDP over DeepSpeed. I have been using Axolotl for fine-tuning, and FSDP has been broken there, whilst DeepSpeed is rock solid. Why FSDP over DeepSpeed jph00?
We've found that FSDP works just as well for our needs, and we appreciated the increased "hackability".
(Axolotl is terrific BTW. I hadn't heard of problems with it with FSDP before -- I'll see if that's something we can help with.)
I wonder if the recent Bitnet 1.58 paper [the use of ternary bits in lieu of fp/int] might be an advancement that could further reduce the computation required for inference?
They also have on option to get paid in crypto for your GPU power.
The challenge is that the AIsoftware architectures are not made "to run over Internet."
It’ll be the first time we’ll have someone who knows AI create leverage to open source it.
Way to go!
It can’t be overstated how important this is. Thank you again.
Join the community building the tools - Help with UI/UX, documentation, keeping up with the latest, and evangelizing whatever method the team building it has devised to keep it sustained.
Being part of the community itself is more valuable than you realize.
- try to implement techniques that are doable on home hardware like the one described in OP (requires some $$$ investment) and give feedback or contribute to documentation / guides
- learn about different techniques and do educational writeups or documentation (like https://vickiboykis.com/2024/02/28/gguf-the-long-way-around/)
- build a tool / library that wrap academic techinques and expose them more easily to end users (like A1111 or comfyUI for stable diffusion)
Anything that can translate the high end research down to something a moderately technical user can use or learn from is a gigantic win
The trick with getting more benefit from sparse approach is to do block sparse (iirc, Tim Dettmers used to work on this as well, a few years ago), but large block size (say 16x16) would require much longer retraining to recover for the lost accuracy…
The block sparsity can really help with saving RAM - because you only need to keep a short array of indexes for the excluded weights. The trouble is the kernel mult functions become complex, so it's a bit of a trade-off between RAM and GPU cycles.
The issue of to what degree it might be possible to train a model from scratch using QLoRA is still an open question. The relora paper showed that it can work in some situations, but attempts to scale it up were unsuccessful. The recent DoRA paper perhaps might allow a "re-DoRA" approach to work. If so, that could be combined with quantization to do "re-QDoRA"!
How does "fine tuning" differ from "training?" Reading the linked article I had assumed I could create my own trained LLM at home with two 24GB GPUs.
(Generally, we've told students at fast.ai since 2017 that they should almost never be starting from random weights -- most of the time it's best to start with a pretrained model and fine-tune that, even if it's from a somewhat different domain to the problem you're working on.)
The electricity would cost more than 10,000€ in Germany, just for the GPUs.
Thorough article!
Question: What's your opinion on:
- How viable will NVIDIA's consumer cards be in the long run?
- Besides https://tinygrad.org, what other cost-effective future alternatives could there be?
For example, giving the model a bunch of text (academic papers and such) about 19th century writers, then asking things like "Who were the main influences on writer X"?
Obviously simple RAG-like approaches don't work, as such information is rarely available in the text as-is, and needs to be "extrapolated" to some extent. Long context models might work (just dumping everything into the prompt), but are way too expensive for my needs.
Other things to try out is how you approach the question "expansion" part, for example using Hypothetical Document Embeddings (HyDE); or how you approach the filtering-out part, e.g. using "System 2 Attention", https://arxiv.org/abs/2311.11829.
For example, imagine that one paper is about how author X was French, in early 19th-c.and how they were one of the first ones to write about topic T. Another paper is about how author Y was inspired by the early 19th-c. French writers writing about T. However, this second article does not mention X at all. Asking about "who were the main influences on X" would not give you the second article.
Of course, I could run "multiple-hop" RAG-like process, where the model keeps asking questions itself and so on in a loop, but this becomes extremely clumsy, and the models (even GPT-4) tend to get out of hand. It is also extremely slow, of course.
There have been some attempts to compare RAG vs FT approaches, I would recommend this paper: https://arxiv.org/abs/2403.01432
Just like with unsloth or axolotl, the people that use this will have to make compromises that give results in a reasonable amount of time.
> At Answer.AI our north star is making useful AI more accessible. $150,000 to create your own high-quality personalized model definitely doesn’t count as accessible!
Renting an A100 on RunPod is ~$1.89 / hour. So you'd need ~80,000 A100 hours to train a useful AI model?
* you’re probably not going to succeed at injecting new knowledge in a way that feels satisfyingly top of mind to the bot
* you’re probably not going to create such a meaningfully new style that it warrants a Lora like in images
What’s an example use case?
Asking the first question is fine, but your follow-up comment sounds more dismissive than curious.
That's probably why the snarky response.
I have considered the feasibility of fine-tuning an LLM on the writings of a specific author. The idea is that it could aid writing in this way: If I currently am researching a specific author across multiple of their books, I often will get a quote of theirs trapped in my head some length of time after reading it. If I have neglected to jot down (or even to highlight) the source of the quote, I could ask the model where the remembered passage came from and get back a higher-quality response.
Author style, maybe, I guess.
It's ALWAYS illicit fan fiction.
Like sure, you need something that is not the friendly question answerer; but do you really need such a broad population as in images to suit your needs? I’m guessing no?
--
Is it possible to 'array' tokenized wokloads across providers of GPU?
I want to farm-out my 'compute' across [things]
More importantly can there be a marketplace for GPU resources that I can effectively point my local job at?
> two 24GB GPUs.
geez
What are the max context lengths / batch sizes you can train at with this method for 2x24gb? What about 4x24gb?
I don't think local will be competitive in future IN GENERAL...but if I have a specific use case and I have a specific training dataset...local with specific training will murder the big commercial models.
4070 super ti 16GB, fp32 44 tflops, Mem 672 GB/s
3080 12gb, fp32 30 tflops, Mem 760 GB/s
3080 Ti 12GB fp32 34 tflops, Mem 912 GB/s
For 50% more gddr, a 4070 Super Ti costs less than 50% more than a base 3080. There's a tradeoff between FLOPS and memory bandwidth though, but using 3 cards instead of 4 should makeup for that.https://www.techpowerup.com/gpu-specs/geforce-rtx-3080-12-gb...
https://www.techpowerup.com/gpu-specs/geforce-rtx-3080-ti.c3...
https://www.techpowerup.com/gpu-specs/geforce-rtx-4070-ti-su...
/s
We already have something we're testing that's gotten 70b training down to dual 16GB GPUs, and we're working it making it even smaller...
I feel bad for them. They're going to be the ones that lay in their death bed thinking "I wish I had allowed myself to have more fun".
Why do you get to decide what's wasteful and what's useful?
We have more energy than we could ever hope to use from the sun and from nuclear. The solution isn't telling people they're wasting precious energy that you would put to better use. Just build more nuclear reactors and more solar.
You're talking to more of a civilization-type who believes you have to use regulation and, if necessary, state violence to stop types of mining that kill habitats, because the technology certainly isn't going to up and decide to do that. It's the job of society to figure this stuff out, arrive at such positions and defend them. There are plenty of good reasons to defend the protection of habitats, even for purely self-interested pragmatic reasons.
I feel certain there will be great benefit, but not in the way AI hypesters expect there to be.
We should strive to use and produce orders of magnitude more (clean) energy.
Not the first time this character has popped up here on HN.
"I write full-time and try to convince people of the danger of AI and advanced technology."