Skip to content

[codex] Add Gemma4 renderer - #4

Merged
joanvelja merged 1 commit into
mainfrom
codex/gemma4-renderer
Jun 6, 2026
Merged

joanvelja merged 1 commit into
mainfrom
codex/gemma4-renderer

Conversation

@joanvelja

Copy link
Copy Markdown
Owner

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_MAP entries, 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 when add_generation_prompt=True and enable_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 .devN release 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

  • Add Gemma4Renderer with text/tool rendering, tool response handling, generation prompt support, masks, message roles, and bridge support.
  • Add Gemma4 tool-call/reasoning parsing, including Gemma DSL strings and JSON-quoted fallback arguments.
  • Register Gemma4RendererConfig, lazy exports, registry entry, and exact model-map entries for the current Google Gemma4 full checkpoints.
  • Add Gemma4 focused parity and parser tests, plus shared config/roundtrip/build/render-id matrix entries.
  • Fix hatch-vcs dev-tag handling and align dev/release publish workflows.
  • Sync uv.lock project metadata for the openai-harmony>=0.0.4 dependency floor.

Validation

  • UV_FROZEN=true uv run --frozen pytest -q -> 1956 passed, 65 skipped, 1 xfailed
  • UV_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 deselected
  • UV_FROZEN=true uv run --frozen ruff check renderers/gemma4.py tests/test_gemma4.py
  • git diff --check && git diff --cached --check
  • SETUPTOOLS_SCM_PRETEND_VERSION=0.1.9.dev41 SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RENDERERS=0.1.9.dev41 uv build

@joanvelja
joanvelja force-pushed the codex/gemma4-renderer branch from e4b0fc2 to bf12514 Compare June 6, 2026 18:33
@joanvelja
joanvelja marked this pull request as ready for review June 6, 2026 18:46
@joanvelja
joanvelja merged commit 9d68108 into main Jun 6, 2026
6 checks passed
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
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