-
Notifications
You must be signed in to change notification settings - Fork 490
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
[WIP] Add 2D Parallelism (FSDP + Tensor Parallel) LoRA #2204
base: main
Are you sure you want to change the base?
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchtune/2204
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
This is really cool and awesome addition to our library!! As discussed in a few of our issues (#2018, etc), this is something we are very eager to add soon. I'll take a look over your implementation and the outstanding concerns and lyk any high-level comments. Obviously, most people on the team are off for the holidays so we'll look to get this land-able, but will likely be sometime early Jan. Last point, do you mind if I help work on this, too? Your contributions will 100% not be lost in anything that gets landed :) |
Awesome, sounds great :) |
Context
What is the purpose of this PR?
Changelog
What are the changes made in this PR?
lora_finetune_distributed.py
DTensor
like in torchtitan for easy-to-understand device_mesh shardingDistributedSampler
to shard data along "dp" dimensionLoRALinear
to remap naming so that the Tensor Parallel layer_plan can target the main model weightsTest plan
Please make sure to do each of the following if applicable to your PR. If you're unsure about any one of these just ask and we will happily help. We also have a contributing page for some guidance on contributing.
pre-commit install
)Successful run commands:
Llama-3.1-8B-Instruct on a single 8xH100 Node (FSDP=1, TP=8)
Llama-3.3-70B-Instruct on two 8xH100 Nodes (FSDP=2, TP=8)
Limitations
Although the above run commands work (loss goes down at reasonable rate for low batch size and/or gradient accumulation), I found that many features did not quite work with this 2D parallelism yet. And there are other concerns with the code as it stands:
[W1223 03:00:54.225759032 Functional.cpp:46] Warning: At the time of process termination, there are still 2528 unwaited c10d_functional collective calls. Please review your program to ensure c10d_functional.wait_tensor() is invoked on all tensors returned from c10d_functional collective ops before they are used. (function ~WorkRegistry)
DTensor
has issues with torch compile so setcompile=False
. Ideally this will get fixed since compile is a pure win.dataset.packed=True
combined withtokenizer.max_seq_len
UX
Acknowledgments
Thanks to @akashc1 for helping make this work!!