This is the full-precisionsafetensorsmaster for my Gemma 4 12B coding fine-tune — the same model many of you have been running as GGUF, now in its original weights. 🧠💻 A focused fine-tune of Gemma 4 12B on verifiable Python coding data: it reasons in the open (edge cases, complexity, approach) and then writes a clean, runnable solution.
model.safetensors, bf16). Use it to:transformers (needs a recent build with gemma4_unified support).🏃 Just want to run it? You don't need this repo — grab a ready-made quant from the GGUF repo → (runs in ~4.5 GB of VRAM / unified memory in LM Studio, Ollama, llama.cpp, Jan…). This master is for builders. 💚
max_position_embeddings = 262144 (256K) — the
well-known upstream Gemma 4 metadata bug (config.json once said 131072) is already fixed here, so anything you
quantize/convert from these weights inherits the full 256K. 💚 Thanks to the community member who spotted it!1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4repo = "yuxinlu1/gemma-4-12B-coder-fable5-composer2.5-v1"
5tok = AutoTokenizer.from_pretrained(repo)
6model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype=torch.bfloat16, device_map="auto")
7
8msgs = [{"role": "user", "content": "Write a Python function to check if a string is a valid IPv4 address."}]
9inputs = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt").to(model.device)
10out = model.generate(inputs, max_new_tokens=1024)
11print(tok.decode(out[0][inputs.shape[-1]:], skip_special_tokens=True))🧠 Thinking mode: it thinks in Gemma's native thought channel before answering (keepenable_thinking=true, the default chat template handles it). Recommended sampling:temp 1.0, top_p 0.95, top_k 64; for coding you can also go greedy (temp 0) for more deterministic solutions. Needs a recenttransformersthat knows thegemma4_unifiedarchitecture.
| Quant | Size | Vibe |
|---|---|---|
| 🟢 Q2_K | 4.5 GB | tiniest — runs almost anywhere |
| 🟡 Q3_K_M | 5.7 GB | great for 8 GB VRAM |
| 🔵 Q4_K_M | 6.87 GB | the sweet spot 👌 (recommended) |
| 🟣 Q6_K | 9.11 GB | near-lossless |
| ⚪ Q8_0 | 11.8 GB | basically full quality |
⚠️ GGUF needs a recent llama.cpp — this is thegemma4_unifiedarchitecture, older builds won't load it.
MTP/ folder. It's the
stock Gemma 4 drafter, so it pairs with any Gemma 4 12B quant — including these coder quants — for
lossless speculative decoding (byte-for-byte identical output, just faster). Because it's trained on base Gemma 4,
the hit-rate on this fine-tune is a bit lower than on vanilla Gemma 4, but it's free and has no downside. Add three
flags (--model-draft, --spec-type draft-mtp, --n-gpu-layers-draft); see the
main repo for the full command. 🏎️google/gemma-4-12B-it.