[Bug Fix] GLM-V / GLM-OCR: field detection for transformers 5.x and MTP omission fix#21134
[Bug Fix] GLM-V / GLM-OCR: field detection for transformers 5.x and MTP omission fix#21134Fridge003 merged 2 commits intosgl-project:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on enhancing the robustness and compatibility of the model loading and processing mechanisms for GLM-V and GLM-OCR architectures. It resolves issues related to MTP acceptance rates, ensures proper configuration detection for newer GLM models, and corrects an underlying algorithmic flaw in GLM-OCR's data interpretation, leading to more accurate and stable model behavior. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces several bug fixes for GLM-V and GLM-OCR models. The changes include correctly detecting num_nextn_layers from text_config for newer transformer versions, adjusting the model weight loading logic for MTP, and fixing an incorrect context_dim calculation in GLM-OCR. The changes appear correct and align with the pull request's objectives. I've provided one suggestion to improve code readability in weight_utils.py.
| num_nextn_layers = getattr( | ||
| getattr(hf_config, "text_config", hf_config), | ||
| "num_nextn_predict_layers", | ||
| getattr(hf_config, "num_nextn_predict_layers", 0), | ||
| ) |
There was a problem hiding this comment.
While this logic correctly retrieves num_nextn_layers by checking text_config first, the nested getattr calls are a bit difficult to parse. For improved readability and maintainability, consider refactoring this into a more explicit conditional block.
For example:
text_config = getattr(hf_config, "text_config", None)
if text_config and hasattr(text_config, "num_nextn_predict_layers"):
num_nextn_layers = text_config.num_nextn_predict_layers
else:
num_nextn_layers = getattr(hf_config, "num_nextn_predict_layers", 0)|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
13 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
Mainly modify several issues