Skip to content
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

⚡ Fix GRPO PEFT #2725

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

⚡ Fix GRPO PEFT #2725

wants to merge 5 commits into from

Conversation

qgallouedec
Copy link
Member

What does this PR do?

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

state_dict = unwrapped_model.state_dict()
if isinstance(unwrapped_model, PeftModel):
unwrapped_model = copy.deepcopy(unwrapped_model)
unwrapped_model.merge_and_unload()
Copy link

@tgaddair tgaddair Jan 31, 2025

Choose a reason for hiding this comment

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

Hey @qgallouedec, just want to flag that this is quite a compute and memory intensive operation, and there may be a better way to do this.

Assuming the underlying Peft model is LoRA, vLLM already supports native dynamic LoRA inference, which can be done like so:

self.llm = LLM(
            ...,
            enable_lora=True,
        )

lora_request = LoRARequest(
     "<unique_str>",
     self.state.global_step,  # needs to be a unique identifier
     lora_path=checkpoint_dir_containing_adapter_weights,
)

outputs = self.llm.generate(
    all_prompts_text,
    sampling_params=self.sampling_params,
    lora_request=lora_request,
    use_tqdm=False
)

Copy link
Member Author

Choose a reason for hiding this comment

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

Wow thanks you so much for the pointer. Let me try this

@gagan3012
Copy link

Hello,
Are there any updates on this PR as this is currently a blocker in my work.

@qgallouedec
Copy link
Member Author

It's WIP, high priority. But if you find a fix in the meantime feel free to controbute 😊

@tgaddair
Copy link

tgaddair commented Feb 1, 2025

Hey @qgallouedec, please see #2730 for a follow-up that implements my suggestion.

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