-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
👮 Deprecate policy
in favor of model
in PPOTrainer
#2386
Conversation
if module is not None: | ||
disable_dropout_in_model(module) | ||
if args.stop_token and args.stop_token == "eos": | ||
args.stop_token_id = processing_class.eos_token_id | ||
self.model = PolicyAndValueWrapper(self.policy, self.value_model) |
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.
model
replaced by policy_and_value
policy
replaced by model
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. |
def __init__( | ||
self, | ||
config: PPOConfig, | ||
processing_class: Optional[ | ||
Union[PreTrainedTokenizerBase, BaseImageProcessor, FeatureExtractionMixin, ProcessorMixin] | ||
], | ||
policy: nn.Module, | ||
ref_policy: Optional[nn.Module], | ||
model: nn.Module, |
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.
If I'm not mistaken, won't this breaking change be introduced in the next TRL release (i.e. v0.13.0
instead of 0.150
)? In other words, don't we technically need to support both sets of args until v0.15
?
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.
The decorator allows for supporting both args, and when the old one is used, raises a warning:
>>> from datasets import load_dataset
>>> from transformers import AutoModelForCausalLM, AutoModelForSequenceClassification, AutoTokenizer
>>> from trl import PPOConfig, PPOTrainer
>>> args = PPOConfig("my_out_dir")
>>> tokenizer = AutoTokenizer.from_pretrained("EleutherAI/pythia-1b-deduped")
>>> model = AutoModelForCausalLM.from_pretrained("EleutherAI/pythia-1b-deduped")
>>> ref_model = AutoModelForCausalLM.from_pretrained("EleutherAI/pythia-1b-deduped")
>>> reward_model = AutoModelForSequenceClassification.from_pretrained("EleutherAI/pythia-1b-deduped", num_labels=1)
>>> value_model = AutoModelForSequenceClassification.from_pretrained("EleutherAI/pythia-1b-deduped", num_labels=1)
>>> dataset = load_dataset("trl-internal-testing/descriptiveness-sentiment-trl-style", split="descriptiveness")
>>> trainer = PPOTrainer(
... config=args,
... processing_class=tokenizer,
... policy=model, # old arg here
... ref_model=ref_model,
... reward_model=reward_model,
... value_model=value_model,
... train_dataset=dataset,
... )
/fsx/qgallouedec/transformers/src/transformers/utils/deprecation.py:165: FutureWarning: `policy` is deprecated and removed starting from version 0.15.0 for `PPOTrainer.__init__`. Use `model` instead.
return func(*args, **kwargs)
Did I misunderstand your point?
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.
Ah I was mistaken indeed. This looks great then!
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.
Overall LGTM, but I have a concern this will break the trainer in the next release instead of the desired v0.15
. I realise this trainer isn't used much, so it's probably OK to break across revisions in the interest of reaching stability long-term
What does this PR do?
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines.
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.