r/LocalLLaMA • • 15h ago

Resources AMD-specific llama.cpp patch nearly doubles prefill/decode

https://devnull.land/amd-specific-llama-cpp

I know we're all a bit faded on the vibe-coded inference engines (as incredible as Strata/Splash/Basalt/Halogen/Gufo/etc. are for their specific models/hardware), but this is different enough that I thought it was worth sharing the write-up I stumbled across about llama-cpp-rdna-boosts.

This github repo is a minimal patch you can apply to your pinned llama.cpp build to specifically boost performance on AMD RDNA 3 & 4 cards (edit: “best-effort” RDNA 2 support too), while maintaining llama.cpp's broad compatibility with nearly every model. The write-up documents his R9700's prefill increasing from 700tps to 1300 tps & decode from 35tps to 55tps on Q6_K_L Swift-1.5-Qwen3.8-27B. That's an increase of ~80% over base llama.cpp before patching, though purpose-built inference engines still appear to have a slight edge.

I don't have an R9700 to test this out (...yet) but it seemed worth sharing for everyone here who's running AMD hardware, but is looking for broader model compatibility than model-specific custom engines can provide. Has anyone here tried this?

232 Upvotes

97 comments sorted by

59

u/ThankGodImBipolar 15h ago

The post should probably clarify that this targets mainly RDNA 3 and 4, as there's a lot of people with MI50s and V620's on this subreddit.

Happy to see that it supports RDNA 3 though, as normally these AMD specific PRs/engines/etc. are STX-H or RDNA4 only. 

8

u/returnity 15h ago

Thanks for that, I’ve edited the OP to note that.

20

u/noctrex 14h ago

It also has some patches for RDNA2.
I'm using it and I'm seeing better performance on my underclocked V620.
For example with Ornith-1.5-35B-A3B Q6, I got from ~880pp / ~80tg up to ~1400pp / ~100 tg.

12

u/ThankGodImBipolar 14h ago

Damn - the README says that RDNA 2 support is "best effort," but I'd have thought that there wouldn't be much to do without WMMA. +60% prompt processing is no joke. 

6

u/noctrex 14h ago

Well, we can try it out more and even submit some issues to this repository so the author can add even more patches for RDNA2, I intend to send some

4

u/twnznz 13h ago

If you have an Mi50, please see the rapid chestnut. https://github.com/benpeterson40/castagna-veloce

1

u/Ok_Cow1976 12h ago

It's for 4 mi50s, it seems. Performance improvement on 1, 2, 3 mi50s?

26

u/jacek2023 llama.cpp 15h ago

So why no PR?

61

u/Look_0ver_There 14h ago edited 14h ago

I'm the primary maintainer of the repo OP refers to. In short, too many ideas to slow down and wait for each one to push to mainline.

I do have a directory there with outstanding patches to push to mainline, but I've been so busy working on the repo that frankly I'd rather get everything polished up and stable, and maybe when things slow down, I'll think about submitting patches to mainline.

There's also the fact that half of repo's changes completely supplants upstream's code that the main llama.cpp maintainers have written themselves. Fighting that inertia is something I don't have the energy for at the moment.

If someone wants to grab my diffs and create upstream PRs from them, then I have no objections to people doing that. People are most welcome to do so, so long as credit is given.

11

u/returnity 13h ago

Upvoting for visibility, and thank you for your contribution to the community! Hope you don’t mind me sharing your work

7

u/jacek2023 llama.cpp 14h ago

But are you able to separate some atomic changes from your repo? At least you will move some functionality from your fork to the mainline this way

28

u/Look_0ver_There 13h ago

As soon as I find some time to do so, yes, otherwise I'm happy to have someone help with that task while I focus on improving the change set. Still very busy refactoring a bunch of stuff.

I'd already submitted some changes in the past. They got sat on, and then when I thought it might get admitted after over 100 comments, one of the maintainers suggested a different solution which didn't perform as well as my proposal, and wanted me to test their solution for them. After that I kind of lost interest in spending more energy on that exchange and decided to just focus on what I want to do.

I have no antipathy towards the llama.cpp devs. I truly appreciate them, but I'm just not cut out for climbing a 100+ comment PR mountain for every change. I'll die of old age before even one quarter of my changes get in.

7

u/Aromatic-Low-4578 12h ago

Very well put. Appreciate you sharing your work.

2

u/Intrepid-Second6936 9h ago

Sorry to hear about that! Yeah llama.cpp moves very fast but it's also pretty evident in their current PR mountain how any changes suggested can also get lost without being continuously pushed for review.

Hoping there's maybe some way for you to able to get your changes merged upstream, maybe with some kind of rally on r/LocalLLaMA to push up the PR with reactions or something.

Will definitely try this out, but it'll probably be hard to stay on this fork while waiting on and seeing all the new changes currently happening on llama.cpp to get Inkling 2 Mini working properly without degradation in perf.

Amazing work though! Glad to see changes like this help out everyone on our smaller AMD crew side in this community. 🙌

3

u/Look_0ver_There 8h ago

Thank you. The big problem with maintaining this patch set as I have it is that every rebase to resync it with upstream is a full day job, and that's why I only do it once/week. Actually tomorrow night is when I'll do the next resync, and then it'll pick up all the Inkling work. I've been keeping an eye on it and waiting for it to settle down a bit as I don't want to do a full day's work only to miss on some important Inkling update.

In short, Inkling support should be there by Sunday evening. I'll then figure out what to do with it, whether to keep it aligned with upstream, or do what I did with qwen4exp and use it as a starting point to optimize it further and force a clean break from upstream after that for Inkling support. The qwen4exp support in the repo is now pretty far removed from upstream's version for example

1

u/Intrepid-Second6936 8h ago

That'd be great! Appreciate all your hard work, yeah I normally actually don't update llama.cpp a lot at all, but if you do end u re-basing at some point that would be amazing!

I'm already seeing posts and changes that seem to show massive speed increases with inkling 2 mini, so I might genuinely be using your fork for a while after that re-base 🙏

1

u/thesolewalker 6h ago

why not maintain your own fork like patientx comfyui-rocm (which I am using) ? if its not too much harder to maintain of course.

1

u/Daniel_H212 8h ago

Does it help with strix halo?

2

u/Look_0ver_There 8h ago

Yes. I have Strix Halo's too, so gfx1151 is one of the primary architectures supported by the repo.

Prefill is not as fast as, say, gufo or Halogen for Qwen3.8-Flash-Next, but it's respectable at ~1200-1300t/s for prefill. Decode speeds do seem to be pretty competitive with either of those 2 though.

All other models that llama.cpp supports should run at a pretty nice speed boost too. Even Qwen3.8-27B-Q8_0 runs okay with a BF16 KV cache.

20

u/returnity 15h ago

Have you ever submitted a PR to llama.cpp? It's can be a byzantine nightmare. I tried to get a one-line hand-written fix for Nemotron Bolt compatibility in there when that released, and I regretted it.

8

u/DrPoopyPants 13h ago

So true. Love llama.cpp, not so much the devs. One young hugging face employed dev admin straight up accused my code of being copied from another dev (he had to join the convo and say it was a-ok), but by then we gave up and now ds4 is the best way to do DeepSeek inference.

I still get comments saying my branch is 2x the DeepSeek performance of official llama.cpp, but I’m not touching it anymore.

2

u/returnity 13h ago

Ds4 was my entry point into alternative inference engines and it’s still how I run my custom SSD-streaming quant of DSv4.1. Can’t say enough good stuff about it. I just switched to Splash for Qwen models, because it’s built by the devs of DFlash2 and it absolutely screams, but I’ll always be repping dwarfstar.

15

u/jacek2023 llama.cpp 15h ago

Yes, but I am a programmer, so code reviews are a normal part of my work :) Without human reviews, projects turn into trash.

21

u/returnity 15h ago

Don’t disagree, but that doesn’t mean llama.cpp’s current state of affairs is ideal. Look how long it took to merge basic functionality like MTP for Flash Next, as a recent example. Not hating but there’s a reason these vibecoded engines are having a moment, and part of it is the pace of development due to gatekeeping of contributions (IMHO).

That doesn’t diminish my gratitude for the project and its dedicated contributors, just being real. I understand it’s become an intricate and complex codebase that requires considered development, but you can’t say there isn’t room to improve.

11

u/jacek2023 llama.cpp 15h ago

"Look how long it took to merge basic functionality like MTP for Flash Next, as a recent example."

my number one example is DiffusionGemma (almost half a year now). I will probably submit an alternative PR just to see what happens ;) But it needs lots of work

9

u/returnity 15h ago

Wait we still can’t run DiffusionGemma in mainline?!

7

u/jacek2023 llama.cpp 15h ago

That support was vibe coded by Unsloth, if I'm correct. It's unclear to me what the plans are for diffusion models in llama.cpp. I have some ideas for supporting them in llama-server or creating some other kind of UI, but both ways are risky (could be rejected quickly), so I keep procrastinating on both :)

4

u/noctrex 14h ago

Didn't the same thing happen just now with Inkling?
unsloth posted their vibe coded PR, but it wasn't good and was not accepted, and llama.cpp used another more proper PR.
That's why we see on their model page the mainline GGUF and their own, instead of accepting the mainline as standard.
It seems they're drifting more and more from mainline, with their vibecoded fork.

1

u/jacek2023 llama.cpp 14h ago

I have same same observations (QFN was another example) but I don't know any more info so I can only speculate ;)

1

u/CoolConfusion434 14h ago

That's one of my few bookmarked PRs I keep hopium out for: https://github.com/ggml-org/llama.cpp/pull/24423

It'd be great if you can submit something that appease the PR merging gods.

3

u/noctrex 14h ago

But isn't this the state of almost every open source project that isn't purely vibecoded nowadays? I see many projects that are just getting flooded with vibe PRs, and there isn't enough manpower to sort through them all, and be review by humans, not just vibes.

1

u/darktotheknight 7h ago

Partly yes, but this was also an issue pre-vibecoding.

There are a bunch of categories of PR. One is the absolutely low-effort one, they will just PR absolutely minor/worthless things, like single typos in code comments. They're then listed as "Contributors" to the project. I always suspected these people are trying to polish their GitHub for job hunting.

Then there are PRs which flip the entire repo upside down without any clear benefits. They ignore any sort of good coding practices and the whole codebase feels like their messy playground. It is unmaintainable. Happy that you love the software. But ffs just do your own thing in your own fork and don't bother me with it.

Then comes vibecoding. PR with 320 commits. Created 200 new files, added 78.000 new lines of code. And they expect me to review it. They don't even have a clue what the code is doing themselves, but expect me to merge it. Yeah, no thanks. You can keep your "malware". That's what forks are for: have fun in your own repo. No need to pull down my reputation and years and years of trust I gained from my users.

4

u/Important-Shallot-49 6h ago

PR with 320 commits. Created 200 new files, added 78.000 new lines of code.

https://i.imgur.com/8EllSwX.png

i used to feel some sort of innate obligation to put my own FOSS stuff out because i was using so much of the overall opensource ecosystem but not anymore.

1

u/darktotheknight 5h ago edited 4h ago

I still like putting my FOSS stuff out there, but I'm much more sensitive about people trying to hijack the trust and track-record of my projects. If you have a huge problem with PR and Issue spams, disabling these features on your GitHub repo is also an option.

1

u/altertuga 15h ago

So it sounds like it's all according to plan. Those that want unstable and not understood vibecode can get it, and those of us that prefer stable and understood can get it too. I know which side I'm in, just pick yours.

6

u/returnity 15h ago

Why do I have to pick a side? I support any work that moves the local AI community in a positive direction, and I use both Splash (which is neither vibeslop nor unstable) and llama.cpp daily. I’ll pass kindly on the false dichotomy, thanks.

-1

u/altertuga 14h ago

So a second ago you were complaining about llama.cpp being slow and missing out, and now we can all be friends and improve things as a family. Nah, I'm here for the conflict.

6

u/returnity 13h ago

I bet you’re a fun guest at family Thanksgiving =P

1

u/CevicheMixto 13h ago

Is auto-closing them, because no can be assed to look at them part of your process?

13

u/noctrex 14h ago

its not so bad, I've merged some fixes too and there wasn't any problem

1

u/mister2d 11h ago

This is why we have nicer things like community driven inference engines for consumer AMD hardware.

21

u/Shot-Height-7194 15h ago

Because they don't like vibe coded PRs, they take months to review, they say you need to understand every line etc

16

u/jacek2023 llama.cpp 15h ago

So nobody understands this code?

-17

u/Cool-Chemical-5629 15h ago

Linus Torvalds recently merged over 41000 lines of code into Linux OS codebase, all of which were AI generated fixes. Do you think he reviewed every single line to get familiar with what the code actually does?

29

u/altertuga 15h ago

So you believe nobody reviewed those fixes and understands them because Linus did not review them himself? I don't think your argument is as load bearing as you believe.

-7

u/twack3r 15h ago

Please be a bot. If the load bearing malpractice has crossed species into humans already, we’re done.

6

u/chiniwini 14h ago

If the load bearing malpractice has crossed species into humans

Where do you think LLMs got it from? Aliens? God?

-7

u/Cool-Chemical-5629 15h ago

I never said I believe nobody reviewed those fixes. My point was that Torvalds himself trusted them enough to merge, blindly at that.

4

u/Adventurous_Boat_492 15h ago

He seems to be pretty discerning about it. r/linuxsucks is offended about him being too strict about AI slop: https://www.reddit.com/r/linuxsucks101/s/MduPj23SfD

3

u/james_pic 14h ago

No, but I think he delegated reviewing them to subsystem maintainers.

3

u/Thunderstarer 14h ago

What? No. You're thinking about the ext4 patch he reviewed a few days ago, which was 41K lines of code that he eviscerated the author over and refused to merge.

Torvalds does use LLMs for Linux kernel development, but in this specific case, he went on a whole rant about how it was wildly irresponsible to generate such a large volume of unreviewed code:

Get your shit together and stop this kind of idiocy. And tell your AI companion to get its act together, and do any new development and test-cases ON A SEPARATE DAMN BRANCH, so that it can be merged during the MERGE WINDOW. What's so hard to understand about this?

3

u/maternion 15h ago

Did he merge it? I thought he just got super angry :D

9

u/ToaruBaka 15h ago

He was mad because a bunch of patches showed up right at the end of the merge window. Behavior that has angered him for decades lol.

3

u/CoolConfusion434 14h ago

He did, with a ton of reservations and some noted words: https://www.phoronix.com/news/Linus-Torvalds-EXT4-AI-Big. He can't possibly gatekeep every single line of code. He has to delegate work or progress will slow down to a crawl (GG does as well). He's counting on the fact that core team won't do this kind of brainless thing and dump 41K lines of changed code.

1

u/Cool-Chemical-5629 15h ago

Yes, according to the article at cybernews, he did. AI-generated bug fixes anger Linus Torvalds | Cybernews

Although Torvalds accepted and merged it, he expressed his irritation on the kernel mailing list.

7

u/bootkeen 13h ago

what is the future of this patch? will it be mainteined or rebased onto latest llama versions? is it going to be PRed and merged into original llama.cpp?

3

u/returnity 13h ago

Probably never for the latter, but it appears to be designed so you can just apply it to future builds of llama.cpp as well. If there are merge conflicts in the future, your agent can probably resolve them easily enough; mine rebase my crazy complex cherry-picked builds with 10+ overlapping PRs on a weekly basis and they always successfully resolve the new merge conflicts.

21

u/d0pe-asaurus 15h ago

I use https://github.com/achyudh/llama.cpp/tree/feature/adaptive-kv-stream-rocm which combines llama-cpp-rdna-boosts with a port of adaptive-kv-streaming. Works with gfx1201 and gfx1200.

Ever since finding out about it i haven't changed a thing in my setup, I can run Qwen 3.8 27B UD-IQ4-XS, 262k context, Q8/Q4 K/V cache on my 9060xt.

3

u/archeebunker 14h ago edited 14h ago

Does this work on Windows?

2

u/d0pe-asaurus 14h ago

Someone has made a fork of this fork to make it work for windows. They even have pre-built binaries.

https://github.com/raffidahmad/llama-cpp-kvstream-windows

1

u/returnity 13h ago

It’s forks all the way down

1

u/archeebunker 11h ago

Thanks. I rebuilt this for my RX 9060 XT to work on Windows and I'm getting ~ 35 tokens/second (9060 is half the speed of 9070)

1

u/d0pe-asaurus 11h ago

Nice, glad that worked out for you

2

u/Look_0ver_There 19m ago

I'm the main author (there are many contributors) to the rdna-boosts repo. `rdna-boosts` added support for KV cache streaming from the host about 3 weeks back. Do you have any objections to me checking out your repo to see if there's anything that can be back-ported into my solution for that feature?

2

u/d0pe-asaurus 15m ago

I haven't checked rdna-boosts since 2 months ago, thanks for adding kv-cache streaming, maybe I should check it out again.

And the adaptive-kv-stream-rocm repo isn't mine but i'm sure the author u/bottlestreet3d wouldn't mind.

1

u/kind_cavendish 14h ago

How do you do it? Im on a 9060xt aswell and im trying to run qwen 3.8.

0

u/maternion 15h ago

I have only ever tried radiance excluding llama.cpp, and I have the same card.  What does the kv streaming port allow? And will these additional features be bottlenecked by my low bandwidth? 

1

u/returnity 14h ago

FWIW, the Apple Silicon engine I use, Splash (by the creators of DFlash2), has SSD KV cache overflow for when your desired context size doesn’t fit fully into RAM, and it only slows decode by about 20% when it switches over to SSD KV at the length threshold, so I doubt you’ll notice much impact from just moving it out of VRAM to RAM.

3

u/d0pe-asaurus 15h ago

Allows you to run a ~14GB model with 262k context by adaptively moving kv cache (context) in and out of VRAM.

The answer to the 2nd question, naturally, is yes since regular ram is slower than vram. But in practice I don't feel it slower than base llama.cpp, and I use 2133mhz DDR4

1

u/maternion 15h ago

Is this the only engine that shifts kv cache between vram and ram? Since I suppose all others move moe or other layers but keep kv on vram. So since kv is used a lot I wondered if low bandwidth would cause severe slowness.

And i have 3000MHz so i guess it's not an issue then!  

4

u/d0pe-asaurus 15h ago

No, adaptive-kv-streaming is a well known technique, there's even a PR for it in base llama.cpp. The engine i linked before is a port of the nvidia-only https://github.com/RaymondHuang210129/llama.cpp-adaptive-kv-streaming/

adaptive-kv-stream-rocm is just the fork that readily implements it with the other llama.cpp RDNA boosts

1

u/MmmmMorphine 15h ago

Am I correct in supposing my card's 8x pcie4 would greatly limit the practical impact of that approach?

I'd also assume that sad memory bus in general on the 4060ti would be a second nail in that coffin, but I'm no real expert on these matters

6

u/OverdosedSauerkraut 15h ago edited 15h ago

Nice find/work! I'll try to check it out over the weekend. I really wish llama.cpp devs took performance seriously...

However after looking into the repo I can see why this won't get merged in the mainstream. Though it also cleans up a lot of crap in the code. This seems like one of the mega-MRs that does everything and noone wants to review.

3

u/returnity 14h ago

Can’t take credit for the work, just the find. Always happy to help good work get more exposure though.

3

u/TheCat001 14h ago

Any boost for RDNA2 ? :(

1

u/Filters83to 13h ago

Nice find! Btw 99% of the problem can be solved by Claude or codex, just ask them to optimize it for your setup and you are good to go ( kinda ;) )

1

u/p186 10h ago

Nice. I’m rebuilding my workstation and have 2 GPUs that use RDNA 3/4. Thanks OP.

1

u/Beneficial_Fish_7509 9h ago

Things are really looking bright for AMD hardware with LLMs. It seems like a lot of the issues were software, not hardware.

1

u/Daniel_H212 8h ago

Does this help strix halo?

1

u/xsilas43 6h ago

Yes these patches provide a significant boost on my 9070xt.

1

u/Samecowagain 5h ago

If you own an R9700 and run Qwen 3.8 at home on it, I would switch to Radiance instead. https://codeberg.org/StillDeadcode/radiance - installed as docker, easy to setup, and dedicated for the R9700 and a few models. Plus you get help on discord launch80 if needed, or can exchange feedback with others.

I run a dual R9700 setup with Qwen 3.8 27b IQR8, 200k context and 3500 t/s prefill and 140 t/s generation.

1

u/Frizzy-MacDrizzle 2h ago

Not AMD, I pulled llama.cpp last night, nov 28, 2026. Recompiled with specific 120a arch. Boom, no hardware change, no model change, 27 tgs without any tweaking qwen 3.8 command line. Not much.

The pull and recompile with 615 driver and cuda13.5 is going 47 to 50+ on two 5060s.

I’m not moving to Strata, locked to a small amount of models and is not compatible with my software layer is not going to happen, so if you get more tgs, great I’m happy for you.

It seems MAYBE, there are changes in cpp too.

1

u/Mitchy103 2h ago

yeah, saw this was trending on Hacker News. This look great! I do have an AMD GPU laying around, will try to give it a shot. I wish that this changes can also be merge by llama.cpp, recently they put a lot of efforts in improving the speed! Quite exiting ;)

1

u/modernkennnern 52m ago

How does this compare to Strata?

I use Strata on a RX 9070XT, but if I don't have to use such model-specific engines I'd rather not; especially since everyone says it trades quality for speed (I can't confirm or deny that myself: never ran Q3.8FN on any other engine for a prolonged time)

1

u/Sh1ftyFella 14h ago

I wish people would actually do more testing and more variety before doing write-ups like this. I know it’s mentioned in the article that he is using an eGPU but there should be no reason r9700 should be that slow on stock llama. Especially with MTP

-1

u/noctrex 14h ago

1

u/returnity 14h ago

That’s the repo I linked in OP.

2

u/noctrex 14h ago

Yep, just saw it. Sorry! Actually quite good performance wise.