Repository navigation
Conversation
AutoEPMoELayer.expert_storage_affine_maps() describes, in global ranks, where every element of each packed expert parameter is stored: the packed [local_experts, ...] tensor of every expert-data-parallel replica under ZeRO-0/1/2, or each holder's ds_tensor partition without padding under ZeRO-3. A transfer plan built from it reads straight from training storage, so expert weights no longer need to be normalized to packed EP tensors first. autoep_storage_affine_map nests the placement's layout map with ZeRO's storage map of each packed tensor, so every holder of an element, across EDP replicas and redundant experts, is listed for the planner's replica selection. The maps are in the parameter's own shape. The maps are built locally: groups keeps the ranks of every expert data parallel group, which every rank creates anyway, so a rank can locate other ranks' replicas without a collective. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18423bfa1f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A quantized ZeRO-3 partition is encoded with a separate scale, and an NVMe-offloaded partition is only a placeholder in memory, so element offsets into either do not address the weights. Apply the same check zero_param_storage_affine_map already applies. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
…e copies autotp_storage_affine_maps treated AutoEP experts, which AutoTP leaves whole on every TP rank, as replicated over TP, describing one EP rank's packed tensor as the whole parameter. Take their maps from the AutoEP layer, and refuse expert optimizer states before any collective. Document that storage maps list only authoritative copies (those the optimizer step updates and the forward reads), that derived copies such as gathered ZeRO-3 parameters are left out, and that maps must be rebuilt after every rank switches to a new expert placement. The storage-map test reads shards through zero_param_storage_shard and covers ZeRO-2 with AutoTP. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
Each EP rank holds different experts, so one rank can refuse its expert storage (e.g. a quantized partition) while its tensor-parallel peers accept theirs, leaving them waiting in the all-gather. Send the refusal through the same all-gather so every peer raises. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
|
Ready to review @delock Thanks! |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
Summary
#8800 describes AutoEP expert weights as one packed
[local_experts, ...]tensor per EP rank. What a process actually stores is different:So a plan built from #8800's maps cannot read from training storage until the storage is first normalized to packed EP tensors.
This PR describes the storage itself. It nests #8800's placement map with #8885's ZeRO storage maps, so
plan_transfer(#8623) reads directly from runtime storage:Related: #8252, #8800, #8885.
Changes
AutoEPMoELayer.expert_storage_affine_maps()returns one storage map each forw1,w2andw3.zero_param_storage_shard(param)([AffineIR] Affine storage maps for live ZeRO parameters and optimizer states #8885) returns it:param.dataunder ZeRO-0/1/2, orparam.ds_tensorwithout its trailing padding under ZeRO-3.replica_selectorcan choose among them.ds_tensorsize that differs from even partitioning;NotImplementedError).autoep_affine.autoep_storage_affine_map(descriptor, logical_shape, holders_by_ep_rank, partition_numel_by_ep_rank=None)is the layer-independent builder. It is also convenient for target maps.groupskeeps every EDP group's ranks (_get_expert_data_parallel_group_table), not only the caller's.autotp_storage_affine_maps(model)([AffineIR] Affine storage maps for live ZeRO parameters and optimizer states #8885) takes the maps of AutoEP experts from their layer. AutoTP leaves experts whole on every TP rank, so before this it described them as replicated over TP: one EP rank's packed tensor described as the whole parameter. Withoptimizer_states=Trueit raisesNotImplementedErrorfor AutoEP experts before any collective.autoep.rstgains a section onexpert_storage_affine_maps();affine_ir_spec.md§10 is updated (below).Authoritative and derived copies
Storage maps list only authoritative copies: the storage the optimizer step updates and the next forward reads (
param.data, ZeRO-3ds_tensor). A write through a map therefore lasts.The runtime also keeps derived copies that it regenerates from authoritative ones:
A write to a derived copy alone is lost or leaves the authoritative copy stale. So maps leave derived copies out, and
zero_param_storage_shardrefuses a gathered parameter (callengine.empty_partition_cache()first). Whether a copy is authoritative depends on the side: the low-precision weights are authoritative for a rollout engine, which is what these maps serve, but derived on a training engine, where loading weights needs the fp32 master (not described).Not in scope
Follow-ups
NotImplementedError.Tests
tests/unit/v1/moe/test_autoep_checkpoint.py::TestAutoEPExpertStorageMaps(4 ranks, EP 2), with ZeRO-2, ZeRO-3, and ZeRO-2/3 + folded AutoTP 2:extract(full, rank)equals each rank'szero_param_storage_shard(param)bit for bit.fullcomes fromGatheredParametersand the runtime's packing order, so the reference does not depend on the affine maps.[[3], [0], [2], [1]]and executing it into NaN-filled targets reproduces the expected experts exactly.autotp_storage_affine_maps(model)gives the experts the same maps as their layer (fails without the fix), and refuses expert optimizer states.tests/unit/checkpoint/test_autoep_affine.py:tests/unit/utils/test_groups.py: the EDP table survives subgroup destruction.Validation on 8× Intel Arc Pro B70 (torch 2.14.0.dev20260804+xpu):
test_autoep_affine,test_autoep_affine_universal,test_zero_affine,test_affine_transfer_plan,test_affine_shard_map,test_autoep_zero3_metadata,tests/unit/utils/test_groups,test_autoep_checkpoint,test_autoep_unit: 531 passed, 8 skipped.After the AutoTP fix:
TestAutoEPExpertStorageMaps6 passed,test_zero_affine27 passed.