Skip to content

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 initiates a refactoring effort for the ms-swift v4 codebase, specifically targeting the callback component. The core change involves enhancing the system's flexibility and clarity by transitioning from a simple list-based approach to a more structured dictionary for managing and registering extra callbacks. This update improves how different callback functionalities are identified and integrated into the system.

Highlights

  • Callback Management Refactoring: The extra_callbacks variable in swift/plugins/callback.py has been refactored from a list to a dictionary, allowing callbacks to be registered and accessed by name.
  • Named Callback Registration: The EarlyStopCallback and PerfMetricsLogCallback are now explicitly registered within the extra_callbacks dictionary using descriptive keys ('early_stop', 'perf_log').

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

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 how extra callbacks are managed in swift/plugins/callback.py. The extra_callbacks variable has been changed from a list to a dictionary, which serves as a registry for available callbacks like EarlyStopCallback and PerfMetricsLogCallback. This is a positive change that improves the code's structure and maintainability by allowing callbacks to be accessed by name. The implementation is clean and follows good practices. I have no specific suggestions for improvement on this change.

@Jintao-Huang
Copy link
Collaborator Author

/gemini review

@Jintao-Huang Jintao-Huang changed the title [v4] refactor ms-swift v4 (pipelines/callback/dataset) [v4] refactor ms-swift v4 (pipelines/callback/tuner_plugin) Jan 16, 2026
@Jintao-Huang Jintao-Huang changed the title [v4] refactor ms-swift v4 (pipelines/callback/tuner_plugin) [v4] refactor ms-swift v4 (pipelines/arguments/swiftmixin/callback/tuner_plugin) Jan 16, 2026
@Jintao-Huang
Copy link
Collaborator Author

/gemini review

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 is a significant refactoring effort for ms-swift v4. The core changes include renaming the --train_type argument to --tuner_type for better clarity, and a major restructuring of the plugins module into more organized packages like callbacks, loss, optimizers, and tuner_plugin. The move away from the custom swift.tuners.Swift class in favor of the standard peft library is a great improvement for maintainability and interoperability. The changes are widespread across documentation, examples, and core library code, and for the most part, they are consistent and well-executed.

I've found a few minor inconsistencies and potential issues:

  • A couple of documentation files and an example script have inconsistent parameter renames (sft_type to train_type instead of tuner_type, and --tuner_backend to --train_backend).
  • An example notebook seems to contain user-specific metadata changes.
  • Some comments in an example script point to outdated file paths after the refactoring.

Overall, this is a solid refactoring that improves the framework's structure and clarity. Addressing the minor issues I've pointed out will make it even better.

@Jintao-Huang
Copy link
Collaborator Author

/gemini review

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 introduces a significant and valuable refactoring for ms-swift v4. The key changes include renaming the train_type argument to tuner_type for better clarity, restructuring the plugin system for callbacks and tuners into dedicated modules, and aligning with the peft library by replacing custom Swift class methods with standard PeftModel usage. These changes improve code organization, maintainability, and standardization. The updates across documentation, examples, and internal arguments are largely consistent. I've identified a minor inconsistency in one of the examples and a potential bug in the new LISACallback implementation. Overall, this is a solid step forward for the framework.

@Jintao-Huang
Copy link
Collaborator Author

/gemini review

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 introduces a significant refactoring for the upcoming v4 release. The changes primarily focus on improving modularity and aligning with standard libraries. Key changes include renaming train_type to tuner_type across the codebase, restructuring the plugins module into more specific modules like callbacks, rewards, and tuner_plugin, and replacing the custom Swift class with peft.PeftModel. These are excellent changes that enhance maintainability and extensibility. The refactoring has been applied consistently across a large number of documentation and example files. I have one suggestion to improve consistency in an example file.

Comment on lines 42 to +44
model = Swift.from_pretrained(model, adapter_dir)
# You can also write it as:
# model = PeftModel.from_pretrained(model, adapter_dir)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While Swift.from_pretrained might still work for backward compatibility, it's better to consistently use PeftModel.from_pretrained across all examples to align with the refactoring's goal of adopting the peft library more directly. This will improve consistency and reduce confusion for users.

Suggested change
model = Swift.from_pretrained(model, adapter_dir)
# You can also write it as:
# model = PeftModel.from_pretrained(model, adapter_dir)
model = PeftModel.from_pretrained(model, adapter_dir)

@Jintao-Huang Jintao-Huang merged commit d0c71e4 into modelscope:main Jan 17, 2026
2 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.

3 participants