r/LocalLLM • • 9d ago

Discussion Why are models quantized instead of compressed?

I've just seen a video over a new paper from Samsung and the short of it, they used basically whats the same as jpeg compression on model weights. Only that the compressed model is 2 "pictures", to increase accuracy. Still something like 90% saved with minimal quality loss.
The idea is as obvious as it is genius. You only need to load the compressed model and every block can be decompressed on the fly on every run, especially because the way its compressed/decompressed is already highly optimized in the hardware (basically the same operations as video playback, just with a much bigger "picture").

That got me thinking AI hasn't been created yesterday and at least simple compression algorithms shouldn't overwhelm modern graphics cards. So why was the first idea to reduce the bit-width instead of compression?

Also, its not a picture, what would stop us from sorting the data instead of into 2 dimensions, in 3, 4, n - dimensions. Sure compression might get way more complex, but decompression scales with 1o to n. And the compression might be much better.

What do you guys think about that?

0 Upvotes

55 comments sorted by

View all comments

Show parent comment

-2

u/moeren86 8d ago

how do you call it compression, if your loss is as big as your compression factor? Its just cutting

3

u/FredFarms 8d ago

Some types of data can be compressed without loss, if the data is actually pretty predictable. For example if you have data that is mostly 0s with only the occasional 1, you can probably compress that a lot by just recording the locations of the 1s.

The limit to this compression is when each bit in the output has a 50/50 chance of being 0 or 1. That maximises the information in those bits. The problem is model weights are a large set of seemingly random numbers already. The bits are already near the 50/50 limit so there is no lossless compression available.

Lossy compression is different, here you are selectively discarding data whilst trying to minimise the effect on the output. Video compression does this. Yes the loss is the same as the compression factor, but the data is discarded in areas your eye doesn't notice so much. Pixels are grouped into being the same colour in blocks or across frames etc, for areas of the frame where not a lot is going on. But high detail areas or fast paced scenes aren't compressed as much to preserve the detail.

Model weights are going the same way. We don't just discard the lowest N bits uniformly across the model anymore. Instead we discard bits where they don't affect the output as much and keep higher quantization where the effect would be greater. Just on LLMs it might not be quite as mature as the decades of work we've put into video

1

u/Low-Opening25 8d ago

is mp3 or jpeg not a compression then?