-
Notifications
You must be signed in to change notification settings - Fork 600
Support GRPO #3146
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
Open
tastelikefeet
wants to merge
8
commits into
InternLM:main
Choose a base branch
from
tastelikefeet:feat/reload_state_dict
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Support GRPO #3146
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bb6d2e7
support specify device and reload state dict
tastelikefeet 5d3058b
change func name
tastelikefeet 1ac28e4
fix loading
tastelikefeet 0c6b188
Merge branch 'main' into feat/reload_state_dict
tastelikefeet 8429b91
fix
tastelikefeet 916217e
fix device_id
tastelikefeet b1fda51
lint code
tastelikefeet fc6a499
Merge commit 'f6f7a5d707e3ccbc69af10babf1c9afcaf72a402' into feat/rel…
tastelikefeet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
import json | ||
import os | ||
import os.path as osp | ||
import re | ||
from abc import ABC, abstractmethod | ||
from collections import defaultdict | ||
from collections import OrderedDict, defaultdict | ||
from functools import partial | ||
from glob import glob | ||
from typing import Iterator, Tuple | ||
|
@@ -145,6 +146,31 @@ def items(self): | |
|
||
|
||
def create_loader(model_path: str, pattern: str) -> BaseLoader: | ||
if not isinstance(model_path, (str, os.PathLike)): | ||
|
||
def generate(): | ||
generator = OrderedDict() | ||
model_dict = {} | ||
if not isinstance(model_path, dict): | ||
for key, value in list(model_path): | ||
model_dict[key] = value | ||
else: | ||
model_dict = model_path | ||
for key, value in model_dict.items(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
match = re.findall(pattern, key) | ||
if not match: | ||
if -1 not in generator: | ||
generator[-1] = {} | ||
generator[-1][key] = value | ||
else: | ||
layer = int(match[0]) | ||
if layer not in generator: | ||
generator[layer] = {} | ||
generator[layer][key] = value | ||
return generator | ||
|
||
return generate() | ||
|
||
args = (model_path, pattern) | ||
|
||
if osp.exists(osp.join(model_path, SAFE_WEIGHT_INDEX_NAME)): | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we specify the cuda devices by the env var CUDA_VISIBLE_DEVICES?
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.
No, trl will specify which GPU to load the model:
https://github.com/huggingface/trl/blob/main/trl/trainer/grpo_trainer.py#L416
Uh oh!
There was an error while loading. Please reload this page.
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.
https://github.com/vllm-project/vllm/blob/d0a7a2769d92619afdcdc3b91c78098eaa9e38c0/vllm/engine/arg_utils.py#L718
According to vllm's EngineArgs definition, the value of
device
can be one of the following:I haven't found a case to build the vllm engine with specifying device ids
Could you please provide an example?