Skip to content

[bug-fix] GLM OCR Patch Merger context_dim - #37962

Merged
vllm-bot merged 6 commits into
vllm-project:mainfrom
JaredforReal:ocr
Mar 26, 2026
Merged

vllm-bot merged 6 commits into
vllm-project:mainfrom
JaredforReal:ocr

Conversation

@JaredforReal

@JaredforReal JaredforReal commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Modified the reading logic in GLM-OCR, the original algorithm implementation error, although the numbers just want to wait, but in fact, it should be text_config intermediate_size is the correct design intention, and not modifying it will affect subsequent model iterations.
Change from vision_config.out_hidden_size * vision_config.in_channels to context_dim=text_config.intermediate_size

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Copilot AI review requested due to automatic review settings March 24, 2026 05:29
@mergify mergify Bot added the bug Something isn't working label Mar 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request correctly updates the Glm4vVisionTransformer and GlmOcrVisionTransformer constructors to accept text_config, and modifies the GlmOcrPatchMerger to use text_config.intermediate_size for context_dim. These changes align with the stated purpose of fixing the GLM OCR Patch Merger context_dim and appear to be correct and necessary for the model's functionality.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the GLM-OCR vision tower wiring so the patch merger’s context_dim is derived from the text config (instead of a vision-derived product), aligning the merger MLP dimensions with the language-side configuration.

Changes:

  • Pass text_config into GLM4V/GLM-OCR vision transformer construction paths.
  • Change GLM-OCR patch merger context_dim to text_config.intermediate_size.
  • Update transformers config imports/type references to include text config types.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
vllm/model_executor/models/glm_ocr.py Uses text_config.intermediate_size for the OCR patch merger context_dim and threads text_config into the OCR vision transformer.
vllm/model_executor/models/glm4_1v.py Extends Glm4vVisionTransformer constructor and call site to accept text_config; updates config imports accordingly.
Comments suppressed due to low confidence (1)

vllm/model_executor/models/glm4_1v.py:615

  • The new text_config parameter on Glm4vVisionTransformer.__init__ is not used anywhere in the implementation. If it’s required for a later change (e.g., deriving context_dim), please wire it into the logic (or store it) now; otherwise, dropping the parameter would avoid an API change and potential confusion for future call sites.
class Glm4vVisionTransformer(nn.Module):
    def __init__(
        self,
        text_config: Glm4vTextConfig,
        vision_config: Glm4vVisionConfig,
        norm_eps: float = 1e-6,
        quant_config: QuantizationConfig | None = None,
        prefix: str = "",
    ) -> None:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vllm/model_executor/models/glm4_1v.py Resolved
Comment on lines 306 to 309
self.merger = GlmOcrPatchMerger(
d_model=vision_config.out_hidden_size,
context_dim=vision_config.out_hidden_size * vision_config.in_channels,
context_dim=text_config.intermediate_size,
quant_config=quant_config,

Copilot AI Mar 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description still contains the template placeholder text and does not include a test plan / test results. Please update the PR description to document how this context_dim change was validated (or why tests are not applicable).

Copilot uses AI. Check for mistakes.
@Isotr0py
Isotr0py enabled auto-merge (squash) March 24, 2026 07:58
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Mar 24, 2026
@vllm-bot
vllm-bot merged commit 757eafc into vllm-project:main Mar 26, 2026
56 of 57 checks passed
RhizoNymph pushed a commit to RhizoNymph/vllm that referenced this pull request Mar 26, 2026
Signed-off-by: JaredforReal <w13431838023@gmail.com>
nithinvc pushed a commit to nithinvc/vllm that referenced this pull request Mar 27, 2026
Signed-off-by: JaredforReal <w13431838023@gmail.com>

Signed-off-by: Nithin Chalapathi <nithin.ch10@gmail.com>
JiantaoXu pushed a commit to JiantaoXu/vllm that referenced this pull request Mar 28, 2026
Signed-off-by: JaredforReal <w13431838023@gmail.com>
puririshi98 pushed a commit to puririshi98/vllm that referenced this pull request Apr 7, 2026
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: Rishi Puri <riship@nvidia.com>
mtparet pushed a commit to blackfuel-ai/vllm that referenced this pull request Apr 9, 2026
Signed-off-by: JaredforReal <w13431838023@gmail.com>
mystous pushed a commit to mystous/vllm_hybrid that referenced this pull request May 10, 2026
Signed-off-by: JaredforReal <w13431838023@gmail.com>
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
Signed-off-by: JaredforReal <w13431838023@gmail.com>
@JaredforReal
JaredforReal deleted the ocr branch June 5, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants