[AffineIR] Plan expert transfers from the live runtime placement #8800
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8800"
general
weight: 0.35
jinyouzhi
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.Maps of what each process actually stores under expert data parallelism (EDP) and ZeRO are left to a follow-up, which builds them by nesting these layout maps with ZeRO's storage maps.
Related: #8252 (§8.4 AutoEP expert placement), #8230, #8544.
Changes
AutoEPMoELayer.expert_affine_maps()returns the affine maps of the livew1/w2/w3.- Map ranks are EP-local ranks. The docstring explains how to translate them with
dist.get_global_rank(self.ep_group, rank).- Each shard is the unpartitioned packed
[local_experts, ...]tensor. ZeRO-3/EDP fragments stay outside the map, and the shape comes fromds_shape.- No collectives.
AutoEPMoELayer.plan_expert_transfer(target_placement, limits=None, *, replica_selector=None)returns oneTransferPlanper expert parameter.- It only plans: it moves no data, swaps no parameters and migrates no optimizer state.
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.autoep_placements_equal), and each parameter's publishedDS_AUTOEP_UC_METAplacement and affine map must equal the live lowering.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.- A placement the descriptor can express is not necessarily one the runtime can execute. The target placement is only used for planning.
Not in scope
Tests
tests/unit/v1/moe/test_autoep_unit.py: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: from EP=2 into 3 ranks with reordered, uneven, empty and replicated placements; executing the plan reproduces the target shards, every element is written once, and planning never callsrebuild/extract.test_live_expert_maps_reject_a_placement_the_weights_do_not_have,test_live_expert_maps_identify_placement_ranks_by_id,test_live_expert_maps_reject_a_published_map_the_placement_does_not_produce.tests/unit/checkpoint/test_autoep_affine.py:test_placements_equal_identifies_ranks_by_id.Results (Intel Arc Pro B70):
test_autoep_unit.py,test_autoep_affine.py,test_autoep_affine_universal.py,test_affine_transfer_plan.py,test_affine_shard_map.py,test_autoep_zero3_metadata.py: 432 passed, 6 skipped.test_autoep_checkpoint.py(8× B70): 32 passed, 2 skipped.Contribution checklist
Related work.
plan_transfer).A search for AutoEP placement and transfer and for affine maps found no overlapping PR.
Commands and results. Hardware and software: Intel Arc Pro B70 (XPU, XCCL), Level Zero driver 1.15.39122 (compute runtime 26.27.39122.11), torch 2.14.0.dev20260804+xpu.
Results are listed under Tests above.
Numerics, performance, memory. Training is not affected. The new methods only run when called and use no collectives.
Compatibility matrix.
| | Validated | Not validated |
|---|---|---|
| ZeRO | Independent: maps describe the unpartitioned packed tensors | Storage under EDP/ZeRO (follow-up) |
| Parallelism | EP=2; target placements on 3 ranks | |
| Precision | Dtype-independent: maps describe shapes and offsets | |
| Accelerator | XPU | CUDA, HPU |
AI assistance. This PR was developed with AI assistance (GitHub Copilot CLI). I reviewed every changed line and ran the tests above.