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
eeb2e16
Load the dense part sharded, and size the load warmup to each rank
shengliangxu Oct 30, 2026
fd89630
Import the dense-sharding helpers' modules at the top of the file
shengliangxu Oct 29, 2026
1c37cac
Keep the dense-sharding helpers' docs to what a maintainer needs
shengliangxu Oct 29, 2026
31152c7
Fail every rank when one fails preparing the meta-DCP load
shengliangxu Oct 29, 2026
e5cc54e
Load the EP dense shards on the mesh's device, and say so briefly
shengliangxu Oct 29, 2026
b7c6827
Load both aliases of a tied param in the EP dense load
shengliangxu Oct 29, 2026
4c16666
Import safetensors at the top of the dense-sharding tests
shengliangxu Oct 29, 2026
85c48fd
Check for missing gradients before the EP test's collective comparisons
shengliangxu Oct 30, 2026
f77ada2
Hand the meta-DCP load's prepared state over by name
shengliangxu Oct 30, 2026
f3ea182
Import the layer-wildcard helper from either transformers location
shengliangxu Oct 30, 2026
136ca74
Refuse a sharded dense part that from_pretrained did not leave on meta
shengliangxu Oct 30, 2026
a906c3a
Warn when the EP-aware warmup sizing falls back to transformers' own
shengliangxu Oct 30, 2026
cd06541
Say why _fsdp2_wrap_modules imports where it does
shengliangxu Oct 30, 2026
658932c
Stand in a list for the unplaced keys in the dense-meta refusal test
shengliangxu Oct 30, 2026
4e0cd27
Import the dense-wrap helpers at module scope
shengliangxu Oct 30, 2026
2fd4411
Warn when the warmup sizing hook has other parameters, and name EP_DE…
shengliangxu Oct 30, 2026
b3198d8
Say which VLMs keep their vision blocks unwrapped, and which buffers …
shengliangxu Oct 30, 2026
44f34b1
Move the dense-sharding and warmup tests into test_model_load_utils.py
shengliangxu Oct 30, 2026
9fa6231
Materialize the sharded dense part on the GPU each rank is bound to
shengliangxu Oct 31, 2026
8dc6aa7
Fail every rank when one rank fails to wrap the sharded dense part
shengliangxu Oct 31, 2026
7ea4ac7
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