feat(adapters): Gemma 4 Unified (encoder-free 12B) adapter + single-file safetensors loader - #58
Merged
Merged
Conversation
…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>
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 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.py—Gemma4UnifiedAdapter(subclass ofGemma4Adapter): 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 (nov_proj, indices 5/11/17/23/29/35/41/47) are handled per-tensor.sharded_loader.py— single-file no-index fallback: synthesizeweight_mapfrom the file header. Gemma 4 12B-it ships one 24 GBmodel.safetensorswith noindex.json.tools/tern_ppl_bench.py—--dtypeflag (use bf16 for Gemma numerics) + tokenizer-source override (the Gemma 4 family shares one tokenizer, vocab 262144).Validation
google/gemma-4-12B-itcheckpoint: 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.dev0Gemma4Unifiedforward bug (text-only collapses; llama.cpp runs the same weights coherently). Diagnosis + queue recorded insynapticode-opsDISPOSITION_QUEUE Q15; quality eval re-runs from staged assets once the upstream forward is fixed.🤖 Generated with Claude Code