Repository navigation
[SimpleFSDP] Add support for hsdp+tp - #1343
Conversation
dc82ddf to
cbd4fd1
Compare
| target_spec=target_spec, | ||
| ) | ||
|
|
||
| for placement in placements: |
There was a problem hiding this comment.
Instead of doing this for loop over placements (which tries to be generic but actually hard to make every possible case correct), let's be more explicit about the 3 types DP / FSDP / HSDP, where there is at most 1 replicate dim, and at most 1 shard dim.
I think we can just have three if-else conditions (instead of DP / FSDP before), and one redistribute_local_tensor outside, just like before.
The FSDP2 code for dealing with HSDP is also here, for your reference
https://github.com/pytorch/pytorch/blob/dfef1e44085bb156abc4aff0f34a0b82a4a337b8/torch/distributed/fsdp/_fully_shard/_fsdp_param.py#L324
cbd4fd1 to
fe081b9
Compare
tianyu-l
left a comment
There was a problem hiding this comment.
There are two high level things this function does:
- do the actual sharding
Replicate->placements[-1](index is 1 if 2D, 0 if 1D) - figure out what the
DTensorSpecshould be for the returned DTensor.
I suggest we don't mix up the two, as in the previous implementation you are first doing 2 and then 1.
fe081b9 to
de47d6c
Compare
de47d6c to
e174cbb
Compare
tianyu-l
left a comment
There was a problem hiding this comment.
LGTM!
Recently I modified FSDP2 code to support FSDP + EP + TP. pytorch/pytorch#157216
I think for _distributed_tensor we can do the same thing. However, for ReplicateComputation there needs to be bigger change.
We can discuss how to support them in later.
Sounds good! Excited to have EP in simplefsdp! |
As titled, this pr adds support for SimpleFSDP's HSDP + TP The profile trace below shows the three streams for FSDP's All-gather/Reduce-scatter; DDP's All-reduce; and TP's communications. <img width="1499" alt="Screenshot 2025-06-25 at 8 13 39 PM" src="https://github.com/user-attachments/assets/4d9a7561-8895-48e6-b728-bcc1f95d8f2c" /> The loss below shows SimpleFSDP & FSDP2's losses matches under HSDP + TP mode (seed=42). <img width="1521" alt="Screenshot 2025-06-25 at 8 27 11 PM" src="https://github.com/user-attachments/assets/b497c1f9-a766-4a00-9e42-cbc8ce1ca1b8" />
As titled, this pr adds support for SimpleFSDP's HSDP + TP The profile trace below shows the three streams for FSDP's All-gather/Reduce-scatter; DDP's All-reduce; and TP's communications. <img width="1499" alt="Screenshot 2025-06-25 at 8 13 39 PM" src="https://github.com/user-attachments/assets/4d9a7561-8895-48e6-b728-bcc1f95d8f2c" /> The loss below shows SimpleFSDP & FSDP2's losses matches under HSDP + TP mode (seed=42). <img width="1521" alt="Screenshot 2025-06-25 at 8 27 11 PM" src="https://github.com/user-attachments/assets/b497c1f9-a766-4a00-9e42-cbc8ce1ca1b8" />
As titled, this pr adds support for SimpleFSDP's HSDP + TP The profile trace below shows the three streams for FSDP's All-gather/Reduce-scatter; DDP's All-reduce; and TP's communications. <img width="1499" alt="Screenshot 2025-06-25 at 8 13 39 PM" src="https://github.com/user-attachments/assets/4d9a7561-8895-48e6-b728-bcc1f95d8f2c" /> The loss below shows SimpleFSDP & FSDP2's losses matches under HSDP + TP mode (seed=42). <img width="1521" alt="Screenshot 2025-06-25 at 8 27 11 PM" src="https://github.com/user-attachments/assets/b497c1f9-a766-4a00-9e42-cbc8ce1ca1b8" />
As titled, this pr adds support for SimpleFSDP's HSDP + TP
The profile trace below shows the three streams for FSDP's All-gather/Reduce-scatter; DDP's All-reduce; and TP's communications.
The loss below shows SimpleFSDP & FSDP2's losses matches under HSDP + TP mode (seed=42).