Repository navigation
[codex] Add Gemma4 renderer - #4
Merged
Merged
Conversation
joanvelja
force-pushed
the
codex/gemma4-renderer
branch
from
June 6, 2026 18:33
e4b0fc2 to
bf12514
Compare
joanvelja
marked this pull request as ready for review
June 6, 2026 18:46
joanvelja
added a commit
that referenced
this pull request
Jun 23, 2026
…elja fork Brings upstream renderers 942449c..1933293 (10 commits incl. unsloth-llama tokenizer fix PrimeIntellect-ai#90, dev49 publish) while preserving our custom renderers: gemma4 (#4), nemotron3 (PrimeIntellect-ai#77/#5), hf-compat loaders, dev-tag vcs fix. # Conflicts: # renderers/base.py # renderers/configs.py # renderers/nemotron3.py # tests/conftest.py # tests/test_nemotron3_ultra.py # tests/test_renderer_config_parity.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a hand-coded Gemma4 renderer for the current first-party Google Gemma4 checkpoints, covering text/tool chat template rendering, typed config registration, auto-routing, tool-call parsing, reasoning extraction, and shared renderer test coverage.
The renderer is intentionally text/tool only for now: image/audio/video content parts raise explicitly until a multimodal sidecar is implemented, so auto-routing does not silently drop non-text inputs.
Root Cause / Context
The initial Gemma4 integration needed to follow the repository's pattern for adding renderer families: exact
MODEL_RENDERER_MAPentries, typed config, registry export, parser support, and parity tests. Gemma4 also has a size-specific generation-prompt variant: E2B/E4B and 31B/26B-A4B differ whenadd_generation_prompt=Trueandenable_thinking=False. This PR mirrors the existing Qwen3.5 approach by handling the per-model variant exactly and parity-testing the in-family sizes.The repo's automated
.devNrelease tags also caused hatch-vcs/setuptools-scm metadata resolution to fail before pytest collection. This PR makes local version discovery ignore those dev tags and updates the dev publish workflow to pass the intended dev version explicitly when building from a dev tag.Changes
Gemma4Rendererwith text/tool rendering, tool response handling, generation prompt support, masks, message roles, and bridge support.Gemma4RendererConfig, lazy exports, registry entry, and exact model-map entries for the current Google Gemma4 full checkpoints.uv.lockproject metadata for theopenai-harmony>=0.0.4dependency floor.Validation
UV_FROZEN=true uv run --frozen pytest -q->1956 passed, 65 skipped, 1 xfailedUV_FROZEN=true uv run --frozen pytest tests/test_gemma4.py tests/test_renderer_config_parity.py tests/test_roundtrip.py tests/test_build_helpers.py tests/test_render_ids.py -q -k gemma->63 passed, 725 deselectedUV_FROZEN=true uv run --frozen ruff check renderers/gemma4.py tests/test_gemma4.pygit diff --check && git diff --cached --checkSETUPTOOLS_SCM_PRETEND_VERSION=0.1.9.dev41 SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RENDERERS=0.1.9.dev41 uv build