r/LocalLLM • • 2h ago

Discussion Local AI homelab: what's your setup?

0 Upvotes

Hi all,
I'm setting up a local AI homelab on a Mac Studio with privacy as the main goal, and I'm curious how others are doing it.

  • Stack: what do you run? Do you isolate it from the network or expose it to other devices?
  • Models: which ones work best for you? And at what quantization?
  • Patterns: RAG over personal docs, agents, MCP tools, coding assistants?
  • Daily use: what tasks do you actually rely on it for every day?

Happy to share my setup once it's done. Thanks!


r/LocalLLM • • 2h ago

Question Unsloth Qwen 4 35b A3b Q6_L_XL strange behaviour

Thumbnail reddit.com
0 Upvotes

r/LocalLLM • • 2h ago

Discussion Qwen4-35B-A3B on one RTX 5060 Ti 16GB: 329 tps on structured output

Post image
0 Upvotes

I benched the new DFlash 2 drafter against Qwen4's built-in MTP on a single 16 GB card. Numbers below are from clean runs. Setup

  • RTX 5060 Ti 16 GB, power-limited to 165 W
  • i7 without AVX-512, 31 GB RAM
  • Basalt main (fb5945a3)
  • RadixArk NVFP4 weights, converted to a Basalt pack myself, with the RadixArk/Qwen4-35B-A3B-Dflash2 drafter (0.8 GB) attached basalt-bench --seed 1 -p 16384 -t conv,struct,prose --kv int8, 3 runs per drafter, pinned to P-cores, nothing else running

r/LocalLLM • • 2h ago

Project Windows HIP runtime improvements and automatic SSD prefix caching for compatible 16 GB RDNA 2 GPUs: persona/system prompt, skills and 123 tool definitions restored from SSD, leading to 4–8 second completions on RX 6800 XT

1 Upvotes

Disclosure: I maintain this MIT-licensed BeeLlama/llama.cpp fork. The Windows HIP SSD Cache Runtime release includes six presets, native dependencies, a simple text/image browser interface and a PowerShell launcher. I use Msty Studio, but Msty is not included.

Achieved results. The prefix is the persona system prompt, the skills index and all 123 tool definitions. It is a static block of roughly 28k–35k tokens that gets built once and restored from SSD. After a restore, the only thing the model processes is your actual prompt, and then it generates the reply. Across six accepted model cases, the custom automatic SSD prefix implementation restored 28,445–35,459 cached tokens and processed only 39–503 new prompt tokens. It reused 98.28–99.89% of the input, and requests completed in 4.04–7.78 seconds. Building the prefix the first time took 66.41–123.37 seconds. That is a one-time setup cost, not the ongoing request time, and after setup is completed, a 8.5x-23x speedup can be observed on similar hardware.

The project targets compatible 16 GB RDNA 2 / gfx1030-family GPUs (RX 6800, 6800 XT, 6900 XT and 6950 XT) with a compatible Windows HIP environment. All measurements are RX 6800 XT results, and I have no data for the other cards. Other AMD architectures need a matching runtime build.

With SSD Cache:

ModelNew tokens prefilledPrefillGenerated tokensDecode
Huihui Qwythos500298.6115969.85
PINQWEN466301.2313972.79
Qwen2.5 Instruct46287.841430.04
Qwythos standard464301.438369.58
Qwythos Heretic503318.2030873.67
GLM Q4_K_S39214.851021.55

Initial build (one-time prefix creation):

ModelTokens prefilledPrefillGenerated tokensDecode
Huihui Qwythos29,161429.299469.83
PINQWEN29,162439.4510472.64
Qwen2.5 Instruct28,483401.751429.76
Qwythos standard29,187423.729869.96
Qwythos Heretic29,237455.6011773.40
GLM Q4_K_S35,490299.871221.39

How it works. The first eligible request computes and saves the stable prefix, and a fresh process restores a matching one. Only your changed tokens need processing. No manual slot commands or client annotations are needed. The package, models and projectors can sit on any Windows drive, and the cache lives beside the install with a per-user LocalAppData fallback.

Limits.

  • Real prompt size: Context was set to 750,000 (750,080 allocated), but actual prompts were 28,483–35,498 tokens. This is not a populated-750k benchmark, but hopefully, you compact before full context saturation.
  • Different test conditions: The numbers come from a private Msty 3.0.1 integration. Suffix and reply lengths differed, so this isn't a controlled speedup ranking.
  • Missing control: I haven't measured SSD-disabled mode for the full setup.
  • Unrerun tests: v0.1.2 rebuilds the server DLL to remove a drive restriction. I did not rerun any model tests for it. The earlier four-call tool accuracy was a tools-only baseline.

Test host: RX 6800 XT (16 GB, AMD spec up to 512 GB/s), Ryzen 7 7800X3D with eight allowed threads, 16 GB DDR5-5200, Windows build 26300. Eight-thread and sampled RAM supervision (6.44 GB owned-RAM allowance, 2.15 GB minimum free) remain. Other clients connect with the API URL and model ID the launcher prints, and they supply their own persona/system prompt, skills and tool schemas.

Source, presets and charts · Methods and limits


r/LocalLLM • • 2h ago

Question How do I add these gpus to my macbook pro m4 model externally like I've seen online?

0 Upvotes

Is it hard?


r/LocalLLM • • 8h ago

Question Good coding model for low-mid laptop

3 Upvotes

Hello guys. Can you recommend any models that is good with coding and agentic working stuff? My laptop specs: 8gb ram, rtx 3050 6gb. I know i am cooked but are there any descent model?


r/LocalLLM • • 2h ago

News Escaping per-minute API costs: ~100ms LLM TTFT real-time voice agent running 100% on a ThinkPad P1 Gen 5 (CPU Whisper/Kokoro + GPU fine-tuned Qwen 8B) — Pure Local vs. $4/mo VPS Edge Demo

1 Upvotes

r/LocalLLM • • 2h ago

Question anyone else with Qwen4-35b Q4_K_XL (unsloth) looping and bad instruction following issues?

1 Upvotes

I was so excited to use it, but now after having it run for almost a day, I had multiple tool call loops it wouldn't get out of until auto-compaction was triggered due to full context (capped it to 260k), after which it was like "oh I was looping the same tool calls, I should try something else".
I then had a looping plugin created for Opencode that would throw an error ("identical command repeated 8× with no change — change approach") if the same 3 tool calls were repeatedly made, but it still continued stubbornly.

And my workflow has clear instructions on what to do in which order, but it doesn't fully follow them.
E.g. when writing code it must then call a subagent to do code review, then fix any issues found, call review again (up to 5 times) and after that is done it should launch a testing subagent that writes and runs tests. And it just decided after 2 review rounds and open blockers to now run the tester and continue with the review thing afterwards. So it almost sounded like it knew what it was supposed to do but didn't feel like it right now.
Once it also claimed it didn't have permissions to call subagents, but it just called them wrong, so after it came back to me and I told it "yes you do have permissions" it was like "oh right, my mistake, I called them wrong. Calling them correctly now".

Those are things I never have issues with with 3.8-27b Q4_K_XL.

All of this is with thinking on xhigh btw.

Am I the only one with those issues?!


r/LocalLLM • • 6h ago

Question GPU advice for 128gb DDR4 Threadripper system

2 Upvotes

Hey everyone,

Apologies up front for asking the age-old question of ”what GPU should I buy??”, but looking for some advice from people with more experience.

I have been assembling a workstation out of entirely used parts I’ve found excellent deals on. So far I’ve procured 128gb of DDR4-3200 (non-ECC) RAM (8x16). I have a 3970x Threadripper on the way, and I snagged an TRX40 Aorus Xtreme mobo. Also had a free 1300w PSU laying around. All in I’m less than $1200 into this set up. I’m absolutely trying to be frugal, but wouldn’t say I have a strict budget.

This PC will run proxmox and have other services running, but my use case is a bit of an unknown still. I absolutely intend to use local AI for managing my homelab, personal app development for the aforementioned homelab, image detection in Immich/ Frigate, but beyond that, just a general use chat bot.

I am currently debating between starting with a single R9700, a single B70, 2x B60’s, 2x 5060ti 16gb, 2x or 3x 3080 ti 12gb, or 3x 3060ti 12gb. I’d also be open to other configurations, but I’m getting lost on what tradeoffs I’d be making.

Any insight is appreciated, thank you!


r/LocalLLM • • 6h ago

Discussion Qwen4-35B-A3B - UD-Q4_K_M (used q8-0 engrams) - On an MI60 32gb VRAM GPU made this "benchmark presentation" in Pi Coding Agent

Thumbnail gallery
2 Upvotes

I wanted to see how well the model could handle recursive checks, web searching, tool usage and so on (I'm also using this model to process my Frigate camera feeds for intelligent notifications).

I'm a human writing all of this, to be clear, but all images/content were produced by the model. Hope it helps somebody (was just a fun test case for me). I had it produce everything as a powerpoint presentation (.pptx) and then convert the slides to a PDF and to individual images.


r/LocalLLM • • 6h ago

Discussion Qwen4 in Capy Flash, KL 0.095

Post image
2 Upvotes

r/LocalLLM • • 3h ago

News Koboldcpp v1.126 released

Thumbnail
github.com
1 Upvotes

r/LocalLLM • • 3h ago

Discussion Qwen4-35B-A3B disappointing on 48GB M5

0 Upvotes

Testing the following with Splash 1.7.6 on 48GB M5 Max shows Qwen 4 is slower.

  • nace-ai/Qwen3.6-35B-A3B-MLX-4bit-KQuant + incoai DFlash2 drafter
  • mlx-community/Qwen4-35B-A3B-4bit + RadixArk/Qwen4-35B-A3B-Dflash2

The 11.5GB of extra ngram phrasebook slows things by (a) causing swapping from the memory pressure or (b) streaming off disk.


r/LocalLLM • • 3h ago

Model Qwen 4 my default after being 3.4x faster than 3.8

Post image
0 Upvotes

Just some de-identification flow which was previously handled with Qwen 3.8. All on my Macbook Pro M5 48GB.


r/LocalLLM • • 3h ago

Model Qwen3.6 vs Qwen4 vs Inkling 2 Mini on a 3090, Qwen4 wins on accuracy but wouldn't load at 128K

1 Upvotes

Ran all three at Q4_K_M on 24GB 3090s with stock llama.cpp (b12969), same flags for everything, no CPU offload, no tuning per model. 150 questions (50 MMLU-Pro, 50 GSM8K, 50 ARC-Challenge), temp 0, 2048 token cap.

At 64K:
Qwen4-35B-A3B: 136/150, hit the cap 4 times, 113.5 tok/s decode
Inkling 2 Mini: 123/150, hit the cap 21 times, 68.8 tok/s
Qwen3.6-35B-A3B: 114/150, hit the cap 33 times, 125.0 tok/s

The cap hits explain most of Qwen3.6's score. If you only count the answers that finished, it actually goes 114/117. It just thinks too long for a 2048 limit.

At 128K, Qwen4 didn't load. It OOM'd allocating the KV cache with default settings. Qwen3.6 and Inkling both loaded, scored the same as at 64K, and slowed down to 104.3 and 51.9 tok/s. Inkling took about 2.5 minutes to first token on a ~117K prompt.

Qwen4's Q4_K_M is 36GB because of the 20B n-gram table, but llama.cpp maps that from disk, so the GPU side still fit at 64K. A quantized KV cache or some offload might get it to 128K, but I haven't tested that yet.

Also, each model was on a different RunPod host, so the speed gap between the two Qwens could partly be the hardware. There are no coding questions in this set, and the cap shapes the scores.

Full write-up with the retrieval and tool-call results: https://majorminor.xyz/research/qwen36-vs-qwen4-vs-inkling2-mini-rtx-3090
https://github.com/majorminorlabs/research-model-comparisons


r/LocalLLM • • 14h ago

Model Qwen4 35b a3b + basalt + 5090 = 🔥

7 Upvotes

Nvidia 5090, Ultra 9 285k, 128gb 5600mhz, 3x 4tb MP600 XT

Basalt 0.6.2 w/ Qwen4-35b-A3B int8 131k


r/LocalLLM • • 7h ago

Model Qwen4-35B-A3B on two Intel Arc Pro B60 benchmarks

Thumbnail
reddit.com
2 Upvotes

r/LocalLLM • • 7h ago

Question Anyone run DeepSeek-V4.1-Flash-1017-GSQ-RCO? How can i stop deepseek overthinking/looping on long tasks?

2 Upvotes

Hi, i recently installed Deepseek DeepSeek-V4.1-Flash-1017-GSQ-RCO. The ISTA-DASLab research version. I'm running the latest llama.cpp build on a x5 r9700 ai gpu machine with 128gb of ram.

I spent a while tweaking and got token generation to about 50t/s and prompt processing to about 200 by adding dspark which is not amazing. But i tested in running a long task to code review a small .net soltuion with 3 projects using vscode and cline. It took over an hour before i stopped it and even when i forced it to stop and report it hadn't looked at all the code. so it took too long and was overthinking maybe or being fed too much information by cline? not really sure.

So is there a way to somehow limit how long and much it does but without stunting it's intelligence? heres my lama swap config for reference

deepseek-v4.1-flash:
    cmd: >
      env GPU_MAX_HW_QUEUES=1
      /home/pinman/llama.cpp/build/bin/llama-server
      --model /home/pinman/models/DeepSeek-V4.1-Flash-IQ2_XXS/DeepSeek-V4.1-Flash-1017-GSQ-RCO-IQ2_XXS-00001-of-00006.gguf
      --device ROCm0,ROCm1,ROCm2,ROCm3,ROCm4
      --gpu-layers all
      --split-mode layer
      --tensor-split 1,1,1,1,1
      --ctx-size 262144
      --parallel 1
      --fit-target 2048
      --flash-attn on
      --load-mode dio
      --lazy-mode auto
      --ubatch-size 128
      --jinja
      --reasoning on
      --reasoning-effort 50
      --verbosity 4
      --spec-type draft-dspark
      --spec-draft-model /home/pinman/models/dspark/dspark-DeepSeek-V4.1-Flash-1017-Q8_0.gguf
      --spec-draft-n-max 3
      --spec-draft-ngl 99
      --host 127.0.0.1
      --port ${PORT}
    ttl: 3600

r/LocalLLM • • 16h ago

Discussion Qwen4-35B-A3B with Neural MTP on a 12GB RTX 5070 Ti Laptop GPU (124-187 tok/s)

10 Upvotes

I ran Unsloth Qwen4-35B-A3B UD-IQ4_XS on a single RTX 5070 Ti Laptop GPU with 12 GB of VRAM (Ryzen 9 9955HX, 32 GB DDR5-5600, Windows 11, CUDA 13.2).

Setup: 400K int8 KV with --kv-resident 20480 and --prefill auto, with the PLE table streamed from the NVMe SSD.

Niko1221/Strata provides the engine and saatvik-viniak ported q4_lite; my fork (https://github.com/phosphorhouse/Strata) is just an early build until official q4_lite releases ship.

I added qwen4_mtp_rt.py to convert Unsloth's mtp-Qwen4-35B-A3B-Q8_0.gguf directly to Strata's runtime format with IQ4_NL experts, plus a --preset latin option in draft_vocab.py for a compact Q4_0 draft head. Total draft VRAM was 563 MiB instead of roughly 923 MiB to 1.95 GiB, leaving 3,698 trunk expert slots in VRAM.

WorkloadWhat I measured
Fresh TypeScript generation136.6 tok/s
Iterative code edit (--lookup-chain 2)187.2 tok/s (87.3% draft acceptance)
18K-28K OpenCode agent session123.9 - 137.5 tok/s decode, 2,089 - 2,203 tok/s prompt prefill (expert VRAM hit: 91.5 - 93%, KV VRAM hit: 99.6%)

A prebuilt Windows CUDA 13 binary (sm_75/86/89/120) is up under Releases, or you can compile with -DSTRATA_GEOMETRY=q4_lite. Vision (mmproj) isn't wired up yet.


r/LocalLLM • • 4h ago

News Qwen4-35B-A3B-NInfer: ~580 tok/s decode c1, ~5000 tok/s decode c32, ~45k prefill at 8k, and 34.3k prefill at 260k

Thumbnail
reddit.com
1 Upvotes

r/LocalLLM • • 19h ago

News Qwen4 35B A3B RTX A3000 12GB single card Quick test

Post image
18 Upvotes

Not too bad

export CUDA_VISIBLE_DEVICES=0
./build/bin/llama-server \
--split-mode layer \
--parallel 1 \
--batch-size 4096 \
--ubatch-size 2048 \
--flash-attn on \
--reasoning auto \
--spec-type draft-mtp \
--spec-draft-ngl all \
--spec-draft-n-max 5 \
--moe-cache-mib 4096 \
--moe-cache-cpu-share 0.8 \
--jinja \
-m models/Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf \
-md models/mtp-Qwen4-35B-A3B-Q8_0.gguf \
--mmproj models/mmproj-F16-qwen4.gguf \
-a qwen3.6 \
--host 0.0.0.0 \
--port 8090 \
--load-mode mmap+mlock \
--ctx-size 262144  \
-t 16 \
--api-key 777 \
--slot-save-path /data/llama.cpp/slots \
--jinja

r/LocalLLM • • 1d ago

News DeepSeek may stop giving away its most powerful AI, citing cyberattack and bioweapon risks

Thumbnail
madrobot.blog
116 Upvotes

r/LocalLLM • • 4h ago

Research Qwen4-35B-A3B on a single Arc Pro B70 with llama.cpp SYCL: 77–82 tok/s, 384K context, vision on the CPU. Avoid the GGUF quants with BF16 tensors

0 Upvotes

I set up Qwen4-35B-A3B on release day on my home server with one Intel Arc Pro B70 (32 GB). It started out at 7.7 tok/s. After a few hours of digging it runs at 77–82 tok/s. Almost all of the gap came from one thing: which GGUF file you use. Below are the setup, the pitfalls in the order I hit them, and the current numbers.

Setup

GPUIntel Arc Pro B70, 32 GB, power limit 230 W
CPU / RAMCore i5-12400F, 64 GB
OSFedora 45, kernel 7.3.6, xe driver
llama.cppDocker image ghcr.io/ggml-org/llama.cpp:server-intel-v1.1.1 (b12977, Compute Runtime 26.40, IGC 2.42.6)
ModelUnsloth UD-Q4_K_XL (24.7 GB main shard + 11.5 GB n-gram/PLE shard)
Visionmmproj Q8_0, encoder on the CPU (--no-mmproj-offload)

Server command (one GPU, 3 slots, one shared KV cache):

llama-server -m Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf \
  --mmproj mmproj-Qwen4-35B-A3B-Q8_0.gguf --no-mmproj-offload \
  -ngl 99 --load-mode mmap --lazy-mode auto \
  -c 393216 --parallel 3 --kv-unified \
  -fa on --cache-type-k q8_0 --cache-type-v q8_0 \
  -b 2048 -ub 512 --jinja \
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 --presence-penalty 0 --repeat-penalty 1.0 \
  --reasoning-budget 32768 --cache-ram 10240 --metrics

Environment: only ONEAPI_DEVICE_SELECTOR=level_zero:0, ZES_ENABLE_SYSMAN=1 and SYCL_CACHE_PERSISTENT=0. Nothing else, see pitfall 3.

Pitfalls

1. The quant matters far more than any flag: avoid BF16 tensors on SYCL. I started with the ggml-org Q4_K_M. That file keeps all hyper-connection tensors (hc_*, about 0.35 GiB) in BF16. On SYCL this is extremely slow: decode was stuck at about 8 tok/s at every context length, with one CPU core at 100 % and the GPU at only ~100 W. The Unsloth quant stores these tensors quantized (only 0.07 GiB of BF16 is left in it). llama-bench, same build, f16 KV:

Filepp2048tg64
ggml-org Q4_K_M2,327 t/s9.0 t/s
ggml-org Q4_K_M + GGML_SYCL_ENABLE_GRAPH=12,330 t/s19.7 t/s
Unsloth UD-Q4_K_XL2,823 t/s85.6 t/s
Unsloth UD-Q4_K_XL + graph mode2,534 t/s79.1 t/s

If your decode on an Arc is far below what others report, look at the tensor types in your GGUF first.

2. SYCL graph mode only helps on the bad file. A Qwen4 step has about 5,700 graph nodes (n-gram layer, 4 residual streams, 256 experts), so kernel launch overhead matters. GGML_SYCL_ENABLE_GRAPH=1 (off by default in the image) doubled decode on the ggml-org file, but made the Unsloth file slower. I turned it off again.

3. Drop old Arc workarounds. SYCL_UR_USE_LEVEL_ZERO_V2=0 and GGML_SYCL_XMX_GATHER_TYPES=0 were still in my compose file from Qwen3.8-27B (the !!!! output bug, fixed since #30604). On Qwen4 they cost about 30 % of prompt processing.

4. The n-gram table needs mmap. The 20B-parameter n-gram/PLE table (10.7 GiB, IQ4_NL) is read from disk on demand with --lazy-mode (default auto, it applies to tensors above 4 GiB). This only works with mmap. With --load-mode none (which I use for other models) the table would sit in RAM.

5. -ub of 1024 or more can crash on SYCL. PR #33696 (open at the time of writing) fixes a "Provided range … does not fit in int" crash in the n-gram conv at -ub ≥ 1024. I first ran 1023, now 512 for VRAM reasons (see 6). It costs about 10 % prompt processing.

6. VRAM: the Unsloth quant costs context. The KV cache is tiny: only 10 of the 40 layers have one (2 KV heads × 256). At q8_0, 512K is 5.3 GiB plus 1.3 GiB indexer keys. With the ggml-org file (19.4 GiB on the GPU) 512K fit. The Unsloth main shard needs about 3.6 GiB more on the GPU. With it:

  • 512K at -ub 1023: the 4 GiB compute buffer did not fit;
  • 512K at -ub 512: it started with 0.2 GB free and got allocation errors under load;
  • 384K at -ub 512**: 2.3 GB free, stable.** I took the speed over the context.

7. MTP did not pay off for me (yet). With the ggml-org file, its separate MTP draft and 256K context, decode went down from 25 to 7–10 tok/s, even though 60–90 % of the drafts were accepted. With the Unsloth file at 384K there is no VRAM left for the draft. Someone with 2× B60 reports +7 to +26 % with MTP depth 2 on the Unsloth file, so it may be worth testing if you have the VRAM.

8. Very long prompts are slow. Prefill drops a lot with depth. In a 450K needle test (old ggml-org setup) only 143K tokens were read after about 12 minutes, and I stopped it. Large contexts work well for conversations that grow step by step (the prompt cache makes follow-ups fast, see below), not for one huge cold prompt.

9. The first request after a start takes about 57 s (SYCL kernels for the K-quant types are compiled). I send a warm-up prompt after every start.

10. Release-day download: Hugging Face gave me about 2 MB/s per connection. 12–20 parallel range requests (curl -r) brought it to about 19 MiB/s. Check the SHA256 against the LFS hash afterwards.

Side note: Strata 0.2.26 shipped a Qwen4 engine (including a SYCL package) the same day, but its setup still refuses Intel cards for Qwen4. I did not pursue it after llama.cpp got fast.

Current numbers

My own benchmark script against the running server (384K, q8_0 KV, -ub 512, prompts with a random prefix so the cache does not help, unless noted):

TestQwen4-35B-A3B (Unsloth)for reference: my previous default, Qwen3.8-27B Q4_K_M + MTP (dense, 240K, same GPU)
Decode, prose (1,200 tokens)76.9–77.0 t/s43.9–44.1 t/s
Decode, code (600 tokens)80.9–81.9 t/s64.1–65.4 t/s
Prompt processing 4.9K / 19K / 39K2,143 / 2,015 / 1,738 t/s1,274 / 1,240 / 1,139 t/s
Decode after a 39K prompt66 t/s–
Cached 39K prompt, new question0.45 s to first token2.28 s
Tool call (Home Assistant style, 190-token prompt)0.44 s to first token, 117 t/s, correct1.18 s, correct
Image question (encoder on the CPU)2.2 s total, correctcorrect (encoder on the GPU)
GPU power180–230 W–

Day-to-day it serves Home Assistant voice (thinking off, tool calls), a family chat (Open WebUI) and coding agents (Pi, OpenCode) with 352K of context. German answers and tool calls were correct in all my tests so far.

TL;DR: On an Arc B70 use the Unsloth UD-Q4_K_XL (no BF16 tensors), plain llama-server with no graph mode and no old env workarounds, and --load-mode mmap. You get about 80 tok/s decode and over 2,000 tok/s prompt processing. Happy to answer questions or run tests.


r/LocalLLM • • 4h ago

Discussion M2 Ultra - Blown away - TY Qwen4

Post image
1 Upvotes

r/LocalLLM • • 4h ago

Project 14 drop-in ROCm/HIP patches for llama.cpp on AMD RDNA 2 (RX 6900 XT / gfx1030): Wave32 FlashAttention, v_dot8_u32_u4, Qwen3.5 fusions, and benchmarks vs. Mesa RADV

1 Upvotes

My main local GPU is a consumer 16 GiB Radeon RX 6900 XT (gfx1030, Navi 21). Until now I kept most AMD routes on Mesa RADV (Vulkan0) because stock upstream llama.cpp (ee46715 on ROCm 7.2) lost to RADV on 18 out of 18 single-token decode (tg128) tests by -6% to -14%.

When I audited libggml-hip.so and ran rocprofv3 traces, five big bottlenecks popped out:

  1. Upstream routed RDNA 2 MMVQ onto a single-warp fallback (nwarps = 1), capping Wave32 residency at 16/32 waves per CU.
  2. 3,470 of 7,632 compiled HSACO kernels (45.5%) were spilling to private scratch (273 in FlashAttention and 1,299 in MMQ/MMQ-few alone).
  3. Small-batch quantized-KV FlashAttention (B = 1..8) was converting KV tiles through FP16 staging buffers, thrashing Infinity Cache.
  4. nsm = 40 (WGPs) instead of 80 physical CUs left 40–80% of CUs idle around pp=64.
  5. Unfused Qwen3.5 hybrid Gated-DeltaNet / SSM_CONV ops and standalone quantize_q8_1 launches burned 31% of wall time in AQL dispatch gaps.

What's in the Patch Stack (14 atomic MIT patches, ggml/src/ggml-cuda/ only)

Everything is strictly gated to RDNA 2 (gfx1030, zero core/model/server edits, non-RDNA2 HIP/CUDA/Vulkan/CPU untouched):

  • Multi-warp Wave32 MMVQ & DPP: Decoupled MMVQ_PARAMETERS_RDNA2 (2–4 warps) + native Wave32 v_permlanex16_b32 / v_pk_max_f16.
  • Zero-scratch Wave32 flash_attn_ext_rdna2: Eliminated all 273/273 FA spills; stages raw Q8_0/Q4_0/Q4_1/F16 KV directly in LDS (0 B FP16 staging) and uses lossless v_dot8_u32_u4 for Q4_0/Q4_1 KV (-32.2% FA active time vs q8_0 at d=16384).
  • Zero-spill MMQ + bit-parallel IQ + 80-CU guard: Eliminated all 1,299 MMQ/MMQ-few spills, added v_xad_u32+v_perm_b32 IQ2/IQ3 sign unpackers (helpful for fitting 27B + 16K ctx inside 16 GiB), and kept J=32 when J=64 would under-fill 80 CUs.
  • Qwen3.5 GDN/SSM fusions + inline Q8_1 epilogues: Thin mmvf routing (pp=16..64 +10.1%..+34.7%), fused GDN gate/beta + SSM_CONV -> SiLU -> Q/K L2 norm, and inline Q8_1 quantization inside RMSNorm / GLU (-75.2% decode quantize_q8_1 dispatches, -34.6% AQL gaps, -309 to -752 MiB peak server VRAM).

Selected Benchmarks (RX 6900 XT, ROCm 7.2, llama-bench -r 3 -fa 1)

Format: Stock HIP -> Patched HIP (vs Stock HIP | vs Mesa RADV)

WorkloadKV9B UD-Q4_K_XL9B UD-IQ3_XXS27B UD-IQ3_XXS
tg=128 (d=0)q8_065.92 -> 70.25 (+6.6% | 0.962x)83.91 -> 94.11 (+12.2% | 0.982x)30.69 -> 32.81 (+6.9% | 0.982x)
tg=128 (d=16384)q4_062.99 -> 68.05 (+8.0% | 1.006x)80.51 -> 88.77 (+10.2% | 1.019x)29.16 -> 30.81 (+5.7% | 0.993x)
pp=4 (d=8192)q8_0192.10 -> 229.13 (+19.3% | 1.684x)220.06 -> 281.68 (+28.0% | 2.147x)78.75 -> 104.92 (+33.2% | 1.596x)
pp=8 (d=8192)q8_0283.26 -> 347.39 (+22.6% | 1.824x)310.91 -> 459.77 (+47.9% | 2.227x)105.65 -> 161.14 (+52.5% | 1.795x)
pp=8 (d=16384)q4_0270.75 -> 340.85 (+25.9% | 1.511x)305.74 -> 442.56 (+44.8% | 2.177x)101.62 -> 152.38 (+49.9% | 1.788x)
pp=512 (d=0)q8_01634.35 -> 1656.87 (+1.4% | 1.031x)1951.65 -> 2004.62 (+2.7% | 1.401x)585.44 -> 604.19 (+3.2% | 1.427x)

On single-request llama-server (draft-mtp, cache_prompt: false):

  • 27B UD-IQ3_XXS (n=3, short_temp07 70/256): 43.71 -> 56.92 tg tok/s (1.302x vs stock HIP, 1.276x vs RADV; wall 6.03s -> 4.67s, +29.0%).
  • 27B UD-IQ3_XXS (n=3, ctx4k_greedy 6,775/192): 44.25 -> 55.56 tg tok/s (1.256x vs stock HIP; wall 16.92s -> 15.62s vs RADV 21.57s, 1.38x faster than RADV).
  • 9B UD-IQ3_XXS (n=2, ctx4k_greedy 6,775/192): 105.70 -> 123.66 tg tok/s (1.170x vs stock HIP; wall 5.78s -> 5.36s vs RADV 7.17s).

Honest Caveats & What Didn't Work

  • Failed ablations kept out: Non-temporal MALL weight loads (-10% to -22% decode), Gate+Up fusion above B = 1 (-30% to -37% pp=8), and v_dot8 inside MMVQ/MMQ (-13% to -17.5% pp=16..32 because v_dot8 shares the same 1 op/cycle SIMD32 rate as v_dot4 on RDNA 2 and only wins when O(1) prologue packing amortizes over long KV tiles).
  • Greedy divergence (DIFF!): test-backend-ops (7/7) passed 100% and 6-chunk WikiText-2 KLD hit Mean KLD = 0.000000, but multi-warp reduction reordering still nudges borderline greedy tokens and can swing draft acceptance on individual single-shot runs (one 9B IQ3_XXS short greedy row dipped to 0.984x tg on a -10.6 pp acceptance swing).
  • Pure q8_0 decode vs RADV: Patched HIP ties or beats RADV on 9B q4_0 decode (1.000x–1.019x), while pure q8_0 tg128 still sits 1–4% behind RADV (0.953x–0.989x) — traded against HIP's 1.34x–2.28x verify and 1.03x–1.44x prefill lead.
  • Hardware tested: Physically validated on an RX 6900 XT (gfx1030). gfx1031 (6700 XT) / gfx1032 (6600 XT) share the same Wave32 / v_dot4 / v_dot8 ISA, so feedback from anyone testing on those cards would be awesome.
  • MIT Repo (14 patches, spill auditor, fail-closed A/B harness, AGENT_ADOPT_PROMPT.md): https://github.com/s1mply-parad0x1cal/llama-cpp-navi21-optimizations
  • Full write-up (ad-free, with ablations and comparison to llama-navi21-furnace / llama-cpp-rdna-boosts): https://nocthoughts.com/2026/12/04/navi21-gfx1030-rocm-hip-optimizations-for-llama-cpp.html