Skip to content

[bugfix] fix megatron_core main/dev mtp#9588

Closed
Jintao-Huang wants to merge 1 commit into
modelscope:mainfrom
Jintao-Huang:fix_megatron_core_main_mtp
Closed

[bugfix] fix megatron_core main/dev mtp#9588
Jintao-Huang wants to merge 1 commit into
modelscope:mainfrom
Jintao-Huang:fix_megatron_core_main_mtp

Conversation

@Jintao-Huang

Copy link
Copy Markdown
Collaborator

@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

This pull request introduces support for Megatron-Core version 0.19.0rc0 and above in swift/megatron/trainers/base.py. It conditionally adjusts the mtp_loss_scale calculation in _log_callback based on the Megatron-Core version and the presence of save_metrics_to_tracker on MTPLossLoggingHelper. The review feedback suggests improving the version check by comparing the release tuple directly, which ensures that development and pre-release versions of 0.19 are correctly identified.

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.

RouterReplayAction = None

mcore_016 = version.parse(megatron.core.__version__) >= version.parse('0.16.0rc0')
mcore_019 = version.parse(megatron.core.__version__) >= version.parse('0.19.0rc0')

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.

medium

Using version.parse(...) >= version.parse('0.19.0rc0') can evaluate to False for development or pre-release versions of 0.19 (such as 0.19.0.dev0 or 0.19.0a0) because PEP 440 considers dev/alpha/beta releases to be lower than release candidates (rc).

To ensure that all 0.19 releases (including dev and pre-releases) are correctly identified as mcore_019, you can compare the release tuple of the parsed version directly.

Suggested change
mcore_019 = version.parse(megatron.core.__version__) >= version.parse('0.19.0rc0')
mcore_019 = version.parse(megatron.core.__version__).release >= (0, 19)

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.

2 participants