Repository navigation
Conversation
Expose the affine maps of an AutoEPMoELayer's live expert weights and plan their movement to a target placement through the affine transfer planner (deepspeedai#8623), without reading checkpoint metadata or materializing the logical parameter. 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: 9637a10dbf
ℹ️ 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".
| affine_maps[name] = autoep_placement_to_affine_map(placement, self._expert_logical_shape(param)) | ||
| return affine_maps | ||
|
|
||
| def plan_expert_transfer(self, |
There was a problem hiding this comment.
Add user documentation for the transfer-planning API
For downstream code that consumes these new public planning methods, the dedicated AutoEP documentation and affine IR specification remain unchanged, so users are not given a discoverable contract for constructing target_placement, translating the separate source/target EP-local rank namespaces, or normalizing ZeRO/EDP storage before applying segment offsets. Add this API and its placement/normalization requirements to docs/code-docs/source/autoep.rst or the affine specification rather than relying only on implementation docstrings.
AGENTS.md reference: AGENTS.md:L26-L26
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Added in c02604d: a "Planning expert placement transfers" section in docs/code-docs/source/autoep.rst covering how to build target_placement with make_autoep_placement_descriptor, the source/target EP-local rank namespaces (and dist.get_global_rank(layer.ep_group, rank)), element offsets into the unpartitioned packed [local_experts, ...] tensor (gather under ZeRO-3; EDP replicas hold the same tensor), replica selection, PlanBudget limits, and the uniform live-placement requirement. affine_ir_spec.md §8.4 now points to the runtime API.
Describe expert_affine_maps() and plan_expert_transfer(): how to build a target placement, the EP-local rank namespaces of a plan, the element offsets into the unpartitioned packed tensor under ZeRO-3/EDP, replica selection, plan budgets, and the uniform live placement requirement. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
# Conflicts: # docs/code-docs/source/autoep.rst
Summary
#8623 plans shard-to-shard copies between two
ParamAffineMaps. Today, though, the only AutoEP maps come from checkpoint metadata, so nothing at runtime can feed the planner. This PR closes that gap: it builds the source map from the placement the liveAutoEPMoELayeractually holds, and builds the target map from a target placement descriptor. Both maps then go straight toplan_transfer.Related: #8252 (§8.4 AutoEP expert placement), #8230, #8544.
Changes
AutoEPMoELayer.expert_affine_maps()returns the affine maps of the livew1/w2/w3.dist.get_global_rank(self.ep_group, rank).[local_experts, ...]tensor. ZeRO-3/EDP fragments stay outside the map, and the shape comes fromds_shape.AutoEPMoELayer.plan_expert_transfer(target_placement, limits=None, *, replica_selector=None)returns oneTransferPlanper expert parameter.autoep_affine.plan_autoep_placement_transfer(source_placement, target_placement, logical_shape, ...)is the layer-independent form. Both placements go through the existingautoep_placement_to_affine_map, so no second placement→map conversion is introduced.repack_expert_weightsactually packed the weights; today that is contiguous and uniform. A descriptor that disagrees raisesNotImplementedError, rather than producing a map that addresses shards the weights do not have.Not in scope
Tests
tests/unit/v1/moe/test_autoep_unit.pyadds three tests:test_live_expert_maps_address_the_packed_runtime_weights: for each rank, the map's shard shape and contents match the real packedw1/w2/w3. The reference is the full tensor fromrepack_expert_weights(ep_size=1), which does not depend on any affine map.test_plan_expert_transfer_moves_live_shards_into_target_packed_order:rebuild/extract.test_live_expert_maps_reject_a_placement_the_weights_do_not_have: a mismatched descriptor and a mismatched logical shape both raise.Results:
test_autoep_unit.py,test_autoep_affine.py,test_autoep_affine_universal.py,test_affine_transfer_plan.py: 354 passed, 6 skipped.