-
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
🔬 SFT simplification #2405
base: main
Are you sure you want to change the base?
🔬 SFT simplification #2405
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. |
# This should not work because not enough data for one sample | ||
training_args = SFTConfig( | ||
output_dir=tmp_dir, | ||
dataloader_drop_last=True, | ||
max_steps=2, | ||
eval_steps=1, | ||
save_steps=1, | ||
per_device_train_batch_size=2, | ||
max_seq_length=1024, # make sure there is NOT at least 1 packed sequence | ||
packing=True, | ||
report_to="none", | ||
) | ||
with self.assertRaises(ValueError): | ||
_ = SFTTrainer( | ||
model=self.model, | ||
args=training_args, | ||
train_dataset=self.dummy_dataset, | ||
formatting_func=formatting_prompts_func, | ||
) | ||
|
||
# This should not work as well | ||
with self.assertRaises(ValueError): | ||
training_args = SFTConfig( | ||
output_dir=tmp_dir, | ||
dataloader_drop_last=True, | ||
max_steps=2, | ||
eval_steps=1, | ||
save_steps=1, | ||
per_device_train_batch_size=2, | ||
packing=False, | ||
report_to="none", | ||
) | ||
_ = SFTTrainer( | ||
model=self.model, | ||
args=training_args, | ||
train_dataset=self.dummy_dataset, | ||
formatting_func=formatting_prompts_func, | ||
) | ||
|
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 new implementation extend the support for these two cases
@@ -807,8 +768,6 @@ def test_sft_trainer_infinite_with_model(self): | |||
eval_dataset=self.eval_dataset, | |||
) | |||
|
|||
self.assertTrue(trainer.train_dataset.infinite) |
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 trainer is not "infinite" (subclass of ConstantLenghtDataset
) anymore: it's better since we can use num_epochs now
FSDP + QLora from https://github.com/huggingface/peft/blob/main/examples/sft/run_peft_qlora_fsdp.sh green: main |
* First changes * Other files * Finally * rm comment * fix nashmd * Fix example * Fix example [ci skip]
* fix chat for windows * add some tests back * Revert "add some tests back" This reverts commit 350aef5.
* datast_config_name * Update trl/utils.py [ci skip] * sort import * typo [ci skip] * Trigger CI * Rename `dataset_config_name` to `dataset_config`
* Remove unused deepspeed code * add model prep back * add deepspeed even if it doesn't work * rm old code
* `model_config` -> `model_args` * sort
What does this PR do?
Context
This PR is the first iteration of SFT refactoring: tests have deliberately been left unmodified, to ensure continuity of support for the user and, if possible, no breaking changes.
Other PRs will follow to further simplify the SFT (to be discussed on a case-by-case basis). These modifications would require test modifications and breaking changes. For example:
ConstantLengthDataset
in favor of thepacking
argument alone.TrainingArguments
and imposeSFTConfig
.What's in this PR
This PR refactor and simplifies SFT.
Add full conversational/standard dataset support
Part of #2071
Refactor packing
Drop
ConstantLengthDataset
in favour of a simpler approach (seepack_examples
)Current status
Testing. The goal is to gather code example from anywhere and ensure there're still working.
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.