-
Notifications
You must be signed in to change notification settings - Fork 840
[init]support gptq grpo in colocate mode #5569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[init]support gptq grpo in colocate mode #5569
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @ItGirls, 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 introduces a significant enhancement by enabling the training of GPTQ quantized models with GRPO using vLLM in colocate mode. The core problem addressed is the incompatibility between GPTQ models and LoRA merging within the vLLM acceleration framework. The solution involves a revised approach to managing LoRA parameters, where they are saved locally and then dynamically provided to the vLLM engine during inference via a new AdapterRequest
mechanism. This change allows for efficient training of quantized models without the previous merging limitations, improving the overall flexibility and capability of the training pipeline.
Highlights
- GPTQ GRPO Training Support: This PR enables the training of GPTQ quantized models using GRPO (Generative Reinforcement Learning with Policy Optimization) within vLLM's colocate mode. This resolves a critical limitation where GPTQ models previously could not be merged with LoRA when vLLM acceleration was active, leading to training errors.
- Enhanced LoRA Parameter Handling: A new mechanism has been implemented to handle LoRA adapter parameters. Instead of attempting to merge LoRA directly into the quantized model, the adapter weights are now saved locally and then passed to the vLLM engine via an
AdapterRequest
during inference. This allows for dynamic loading of LoRA adapters without requiring a full model merge. - New Configuration Option:
local_adapter_path
: A new command-line argument,local_adapter_path
, has been introduced. This argument specifies a temporary directory where LoRA adapter weights are stored, facilitating their transfer and use by the vLLM engine in colocate mode.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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
-
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. ↩
There was a problem hiding this 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 support for training GPTQ-quantized models with GRPO in colocate mode. The core idea is to save LoRA adapters to a local path instead of merging them, which is a good solution for quantized models. The implementation looks solid. My review includes suggestions to fix a typo in the documentation, remove unused code, improve code robustness by using os.makedirs
, and fix some typos in comments and log messages.
@@ -0,0 +1,88 @@ | |||
# 采用Colocate模式进行GTPQ量化模型的GRPO训练 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggestion, I already changed the file.
@@ -107,6 +110,9 @@ def __init__(self, | |||
from swift.trainers.rlhf_arguments import GRPOConfig | |||
args: GRPOConfig = kwargs['args'] | |||
self.args = args | |||
self.local_adapter_path = getattr(args, 'local_adapter_path', None) | |||
self.enable_lora = True if self.local_adapter_path else False | |||
self.update_adapter_count = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggestion. I removed the unused variable.
# delete exists files | ||
shutil.rmtree(self.local_adapter_path) | ||
logger.info(f"step:{self.state.global_step},deleta previous lora") | ||
|
||
os.mkdir(self.local_adapter_path) | ||
self.update_adapter_count+=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple of issues in this block:
- Typos in the comment on line 583 and the log message on line 585.
os.mkdir
on line 587 is not as robust asos.makedirs
, which can create parent directories if they don't exist.update_adapter_count
is incremented on line 588 but is unused and should be removed.
# delete exists files | |
shutil.rmtree(self.local_adapter_path) | |
logger.info(f"step:{self.state.global_step},deleta previous lora") | |
os.mkdir(self.local_adapter_path) | |
self.update_adapter_count+=1 | |
# delete existing files | |
shutil.rmtree(self.local_adapter_path) | |
logger.info(f"step:{self.state.global_step}, deleted previous lora") | |
os.makedirs(self.local_adapter_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot. I fixed the misspelled word and replaced 'mkdir' with 'makedirs', also deleted the unused variable.
res = self.engine.infer(infer_requests, request_config, use_tqdm=use_tqdm) | ||
# use adapter_request path lora to vllm engine | ||
if self.local_adapter_path: | ||
assert os.path.exists(self.local_adapter_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I followed the modification instructions.
…lmin colocate mode
thanks for the contributing! Is this PR ready for review? |
Yes, of course.
发自我的iPhone
…------------------ Original ------------------
From: jinghanhu ***@***.***>
Date: Fri,Aug 29,2025 2:43 PM
To: modelscope/ms-swift ***@***.***>
Cc: ItGirls ***@***.***>, Mention ***@***.***>
Subject: Re: [modelscope/ms-swift] [init]support gptq grpo in colocate mode(PR #5569)
hjh0119 left a comment (modelscope/ms-swift#5569)
thanks for the contributing! Is this PR ready for review?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
yes, of course.It's ready for review. |
PR type
PR information
support gtpq model in GRPO training mentioned by #3949 , #5372
using vllm colocate mode.
Experiment results
Paste your experiment result here(if needed).