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

LLM Finetune Functionality #277

Merged
merged 11 commits into from
Aug 24, 2023
Merged

LLM Finetune Functionality #277

merged 11 commits into from
Aug 24, 2023

Conversation

dsikka
Copy link
Contributor

@dsikka dsikka commented Aug 8, 2023

Summary

  • Enable LLM finetuning in sparsify by adding support for the llmfoundry library
  • This is done by adding an additional task called finetune which provides support for all the steps required for llmfoundry finetuning integration
  • Currently, this workflow launches finetuning given a llfoundry compliant yaml file (provided using the --data cli arg to the sparsify command)
  • Exporting steps are currently skipped and as there is no sparseml support atm, in order to allow ddp training, finetune.py includes the steps which can be wrapped in launch_ddp and trainhook
  • As the only essential arg is the data arg containing the yaml file, there are no finetune specific train args but this can be added in as greater finetuneing support is flushed out

Testing

  • A sample yaml can be found under the new samples folder
  • Tested locally using both 1 GPU and for DDP Training
  • The following command was used for testing:
sparsify.run sparse-transfer --use-case finetune --data ../src/sparsify/auto/samples/finetune_llmfoundry_sample.yaml

This produces the following output in the running directory after training is complete.
sparse_transfer_finetune_2023_08_09_01_24_08

All paths from llmfoundry are updated to use the working directory as the root and therefore, the output directory shown above contains the checkpoints and all other llmfoundry-specific outputs.

@dsikka dsikka marked this pull request as ready for review August 8, 2023 23:19
@dsikka dsikka requested a review from eldarkurtic August 9, 2023 13:43
@dsikka
Copy link
Contributor Author

dsikka commented Aug 9, 2023

@eldarkurtic As part of your review, please pay special attention to the fsdp handling to ensure it is being applied how you expect it to. If you can pull down and test a model for accuracy/speed, that would also be appreciated.

Copy link

@Satrat Satrat left a comment

Choose a reason for hiding this comment

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

LGTM overall, just had a few nitpicky comments. I haven't tried running this on machine yet, will give it a go later today

src/sparsify/auto/scripts/main.py Outdated Show resolved Hide resolved
src/sparsify/auto/tasks/runner.py Outdated Show resolved Hide resolved
src/sparsify/auto/tasks/runner.py Outdated Show resolved Hide resolved
src/sparsify/auto/tasks/finetune/runner.py Show resolved Hide resolved
src/sparsify/auto/tasks/finetune/finetune.py Show resolved Hide resolved
src/sparsify/auto/tasks/finetune/finetune.py Outdated Show resolved Hide resolved
src/sparsify/auto/tasks/finetune/finetune.py Outdated Show resolved Hide resolved
src/sparsify/auto/tasks/finetune/finetune.py Outdated Show resolved Hide resolved
Copy link
Member

@bfineran bfineran left a comment

Choose a reason for hiding this comment

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

looks great overall, see few comments

src/sparsify/auto/tasks/finetune/finetune.py Outdated Show resolved Hide resolved
src/sparsify/auto/tasks/finetune/runner.py Show resolved Hide resolved
@dsikka dsikka requested review from bfineran and Satrat August 13, 2023 21:43
src/sparsify/auto/tasks/finetune/__init__.py Outdated Show resolved Hide resolved
src/sparsify/auto/tasks/finetune/finetune.py Outdated Show resolved Hide resolved
src/sparsify/auto/tasks/finetune/finetune.py Outdated Show resolved Hide resolved
src/sparsify/auto/tasks/finetune/finetune.py Outdated Show resolved Hide resolved
src/sparsify/auto/tasks/finetune/finetune.py Outdated Show resolved Hide resolved
src/sparsify/schemas/auto_api.py Outdated Show resolved Hide resolved
src/sparsify/schemas/auto_api.py Outdated Show resolved Hide resolved
@dsikka dsikka requested a review from rahul-tuli August 14, 2023 19:46
Satrat
Satrat previously approved these changes Aug 15, 2023
bfineran
bfineran previously approved these changes Aug 17, 2023
* add functions to mask weights during finetuneing

* update logic for loading weights

* update yaml

* update mask name

* add logic to update batchsize based on gpu count

* make sparsify requirements less broad; move sparseml[transformers] to nm deps

* remove flash-attn

* quality
@dsikka dsikka dismissed stale reviews from bfineran and Satrat via 2409ab8 August 23, 2023 18:50
@dsikka dsikka requested a review from Satrat August 24, 2023 14:13
@dsikka dsikka merged commit 7d5b20d into main Aug 24, 2023
3 checks passed
@dsikka dsikka deleted the llm_finetune branch August 24, 2023 16:36
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.

None yet

4 participants