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

📦 Support for packing tokenized datasets for SFT #2011

Merged
merged 3 commits into from
Nov 25, 2024

Conversation

kmehant
Copy link
Contributor

@kmehant kmehant commented Sep 3, 2024

What does this PR do?

Fixes #1848

Before submitting

Who can review?

@qgallouedec

Anyone from the community!

@kmehant kmehant changed the title feat: add support for packing tokenized datasetS feat: add support for packing tokenized datasets Sep 3, 2024
@kmehant
Copy link
Contributor Author

kmehant commented Sep 22, 2024

Anyone having bandwidth, requesting review thank you - @qgallouedec @lewtun @kashif @lvwerra or others from community.

Discussion can be seen here - #1848

Copy link
Member

@lewtun lewtun left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @kmehant ! Overall it looks good to me - would you mind adding an integration test for this scenario?

trl/trainer/sft_trainer.py Outdated Show resolved Hide resolved
trl/trainer/utils.py Outdated Show resolved Hide resolved
trl/trainer/utils.py Outdated Show resolved Hide resolved
@HuggingFaceDocBuilderDev

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.

@kmehant
Copy link
Contributor Author

kmehant commented Oct 2, 2024

@lewtun Thank you for your review. I have addressed the review comments and as well added the test cases. Thank you.

@kmehant kmehant requested a review from lewtun October 2, 2024 06:38
@kmehant kmehant force-pushed the pack-pretok branch 4 times, most recently from 0d0f34c to c689f24 Compare October 9, 2024 04:26
@kmehant kmehant force-pushed the pack-pretok branch 2 times, most recently from 95113ee to 25b997d Compare October 24, 2024 04:23
@kmehant
Copy link
Contributor Author

kmehant commented Oct 24, 2024

Screenshot 2024-10-24 at 10 14 30 AM

@lewtun @qgallouedec apologies for the failing tests before. Tests passing now for me locally! Thank you.

@kmehant
Copy link
Contributor Author

kmehant commented Oct 29, 2024

@lewtun @qgallouedec rebased looking for escalation, thanks.

@kmehant kmehant force-pushed the pack-pretok branch 3 times, most recently from b13e324 to 3e9110b Compare November 8, 2024 05:33
@kmehant
Copy link
Contributor Author

kmehant commented Nov 12, 2024

@lewtun @qgallouedec pulse pinging for review and merge, thank you.

Signed-off-by: Mehant Kammakomati <mehant.kammakomati2@ibm.com>
Signed-off-by: Mehant Kammakomati <mehant.kammakomati2@ibm.com>
@kmehant
Copy link
Contributor Author

kmehant commented Nov 25, 2024

@lewtun @qgallouedec it will be of great help pushing this forward before it gets into stale state for being open for a long time after having a positive discussion over the issue #1848 with @qgallouedec.

If you would like to tag anyone else from the community who have bandwidth basing on our discussion over the issue (#1848) would be nice!

constant_len_dataset = ConstantLengthDataset(
self.tokenizer,
self.dummy_tokenized_dataset,
dataset_text_field=None,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
dataset_text_field=None,

Comment on lines 134 to 139
"content": [
{
"type": "text",
"text": "Oh ye, you are right, what is 1+1",
}
],
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"content": [
{
"type": "text",
"text": "Oh ye, you are right, what is 1+1",
}
],
"content": [{"type": "text", "text": "Oh ye, you are right, what is 1+1"}],

@qgallouedec
Copy link
Member

Sorry for the delay. I'm trying to keep track of all these issues but it's not easy.

Lgtm overall, thanks. Just making a few comments

Signed-off-by: Mehant Kammakomati <mehant.kammakomati2@ibm.com>
@kmehant
Copy link
Contributor Author

kmehant commented Nov 25, 2024

@qgallouedec Thank you for circling back, I have addressed your comments.

@kmehant kmehant requested a review from qgallouedec November 25, 2024 08:44
@qgallouedec qgallouedec changed the title feat: add support for packing tokenized datasets 📦 Support for packing tokenized datasets for SFT Nov 25, 2024
@qgallouedec qgallouedec merged commit 17e8060 into huggingface:main Nov 25, 2024
13 checks passed
dushyantbehl added a commit to dushyantbehl/fms-hf-tuning that referenced this pull request Nov 29, 2024
Remove packing check as packing support for pretokenised data is merged
to trl. See huggingface/trl#2011

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>
dushyantbehl added a commit to dushyantbehl/fms-hf-tuning that referenced this pull request Dec 2, 2024
Remove packing check as packing support for pretokenised data is merged
to trl. See huggingface/trl#2011

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>
dushyantbehl added a commit to dushyantbehl/fms-hf-tuning that referenced this pull request Dec 3, 2024
Remove packing check as packing support for pretokenised data is merged
to trl. See huggingface/trl#2011

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>
willmj added a commit to foundation-model-stack/fms-hf-tuning that referenced this pull request Dec 3, 2024
* Add initial implementation of dataloader v1

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>

* tests: reformat mock.patch to inside unit tests

Signed-off-by: Will Johnson <mwjohnson728@gmail.com>

fmt

Signed-off-by: Will Johnson <mwjohnson728@gmail.com>

* Add data config argument to data preprocessor

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>

* fix: Changes to support current implementation

Signed-off-by: Abhishek <maurya.abhishek@ibm.com>

* Ensure data handling is done within process dataargs
Removes unused dead code after adding the new framework and refactors
some test cases and files.

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>

* Remove accelerator in favor of torch distributed check for multi node
data preprocessing

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>

* Refactor data util tests as data handler tests.

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>

* fix: add __init__.py to add tuning.data to python package

Signed-off-by: Will Johnson <mwjohnson728@gmail.com>

* fix: multi GPU prepare training dataset

Signed-off-by: Will Johnson <mwjohnson728@gmail.com>

* fix: lint

Signed-off-by: Will Johnson <mwjohnson728@gmail.com>

* fix: Add TODO

Signed-off-by: Will Johnson <mwjohnson728@gmail.com>

* test: add test for process_dataset_configs in HFBasedDataPreProcessor

Signed-off-by: Will Johnson <mwjohnson728@gmail.com>

* add: test cases for framework

Signed-off-by: Abhishek <maurya.abhishek@ibm.com>

* fix: update function name get_dataprocessor->get_datapreprocessor

Signed-off-by: Will Johnson <mwjohnson728@gmail.com>

* Rename loader to processor

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>

* data folders should be together

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>

* Add code comments and make code path clearer.
Remove packing check as packing support for pretokenised data is merged
to trl. See huggingface/trl#2011

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>

---------

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>
Signed-off-by: Will Johnson <mwjohnson728@gmail.com>
Signed-off-by: Abhishek <maurya.abhishek@ibm.com>
Co-authored-by: Will Johnson <mwjohnson728@gmail.com>
Co-authored-by: Abhishek <maurya.abhishek@ibm.com>
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.

Support packing for pretokenized datasets
4 participants