gemma4-comfyui-mcp
Local, offline LLMs fine-tuned to be ComfyUI experts that drive the full
comfyui-mcp tool surface — 178
tools (113 MCP server tools + 65 live-canvas panel_* tools) — in Gemma 4's
native tool-call format. These are the free, no-API-key backends for the
comfyui-mcp Agent Panel: pick Ollama (local) in the panel and the agent
edits your live graph, generates images/video/audio, manages models and
custom nodes, and runs your workflows — entirely on your GPU.
Quickstart (Ollama, recommended):
ollama pull artokun/gemma4-comfyui-mcp:e4b # default — ~3.5 GB VRAM at q4
# also: :e2b (~2 GB VRAM) :12b (~8 GB VRAM)
Size ladder
Pick by VRAM budget. Every rung is the same data, same recipe — only the base size changes.
| Tag | Rung | Folder | Download (q4) | VRAM (q4) | Status |
|---|---|---|---|---|---|
:e2b | Gemma 4 E2B (Heretic-ara) | e2b/ | 3.4 GB | ~2 GB | ✅ available |
:e4b | Gemma 4 E4B (Heretic) | e4b/ | 5.3 GB | ~3.5 GB | ✅ available — the default |
:12b | Gemma 4 12B (Heretic) | 12b/ | 7.4 GB | ~8 GB | ✅ available |
:26b-a4b | Gemma 4 26B-A4B, NVFP4 (nvidia) | — | — | — | ⏸ parked (QLoRA+MoE routing interact poorly) |
Each folder ships the GGUF quant(s), the LoRA adapter (r=32 — apply to the base or re-export any quant yourself), the trained chat template, and tokenizer/trainer configs.
What makes these different
A stock model meets comfyui-mcp's ~200-schema catalog cold and burns its context (and your patience) learning it. These models were trained on the tool suite itself:
- Data: 1,055 server-verified tool-use trajectories (e4b/e2b; the earlier
12b rung trained on the initial 772) — synthesized TOUCAN-style against a
live ComfyUI + comfyui-mcp server: task synthesis → real trajectory
generation → server-verified filtering (every outcome checked against
the actual server state, never the model's claims). Grounded in real pack
workflows (krea2 / ideogram / qwen-edit / wan / ltxv) and skills. Fully
open:
artokun/comfyui-mcp-trajectories. - Trimmed-context tool-menu training: each example is rendered with the tools it actually calls plus random distractors (≤24 of the 178), in random order — the model learns to navigate a menu, not memorize positions, and generalizes to the full surface at inference (the xLAM/Toucan/Hermes recipe).
- Teachers: open-weight only. No Anthropic/OpenAI/Google outputs anywhere in the training data (ToS), enforced by a blocklist in the dataset assembly.
- Bases: the Heretic-abliterated Gemma 4 family (Optuna-optimized directional ablation — cleanest abliteration lineage), chosen by a server-verified bake-off over other abliterated variants.
- Recipe: QLoRA r=32 / α=32 on q/k/v/o + MLP projections, 2 epochs, cosine LR 2e-4, seq len 12–16K, loss masked to assistant turns.
Validation
Every rung is validated in llama-server --jinja before release: native
tool-call emission (finish_reason=tool_calls), correct tool selection,
well-formed JSON arguments, and dimension/parameter extraction from
natural-language requests. Final train loss: 0.022 (e4b), 0.021 (e2b);
the 12b rung additionally passed live end-to-end panel runs.
Known behavior: :e2b reasons verbosely before calling — give it
max_tokens ≥ 512 or the call gets truncated mid-thought. The current :e2b
tag is the v2 retrain (see Arena results below).
Usage
ComfyUI Agent Panel (the intended home): install
comfyui-mcp, pull a tag, pick
Ollama (local) in the panel's backend picker. :e4b is the built-in
default — zero further config.
Plain Ollama / any OpenAI-compatible client:
ollama pull artokun/gemma4-comfyui-mcp:e4b
# tags ship num_ctx 65536 + temperature 0 + the ComfyUI agent system prompt
llama.cpp:
llama-server -m e4b/model-q4_k_m.gguf --jinja -c 16384
From the adapter (transformers + PEFT): load the base
(AutoModelForImageTextToText — Gemma 4 is the unified multimodal arch),
attach <size>/adapter_model.safetensors, merge_and_unload(). A clean
re-export path (sharded 16-bit + GGUF) ships in
finetune/train/reexport.py.
Repo layout
12b/ e4b/ e2b/ model-q4_k_m.gguf (+q5/q8 where built), LoRA adapter,
chat_template.jinja, tokenizer/trainer configs
finetune/ the COMPLETE pipeline: datagen (task synth + tool-surface
export), train (QLoRA + dataset prep + re-export),
arena (server-verified eval harness), package (Modelfile)
finetune/data/ train/val JSONL (1,055 trajectories) + the 178-tool surface
Limits
Tool calling is the trained strength. Vision is limited at these sizes — the
agent generates but can't visually critique its own outputs — and hard
multi-stage graph composition (multi-output pipelines built in one shot)
remains frontier-model territory (see the measured arena table below; the
harness is in finetune/arena/).
Arena results (measured, server-verified)
Scores on the comfyui-mcp LLM Arena — a 10-scenario ladder (health → generation → break/fix → multi-stage pipelines) where every result is verified against a live ComfyUI server, not the model's claims. Best of 3 full runs per model, RTX 4090, PASS=2/PARTIAL=1/FAIL=0:
| Model | Score | vs. stock base |
|---|---|---|
:e4b | 14/20 (13–14) — best local model we've tested | stock gemma4:e4b: 12/20 |
:12b | 13/20 (12–13) | stock 12b unbenchmarked |
:e2b v2 | 10/20 (7–10) | stock gemma4:e2b: 8/20 |
Every rung beats its stock base. For calibration, the same ladder scores frontier hosted models 19–20/20 and the best small hosted models 17–19/20 — these are honest local-tier numbers, not marketing.
e2b v2 note: the initial e2b release regressed below stock (4/20) — the
smallest rung couldn't bridge between the direct-call training format and the
deployed 6-tool router envelope, dropping call_tool's name field. v2
retrains on a dual-view mix (direct calls + the exact runtime router format +
fresh server-verified arena trajectories) — zero malformed envelopes across
all verdict runs. Details: comfyui-mcp#183.
Credits & license
Bases by p-e-w (Heretic) and coder3101; Gemma 4 by Google DeepMind (Gemma license). Fine-tune, data, and pipeline by @artokun — part of the comfyui-mcp project.