Skip to content

Render selected chat templates without blanket turn rewrites - #698

Merged
jjang-ai merged 1 commit into
mainfrom
fix/gemma4-tool-turn-closure-20261031
Oct 31, 2026
Merged

jjang-ai merged 1 commit into
mainfrom
fix/gemma4-tool-turn-closure-20261031

Conversation

@jjang-ai

@jjang-ai jjang-ai commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

The tokenizer automatically rewrote selected templates so tool-result turns stayed open regardless of the following role. This can remove a valid close before a new user message and changes bundle/explicit-override templates without their owner's instruction.

Compile the selected template unchanged. Remove the blanket rewrite/cache, keep legacy-spelling diagnostics, and retain the deprecated identity repaired entry point for source compatibility. Bundle/export corrections remain explicit and separate: jjang-ai/jangq#45 synchronizes the canonical next-role closure correction into both template locations.

Five focused Swift Testing cases pass in an actual-source CPU control, after failing with seven issues against the original implementation. Coverage includes both old condition spellings, a rendered explicit tool-result/user boundary, unrelated formats, repeated calls and the tokenizer call site. Existing actual-template render controls: 192 renders, zero render errors; 128 Swift/Python byte comparisons agree. All32 corrected tool-result→user boundaries close; the original runtime rewrite leaves all32 open. These are render/source controls, not model-quality proof.

Draft pending the affected native Gemma proof and consumer pin. Prior unrelated model/kernel/cache/UI qualification is retained. No quantization, sampler, thinking-setting, GPU/cache policy, release tag or publication changes. The reported repeated reasoning markers are not declared causally resolved by these controls. Reference osaurus-ai/osaurus#3237. No screenshots or private evidence included.

CI at e9ccbbd08dce79f6625c800db61624d25069c76b, run 41170320304: both Linux SwiftPM and four Linux container builds pass; macOS/CUDA are queued. Lint requests formatting changes across 1,024 files; 31 hunks in Tokenizer.swift are outside this PR’s call-site/comment change, and the other three changed files are absent from its diff. No repository-wide reformat or gate change is included. CPU controls load no model and measure no inference speed.

@jjang-ai

Copy link
Copy Markdown
Contributor Author

SOURCE EVIDENCE: runtime e9ccbbd08dce79f6625c800db61624d25069c76b; Osaurus consumer bb8bf74bcd2973cf5b0291c7f45604204dc92496; signed proof-app binary SHA-256 89924b35f7cc7b92db46d31ffbdd537da654ff17c0b440550bb82431250d3169. The tokenizer now compiles its selected source unchanged. Five authority regressions pass after failing with seven issues on the old implementation. 192 actual-template renders have zero errors;128 Swift/Python comparisons agree;32/32 corrected next-user boundaries close, versus0/32 with the old blanket rewrite. No kernel/sampler/cache policy change.

LIVE EVIDENCE: real local quantized Osaurus UI, 12B QAT JANG_4M: eight user turns cover supported Off→On→Off→On thinking, tools absent/offered/called/absent, actual image+calculator, grounded text after image, exact text and identical-image/text replay, and process restart. Correct answers/natural stops/settled UI throughout. A separate restored-history emulation using the genuine transcript cut after its completed tool result also answers the next user correctly; this is not timed-cancellation proof. Eight ordinary turns plus one emulation pass their bounded correctness rows. Decode rates35.815–45.443 tokens/s are observations, not a speed comparison. Same-control restart restores1515/1627 input tokens from disk (3.362s load-inclusive TTFT); tool continuations report1305/1458 and2369/2595. Actual topology8KV+40rotating, pagedRAMoff,diskL2on,TurboQuantLayers0. Missing per-turn cache counts remain missing. Effective sampler follows bundle temperature1/top_k64/top_p0.95, no penalty override and sampler_was_changed=false; existing output limit16384, natural stops.

FAILED/OPEN: E4B QAT JANG_4M first calculator turn succeeds at73.535/72.913 decode tokens/s. The following user turn gives the correct answer but includes unnecessary/malformed calls and an empty-output recovery; tool-quality score1/2 native turns, answer correctness2/2. It is retained as failed rather than counted from its final answer. The initial prompt preceding those calls is byte-identical under old runtime/current patch/pinned Google canonical rendering; no claim that this PR fixes that model/output/parser issue. Further canonical exporter work is isolated in jjang-ai/jangq#46, still draft. A subsequent API diagnostic also yielded malformed quoting and is not a quality pass. No full-family/quant certification, exact12BMXFP load claim, all-media-cache claim or M2GPU prevention claim.

CI: both Linux SwiftPM and four container builds pass; macOS/CUDA queued. Lint requests1,024-file global formatting;31Tokenizer.swift formatting hunks are outside this PR's changed lines, other changed files absent. No global reformat/admin/gate change. Consumer all8CI checks pass in41170650897. Current source and native scope are frozen; prior unrelated acceptance remains retained. No tag, release, model upload or workflow retry.

Receipt identities (private contents retained locally; no screenshots uploaded):

  • consumer-app-identity.json SHA-256 4c8de120c16af1a11e4b8da0c3999861fc7f9f96856868d84d03bc8733ec5161
  • native-turns-through-8-stable-restart.json SHA-256 4af30280ffc22aceb18ab0bc4f21920bb4a40a1ceda5e877d2e91590ecc70c84
  • native-interrupted-turns.json SHA-256 5076fa1ac654fd05a88acbb9c80f7141979e8a1acaec3a18666fa416a8c27578
  • native-replay-equality.json SHA-256 c49479644d29cd6afee19dae71832408e071f7e082c3562b56bdac89a4b10875
  • e4b-failed-tool-quality.json SHA-256 710f49dfed56f62cd487c5da2dc353c8eeee60b9bb8fc6ff38dd2081e20e1117
  • e4b-actual-request-render-comparison.json SHA-256 6f0ff336fc00e9d8351592bd96d4ff32f2d8c6eeee91945b4c3b126f6d62df09
  • runtime-lint-attribution.json SHA-256 c1633d326861e07f0595151926c9bce8bdf0db3e2444340c3eee6b0fd7641d63

@jjang-ai
jjang-ai marked this pull request as ready for review October 31, 2026 07:57
@jjang-ai
jjang-ai merged commit da0fced into main Oct 31, 2026
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant