Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fa22d15
Load the dense part sharded, and size the load warmup to each rank
shengliangxu Oct 30, 2026
c599d3a
Import the dense-sharding helpers' modules at the top of the file
shengliangxu Oct 29, 2026
8a5b142
Keep the dense-sharding helpers' docs to what a maintainer needs
shengliangxu Oct 29, 2026
edc01c9
Fail every rank when one fails preparing the meta-DCP load
shengliangxu Oct 29, 2026
5b4a562
Load the EP dense shards on the mesh's device, and say so briefly
shengliangxu Oct 29, 2026
c650ffc
Load both aliases of a tied param in the EP dense load
shengliangxu Oct 29, 2026
bdfc310
Import safetensors at the top of the dense-sharding tests
shengliangxu Oct 29, 2026
9310223
Check for missing gradients before the EP test's collective comparisons
shengliangxu Oct 30, 2026
108b0af
Hand the meta-DCP load's prepared state over by name
shengliangxu Oct 30, 2026
fcdf89d
Import the layer-wildcard helper from either transformers location
shengliangxu Oct 30, 2026
0a26865
Refuse a sharded dense part that from_pretrained did not leave on meta
shengliangxu Oct 30, 2026
0c15827
Warn when the EP-aware warmup sizing falls back to transformers' own
shengliangxu Oct 30, 2026
0fa56e0
Say why _fsdp2_wrap_modules imports where it does
shengliangxu Oct 30, 2026
3f5406b
Stand in a list for the unplaced keys in the dense-meta refusal test
shengliangxu Oct 30, 2026
612433b
Import the dense-wrap helpers at module scope
shengliangxu Oct 30, 2026
b2172ba
Warn when the warmup sizing hook has other parameters, and name EP_DE…
shengliangxu Oct 30, 2026
e8b529b
Say which VLMs keep their vision blocks unwrapped, and which buffers …
shengliangxu Oct 30, 2026
210c41d
Move the dense-sharding and warmup tests into test_model_load_utils.py
shengliangxu Oct 30, 2026
73d3629
Materialize the sharded dense part on the GPU each rank is bound to
shengliangxu Oct 31, 2026
ee76717
Fail every rank when one rank fails to wrap the sharded dense part
shengliangxu Oct 31, 2026
d3616e9
Say so when transformers has no warmup sizing hook to replace
shengliangxu Oct 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions modelopt/torch/utils/fsdp2_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ def _move_to_fsdp_device(model, params: set[torch.nn.Parameter]) -> None:
def fsdp2_wrap(model, shard_root=True, mp_policy=None, cpu_offload: bool = False):
"""Auto-detect a HF causal-LM's decoder layers and FSDP2 ``fully_shard`` each one.

Its callers load causal LMs and text-only VLMs; the expert-parallel dense load, which also takes
VLMs, picks its blocks through
:func:`~modelopt.torch.utils.plugins.model_load_utils._fsdp2_wrap_modules`, keeping a vision
tower replicated.

By default (``shard_root=True``) the root module is wrapped too, so embed/lm_head/norm are
sharded instead of replicated per rank; pass ``shard_root=False`` to leave the root replicated
(only decoder layers sharded). Returns the detected decoder layers so callers can reuse the
Expand Down
Loading
Loading