Feat gemma4 vision encoder local#215
Merged
Merged
Conversation
Rename Gemma4 26B encoder class for consistency and update the Gemma4 snapshot_download patterns to include sharded safetensors. Co-authored-by: Cursor <cursoragent@cursor.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.
Adds Gemma 4's vision tower as a TRIDENT patch encoder. Two variants are registered:
gemma4-e4b(167M, dim 768) andgemma4-26b(569M, dim 1152), selected with--patch_encoder.Only the vision tower is loaded from the multimodal checkpoint. The safetensors header is parsed and the
model.vision_tower.*tensors are read by seeking their byte ranges, so the LLM weights are never materialized (the 26B's vision tower sits inside a ~50 GB shard). Loading the transformers Gemma 4 classes is deferred to_build, so the encoder only needstransformers>=5.0at runtime and the rest of TRIDENT keeps working on 4.x.Credit to @jrs-orellana