Skip to content

Conversation

@tpoisonooo
Copy link

Content

Add an FSDP example for Muon optimizer.

Here is the difference:

  1. Add DistributedSampler
    sampler = DistributedSampler(dataset=train_dataset,
                                 rank=rank,
                                 num_replicas=world_size,
                                 shuffle=True)
  1. Add all reduce
dist.all_reduce(loss, op=dist.ReduceOp.AVG)

Test

loss:
image

GPU usage:

image

I am also a FSDP begginer, for any question, I would try to fix. #25

@tpoisonooo
Copy link
Author

cc @toothacher17

@tpoisonooo
Copy link
Author

tpoisonooo commented Apr 28, 2025

Furthermore, toy_train_fsdp.py is compatible with toy_train.py, for single GPU, just:

export CUDA_VISIBLE_DEVICES="0"
python3 toy_train_fsdp.py

They are same.

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.

1 participant