Repository navigation
[bug-fix] GLM OCR Patch Merger context_dim - #37962
Conversation
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_configinto GLM4V/GLM-OCR vision transformer construction paths. - Change GLM-OCR patch merger
context_dimtotext_config.intermediate_size. - Update
transformersconfig 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_configparameter onGlm4vVisionTransformer.__init__is not used anywhere in the implementation. If it’s required for a later change (e.g., derivingcontext_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.
| 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, |
There was a problem hiding this comment.
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).
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com> Signed-off-by: Nithin Chalapathi <nithin.ch10@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com> Signed-off-by: Rishi Puri <riship@nvidia.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: JaredforReal <w13431838023@gmail.com>
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_channelstocontext_dim=text_config.intermediate_sizeTest Plan
Test Result
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.