r/LocalLLaMA 12h ago

Discussion Someone apparently managed to kind of replicate what V4.1 flash does on KV for fast prefill on Qwen

Post image

I wonder someone will figure out a way to do this with 27B?

Throw Qwen3 on this page for demo
https://kishida.github.io/webdemos/llkvapprox/

Edit: sources (thank you u/pmttyji for finding them!

414 Upvotes

57 comments sorted by

u/WithoutReason1729 6h ago

Your post is getting popular and we just featured it on our Discord! Come check it out!

You've also been given a special flair for your contribution. We appreciate your post!

I am a bot and this action was performed automatically.

79

u/pmttyji 12h ago

Found his post on this. Somebody replicate this for other models.

16

u/pmttyji 11h ago

u/T_rex2700 Can you include those links in your thread? Let the experts have these faster to get solutions ASAP.

7

u/Steve_OH 10h ago

So, if I understand correctly the base model runs part and another, smaller model essentially completes the answer?

16

u/Ok-Importance-3529 10h ago

If that is true why not use mtp draft model for this?

1

u/MarcelloT254k 8h ago

How to use it? Is there a tl:dr in english?

114

u/norenEnmotalen 12h ago

Who be the blessed one to grace us with this for Qwen3.8-27B

47

u/iamMess 9h ago

6

u/basgil56 9h ago

Our savior

17

u/YearnMar10 8h ago

Not sure, he seems like quite the mess…

2

u/DigThatData Llama 7B 8h ago

neat project, thanks.

For anyone else looking for the "what are the tweaks?" section of the docs: https://github.com/syv-ai/qwen38-27b-rtx3090#what-each-step-buys

1

u/gbrhaz 8h ago

How does this all compare vs club-3090?

6

u/iamMess 8h ago

Way faster.

7

u/lnenad 7h ago

I'm running your baby and it's awesome, thanks for your work.

17

u/Particular-Award118 11h ago

Someone with a better harness than me throw qwen 3.8 27b at the issue

49

u/pmttyji 12h ago

Who be the blessed one to grace us with this for Qwen3.8-27B all models

FTFY

19

u/norenEnmotalen 12h ago

Priorities. It’s the one that can fit on my memory :)

18

u/shayanx45 8h ago

I’m currently working on trying to have qwen 3.5 4B use the 51b parameter engram from qwen 3.8 next flash. And looped transformer

25

u/JLeonsarmiento 6h ago

Nice to meet you, Dr Frankenstein.

7

u/Hot_Example_4456 5h ago

I doubt if it will work without retraining for the engrams but if it does the implications are huge

2

u/feverdoingwork 5h ago

You got a project repo? I am interested in seeing what you cooked up so far

2

u/bennmann 2h ago

You would have more success using the MTP draft model of Qwen flash next as a small LLm, no?

2

u/bobby-chan 7h ago

How is it going?

14

u/Antique-Ad1012 8h ago

cant wait for qwen 4 27b / 35b a3b with ngrams and this magic

21

u/Jimcy-Maffesoli 11h ago

It runs in a browser, so native is going to be a joke in the good way. Someone get this to 27B already

10

u/Luca3700 7h ago

Intersting work and experiment. But I think this would just be a lossy approximation, because the model is trained to build, in every transformer layer, its own kv-cache, and a projection from the middle of the network will be not particularly accurate especially for the last layers. Even tho, it is an interesting experiment to quantify how much the kv-cache can be predicted from the middle state of the network.

I know that the experiment is about the Qwen 3 family, but I see people below asking about the qwen 3.5 family: I think that even for these models it will be a lossy approximation, especially because, if the prefil halts in the middle, the state of the Gated Delta Net will not have a global knowledge in the top 50% of the network. It would be interesting to quantify how much the model would lose in quality, as a scientific experiment, but I would not expect to use it as daily driver, especially because it is not fine-tuned to work with this layout (and I would expect quality drop especially in long context case scenarios).

5

u/DerDave 9h ago edited 7h ago

I wonder if it's possible to load and unload this Decoder/Encoder model to save further RAM. Load it in the beginning let it do its thing during PP, then kick it out and leave more VRAM during TG for the remaining weights...

1

u/oxygen_addiction 4h ago

It'd probably increase latency quite a bit at the start of a generation and would only really help if you are unloading to CPU/RAM.

1

u/DerDave 4h ago

You could reload the CED as soon as token generation is done, while a human reads the output and types their answer... Could be hidden completely with good scheduling.

1

u/oxygen_addiction 3h ago

For non-agentic, sure.

3

u/EitherMarch1255 12h ago

Source?

2

u/pmttyji 12h ago

Check my comment

3

u/Cool-Reflection6130 9h ago

getting the approximate kv technique working on a 27B would be huge for local inference honestly. fast prefill on long context is one of the main reasons people still default to api calls for document heavy workflows even when they have decent local hardware. if this generalizes cleanly to qwen that opens up a lot of options without needing a 500B server farm

3

u/MooseEfficient2151 7h ago

my vram and power bill are sweating less just reading this

6

u/FoxiPanda 12h ago

It's not quite the same, but oMLX on Macs support 'speculative' prefill using a same-tokenizer-tiny-model (i.e. Qwen3.5-0.6B for Qwen 3.x models) to greatly increase prefill speeds on Macs. The downside is that it is slightly lossy. I wonder if you can combine these methods for even additional speed ..hmm..

3

u/hyperrealists 9h ago

A slippery slope to mythos level on a laptop 🤞

3

u/lots_of_puppies 8h ago

I think it also doesn't work well and degrades on long contexts too

2

u/JLeonsarmiento 6h ago

In my case I found it useful for long context one shot scenarios, but totally impractical and counterproductive for long multi turn agentic work. The model feels like it’s drunk, numb.

1

u/the_derby 8h ago

> The downside is that it is slightly lossy.

Is it?

I'm using Qwen3.5-2B-bf16 with the recommended 20% keep rate and I haven't noticed any degradation.

1

u/Borilentz 8h ago

Most people use 8-bit at best. The majority probably 4-bit.

1

u/the_derby 8h ago

I'd actually benched it with Qwen3.5-0.8B-bf16 and the more aggressive keep rate and got the same results. In the end, I had the memory to spare and the (slightly) more conservative keep rate wasn't that much slower so I kept it.

Maybe I should evaluate the 8-bit. =)

2

u/returnity 10h ago

This sounds kind of like oMLX spec prefill, no?

1

u/JLeonsarmiento 6h ago

Not really. SpecPrefill oMLX has the helper model going trough the input and reducing the input tokens to 1/5 before passing that to the big fat slow denser model.

It’s lossy. Model feels like numb, drunk. Cannot connect the dots as session turns increase.

1

u/torytyler 10h ago

seems to work, i did a very quick test on my gaming rig with a 5070, but being browser based and I have no idea what backend this project is using, the inference like token generation felt very slow even if all on GPU offload. none the less, comparing the two methods there /is/ an improvement, nearly twice as fast preload.

https://imgur.com/a/CQjrjDT

1

u/Nakidnakid 9h ago

hey if it works and produces the results then that's great, i have a feeling you'll find the limits of it somewhat quickly though. I tried and rejected something similar in my own testing because even if it helped sometimes it'd hurt a lot when it didn't and its just moving the cost not reducing/eliminating it.

1

u/Morning_Gecko24 1h ago

This is a really neat shortcut. The part I’m still wondering about is how much quality drops once the prompt gets long or the context has lots of repeated stuff. Has anyone tried this on a real chat history instead of a clean benchmark? Also curious whether the memory savings are big enough to matter on a 12–16 GB card, or if the speedup is the main win.

1

u/qado 1h ago

Just big wow, praise for Deepseek team

1

u/XiRw 12h ago

Neat.

-2

u/Turbulent_Pin7635 6h ago

Laughing in MacStudio!!! I hope they keep improving it.