Skip to content

[megatron] fix get_mcore_model_config#8057

Merged
Jintao-Huang merged 3 commits intomodelscope:mainfrom
Jintao-Huang:fix_get_mcore_model_config
Feb 16, 2026
Merged

[megatron] fix get_mcore_model_config#8057
Jintao-Huang merged 3 commits intomodelscope:mainfrom
Jintao-Huang:fix_get_mcore_model_config

Conversation

@Jintao-Huang
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Jintao-Huang, 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 improving clarity and robustness within the Megatron model configuration process. It renames a key function to better describe its action and refines the argument processing logic to handle default or empty values more gracefully, preventing unintended overwrites.

Highlights

  • Function Renaming: The function create_mcore_model_config has been consistently renamed to get_mcore_model_config across the codebase to better reflect its purpose of retrieving a model configuration rather than creating a new one.
  • Argument Handling Refinement: The logic within the get_mcore_model_config function was improved to prevent overwriting existing configuration values with None or empty list/tuple arguments from args, ensuring more robust configuration merging.

🧠 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.

Changelog
  • swift/megatron/init.py
    • Updated the import statement for the get_mcore_model_config function.
    • Modified the __all__ list to export the newly named get_mcore_model_config.
  • swift/megatron/model/init.py
    • Updated the import statement to reflect the get_mcore_model_config function name.
  • swift/megatron/model/model_config.py
    • Renamed the create_mcore_model_config function to get_mcore_model_config.
    • Adjusted the logic to only apply argument values if they are not None or empty lists/tuples, preventing accidental overwrites of existing configuration.
  • swift/megatron/model/register.py
    • Updated the import statement for get_mcore_model_config.
    • Modified the MegatronModelMeta class to call the newly named get_mcore_model_config function.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 refactors the create_mcore_model_config function by renaming it to get_mcore_model_config and updates its usage across the codebase. It also modifies the logic within this function to correctly handle arguments with values like 0 or False. While this is a good improvement, the new implementation introduces a potential issue by not skipping empty string values, which could lead to runtime errors in downstream processing. I've provided a suggestion to address this.

key, value = f.name, getattr(args, f.name, None)
if value:
kwargs[key] = value
if value is None or isinstance(value, (list, tuple)) and len(value) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The previous logic if value: would correctly skip falsy values like empty strings (''). The new logic allows 0 and False to be passed, which is correct, but it no longer skips empty strings. This can lead to errors in functions like tuple_type and moe_freq_type, which do not handle empty strings gracefully and will raise a ValueError when int('') is attempted. It's better to explicitly check for and skip empty strings as well.

Suggested change
if value is None or isinstance(value, (list, tuple)) and len(value) == 0:
if value is None or value == '' or (isinstance(value, (list, tuple)) and len(value) == 0):

@Jintao-Huang Jintao-Huang merged commit f562d09 into modelscope:main Feb 16, 2026
1 of 3 checks 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