Quantizing a model to 4bits will sometimes break models entirely! @UnslothAI now has a dynamic 4bit quant format which chooses some parameters to be in 16bit!
We find that:
1. You need to check activation and weight quantization errors. Solely relying on 1 does not work.
2. There are large spikes / outliers in models. Read the LLM.int8() paper for more details on outliers.
3. By increasing VRAM usage slightly, 4bit and 16bit mixtures can do extremely well!
4. Multi-modal vision encoders seem to be extremely sensitive to quantization across models - especially Qwen and Pixtral.
More details here: https://t.co/HkCMpDQhC8
We also uploaded dynamic quants here: https://t.co/mIk60xDQb3
And Colab notebook to finetune Llama 3.2 11B Vision with our new dynamic quants: https://t.co/7gKo83c826
Llama 3 degrades much more than Llama 2 when quantized. 🤔
📌 Most possible reason because Llama 3, trained on a record 15T tokens, captures extremely nuanced data relationships, utilizing even the minutest decimals in BF16 precision fully. Making it more sensitive to quantization degradation.
📌 So sensitive that even the smallest decimal points of each parameter offered by BF16 precision were filled and had a purpose. Other LLMs were trained for far less (2T), and thus did not have time to saturate smaller precision ranges of the parameters like Llama did, and thus are not affected by quantization as much.
📌 It's pretty well established that bigger models are more data efficient / absorb more new information per exposure. They've got more unused information-storing free capacity.
But a model that is trained to within an inch of its life does not have that capacity. And because it is jammed packed, that lack of capacity also results in a lack of redundancy within the network.
So at a fixed, small parameter count, a model that's been pretrained for far longer—like Llama 3 8b, in comparison to earlier similarly-sized models—might have begun to saturate the capacity of its trainable params, and thus not absorb much from continued training.
Therefore, modifying the network is more damaging to overall performance with a smaller model (Llama 3 8B) that has been trained to freakishly high levels of that saturation. i.e. altering one node causes a cascade of brokenness because of that lack of redundancy.
@aidan_mclau fp16 or bf16? I’m always a little nervous seeing people finetune or inference in fp16 models that were pretrained in bf16. The number of exponent bits (and hence range) is lower? I have a todo to look into it closer. Depends on the checkpoint possibly.
Few people know that President Trump is an active user of PyTorch and submits bug fixes using the pseudonym rhymebumblebutt. Thank you for sharing your thoughts on test covfefe
"How is LLaMa.cpp possible?"
great post by @finbarrtimbers
https://t.co/L0aLRXrh9f
llama.cpp surprised many people (myself included) with how quickly you can run large LLMs on small computers, e.g. 7B runs @ ~16 tok/s on a MacBook. Wait don't you need supercomputers to work with LLMs?
TLDR at batch_size=1 (i.e. just generating a single stream of prediction on your computer), the inference is super duper memory-bound. The on-chip compute units are twiddling their thumbs while sucking model weights through a straw from DRAM. Every individual weight that is expensively loaded from DRAM onto the chip is only used for a single instant multiply to process each new input token. So the stat to look at is not FLOPS but the memory bandwidth.
Let's take a look:
A100: 1935 GB/s memory bandwidth, 1248 TOPS
MacBook M2: 100 GB/s, 7 TFLOPS
The compute is ~200X but the memory bandwidth only ~20X. So the little M2 chip that could will only be about ~20X slower than a mighty A100. This is ~10X faster than you might naively expect just looking at ops.
The situation becomes a lot more different when you inference at a very high batch size (e.g. ~160+), such as when you're hosting an LLM engine simultaneously serving a lot of parallel requests. Or in training, where you aren't forced to go serially token by token and can parallelize across both batch and time dimension, because the next token targets (labels) are known. In these cases, once you load the weights into on-chip cache and pay that large fixed cost, you can re-use them across many input examples and reach ~50%+ utilization, actually making those FLOPS count.
So TLDR why is LLM inference surprisingly fast on your MacBook? If all you want to do is batch 1 inference (i.e. a single "stream" of generation), only the memory bandwidth matters. And the memory bandwidth gap between chips is a lot smaller, and has been a lot harder to scale compared to flops.
supplemental figure
https://t.co/2j6NGSFRPc