Skip to content

How to quantize both vision encoder and llm together? #1998

Closed

Description

@XULU42

I am trying to quantize dots_ocr model, whose submodules are ['model','vision_tower','lm_head'], as shown below:

Image

By tracing the code down, I found that this code is for parsing modules for quantization, but it only return one module. By experiment, I can quantize either vision_tower or model separately and loading by vllm, but I can't quantize both due to above mechanism. Please help me figure out how to solve this, thanks^_^

Activity

  1. LiMa-cas commented on Oct 15, 2025

    @LiMa-cas

    I have quantized thinker or talker seperately,but I can not put them together,same questions

  2. XULU42 commented on Oct 15, 2025

    @XULU42
    Author

    I was able to quantize dots_ocr by changing code here and below to a for loop. It works, but looks ugly, looking forward to official mechanism to support both model quantization.

  3. Qubitium commented on Oct 15, 2025

    @Qubitium
    Collaborator

    I was able to quantize dots_ocr by changing code here and below to a for loop. It works, but looks ugly, looking forward to official mechanism to support both model quantization.

    @XULU42 Can you post your code diff? I would be awesome if you can create a PR to add this support. Don't worry about breaking things,once you create a PR and an associated unit test to tests/models (just copy another model's unit teset and modify) I can help with the PR testing and review.

    I am already overworked so don't have the time to implement everything that everyone wants without external help.

  4. XULU42 commented on Oct 15, 2025

    @XULU42
    Author

    I would issue an PR later, but it seems to be a root change in module loop mechanism, may cause problem for other supported models. Thanks for your dedication to community. Your health is precious, please take care.

  5. Qubitium commented on Oct 15, 2025

    @Qubitium
    Collaborator

    but it seems to be a root change in module loop mechanism, may cause problem for other supported models.

    Don't worry about breakage. Module looper needs needs to eventually handle parallel models so I expect structual changes for world models where text, vision, audio module exists concurrently in the modules tree. Right now, the module tree auto extraction is expecting a linear single branch from top to bottom but current VL models are now structured where essentially there are two+ parallel branches in the module tree.

  6. XULU42 commented on Oct 15, 2025

    @XULU42
    Author

    but it seems to be a root change in module loop mechanism, may cause problem for other supported models.

    Don't worry about breakage. Module looper needs needs to eventually handle parallel models so I expect structual changes for world models where text, vision, audio module exists concurrently in the modules tree. Right now, the module tree auto extraction is expecting a linear single branch from top to bottom but current VL models are now structured where essentially there are two+ parallel branches in the module tree.

    The situation is clear. Let's try to add mechanism to parse and quantize parallel branches.

  7. LWQuestc commented on Mar 6, 2026

    @LWQuestc

    I was able to quantize dots_ocr by changing code here and below to a for loop. It works, but looks ugly, looking forward to official mechanism to support both model quantization.
    @XULU42 I've been working on something similar lately. If you don't mind, could I take a look at your code for reference? Thanks!

  8. namgyu-yun commented on Mar 15, 2026

    @namgyu-yun
    Contributor

    Quantizing the vision encoder is uncommon because: (1) calibration requires multimodal (image-text) samples, whereas most pipelines are built around text-only inputs, (2) vision encoders represent a small fraction of total parameters (e.g., ~1.5% / 0.42B out of 27.44B in Gemma3-27B).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions