FSDP2 calibration with hf_ptq.py [2/2]#2013
Draft
sugunav14 wants to merge 33 commits into
Draft
Conversation
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
…r param Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Distribute quantized weight-packing across FSDP2 ranks: each rank packs its own Shard(0) row-slice in place via a meta-skeleton FSDPParam rebuild (_rebuild_fsdp_param_from_shard) instead of every rank packing the full model. MoE fused experts are packed keep-fused and split into per-expert deployment keys at write time; scale buffers are re-wrapped as Shard(0) DTensors with explicit global shape/stride so unshard round-trips on uneven splits. The FSDP2 export gather is mode-aware (MODELOPT_DISABLE_SHARD_LOCAL escape hatch) with EXPORT_PHASE_TIMING markers for prep/pack/gather. Supersedes the streaming Option A export path on this branch. Validated on Qwen3-235B and NemotronH-120B: bit-exact vs the standard device_map export at world=4 and world=8; packing 148.7s -> 88.4s (1.68x) from 4 -> 8 ranks. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Each FSDP2 rank writes its owned decoder-layer units concurrently instead of a whole-model full_tensor gather + rank-0 save_pretrained. export_hf_checkpoint forks to _parallel_write_hf_checkpoint (escape hatches MODELOPT_DISABLE_SHARD_LOCAL / MODELOPT_DISABLE_PARALLEL_WRITE); _export_transformers_checkpoint gains a _pack_only early-return so both paths share prep+pack. Per-unit gather (full_tensor) -> HF split_torch_state_dict_into_shards writer -> gather_object index merge. Host memory bounded to ~one chunk of world units; writes parallelize across ranks. Validated: byte-exact vs single-writer reference on tiny Qwen3-MoE + NemotronH (w2) and Qwen3-235B (w8, 146,361 keys); output HF-loadable (get_checkpoint_shard_files). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
Drop all os.environ-gated code from the shard-local + parallel-write path, leaving the validated default behavior as the single path: - EXPORT_PHASE_TIMING phase-timing markers (unified_export_hf) - MODELOPT_DISABLE_SHARD_LOCAL escape hatch + its legacy get_model_state_dict full-pack gather branch (now dead) and _use_shard_local gate - MODELOPT_DISABLE_PARALLEL_WRITE escape hatch on the export fork - SHARD_LOCAL_DEBUG (_dbg) per-rank logging (core_utils) FSDP2 distributed export now unconditionally uses shard-local pack + parallel write. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Suguna Velury <178320438+sugunav14@users.noreply.github.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Type of change: ?
Usage
# Add a code snippet demonstrating how to use thisTesting
Before your PR is "Ready for review"
Make sure you read and follow Contributor guidelines and your commits are signed (
git commit -s -S).Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded
trust_remote_code=True,torch.load(..., weights_only=False),pickle, etc.).CONTRIBUTING.md: ✅ / ❌ / N/AAdditional Information