[bugfix] fix megatron_core main/dev mtp#9588
Conversation
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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.
| mcore_019 = version.parse(megatron.core.__version__) >= version.parse('0.19.0rc0') | |
| mcore_019 = version.parse(megatron.core.__version__).release >= (0, 19) |
modelscope/mcore-bridge#127