Gemma4 NPU2 conversions predate Google's July 2026 template fixes — porting notes for a refresh (2 parser shims)
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 152
- Avg merge
- 4h 14m
- Merged PRs (30d)
- 11
Description
Summary
Google shipped a canonical chat-template fix wave for Gemma 4 in July (template header: "Fixed tool-calling loops, turn closures, and thinking content-ordering. Published 2026-07-09"; plus a 2026-07-20 response_template addition to tokenizer_config.json). The FastFlowLM/Gemma4-E4B-IT-NPU2 conversion (last modified 2026-04-28) still carries the April template, which has the tool-call-swallowing x-regex (content captured before tool_calls) and the O(n) continuation scan.
We grafted Google's July files into the local model folder and verified they work through flm serve — but two small adjustments were needed for FLM's parsers, which you'd presumably want in the refreshed conversion. Sharing both so the update is a drop-in.
Porting note 1 — Jinja: adjacent string literals
Google's July chat_template.jinja uses Python-style adjacent string literals inside a raise_exception(...) call (one message split across three quoted lines). FLM's template engine rejects it:
Failed to load model: Expected closing parenthesis in call args at row 259, column 29
Fix: join the three literals into a single one-line string. Semantics unchanged; that's the only spot in the file.
Porting note 2 — tokenizer_config: bos/eos_token_id required
Google's July tokenizer_config.json drops bos_token_id and eos_token_id. FLM reads them and fails:
Failed to load model: [json.exception.type_error.302] type must be number, but is null
Fix: carry them over from the previous config (bos_token_id: 2, eos_token_id: [1, 106]).
Verification (with both shims applied)
- FLM v0.9.45, Windows 11, Ryzen AI 5 340 (XDNA2), driver 32.0.203.314
- Plain chat: normal.
- Tool calling:
POST /v1/chat/completionswith atoolsarray returnsfinish_reason: "tool_calls", a well-formedtool_callsentry with JSONarguments, andcontent: null— no tool-call text bleeding into content, which the Aprilx-regexordering was prone to.
Ask
A refreshed Gemma4-E4B-IT-NPU2 (and siblings) built against Google's July files, with the two shims above. Weights don't appear to have changed in the July wave, so this may be a metadata-only republish. Happy to test.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Gemma4-E4B-IT-NPU2 model folder and its chat_template.jinja and tokenizer_config.json files, then compare them with Google's July 2026 versions. Apply the two parser-compatibility shims while preserving the updated template behavior, and verify with flm serve using plain chat and a /v1/chat/completions request containing tools.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, json
- Domain
- ai, machine-learning
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100