[quantization] Support Vision Encoder wrapper for Gemma4#796
Conversation
f770fb2 to
5a4ec51
Compare
12e6510 to
c9dcea8
Compare
c9dcea8 to
ab4b0f7
Compare
|
Could you please clarify the cause of |
|
Would you consider adding |
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>
ab4b0f7 to
cc99ea6
Compare
Thank you, I updated PR message, added |
Added. Thank you. @dvsav PTAL |
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:
Nodes without qparam (logs)
Vision Encoder wrapper related nodes:
UnitTests
Command:
27 tests passed. Output
TICO-DCO-1.0-Signed-off-by: Evgenii Maltsev e.maltsev@samsung.com