Lurker News
Here's a project I've been working on for the last few months.

It's a new (I think) algorithm, that allows to adjust smoothly - and in real time - how many calculations you'd like to do during inference of an LLM model.
It seems that it's possible to do just 20-25% of weight multiplications instead of all of them, and still get good inference results.
I implemented it to run on M1/M2/M3 GPU. The mmul approximation itself can be pushed to run 2x fast before the quality of output collapses.
The inference speed is just a bit faster than Llama.cpp's, because the rest of implementation could be better, but with a better development I think it can be a new method to speed up inference - in addition to quantization.
You could call it ad-hoc model distillation :)
You can change the speed / accuracy of a model at will, in real time.
Oh, and as a side effect, the data format allows to also choose how much of the model you want to load into the memory. You can decide to skip say 10-20-40% of the least important weights.
It's implemented for Mistral, it was also tested slightly on Mixtral and Llama. It's for FP16 for now, but Q8 is in the works.
The algorithm is described here, and the implementation is open source.
https://kolinko.github.io/effort/
I know these are bold claims, but I hope they survive the scrutiny :)

Comments (114) 32 threads

Earlier comments
gsuuon1 reply#
Nice writeup! Very curious about the performance per VRAM with this compared to just quantization. Any plans to implement a cross platform version?
kolinko1 reply#
Per VRAM - not much netter, because it still uses all the weights, just not all the time.

I mean - it can also load less weights, but quality seems to degrade quick after offloading more than 20-30% weights.
In other words - this algorithm decouples inference time from VRAM use.
Having said that, I’m curious as well if using effort you can get better results on Q8 cropped to 75% than on Q6.
But it’s still probably a few weeks to get the implementation polished enough to be well tested.

AnthonyMouse1 reply#
> Having said that, I’m curious as well if using effort you can get better results on Q8 cropped to 75% than on Q6.

This is what I wanted to ask. This seems like the same kind of optimization as quantization, sacrificing a bit of quality for performance by discarding some data. So then the question is, which is better, and how do they combine?
You could even potentially get different results at different points in the scale. Maybe Q8 cropped to 75% isn't better than Q6 but Q4 cropped to 75% is better than Q3, or vice versa.

kolinko#
Below Q8 I think it will combine poorly - bucketMul needs to keep a few bits for an index. It can be offset by the fact that the numbers from each bucket are from a limited range. My intuition is that with Q8 this trades off roughly evenly - meaning bucketed Q8 may store as much info as regular Q8, but it will be more difficult with lower quantizations, and cross the boundary of impossible after Q5. Don't have math to back it up, but perhaps some information theoretitian could pick up the calculations.

You could say that these are divergent paths in the future developments (if the results hold for Q8) - perhaps you can crop the Q8 models to Q6 sizes and inference speeds of Q2/Q4. On the other hand, the wildly optimistic scenario is that the bucketMul speeds will overcome even Q1, with dynamic computation pruning - token by token and layer by layer, by having a separate small network that chooses effort levels based on the input data. (someone already proposed it in the thread).
For now, the most important thing is fixing the bugs, doing more serious tests for FP16, and showing how the charts look for Q8. Especially the Q8 is the biggest unknown, although the initial results are hopeful.

yousif_1231231 reply#
I know this doesn't retrain, but I wonder if approaches like this plus quantization could get back any "lost" quality with some post training.

It's great to see, and to know in one's mind how much likely performance and cost will be better in the future.
I know it's fun to work on, but I also want to say THANK YOU for developing open source.

spencerchubb#
At first glance, that sounds like it could work. From what I've read, there seems to be two main ways to regain some quality with quantization: post-training which happens after, and quantization-aware training which quantizes during training but leaves the activations and gradients full precision
kolinko1 reply#
Similar theme, but they skip whole neurons, in my case it’s down to a level of single weights.

From my experiment, skipping whole neurons (so whole rows/columns of matrixes) didn’t allow for such good results. In my case 30-50% neurons whole are skipped with 15% effort, but the rest is used partially still.
There are a few papers on a similar theme that a friend sent me today morning - I plan to add them in the citations part

toisanji#
awesome, looking forward to seeing how your results perform. I tested powerinfer on smaller models and didn't see large performance gains.
kanwisher2 replies#
Could you break down a bit more about why you can skip so many calculations ?
kolinko1 reply#
It’s explained in detail here:

https://kolinko.github.io/effort/equations.html
Long story short - I kind of sort them and pick only the top % that would give a highest result.
One part is choosing them though - I think this was done before in some papers. But the second part was an implementation of multiplication that is efficient on both gpus and cpus when choosing weights almost at will.
All explained on the site, but I just got feedback that it may not be easy enough to read, so I’ll push it through gpt for grmamar fixes soon :) It’s also a bit complicated as an algorithm.

kolinko1 reply#
Nah, sadly this most likely will not work with Q1/Q1.5 implementations - initially I was playing with monte carlo approximations (before I arrived at bucketMul), and the convergence was very slow for binary/ternary networks.

Or, in simpler terms - if you have just ones and zeroes, and minus ones, you can remove zeroes from calculations, but that's it. No good method to figure out which ones are more important than the other ones.
Also, there are no bits left to store positional information when bucketing.
There are some paths that could be explored in this fashion, but it would require a redesign of the algorithm from the ground up.

Continue this thread — 1 reply

punnerud1 reply#
A bit like calculating the fastest route for a car, you probably don’t need to calculate the distances for the opposite side of earth if you will not drive there. Then multiply that by a billion, but the optimization still holds.
kolinko#
Nice analogy, thanks! Yes - you still need a map, because one day you need this road, another day you need info about another road, but you're not using info about all the roads all of the time.

Load more comments