[quantization] Support Vision Encoder wrapper for Gemma4#796
Open
Torrero wants to merge 1 commit into
Open
Conversation
f770fb2 to
5a4ec51
Compare
12e6510 to
c9dcea8
Compare
This commit supports Vision Encoder wrapper for Gemma4 Co-authored-by: Cline TICO-DCO-1.0-Signed-off-by: Evgenii Maltsev <e.maltsev@samsung.com>
c9dcea8 to
ab4b0f7
Compare
Contributor
|
Could you please clarify the cause of |
Contributor
|
Would you consider adding |
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
Introduce a PTQ wrapper (
QuantGemma4VisionEncoder) for the Hugging FaceGemma4VisionEncodermodule, enabling post-training quantization of the Gemma4 vision tower with both dynamic evaluation and statictorch.exportpaths.Changes
tico/quantization/wrapq/wrappers/gemma4/quant_vision_encoder.pyQuantGemma4VisionEncoderregistered againstGemma4VisionEncodervia@try_registerforward): computes RoPE position embeddings via precomputed lookup tables (cos_table/sin_table) and bidirectional attention masks frompixel_position_ids— used during calibration and accuracy evaluation.forward_export): reads precomputedposition_embeddingsandattention_maskfrom registered buffers, avoiding any dynamic shape-dependent computation — safe fortorch.exporttracing__init__, replacing the dynamic matmul+cos/sin with a simple gatherSmoke Tests
Command:
UnitTests
Command:
27 tests passed. Output
TICO-DCO-1.0-Signed-off-by: Evgenii Maltsev e.maltsev@samsung.com