Repository navigation
Fix tiled MLP for ZeRO-3 and FSDP - #1000
Conversation
|
Hi @kashif, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/huggingface/kernels-community/blob/main/CONTRIBUTING.md for more details. |
|
/kernel-bot build liger-kernels |
|
Build request processed. Command: Dispatched (1):
|
|
/kernel-bot merge-and-upload liger-kernels |
|
Build request processed. Command: Merge result: PR is already merged. Continuing with build/upload. Dispatched (1):
|
|
thanks @danieldk happy to help! |
The tiled MLP kernel passes
compute_paramsthrough but never uses it, and computesnum_shardslocally on each rank. Both bite under sharded-parameter backends:ds_idlands in the reduction bucket twice and it asserts.num_shards, so they issue a different number of weight all-gathers and hang.This ports the fixes that DeepSpeed's own TiledMLP uses:
param.ds_grad_is_ready = Falsefor every shard except the last (gated on theds_idmarker, so non-ZeRO backends are untouched).apply_tiled_mlp, all-reducenum_shardsto the per-rank max when distributed, so every rank runs the same number of shards.Same fix is going into linkedin/Liger-Kernel. Verified there on 2x H100: tiled gradients match a non-tiled reference under FSDP2 and DeepSpeed ZeRO-3 (with and without gradient checkpointing). No change for single-GPU or non-distributed runs.