Repository navigation
[OMNIML-6083] Write a sharded model's HF checkpoint without gathering it #2752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shengliangxu
wants to merge
42
commits into
shengliangx/hfep-base-12c-nogather-export
Choose a base branch
from
shengliangx/hfep-12c-nogather-export
base: shengliangx/hfep-base-12c-nogather-export
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
4f33f20
Carry the per-rank expert split the no-gather writer calls
shengliangxu afe23a9
Write a sharded model's HF checkpoint without gathering it
shengliangxu 3de2041
Pick the HF export's route by the model's distribution plan
shengliangxu 3f2ce92
Record the plan the no-gather export tests wrap their models by
shengliangxu 95f0b1a
Note in the changelog that a distributed model must carry its plan
shengliangxu 7413183
File the no-gather export entries under 0.49.0 in the changelog
shengliangxu 4ef871b
Run the no-gather writer's two-rank test on the shared gloo workers
shengliangxu 4283681
Expect the cross-rank name collision on every rank in the two-rank wr…
shengliangxu c97f616
Guard the fused-expert fold's FSDP2 window with a real export
shengliangxu 6ba1e4a
Check on CPU what the GPU-only no-gather export tests checked
shengliangxu 4e0157f
Trim the no-gather export's tests: fold its end-to-end cases, drop co…
shengliangxu 98dda9a
Run the writer's input-scale reduce on the CPU under a gloo-only group
shengliangxu 3b6066e
Check the extra tensors' overlap inside a collective every rank joins
shengliangxu 34d62b8
Drop the export config helper's second generation-config write
shengliangxu 39a8398
Join the extra tensors' overlap check on every rank, holding extras o…
shengliangxu aa4814e
Say what picks the no-gather writer in the distributed export test
shengliangxu 87304a9
Resolve a mixed-precision KV cache on the no-gather export, and take …
shengliangxu 0e0c496
Keep the no-gather export's quant config names in step with its weights
shengliangxu ef9af9f
Copy only inference tensors before the no-gather export's transfer
shengliangxu 59d543d
Drop get_max_batch_size from the changelog's plan-required entry
shengliangxu 3ee4765
Save the ModelOpt state from the no-gather export, as the streaming e…
shengliangxu 32b2ec5
Agree on the expert input-scale keys before the writer reduces them
shengliangxu b921ae2
Keep the blank line ruff format wants before the carried-tensors comment
shengliangxu 4b404ad
Keep each merge group on one rank in the no-gather export
shengliangxu 1f318dc
Refuse a MODELOPT_FSDP2_EXPORT value the export does not know
shengliangxu 8b2e412
Test that an uneven inference-mode shard is written with its global s…
shengliangxu 1159619
Drop the no-gather arm's unused tied-weight map
shengliangxu 2926d00
Use the writer's module-scope imports in the no-gather export
shengliangxu f22b9dc
Record the plan hf_ptq's FSDP2 load shards the model by
shengliangxu 30ecd64
Raise a calibration out-of-memory error for a model over several ranks
shengliangxu c9ffe80
Say who records the plan the export reads, now that the loader does not
shengliangxu d43544f
Say the no-gather export does not overwrite an earlier checkpoint
shengliangxu 5bfe811
Restore the full stop the no-gather README note lost
shengliangxu 23c0b55
Record the plan in the GPU tests that export a model they shard by hand
shengliangxu db65c36
Say what sets keep_fused_experts now that the no-gather export does
shengliangxu c167a6a
Drop the expert-parallel scaffolding the FSDP2 writer never sets
shengliangxu c57a8cf
Import the writer's helpers at module scope, and say why the writer i…
shengliangxu 4ce6a49
Patch the state-dict read where the writer now imports it
shengliangxu f6dfb95
Write the no-gather export's config files with save_non_weight_artifacts
shengliangxu 7c5955d
Number the local split's experts by their FSDP2 offset alone
shengliangxu 55f0bd9
Leave AWQ out of the README's list of calibrations refused when quant…
shengliangxu ac29323
Fix stale comments on the carried tensors, consolidation and EP
shengliangxu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[SUGGESTION] This recording closes the CI gap I raised last pass (the two GPU suites now record their own plans), so the slice stands on its own. What's left is that the plan is recorded by every caller of
parallel_load_and_prepare_fsdp2rather than by the loader, and the identical one-liner now appears at three sites, all immediately after the loader returns:examples/hf_ptq/hf_ptq.py:344tests/gpu/torch/utils/test_model_load_utils.py:68and:114fsdp2_wrapsites intests/gpu/torch/export/test_export_carry_over.py)Two things follow:
parallel_load_and_prepare_fsdp2is public (modelopt.torch.utils.plugins.model_load_utils) and is the only distributed loader ModelOpt ships today. A library caller that pairs it withexport_hf_checkpointnow getsRuntimeError: ... is FSDP2-sharded, but has no distribution plan recorded, and the remedy is the exact line above. The loader knowsworld_sizeand that it FSDP2-shards (fsdp2_wrapatmodel_load_utils.py:845), soset_distribution_plan(model, DistributionPlan(world_size, dense="fsdp"))inside it would serve all three call sites and leave nothing for users to remember. Note that would then need this call dropped, sinceset_distribution_planrefuses to record twice.resolve_distribution_plan's docstring (model_load_utils.py:1103) already asserts the loader-side contract — "a distributed load loads the model by the plan this returns and records it on the model" — which no shipped loader satisfies. A reader of that docstring will not expect to need this line. Either record in the loader, or soften that sentence to say which loaders record and which do not, matching the CHANGELOG entry that now namesparallel_load_and_prepare_fsdp2as recording none.Non-blocking: the behaviour is documented under Backward Breaking Changes and the error names the fix, so this is a duplication/discoverability point, not a defect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving the recording with the callers.
load_pretrainedthe one place a load records its plan. Its FSDP2 route callsparallel_load_and_prepare_fsdp2(_load_sharded) and then records the plan it resolved, once, at the end of every load. If the loader recorded the plan as well, that record would hitset_distribution_plan's record-once refusal.parallel_load_and_prepare_fsdp2directly (hf_ptq, until [OMNIML-6085] [3/3] Run expert-parallel PTQ from hf_ptq.py #2754 moves it ontoload_pretrained, and that GPU test), plus the hand-fsdp2_wraptests.resolve_distribution_plandocstring. It describesload_pretrained's load as [OMNIML-6054] [2/2] Route load_pretrained by the distribution plan #2779 lands it. Narrowing it here would contradict [OMNIML-6054] [2/2] Route load_pretrained by the distribution plan #2779's text when the two merge.parallel_load_and_prepare_fsdp2, and in the error, which says how to record the plan.