Skip to content

Close Gemma tool-result turns in shared bundle export - #45

Merged
jjang-ai merged 2 commits into
mainfrom
fix/gemma4-template-closure-20261031
Oct 31, 2026
Merged

jjang-ai merged 2 commits into
mainfrom
fix/gemma4-template-closure-20261031

Conversation

@jjang-ai

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

Copy link
Copy Markdown
Owner

Gemma exports retained an older tool-result closure branch: a following user turn could begin before the preceding model turn closed. Both affine JANG and MXFP exporters share the same sidecar path, so the correction lives there and keeps the file/embedded templates synchronized.

Backport the canonical Gemma next-non-tool continuation rule. Keep final tool-result turns open for pending generation and assistant continuation, and close them before a new user. Remove the exact instruction that older exports injected for required tool choice; tool-choice validation is not a reason to rewrite the conversation with an extra prompt. Preserve the existing no-thinking generation-prefill policy and generation-token metadata propagation.

The template transformation and metadata writer are now pure helpers, independent of MLX weight conversion. Fifteen focused tests pass, covering single/multiple results, thinking switches, assistant continuation/fragments, pending calls, terminal results, idempotence, legacy instruction removal and file/embedded consistency. Replacing only the transformation with its exact original production implementation yields nine assertion failures and no setup errors. CI runs these contracts on Linux without loading a model.

References: osaurus-ai/osaurus#3237; Google's canonical Gemma 4 template revision 43c9d014b231474fa7212dbb48a762566c2b255d. Current Hub templates of the two reported 12B MXFP variants match the locally inspected JANG variant and retain the old branch.

Actual installed-template controls now pass: 192 renders without errors, 128 Swift/Python byte-identical comparisons, and 32/32 corrected tool-result→user closures. The old runtime rewrite leaves 32/32 open.

CI at e252167b61b478548b029f5e541af307634b2ebd: the 15-case template contract and public-document check pass. The broader macOS run has 800 passes, 64 skips and the same single DSV4 cache offset failure present on exact main base aa6106f8e6cb9c34831a0686e0287650beff1d5a (785 passes, 64 skips). Runs: 41170232719 / 41170232733 / baseline 40565052036. No unrelated DSV code or gates changed.

Draft: affected native model proof remains pending. This PR does not by itself update already-published bundles or establish that the reported thought-channel repetition is caused/fixed by turn closure. No weights, quantization, sampler defaults, runtime template replacement, version tag or release workflow changes. Existing unrelated qualification is retained. No screenshots or private evidence attached.

@jjang-ai

Copy link
Copy Markdown
Owner Author

SOURCE EVIDENCE: tested exporter head e252167b61b478548b029f5e541af307634b2ebd. Both affine and MXFP converters share the sidecar function. Fifteen exporter/metadata cases pass, including both legacy spellings, user closure versus assistant continuation, exact injected-instruction removal and file/embedded identity. Original-function control produces nine assertion failures with no setup errors; the extra persisted-variant case separately fails before its correction.

LIVE EVIDENCE (renderer execution, not model inference): actual 12B/E4B QAT JANG_4M templates rendered through the current Swift Jinja source and Python Jinja2 3.1.6: 192 renders, zero errors, 128/128 byte comparisons agree. Corrected tool-result→user boundaries close 32/32; old runtime surgery leaves 32/32 open. Controls vary history shape, thinking and generation-prompt switches. No model was loaded for these controls, so inference speed/coherence/cache acceptance is not claimed; no sampler was overridden.

Current focused template-contract CI passes (41170232719). Broader run41170232733: 800 passes, 64 skips, one existing DSV4 cache offset128/2048 failure. Exact main base aa6106f run40565052036 has the same failure (785 passes,64 skips). No unrelated DSV change or gate waiver.

This merges only the reproducible exporter source correction. Already-published bundles remain unchanged, and affected native model qualification is pending in runtime698/consumer3256. No bundle upload, tag, release or workflow retry is performed. Earlier unrelated acceptance remains retained.

Local receipt identities:

  • export-variant-green.log SHA-256 4f1c31223fdd6e717fe53daeea28b7235d8f1e8109b99662437f258c5b9dc3d0
  • export-original-revert-control.json SHA-256 84eb8393bab7982997ec500a3bb5d1c94ea71e6bdd2e96696884ea797cfe0e80
  • render-comparison.json SHA-256 3eafd6f9374e5d9bda7be6b340c126ebb44e16daea3f009594c215a46f27d11d

@jjang-ai
jjang-ai marked this pull request as ready for review October 31, 2026 06:55
@jjang-ai
jjang-ai merged commit d938e21 into main Oct 31, 2026
3 of 4 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