DeepSpeed
99137580 - Price affine transfer plans from their schedule, and keep the cheapest (#9145)

Commit
8 hours ago
Price affine transfer plans from their schedule, and keep the cheapest (#9145) 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 by `import 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; `capacity` gives 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's `network_send` and the receiver's `network_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 one `execute_transfers` call, and stages run one after another. A call's rounds come from `schedule_transfers`, so the estimate prices the rounds that `execute_transfers` will run. A round takes its most loaded resource's bytes over that resource's capacity, plus `seconds_per_round`. Copy launches, `seconds_per_region` for each staged or local region of the busiest process, overlap the bytes, so a call takes `seconds_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. - A section in `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: - A round takes its busiest resource, whether the sender's or the receivers' side binds. - Two resources in one round bind on their own (the mixed incast of RFC #9026). - Copy launches overlap the bytes; local copies count as regions; rounds sent and received in place do not. - The GH200 capacities of RFC #9026 give its model rows for direct (4 × 8 GiB / 68.4 GB/s) and sharded (8 GiB / 23.4 GB/s), and the relay through #8936's `local_first_least_loaded` is chosen. - A tie goes to the first name. - Refusals: a routed resource with no capacity, a process with no node, a zero capacity, an unknown intra-node kind, no candidates. 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: - 4× A100-SXM4-40GB (NV12), AMD EPYC 7763; - 4× H200 (NV18), Intel Xeon Platinum 8558. 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: - Across nodes: the `network_send` and `network_receive` terms are checked only against the published GH200 numbers in the unit test; no multi-node run here. - Other accelerators: the module is pure Python over `schedule_transfers` and calls no device or collective, but it was calibrated only on these two NVIDIA machines. - Turning `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. Signed-off-by: Achyuthan Sivasankar <achyuthan.sivasankar@gmail.com> Co-authored-by: Ma, Guokai <guokai.ma@gmail.com>
Author
Parents
Loading