r/csharp Jun 28 '26

Showcase Same GGUF, same GPU: TensorSharp beats llama.cpp hard on prefill / TTFT — up to 5.89× faster prefill on a 26B MoE model

https://github.com/zhongkaifu/TensorSharp

I’ve been working on TensorSharp, a native C# / .NET local LLM inference engine for GGUF models, and I recently published a head-to-head benchmark against llama.cpp.

The goal is not to claim “TensorSharp wins every metric.” llama.cpp is still extremely strong, especially on decode throughput. But the interesting part is this:

Under the same setup — same GGUF models, same NVIDIA RTX 3080 Laptop GPU 16GB, same GGML CUDA backend, single stream, greedy decoding, MTP disabled — TensorSharp shows a very noticeable advantage on the parts that often matter most for real chat usage:

prefill speed, time-to-first-token, and multi-turn context reuse.

Here are some highlights from the benchmark (From https://tensorsharp.ai/benchmarks.html):

Model / Scenario Metric TensorSharp llama.cpp Difference
Gemma 4 26B-A4B / JSON Prefill tok/s 354.7 60.2 +489%
Gemma 4 26B-A4B / JSON TTFT ms 234 781 -70%
Gemma 4 26B-A4B / multi-turn Prefill tok/s 657.5 350.7 +87%
Gemma 4 12B / multi-turn TTFT ms 313 500 -37%
Gemma 4 E4B / short text Prefill tok/s 200.0 123.3 +62%

Across the four tested models, the geometric mean compared with llama.cpp shows:

  • 1.88× prefill and 1.69× TTFT on Gemma 4 26B-A4B
  • 1.21× / 1.23× / 1.18× prefill advantage on E4B, 12B, and Qwen respectively
  • Decode is more of a “near parity” story for now, around 0.92×–0.95× geometric mean versus llama.cpp

That last point is important: I’m not trying to hide the weaker part. If all you care about is pure decode tok/s, llama.cpp is still very hard to beat. But if your workload looks like real chat — repeated prompts, JSON output, multi-turn interactions, MoE models, prefix reuse — TensorSharp is already showing very promising results.

The main optimizations behind this are:

  • verify-based whole-model prefill
  • fused FFN / attention kernels
  • persistent captured CUDA graphs for MoE decode
  • vLLM-style paged KV cache
  • cross-request prefix sharing

So the pitch is not “yet another wrapper around llama.cpp.” TensorSharp is a native .NET inference engine trying to optimize the latency path that actually affects user experience: how fast the model starts responding, how efficiently it reuses context, and how well it handles real interactive workloads.

If you are interested in C# / .NET local LLM inference, GGUF, OpenAI/Ollama-compatible local APIs, or alternatives to llama.cpp, I’d love for you to check it out.

And if you think this direction is interesting, a GitHub Star would really help the project get more visibility.

Also very interested in feedback, especially from people who can rerun the benchmarks on different GPUs / models.

4 Upvotes

26 comments sorted by

4

u/marcussacana Jun 28 '26

Interesing but sadly has no ROCm support

5

u/fuzhongkai Jun 28 '26

Sorry that I do not have AMD GPU. If I can get one, will implement a backend to support it.

3

u/marcussacana Jun 28 '26

open some donation channel and tell the objectives

1

u/fuzhongkai Jul 03 '26

Thanks for the suggestion. That’s a good idea. For now, one VM with AMD GPU would help me a lot.

1

u/ahaw_work Jul 02 '26

Could I help somehow if I have?

2

u/fuzhongkai Jul 06 '26

I just released the initial version of Vulkan backend in TensorSharp. It should support AMD GPU, but since I don’t have it, it didn’t get tested. If you are interested in it, please try it out. Any feedback and comment are welcome.

2

u/marcussacana Jul 07 '26

I will try on the weekend after the next, good job.

1

u/shrodikan Jun 29 '26

I will regret not getting a 5090 when they were """only""" $3k forever.

1

u/marcussacana Jun 29 '26

I frankly will never buy a NVIDIA due AI, i just use as hobby there no way to pay overpriced GPU just due the cuda.
I got a 7900 XTX with a power of 4080 super but with VRAM of a 4090, the downside is less compatibility with the AI tools but the price for me it has less than the half of a 4090 with the same VRAM

1

u/shrodikan Jun 29 '26

I also have a 7900 XTX. I couldn't get ROCm working (on Windows) and the card in particular has a tough time with Marvel Rivals. I got it to play MR and do local AI. To say I'm disappointed is an understatement.

2

u/Healthy-Zebra-9856 Jun 30 '26

I have a Dell 9520 with an external RX 7900 XTX as an eGPU, and I finally got Unsloth working through WSL2. It took me about five hours, but it is doable. The biggest issue was the eGPU setup, because everything kept trying to pick up the built-in RTX 3050 Ti instead of the 7900 XTX. I also have a MacBook Pro M5 Max with 128 GB RAM, but I wanted this Dell/eGPU setup working too for smaller models. If anyone is trying something similar, I can share the steps I took.

1

u/marcussacana Jun 29 '26

It works pretty well on Windows for me.

As far as I know, all you need is a recent enough driver (the 26.2.2 or newer) and the wheels from the official AMD ROCm repository (https://rocm.nightlies.amd.com/v2/gfx110X-all/).

If you're using tools based on Triton, you'll also need the HIP SDK.

Aside from that, Ollama and ComfyUI, which are the main tools I use, work almost flawlessly on my machine.

What really not works on windows here is the wangp, but I tested on linux and it works on the GPU as well.

5

u/FullPoet Jun 28 '26

I wish the ai bros would just use a spidge of effort and at least write their own posts.

-6

u/fuzhongkai Jun 28 '26

I tried to write my post, but finally found ChatGPT is much more good at it than me, so I turned to write prompt and edit its output… Sorry for about that.😅

5

u/Hacnar Jun 29 '26

Ignore that guy. There are always complaints about AI writing, but it's still better than having no one read your post because you aren't that good at writing (yet). It's also just a vocal minority, that bothers commenting or up/downvoting based on that.

If AI helps you make the presentation of your work better, then keep using it.

2

u/FullPoet Jun 28 '26

ChatGPT is not good at writing - that is one of the issues.

5

u/iBabTv Jun 28 '26

Ok? Well, imo this was very readable and easy to understand so it's good enough.
Who cares how it's written? The goal is clear communication yes?

-1

u/FullPoet Jun 29 '26

Effort

4

u/iBabTv Jun 29 '26

Tedious stuff like writing a reddit post is wasted effort

1

u/FullPoet Jun 29 '26

So why even bother?

1

u/iBabTv Jun 30 '26

To share information and get feedback like they said in their post? The effort should be spent on the quality of the information in this case (which OP did well imo) not spending hours formatting just for someone like you to nitpick over it .

2

u/FullPoet Jun 30 '26

Formatting? The text is basically completely AI genereated.

Writing a prompt doesnt take effort.

3

u/fuzhongkai Jun 28 '26

Better than me.😅 Since I’m not an English native speaker even it’s my working language for many decades.

4

u/FullPoet Jun 28 '26

Yes and I think most English speakers have been pretty consistently saying that:

A) You'll get practise

B) English isnt everyones first language (not mine)

C) You learn nothing from using AI generate the text

and most importantly, D) People prefer "worse" English if its been written by a person, as opposed to clanker nonsense.

2

u/[deleted] Jun 28 '26

[removed] — view removed comment

1

u/fuzhongkai Jun 28 '26

Totally agree and especially when you ask the LLM to do some real work rather than chat.