Skip to content

support absorbed_mla & support glm_moe_dsa CP/packing#144

Merged
Jintao-Huang merged 8 commits into
modelscope:mainfrom
Jintao-Huang:support_absorbed_mla
Jul 14, 2026
Merged

support absorbed_mla & support glm_moe_dsa CP/packing#144
Jintao-Huang merged 8 commits into
modelscope:mainfrom
Jintao-Huang:support_absorbed_mla

Conversation

@Jintao-Huang

Copy link
Copy Markdown
Collaborator

No description provided.

@Jintao-Huang Jintao-Huang changed the title support absorbed_mla support absorbed_mla & support glm_moe_dsa CP/packing Jul 9, 2026

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the AbsorbedMLASelfAttention module to support multi-latent attention with matrix absorption, registering it within the model's replacement logic. Feedback highlights several critical robustness issues: inheriting directly from McoreAbsorbedMLASelfAttention when it is None will raise a TypeError at import time, which can be resolved with a dummy fallback class. Additionally, accessing __name__ on self_attention.module and accessing self.pg_collection.cp are prone to AttributeErrors if those objects are None or of unexpected types, and should be safely guarded.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/mcore_bridge/model/modules/absorbed_mla.py
Comment thread src/mcore_bridge/model/register.py Outdated
Comment on lines +166 to +167
elif self_attention.module.__name__ == 'AbsorbedMLASelfAttention':
self_attention.module = AbsorbedMLASelfAttention

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Accessing __name__ directly on self_attention.module can raise an AttributeError if the module is None or a partial object (which does not have a __name__ attribute). Use getattr to safely retrieve the attribute and avoid potential crashes during model registration.

Suggested change
elif self_attention.module.__name__ == 'AbsorbedMLASelfAttention':
self_attention.module = AbsorbedMLASelfAttention
elif getattr(self_attention.module, '__name__', None) == 'AbsorbedMLASelfAttention':
self_attention.module = AbsorbedMLASelfAttention

Comment thread src/mcore_bridge/model/modules/absorbed_mla.py
Comment thread src/mcore_bridge/model/modules/absorbed_mla.py
@Jintao-Huang

Copy link
Copy Markdown
Collaborator Author

/gemini review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for AbsorbedMLASelfAttention and refactors the GLM MoE DSA implementation to align with Megatron-Core, including updates to configuration parsing and the DSA indexer. The review feedback highlights several critical opportunities to improve robustness and prevent runtime crashes, particularly by defensively handling cases where packed_seq_params is empty or passed as a tuple, ensuring sequence packing is active before reshaping tensors, and safely accessing module attributes using getattr.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/mcore_bridge/model/modules/absorbed_mla.py
Comment thread src/mcore_bridge/model/modules/absorbed_mla.py
Comment thread src/mcore_bridge/model/modules/absorbed_mla.py
Comment thread src/mcore_bridge/model/gpts/glm_moe_dsa.py
Comment thread src/mcore_bridge/model/register.py Outdated
@Jintao-Huang Jintao-Huang merged commit 38316cf into modelscope:main Jul 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants