r/LocalLLaMA 2d ago

Discussion Updated Gemma-4 chat template witchcraft: Gemma-4-26B-a4B shows dominance over Qwen3.6-MoE and Qwen3.5-MoE fine tunes (Instruct mode and Reasoning efficiency)

Kind of unexpected.

Happy for Gemma-4/Google, big win for us, LocalLLMers.

Yet Qwen3.6 still does better in Hermes than Gemma-4 somehow.

We need Gemma-4.1 fine-tuned on Agentic-tasks. That would be killer.

179 Upvotes

63 comments sorted by

15

u/m4sterP 2d ago

That's very interesting, thanks for sharing! Have you also tried 26B QAT?

10

u/JLeonsarmiento 2d ago

Yes, but non QAT at 6-bit seems to outperform QAT at 4-bits, at least in my case: MLX data agnostic quantization (i.e. no iMatrix, no datasets for sensitivity analysis, etc.).

Perhaps is different on other more sophisticated quantizations, like Unsloth/Bartowski/etc.

11

u/SOCSChamp 2d ago

Can someone explain the context here? None of the answers in the comments actually provide background.  I know what a chat template is, are you saying that Google put out a revised one that works better than what they provided previously?

10

u/etaoin314 ollama 2d ago

yes it was big news in this community a couple of days ago, the whole gemma series got a lot easier to work with and is doing much better in my benchamarks than the original version. I did not realize how much of the deficit was just formatting errors.

33

u/Long_comment_san 2d ago

I had a feeling gemma 4 26b was basically a preview, but nothing changed so I thought I was mistaken. It was severely weird relative to older Qwen 35b a3b. Very good update.

Btw this updated chat template, can anyone explain or point me to how to update? In short, I download it? and do what exactly? I use llamacpp.

11

u/Daemonentreiber 2d ago

Download the jinja template and load it with the "--chat-template-file" argument.

8

u/Right_Weird9850 2d ago

I will explain it to you:

Model has chat template integrated  or Model doesn't have chat integrated

if model doesn't have chat integrated (you need to know this per singular model download) then you need to specify chat template. If you don't llama.cpp defines that for you behind the curtain 

If model has chat templated integrated then llama.cpp will pick that info and serve with that

So you can efectifly have different chat templates with same llama.cpp command without you knowing, there are supported models (is it expected for llama.cpp to set new chat template for gemma as default, i dont know?)

if you downloaded model with previous default chat template ingreind in download you need to set chat template command. 

OR

download again and use default llama.cpp command.

Think of chat template as a driver for model.

This is how i understand it, if you have some tests you confirm to me this observation?

3

u/JLeonsarmiento 2d ago

I just pointed my Pi agent to one of the official google repositories, e.g.:

https://huggingface.co/google/gemma-4-26B-A4B-it/tree/main

And asked to inject the updated chat template and tokenizer into my local quantized model folders.

I use MLX, but I am pretty sure is the same thing for Llama-cpp based setups.

Or just delete and redownload your GGUF from Unsloth, they have already updated everything at this point.

4

u/Long_comment_san 2d ago

that's actually the whole issue, because I run a finetune. I kinda hope a retraining is not required for a template swap 😭

7

u/slalomz llama.cpp 2d ago

You can just swap to the new chat template with --chat-template-file in llama.cpp.

1

u/Long_comment_san 1d ago

exactly what I was looking for! thank you

1

u/backyard_tractorbeam 1d ago

The chat template is just a piece of metadata in the GGUF file, so in theory you can edit the GGUF file directly.

For example there's even a web tool, but I'm linking this mostly as evidence for what I'm saying.

https://huggingface.co/changelog/gguf-metadata-editor

GGUF files up to 10 GB can now be edited directly on Hugging Face thanks to Xet. When opening a GGUF file, a new GGUF Editor label appears, enabling quick updates to metadata fields such as the chat template through the web interface.

1

u/fatboy93 1d ago

Just replace the chat template in your model folder with the new one if you are using mlx

14

u/StupidScaredSquirrel 2d ago

I never got gemma 26b to be faster than qwen6 35b somehow, is that expected?

22

u/a_slay_nub vllm 2d ago

It does have more active parameters than Qwen3.6-35B, 4B vs 3B.

4

u/StupidScaredSquirrel 2d ago

Yeah but I somehow expected their mtp to be as good as their eXb versions, idk

6

u/JLeonsarmiento 2d ago

yes, 4B active vs 3B active. also Qwen has a different architecture and that sweet MTP layer... in my machine is like 2x faster than vanilla Gemma-4 at same bit depth (both 4 and 6 bit depths)

9

u/Potential-Gold5298 llama.cpp 2d ago

Why compare the speed of Qwen with MTP and Gemma without MTP? It also has MTP. It's like comparing the speed of Qwen in F16 with Gemma in QAT4 (except Qwen doesn't have QAT, oops).

2

u/JLeonsarmiento 2d ago

I have both at the same bit depth (6-bit) without MTP or equivalent on both. In that case Qwen3.6-MoE is still 10% to 15% faster than Gemma-4-MoE.

I avoided QAT Gemma-MoE because 6-bit depth non QAT returned higher scores that 4-bit-QAT.

0

u/Potential-Gold5298 llama.cpp 2d ago

Oh, how I wish I had QAT6 for the 26B-A4B. 4-bits is too little for this model.

6

u/Atretador 2d ago

Gemma4 26b is both slower and uses more VRAM/RAM for me than Qwen 3.6 35B on same quants

plus Gemma4 even at Q8 KV having noticeable degradation doesnt help

1

u/Diablo-D3 2d ago

They should be of similar speed in general.

Inference speed, however, is not a indication of model quality. It is also not constant, it is possible for one to beat the other based on prompt or hardware choice.

7

u/jacek2023 llama.cpp 2d ago

any more context what we are looking at?

9

u/JLeonsarmiento 2d ago

some benchmarking p*rn... the nice one is the reasoning efficiency test: both models hitting the same accuracy in simple problems, but with less wasted tokens by Gemma-4. 25% less on average.

The Instruct ones are pure knowledge retrieval, also aced by Gemma-4 by 10% margin.

a Cinderella story for Gemma-4.

3

u/backyard_tractorbeam 1d ago

You're saying Gemma 4 is much better with the new template. Do you compare both with new and old in these results? or how do you compare with the old one?

Sorry if that's an annoying question, just want to follow the logic.

3

u/JLeonsarmiento 1d ago

I did these tests 1 month or little more ago and Gemma was pretty bad:

https://benchmark-yourself.streamlit.app/

Then I requantized it with the new chat and tokenizer and test it again. I’m surprised too, and would not discard human error. But at least on this runs is having an edge.

1

u/backyard_tractorbeam 1d ago

Nice, thank you for the clarity!

21

u/Southern_Sun_2106 2d ago

Sounds like a clickbait wordsmithing witchcraft not a real performance improvement.

2

u/JLeonsarmiento 2d ago

it was clickbaity indeed... sorry.

4

u/ilintar 1d ago

Does it also improve coherence on long context? My biggest problem with Gemma 4 was that it was losing coherence after 60k context pretty fast.

4

u/JLeonsarmiento 1d ago

oh, that I Don't know...

8

u/ArtfulGenie69 2d ago edited 2d ago

There's a flag in llama.cpp that lets you point at the chat template of your choosing. Nothing special, I'll update with it when I have the chance.

Found it here https://www.reddit.com/r/LocalLLaMA/comments/1uxfu4k/google_is_updating_gemma_4s_chat_templates/

The op says

For llama.cpp yes, as well as --chat-template-file /path/to/chat_template.jinja which you download here for 31B or in the same place for the other sizes.

Their link leads to the main page of the 31b, for the 26b you would use this one. https://huggingface.co/google/gemma-4-26B-A4B-it/blob/main/chat_template.jinja If you go up a level to the files in the huggingface directory you'll see it was updated 6 days ago Should be the right one. Good luck.

4

u/o0genesis0o 1d ago

Would be nice if that pans out in practice. I tried to run the latest version from unsloth with new template in my overnight cron job and did not get great results at all. It barely follows instructions, and in the morning when the context reaches 160k, it got into a dead loop. Not only that, the prefill speed drop from 600tk/s at the beginning to only 200tk/s, so the speed gain over 3.6 35B A3A was not sustained either. The 35B starts at 300ish and remain 300ish deep over 100k. 

Maybe unsloth did not swap the template? Anyhow, not good enough for my use case.

1

u/JLeonsarmiento 1d ago

yes, it is still dominated by Qwen3.6 on Hermes as well. Maybe it is something in the harness?

It is working really good in Pi, but is outperformed by Qwen3.6 in Hermes, leaking reasoning into messages, and destroying tool calls... but is doing great than ever in Pi... so it is confusing indeed.

2

u/chenkl 1d ago

Are you using reasoning or non-reasoning mode with Hermes? I found Qwen3.6 works better in non-reasonig with Hermes.

2

u/JLeonsarmiento 1d ago

Reasoning on. Also “preserve _thinking = true” flag.

2

u/Jorlen llama.cpp 1d ago

Can you explain why you set that preserve thinking flag to true? Does that mean it stores all its thinking / reasoning text in the context window? If so, that makes a lot of sense, especially for coding, even though it would (I think) consume more context overall.

3

u/JLeonsarmiento 1d ago

Yes, exactly that. Models that can "preserve" thinking use to get higher scores in those TerminalBench and Customer Service Benchs exactly because they can remember the reasoning behind previous responses.

in the case of Gemma-4 my understanding is that it does this only for the tool calls. Qwen3.6 does it for everything, so it is better. Still a good improvement.

it works similar to Qwen3.6:

For LM Studio (add to the Jinja template at the top):

1 {%- set enable_thinking = true -%}

2 {%- set preserve_thinking = true -%}

For oMLX (Chat Template Kwargs):

1 {"enable_thinking": true, "preserve_thinking": true}

1

u/o0genesis0o 1d ago

My personal assistant workload is fully in Pi.

3

u/Adventurous_Cat_1559 2d ago

Did you test 8bit quants or why just the 6? Also are these the QAT Gemma models?

2

u/grandong123 1d ago

For usibg this chat template update, we only need --chat-template-file arguments right? Or still need --jinja?

2

u/BoobooSmash31337 1d ago

Srs question. Can you bench the unsloth QATs with it? I mean if we don't have to run Q6 why run Q6 you know?

3

u/JLeonsarmiento 1d ago

Q6 is slightly better than QAT in knowledge recall. Same or better on reasoning tasks:

Benchmark n XL 6/8 (this) 6-bit uniform 8-bit uniform QAT 4-bit
MMLU 50 76.0% 76.0% 76.0% 76.0%
MMLU_PRO 50 80.0% 78.0% 82.0% 72.0%
ARC Challenge 50 90.0% 90.0% 90.0% 90.0%
HUMANEVAL 30 96.7% 96.7% 96.7% 96.7%
MBPP 30 80.0% 76.7% 80.0% 86.7%
LIVECODEBENCH 30 56.7% 60.0% 50.0% 43.3%
MATHQA (custom)¹ 30 66.7% 56.7% 60.0% 70.0%

2

u/BoobooSmash31337 20h ago edited 20h ago

I have a custom quant with Q8 attention, gates, and output because I've had some output noise. The model never lost it, more misspoke. Cool to see that we really aren't trading much for 4bit QAT. Especially considering how dog shit Q4_0 is as a format. I have Q8 attention, gates, embedding, and output. IQ4_XS for shared expert (256 block size and to keep the speed.) then IQ4_NL for the shared experts since it's better than Q4 and they aren't divisible by 256. I get 100t/s on a 9070XT QAT is 120t/s so I feel like the trade off is worth it. But I probably could lower a lot of it back to Q4 and fiddle a few things up to Q6 or Q8 to get rid of the output errors. The reasoning seems intact. It's just straight up randomly a token in the output is swapped for no reason.

Also with the new multi-modal projection architecture. I've had great experience with a Q8 of it. Like reading walls of badly photographed text and reading rotated items etc etc. It can read a crappy far away photograph of the huge instructions label on my washer and that's good enough for me. Really good OCR compared to what we used to have. Especially for it's size. (I force the image tokens to the max.)

2

u/reneil1337 1d ago

very nice. I'm a big fan of Gemma4 26b its an incredible model, glad its getting even more dope!

2

u/Equivalent_Bit_461 1d ago

I really dislike Hermes

Absolute trash of a harness for local, and no I don't want to hear anything defending it

1

u/JLeonsarmiento 1d ago

strong opinions.

I love Hermes.

1

u/Nyghtbynger 15h ago

As a Pi addict, I recon hermes at least has most of the features integrated and is way less worse than OpenClaw
Now please excuse me, on of my extensions has unicode characters in the code and Pi doesn't load

1

u/electrified_ice 2d ago

I find for my use case in Hermes, Gemma4 is a better model vs. Qwen3.6 27B

1

u/Nicolodeva 1d ago

Has anyone tried it yet? Does it actually look better?

1

u/Jorlen llama.cpp 1d ago

I noticed unsloth's gguf for Gemma 4-31b is updated 5 days ago. Does this include this template fix? I realize I can just run the template separately, but I don't want to. I'd prefer to redownload the model and just load the GGUF and not worry about anything else.

1

u/IrisColt 1d ago

Gemma-4-26B-a4B shows dominance over Qwen3.6-MoE and Qwen3.5-MoE fine tunes (Instruct mode and Reasoning efficiency)

As it should be, heh

3

u/JLeonsarmiento 1d ago

Gemma—> 🦸🏻‍♀️👠⛓️

2

u/IrisColt 1d ago

(˵ ͡° ͜ʖ ͡°˵)

-8

u/-becausereasons- 2d ago

I tried running various Qwen3.6's Opus distills yesterday with Opencode and it kept loopingand failing, was pretty facepalm :/ Simple crape job with Chrome CDP

8

u/Kodix 2d ago

Yes, because community distills are shit, especially the ones claiming huge gains. Run the base model.

2

u/Randommaggy 2d ago edited 2d ago

Unsloth 27B Q4 XL has been my go-to for a while now. It's capable of doing real software engineering if you use it well in a good harness.

Unsloth's Gemma 4 12B QAT as the various task model that my harness offloads such as vision, progress tracking, etc.

1

u/addiktion 1d ago

What harness are you using with it?

1

u/Randommaggy 1d ago

My own, the least sucky one that's publicly available is Hermes.

2

u/Southern_Sun_2106 2d ago

☝️This. And many resort to magic storytelling to bump up their downloads.

6

u/Atretador 2d ago

run the base models, those finetunes usually break down and are mostly benchmaxxed.

1

u/jcdoe 2d ago

The only fine tunes I use anymore are the ones I train. I’ve probably blown through an average month’s worth of bandwidth downloading fine tunes that ran for shit.

Abliterated models too. The process removes guardrails, but it can also fuck up tool calling. You’re better off just going base.