From 20.5 to ~100 Tok/s: Running Qwen3-Coder 30B Q4_K_M on an NVIDIA RTX 4070 Ti SUPER 16 GB

I frequently use Microsoft MAI Code 2 Flash in my professional development workflow, particularly for Terraform, PowerShell, and C#.

That experience gave me a pretty clear idea of what I wanted from a local coding model: enough capability and responsiveness that I could realistically use it as part of an everyday development workflow rather than simply as an interesting local inference demo.

I wasn't trying to reproduce MAI Code 2 Flash itself. Qwen3-Coder 30B-A3B is a very different model, and this article isn't intended as a benchmark comparison between the two.

My objective was more practical:

Could I build a completely local coding setup that could serve the same general role in my workflow: understand substantial context, work through infrastructure and application code, integrate with an agent such as Cline, and generate code quickly enough that waiting on the local model didn't dominate the development experience?

That led to a more specific technical problem.

I already had a UD-IQ3_XXS quant of Qwen3-Coder 30B-A3B running entirely in VRAM at approximately:

82.9 tok/s

It was fast.

But I wanted to use the higher-quality Q4_K_M quant.

On my previous Q4 partial-offload configuration, generation performance fell to roughly:

20.5 tok/s

So the experiment became:

Can I keep Q4_K_M, use my 64 GB of fast system RAM intelligently for the MoE weights that don't fit in VRAM, and recover the responsiveness I want from a day-to-day local coding assistant?

Eventually, the answer on my machine was yes.

With the final configuration I measured repeated warm-cache results of approximately 100 tok/s.

But getting there turned out to be considerably more interesting than simply enabling an expert cache.

At smaller cache sizes, performance actually got worse.

Exact test system

Because this experiment depends on GPU performance, host-memory performance, and moving MoE expert weights between system RAM and GPU VRAM, I think the complete host configuration is important.

All results in this article were measured on this machine.

Hardware

  • CPU: Intel Core i9-14900K
  • CPU configuration: 24 cores / 32 logical processors
  • Motherboard: ASUS ROG STRIX Z790-E GAMING WIFI
  • GPU: NVIDIA GeForce RTX 4070 Ti SUPER
  • VRAM: 16 GB
  • System RAM: 64 GB DDR5-6000
  • Memory configuration: 2 × 32 GB Kingston KF560C36-32
  • Configured memory speed: 6000 MT/s
  • System SSD: Samsung 990 PRO 2 TB NVMe
  • Model/Data SSD: Samsung 990 PRO 4 TB NVMe
  • Total SSD capacity: 6 TB NVMe

Operating environment

  • Operating system: Windows 11 Home 25H2, 64-bit
  • Windows build: 26300
  • NVIDIA Windows driver: 32.0.16.1088
  • llama.cpp CUDA build: CUDA 13.5
  • Context used for these tests: 8192 tokens

Exact inference engine

The final working runtime is official upstream ggml-org/llama.cpp.

It is not a third-party fork.

The exact build used for the results in this article is:

  • llama.cpp release: b13007
  • Commit: 8f50b1db9a53059029f35bb6ae0084c01cee7b0b
  • Package: official Windows x64 CUDA 13.5 binary

I have kept this particular build installed as my known-good runtime instead of automatically replacing it whenever llama.cpp releases something newer.

That's intentional.

llama.cpp develops quickly, and I want these measurements associated with the exact runtime that produced them.

Exact model used

I used the Unsloth GGUF release of Qwen3-Coder-30B-A3B-Instruct, specifically:

Qwen3-Coder-30B-A3B-Instruct-Q4_K_M.gguf

Model repository:

https://huggingface.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF

Exact Q4_K_M file:

https://huggingface.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF/blob/main/Qwen3-Coder-30B-A3B-Instruct-Q4_K_M.gguf

The Q4_K_M GGUF is approximately 18.6 GB.

That exact model matters. These measurements are for this particular GGUF and quantization. I would not assume another conversion or quantization will produce identical results.

Why MoE makes this possible

Qwen3-Coder 30B-A3B is a Mixture-of-Experts model.

That changes the VRAM problem.

Instead of thinking only in terms of whether the complete model fits in GPU memory, llama.cpp can keep MoE expert weights in system RAM while using some GPU VRAM as a dynamic cache for frequently used experts.

Conceptually, my final configuration looks like this:

64 GB DDR5-6000 system RAM

→ CPU-resident MoE expert pool

→ pinned host-memory path

PCIe

→ required expert transfers

RTX 4070 Ti SUPER 16 GB

→ GPU-resident model components

→ CUDA/runtime buffers

→ context/KV requirements

→ 10 GiB dynamic MoE expert cache

That means the complete Q4_K_M model does not need to reside in VRAM simultaneously.

I initially went down the wrong path

I originally experimented with a separate MoE-cache fork and tried to build it natively on Windows.

That turned into a long fight with Windows compilation and linking.

I explored both MSVC and LLVM/Clang approaches, and both paths eventually ran into unresolved GGML DLL-symbol problems.

At that point I stopped trying to force the experimental build.

Then came the breakthrough:

The functionality I actually needed was already available in official upstream llama.cpp, including an official Windows x64 CUDA build.

That simplified the project dramatically.

I no longer needed:

  • Linux
  • WSL
  • a custom patched executable
  • a locally maintained llama.cpp fork
  • modifications to my existing LM Studio installation

I switched to the official Windows CUDA 13.5 build of llama.cpp b13007 and restarted the performance testing from there.

First important discovery: --load-mode none

My early expert-cache tests were not encouraging.

Using the normal mmap-backed loading path and a 4 GiB expert cache, I measured:

  • 27.02 tok/s cold
  • 29.75 tok/s warm

That was worse than simply running without an expert cache.

llama.cpp also printed a useful warning suggesting --load-mode none when CPU tensor overrides were being used with mmap enabled.

I tested it.

With --load-mode none, the CPU-resident expert path can use pinned host memory instead of relying on the default mmap-backed path.

On this machine that mattered.

With expert caching completely disabled but --load-mode none enabled, Q4_K_M reached:

36.80 tok/s

That was already almost 80% faster than my old ~20.5 tok/s Q4 result.

But it was still far below the responsiveness I was looking for.

Then I started increasing the expert cache.

Performance over time: the cache-size curve

This became the most interesting part of the experiment.

I initially expected performance to scale somewhat gradually as I increased cache size.

That is not what happened.

Here is the progression I actually measured:

Configuration Decode performance
Previous conventional Q4 setup ~20.5 tok/s
Pinned Q4, expert cache disabled 36.80 tok/s
2 GiB expert cache ~21.3 tok/s
4 GiB expert cache ~33.6 tok/s
6 GiB expert cache, warm 52.09 tok/s
7 GiB expert cache, warm 61.53 tok/s
8 GiB expert cache, warm 73.44 tok/s
Fully GPU-resident UD-IQ3_XXS reference 82.9 tok/s
10 GiB expert cache, cold 89.32 tok/s
10 GiB expert cache, warm #1 100.65 tok/s
10 GiB expert cache, warm #2 100.31 tok/s

That progression completely changed my view of the technique.

If I had stopped after testing a 2 GiB cache, I probably would have concluded:

Dynamic MoE caching makes this model slower.

And based on that measurement alone, that conclusion would have been reasonable.

But it would also have been wrong about the larger-cache configuration.

The same Q4_K_M model went from approximately 21 tok/s at 2 GiB to approximately 100 tok/s warm at 10 GiB.

My interpretation is that, for this model and workload, the smaller caches were not large enough to overcome the cost of expert turnover and host-to-device transfers.

Once enough useful expert data could remain resident in VRAM, performance changed dramatically.

That is an interpretation of my measurements, not a claim that every MoE model will demonstrate the same threshold.

The final llama.cpp configuration

This is the configuration I eventually settled on:

-cmoe -ngl all --moe-cache-mib 10240 --moe-cache-cpu-share 0 --load-mode none -c 8192 --jinja --port 1235

The complete command is essentially:

llama-server.exe -m Qwen3-Coder-30B-A3B-Instruct-Q4_K_M.gguf -cmoe -ngl all --moe-cache-mib 10240 --moe-cache-cpu-share 0 --load-mode none -c 8192 --jinja --port 1235

What those options are doing

-cmoe

Keeps the MoE expert weights in system RAM.

-ngl all

Allows the GPU-eligible portions of the model to reside on the GPU.

--moe-cache-mib 10240

Creates a 10 GiB dynamic GPU cache for the CPU-resident MoE experts.

--moe-cache-cpu-share 0

I disabled CPU computation of cache misses in this configuration.

--load-mode none

This placed the CPU-resident expert pool on the pinned-host-memory path that worked much better in my testing.

-c 8192

Sets the context size used for these measurements.

--jinja

Enables Jinja chat-template processing.

--port 1235

Runs the local server separately from my other local inference services.

Why I stopped at 10 GiB

At the 10 GiB expert-cache setting, nvidia-smi reported:

  • 14,615 MiB VRAM used
  • 1,447 MiB VRAM free
  • 16,376 MiB total

At that point I stopped increasing the cache.

The objective had already been achieved, and I preferred keeping roughly 1.4 GiB of VRAM headroom rather than pushing the GPU to its absolute limit.

So 10 GiB should not be interpreted as a mathematically optimal universal value.

It is the largest setting I tested and accepted for continued use on this particular machine.

The synthetic benchmark crossed my original target

My original reference was the fully GPU-resident UD-IQ3_XXS model at:

82.9 tok/s

The optimized Q4_K_M configuration produced:

  • 89.32 tok/s cold
  • 100.65 tok/s warm
  • 100.31 tok/s on another warm run

The two repeated warm results differ by only:

0.34 tok/s

For that particular repeated workload, ~100 tok/s was reproducible.

That meant Q4_K_M did not merely approach my original IQ3 reference.

It exceeded it.

But there is an important caveat.

Repeatedly sending the same benchmark workload is not equivalent to using the model as a real coding agent.

So I moved on to the real test.

Connecting the setup to my actual coding workflow

The reason I cared about this project in the first place was coding.

I frequently work with Terraform, PowerShell, and C#, and my objective was to make the local model useful in the same general category of workflow where I normally value a fast coding assistant.

Again, I am not claiming Qwen3-Coder and Microsoft MAI Code 2 Flash are equivalent models.

They aren't.

The practical question was whether I could make the local model sufficiently responsive to use it naturally for similar development tasks.

For that test, I connected the optimized llama.cpp server to Cline in Visual Studio Code.

My Cline configuration

The optimized llama.cpp server runs locally on:

http://127.0.0.1:1235

The OpenAI-compatible API is exposed at:

http://127.0.0.1:1235/v1

My Cline configuration is:

  • Client: Cline in Visual Studio Code
  • API Provider: OpenAI Compatible
  • Base URL: http://127.0.0.1:1235/v1
  • API key: a nonempty local placeholder
  • Model ID: the Q4_K_M GGUF identifier advertised by llama.cpp's /v1/models endpoint
  • Context window: 8192

That produces this inference path:

Visual Studio Code

→ Cline

→ OpenAI-compatible HTTP

→ official Windows llama.cpp b13007

→ Unsloth Qwen3-Coder 30B-A3B Q4_K_M

→ 64 GB DDR5-6000 + RTX 4070 Ti SUPER 16 GB

My existing LM Studio installation remains intact.

LM Studio continues to store the GGUF inside my model library, but LM Studio is not in the optimized inference path.

Cline communicates directly with llama-server.exe.

That let me keep the existing LM Studio environment while independently running the optimized expert-cache configuration.

Real Cline performance

This was the benchmark I cared about most.

A fresh Cline task began with a 3,106-token prompt.

The server processed that initial prompt at:

388.37 prompt tok/s

The first cold generation ran at:

52.13 tok/s

I think that number is worth emphasizing.

If I reported only the ~100 tok/s warm result, I would be leaving out an important part of how the system actually behaves.

A cold cache is slower.

As the Cline session continued and the expert cache warmed, I recorded generation speeds including:

  • 99.92 tok/s
  • 94.14 tok/s
  • 83.36 tok/s on an 801-token coding response
  • 85.41 tok/s
  • 83.54 tok/s
  • 81.13 tok/s
  • 79.59 tok/s
  • 94.70 tok/s
  • 101.86 tok/s

Prompt ingestion during agent/tool interactions was also strong.

One 1,301-token prompt segment processed at:

571.08 tok/s

The measurement I personally find most useful is the 801-token coding response at 83.36 tok/s.

That is essentially equal to my original:

82.9 tok/s UD-IQ3_XXS

reference, except the model is now Q4_K_M.

For my intended use case, that's the result that made the experiment feel successful.

So what should the performance claim actually be?

Not:

Qwen3-Coder Q4_K_M always runs at 100 tok/s on an RTX 4070 Ti SUPER.

That is not what I measured.

A more accurate description is:

On my RTX 4070 Ti SUPER, Qwen3-Coder 30B Q4_K_M reached approximately 100 tok/s in repeated warm-cache benchmarks and roughly 80–102 tok/s during warm portions of a real Cline coding session. The initial cold Cline response was substantially slower at 52.13 tok/s.

That is less sensational.

It is also a more accurate reflection of the experience.

What surprised me most

The headline result is nice.

But the result I think is actually most useful is this progression:

2 GiB cache → ~21 tok/s

4 GiB → ~34 tok/s

6 GiB → ~52 tok/s

7 GiB → ~62 tok/s

8 GiB → ~73 tok/s

10 GiB → ~100 tok/s warm

The answer to:

“Does dynamic MoE expert caching help?”

changed completely depending on how much VRAM I gave the cache.

A small cache performed worse than no cache.

A sufficiently large one transformed the same model.

The second important lesson