Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
lewtun
commented
Mar 26, 2024
| response = unwrapped_model.generate(input_ids=query_tensor.unsqueeze(dim=0), **generation_kwargs) | ||
|
|
||
| if generate_ref_response: | ||
| with self.optional_peft_ctx(): |
Member
Author
There was a problem hiding this comment.
I've moved the logic for disabling the adapter to unwrap_model_for_generation()
Also, why did we do the adapter disabling for the reference model but not the active model above?
lewtun
commented
Mar 26, 2024
|
|
||
|
|
||
| @contextmanager | ||
| def unwrap_model_for_generation( |
Member
Author
There was a problem hiding this comment.
I wasn't sure if this belongs in modeling_base.py or as a utility method here - let me know what you prefer!
younesbelkada
approved these changes
Apr 8, 2024
Contributor
younesbelkada
left a comment
There was a problem hiding this comment.
Thanks for 10x-ing PPO Zero-3 🚀
lapp0
pushed a commit
to lapp0/trl
that referenced
this pull request
May 10, 2024
* Speed up PPO by 10x 🔥 * Revert * Clean up * Use relative import * Clean * Fix typing for docs
hiyouga
added a commit
to hiyouga/LlamaFactory
that referenced
this pull request
May 28, 2024
github-merge-queue Bot
pushed a commit
to deepspeedai/DeepSpeed
that referenced
this pull request
Aug 16, 2024
Gives the ability to add and remove the forward hooks in ZeRO 3 by using a context manager. These code changes were taken from a Huggingface [PR](huggingface/trl#1617) and integrated for direct support in DeepSpeed. This is useful in the inference case and the speedup can be observed [here](huggingface/trl#1483). --------- Co-authored-by: root <root@deepspeed-c000004.2d1icxc5dsxehnpuwt3ifc34ph.gvxx.internal.cloudapp.net> Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com> Co-authored-by: Heyang Qin <heyangqin@microsoft.com> Co-authored-by: Logan Adams <loadams@microsoft.com>
Merged
5 tasks
4 tasks
mauryaavinash95
pushed a commit
to DataStates/DeepSpeed
that referenced
this pull request
Mar 20, 2025
Gives the ability to add and remove the forward hooks in ZeRO 3 by using a context manager. These code changes were taken from a Huggingface [PR](huggingface/trl#1617) and integrated for direct support in DeepSpeed. This is useful in the inference case and the speedup can be observed [here](huggingface/trl#1483). --------- Co-authored-by: root <root@deepspeed-c000004.2d1icxc5dsxehnpuwt3ifc34ph.gvxx.internal.cloudapp.net> Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com> Co-authored-by: Heyang Qin <heyangqin@microsoft.com> Co-authored-by: Logan Adams <loadams@microsoft.com>
5 tasks
yxliu-TAMU
pushed a commit
to mincheolseong/ECEN743-GRPO-Project-Proposal
that referenced
this pull request
Apr 20, 2025
* Speed up PPO by 10x 🔥 * Revert * Clean up * Use relative import * Clean * Fix typing for docs
yoonseok312
pushed a commit
to pensieve-ai/LLaMA-Factory-vlm
that referenced
this pull request
Apr 29, 2025
huggingface/trl#1483 Former-commit-id: 65cd8bd
liu-qingyuan
pushed a commit
to liu-qingyuan/LLaMA-Factory-Megafake
that referenced
this pull request
Jun 6, 2025
huggingface/trl#1483 Former-commit-id: 65cd8bd
zhongwei1968
pushed a commit
to zhongwei1968/LLaMA-Factory
that referenced
this pull request
Aug 1, 2025
nmh21207525
pushed a commit
to nmh21207525/pwd_memory_task
that referenced
this pull request
Jan 3, 2026
huggingface/trl#1483 Former-commit-id: 5dc43ba8b373d8803bc22d88b3d0d95ef8b9c7f8
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In PPO, text generation is the main bottleneck and especially so with ZeRO-3 where weights are sharded across N devices and need to be gathered for each forward pass.
This PR introduces a new context manager called
unwrap_model_for_generation()which does a single gather of the model weights to speed up theppo.pyexample script by ~10x relative to naive ZeRO-3 inference. Thank you to @pacman100 for showing me this feature ofdeepspeed🙏 !Note: this context manager is entirely general and can be used in other trainers. For now I've focused on PPO, but happy to roll it out to the other parts of the codebase in follow-up PRs.
As they say, a picture is worth a 1000 words and here's the comparisons against DDP / ZeRO-2 and naive ZeRO-3:
Code to test with
I've checked the script below works with DDP, DDP + LoRA, ZeRO-2, and ZeRO-3:
Inference script
Addresses the speed issue discussed in #1051