Price affine transfer plans from their schedule, and keep the cheapest #9145
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
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 #9145"
general
weight: 0.35
delock
Refs #9026 (the cost model), #8252, #8935.
Why
Plans that move the same data can differ in time by several times. Which holder each target reads and the staging budget are free choices, and the planner guarantees an exact result whichever is picked. In the runs below, the default (the planner's first holder, the larger budget) is up to 76% slower than the fastest candidate. A replica policy (#8935, #8936), a two-stage relay (#9074) or a weight sync (#9045) needs a way to compare candidates before running one. #8967 reports what a batch moves and states that it does not model time; #8966 measures link rates. This adds the step between them: a time estimate per candidate, and the choice.
What
deepspeed/checkpoint/affine_transfer_cost.py, which is not imported byimport deepspeed:TransferCostModel(route, capacity, seconds_per_call, seconds_per_round, seconds_per_region): one machine's calibrated costs.route(sender, receiver)names the resources a message occupies;capacitygives bytes per second per resource kind. Capacities must be positive and finite, and the costs non-negative and finite.node_route(nodes, intra_node): across nodes, the sender'snetwork_sendand the receiver'snetwork_receive; within a node, each GPU's own link (device_send,device_receive, as on NVSwitch) or the link between the two GPUs (device_pair, NVLink).estimate_seconds(stages, model): each stage is oneexecute_transferscall, and stages run one after another. A call's rounds come fromschedule_transfers, so the estimate prices the rounds thatexecute_transferswill run. A round takes its most loaded resource's bytes over that resource's capacity, plusseconds_per_round. Copy launches,seconds_per_regionfor each staged or local region of the busiest process, overlap the bytes, so a call takesseconds_per_call + max(rounds, launches). Rounds sent or received in place launch no copy.cheapest(candidates, model): estimates every candidate and returns the cheapest name with every estimate. A tie goes to the name that sorts first, so ranks given the same model and candidates choose the same plan. The model must be built from data every rank shares.affine-transfer.rst.Not priced: a plan's one-time preparation (#9094), and overlap between stages.
Tests
tests/unit/checkpoint/test_affine_transfer_cost.py, single process. Each expected time is computed in the test from the bytes and the given capacities:local_first_least_loadedis chosen.Each of these changes to the module makes at least one test fail: adding the resources instead of taking the busiest (3 fail), adding launches to the bytes (1), counting in-place rounds as regions (1), counting each message on both sides (2), dropping
seconds_per_round(1), and breaking ties toward the last name (1).Validation
macOS arm64 CPU, Python 3.9.6, torch 2.8.0, on master c00a7f68c: the 6 tests pass; yapf 0.43.0 and flake8 5.0.4 pass on the new files.
On GPU, with this exact module file on master e35282bdb: 4 GPUs of an 8-GPU node, on two machines, driver 595.71.05, torch 2.12.1+cu130, NCCL 2.29.7:
On each, the 6 tests pass. Then a ranking test: 5 moves, each run as 2 to 4 candidate plans that deliver the same bf16 data and differ only in the holders read or the staging budget (16 plans). Each plan's time is the median of 7 runs after 3 warmups, from a barrier to the end of the call, slowest process. The first run of every plan was checked exact against the maps. The model was fitted on each machine from 8 calibration transfers only: one pair at 64 MiB, 256 MiB and 1 GiB in one round and 1 GiB at 64 and 8 MiB budgets, a 1 GiB fan-out to three, a fan-in of three times 1 GiB, and a gather of 2048 pieces of 4 KiB. The candidates were fixed, and their times kept out of view, until the fit was done. Regret is the chosen plan's time over the fastest measured:
| Move | Candidates | A100: model | A100: default | H200: model | H200: default |
| --- | --- | --- | --- | --- | --- |
| 1 GiB held on 2 GPUs, into row halves on the other 2 | first holder or one each, 16/64 MiB budget | 0% | 56.7% | 0% | 38.6% |
| DP2 × TP2 into TP4 (1 GiB) | first holder, local, local then the other | 0.3% | 4.1% | 1.4% | 5.1% |
| Ring of 512 MiB blocks | budget 8/16/32/64 MiB | 0% | 0% | 0% | 0% |
| Rows to columns over 4 GPUs | budget 4/16/32 MiB | 0% | 0% | 0% | 0% |
| 16 weights of 64 MiB held on 2 GPUs, into row quarters on 4 | first holder or split | 0% | 76.4% | 0% | 76.3% |
The estimates rank plans; they are not times. Against the measured times of these 16 plans they range from 62% under to 15% over on the A100 node (5 of 16 within 15%), and from 57% under to 5% under on the H200 node (3 of 16). Rerunning the scoring with the module on master c00a7f68c gives byte-identical output on both machines.
Not validated:
network_sendandnetwork_receiveterms are checked only against the published GH200 numbers in the unit test; no multi-node run here.schedule_transfersand calls no device or collective, but it was calibrated only on these two NVIDIA machines.calibrate_links(#8966) fits into these capacities is left to the caller.The module does not change any training, checkpoint or ZeRO code path, so no ZeRO stage, offload, precision or parallelism setting is affected.