Skip to content

feat(adapters): Gemma 4 Unified (encoder-free 12B) adapter + single-file safetensors loader - #58

Merged
synapticode-ai merged 1 commit into
mainfrom
feat/gemma4-unified-adapter
Jun 7, 2026
Merged

feat(adapters): Gemma 4 Unified (encoder-free 12B) adapter + single-file safetensors loader#58
synapticode-ai merged 1 commit into
mainfrom
feat/gemma4-unified-adapter

Conversation

@synapticode-ai

Copy link
Copy Markdown
Collaborator

Summary

Adds tern-core support for Gemma 4 Unified (the encoder-free dense 12B, Gemma4UnifiedForConditionalGeneration / model_type=gemma4_unified) and the single-file safetensors layout it ships in.

  • adapters/gemma4_unified.pyGemma4UnifiedAdapter (subclass of Gemma4Adapter): registers the unified arch/model_type; FP16-retains the inline encoder-free embedder (embed_vision / embed_audio / vision_embedder.*); dense (no MoE); the 8 value-free global layers (no v_proj, indices 5/11/17/23/29/35/41/47) are handled per-tensor.
  • sharded_loader.py — single-file no-index fallback: synthesize weight_map from the file header. Gemma 4 12B-it ships one 24 GB model.safetensors with no index.json.
  • tools/tern_ppl_bench.py--dtype flag (use bf16 for Gemma numerics) + tokenizer-source override (the Gemma 4 family shares one tokenizer, vocab 262144).
  • Tests — adapter classification + single-file loader (18 new); registry canonical-source test updated for the new adapter.

Validation

  • Full suite: 720 passed, 8 skipped, 1 xfailed (0 failures).
  • Dry-run + real ternary compress validated on the actual 22 GB google/gemma-4-12B-it checkpoint: 3.8× vs BF16 @ threshold 0.7 (318 ternary + 10 INT4 + 349 FP16). Held structural / weight-only / coherence-pending.

Scope note

The compression path here is independent and green. The 12B-it text-only inference (needed for the same-harness PPL eval) is blocked upstream by a transformers 5.10.0.dev0 Gemma4Unified forward bug (text-only collapses; llama.cpp runs the same weights coherently). Diagnosis + queue recorded in synapticode-ops DISPOSITION_QUEUE Q15; quality eval re-runs from staged assets once the upstream forward is fixed.

🤖 Generated with Claude Code

…ile safetensors loader

- gemma4_unified adapter: registers Gemma4UnifiedForConditionalGeneration/gemma4_unified; FP16-retain inline encoder-free embedder (embed_vision/embed_audio/vision_embedder); dense (no MoE); value-free global layers handled per-tensor.

- sharded_loader: single-file no-index fallback (synthesize weight_map from header) — Gemma 4 12B-it ships a lone model.safetensors.

- tern_ppl_bench: --dtype flag (bf16 for Gemma numerics) + tokenizer-source override (family-shared Gemma 4 tokenizer, vocab 262144).

- tests: adapter classification + single-file loader (18 new); registry canonical-source updated. Full suite 720 passed; dry-run + compress validated on real 22GB 12B-it checkpoint (3.8x vs BF16 @t0.7).

Note: 12B-it text-only INFERENCE is blocked upstream (transformers 5.10.0.dev0 Gemma4Unified forward bug); the adapter/loader/compression path is independent and green. See synapticode-ops DISPOSITION_QUEUE Q15.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@synapticode-ai
synapticode-ai merged commit b7ce508 into main Jun 7, 2026
1 check passed
@synapticode-ai
synapticode-ai deleted the feat/gemma4-unified-adapter branch June 7, 2026 22:24
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