Skip to content

[compat] fix FusedDSAIndexerLoss compat mcore<0.19#142

Merged
Jintao-Huang merged 1 commit into
modelscope:mainfrom
Jintao-Huang:fix_FusedDSAIndexerLoss
Jul 9, 2026
Merged

[compat] fix FusedDSAIndexerLoss compat mcore<0.19#142
Jintao-Huang merged 1 commit into
modelscope:mainfrom
Jintao-Huang:fix_FusedDSAIndexerLoss

Conversation

@Jintao-Huang

Copy link
Copy Markdown
Collaborator

No description provided.

@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 a version check for megatron.core to conditionally pass the calculate_per_token_loss parameter to FusedDSAIndexerLoss.apply only when using version 0.19.0rc0 or newer. The review feedback suggests using getattr when accessing calculate_per_token_loss from self.config to make the code more robust against potential AttributeErrors.

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.


kwargs = {}
if mcore_019:
kwargs['calculate_per_token_loss'] = self.config.calculate_per_token_loss

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using getattr(self.config, 'calculate_per_token_loss', False) is safer and more robust than direct attribute access. This prevents potential AttributeError if self.config is a mock object in unit tests or a custom configuration class that does not define calculate_per_token_loss.

Suggested change
kwargs['calculate_per_token_loss'] = self.config.calculate_per_token_loss
kwargs['calculate_per_token_loss'] = getattr(self.config, 'calculate_per_token_loss', False)

@Jintao-Huang Jintao-Huang changed the title [bugfix] fix FusedDSAIndexerLoss [compat] fix FusedDSAIndexerLoss compat mcore<0.19 Jul 9, 2026
@Jintao-Huang Jintao-Huang merged commit a346c19 into modelscope:main Jul 9, 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.

1 participant