Fix checkpoint and broadcast tests to use the accelerator backend #9054
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 #9054"
general
weight: 0.35
delock
Summary
While preparing the Ascend NPU runner for upstream DeepSpeed CI, we are working through the upstream
tests/unitsuite and fixing device-specific failures group by group. This PR covers thegloogroup.Four test files hard-code the gloo backend while DeepSpeed places the model on the active accelerator. Gloo has no transport for NPU tensors, so
_broadcast_model()fails before the test body runs:The tests now use the accelerator's communication backend. No engine or runtime code changes.
Problem
On an Ascend host,
deepspeed.initialize()selects the NPU device, but these tests explicitly initialize gloo:deepspeed.init_distributed(dist_backend="gloo", ...)backend = "gloo"onDistributedTestsubclassesThe model parameters are therefore NPU tensors while the process group is gloo. The first model broadcast fails in [engine._broadcast_model]:
In the NPU CI run of the upstream suite this accounts for 11 cases across the misc and runtime shards: 8 failures + 3 setup errors (the 3 errors come from the module-scoped, 2-process checkpoint fixture in
test_fp32_master_only.py).The tests were written as CPU/gloo tests, but they do not force the CPU accelerator. On an accelerator host, DeepSpeed uses the accelerator device; the backend must match it.
Fix
get_accelerator().communication_backend_name(): CPU → gloo, NPU → hccl, CUDA → nccl).test_fp32_master_only.py, select the device beforeinit_distributed()and skip the 2-process fixture when the accelerator has fewer than 2 devices (CPU is unaffected).TestRealCheckpointUniversalConversionTPxPP, keep the existing CPU path (gloo + forkserver daemonic processes); on accelerators, use the standardDistributedTestlauncher, which skips when fewer than 4 devices are available.On CPU the tests still use gloo and the original execution path, so existing CPU coverage is unchanged.
Files changed
| File | Why it changes | Diff |
|---|---|---|
|
tests/unit/checkpoint/test_autotp_uc_checkpoint.py| The 4-rank TPxPP test hard-codes gloo while the engine places parameters on the accelerator. Use the accelerator backend; keep the CPU/forkserver path; use the standard launcher on accelerators and skip when fewer than 4 devices are present. | +16/-11 ||
tests/unit/checkpoint/test_fp32_master_only.py| Directinit_distributed(dist_backend="gloo")and a glooDistributedTestput NPU tensors on a gloo group. Select the device before init, use the accelerator backend, and skip the 2-process fixture when fewer than 2 accelerator devices are available. | +9/-2 ||
tests/unit/checkpoint/test_fp32_master_stage3_bf16.py| Drop the hard-coded gloo backend; the parameters live on the accelerator. | +2/-1 ||
tests/unit/runtime/test_scalar_parameter_broadcast.py| Drop the hard-coded gloo backend; the scalar parameter lives on the accelerator and is broadcast during engine init. | +2/-1 |Testing
Environment
DS_ACCELERATOR=cpu, torch 2.10.0+cpuNPU
Result: 13 passed (about 5 minutes). The 13 include all 11 previously failing cases plus the other tests in the same files.
CUDA/A100
The four files were also run in full on 4×A100-SXM4-80GB:
| Test file | Result | Time |
|---|---:|---:|
|
tests/unit/checkpoint/test_autotp_uc_checkpoint.py| 45 passed | 195.20s ||
tests/unit/checkpoint/test_fp32_master_only.py| 8 passed | 69.52s ||
tests/unit/checkpoint/test_fp32_master_stage3_bf16.py| 2 passed | 58.89s (combined with scalar) ||
tests/unit/runtime/test_scalar_parameter_broadcast.py| 2 passed | same run || Total | 57 passed, 0 failed | |
TestRealCheckpointUniversalConversionTPxPP(4 ranks, TP=2×PP=2) ran separately in 13.15s and passed, confirming it used the accelerator launcher and NCCL rather than the CPU/gloo path. The directly spawned fixture intest_fp32_master_only.pyalso completed NCCL initialization on GPU (8/8).Pure CPU
Result: 13 passed (about 4m36s).
LOCAL_SIZE=4is needed because the CPU accelerator derivesdevice_count()from the NUMA topology and reports 1 on this host; the 2-rank and 4-rank cases would otherwise be skipped by the existing device-count guard.CPU/gloo path
The preserved CPU/gloo path was also checked without
LOCAL_SIZE=4:TestRealCheckpointUniversalConversionTPxPPran 4 ranks on CPU/gloo and passed in 54.32s, confirming that the CPU/forkserver path is unchanged.test_scalar_parameter_broadcastis skipped on this host because CPUdevice_count()is 1, below the 2 ranks the test needs. This is the existingDistributedTestlauncher gate, not a regression from this change; withLOCAL_SIZE=4the test runs and passes as part of the 13-passed run above.Before / after
| Check |
master| this branch ||---|---|---|
| Affected 11 cases, 4×910B4 | 8 failed + 3 setup errors,
No backend type associated with device type npu| 13 passed in the same files || Four affected files, 4×A100-SXM4-80GB | not run | 57 passed |
| Same tests, pure CPU | not run | 13 passed |
Not tested
tests/unitsuite; only the four affected files/test cases were run.Notes for review
engine._broadcast_model()already broadcasts on the accelerator device, so the process-group backend must match that device; changing the engine would hide the mismatch rather than fix it.Checklist
ast.Strincompatibility unrelated to this diff)