[RFC]Unify CPU offload features to the main code path

Đang mở
#9,154 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
8/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, python

Hướng nghiên cứu

This is a draft RFC, not a bug report. Read the optimization table and the memory-traffic estimate, then the code it cites: csrc/adam/cpu_adam_impl.cpp, deepspeed/ops/adam/cpu_adam.py, and the ZeRO paths in deepspeed/runtime/zero/stage3.py and stage_1_and_2.py. Good first contributions are to comment on the open proposals or benchmark one of them. Done means a measured result or a recorded design decision, not a patch.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

Folding ZenFlow, SuperOffload and ReFlow into DeepSpeed's default CPU offload

WIP, discussions and revisions are more than welcome.
Status: draft for discussion. Part of: #8672 (Q4 2026 roadmap), "ReFlow Integration". The roadmap's "Muon
optimizer offload" item is left to its own RFC, #8463 (L5).

0. Goal and scope

DeepSpeed has three research methods that make CPU optimizer offload faster: ZenFlow, SuperOffload and ReFlow. ReFlow
is in review as #8719. Each method has its own config switch and its own copies of parts of the ZeRO optimizer. A user
gets the gains only by knowing about a method and turning it on, and usually only on ZeRO-3.

Goal. The exact speedups of the three methods become the default behaviour of CPU optimizer offload. Parts that
change the training math stay options. Then the separate implementations go away, but the method names stay as
presets (section 6).

Scope. DeepSpeedCPUAdam with ZeRO-1, ZeRO-2 or ZeRO-3 and offload_optimizer: {device: cpu}, on every
instruction set and accelerator where CPU Adam builds today.

Conditions for anything that becomes a default:

  1. Exact: the same weights and optimizer state, bitwise, as today's default path on the same build. A change that
    alters rounding can only be an option.
  2. Portable: it builds on AVX-512, AVX2, NEON, SVE and the scalar loop, or checks what the machine supports and
    falls back. Today, for example, #8841's fused copy runs only on AVX-512, NEON and the scalar loop
    (csrc/adam/cpu_adam_impl.cpp:282-296).
  3. Memory stated: it states its host-memory and pinned-memory cost per element, and stays under an agreed limit.
    With the default pinned-memory backend (DS_PIN_MEMORY_BACKEND=torch), PyTorch rounds each pinned allocation up
    to a power of two: the pinned fp32 master of a 1e9-element sub-group (3.73 GiB, pinned since #8840) reserves
    4.00 GiB.
  4. Same public results: safe_get_full_grad, safe_set_full_grad and the other safe_* functions
    (deepspeed/utils/tensor_fragment.py) return the same values.
  5. CPU cores: it does not widen the CPU affinity mask, it leaves cores for data loaders, and it keeps an explicit
    OMP_NUM_THREADS. Pinning cores happens only when the user asks.

Code. Master f1d37eb2b (2026-11-23), #8719 at 09a8ab753, #9021 at b2b46ae93. Below, stage3.py means
deepspeed/runtime/zero/stage3.py and stage_1_and_2.py means deepspeed/runtime/zero/stage_1_and_2.py.

1. Why now

  • When a method replaces part of the default code with its own copy, later fixes to the default code do not reach
    that method.
  • The methods copy each other's ideas into separate code.
  • The head-to-head measurements disagree, so we need one benchmark with fixed rules.

2. Which optimizations to make the default

# Optimization Comes from; where it is today Exact? Evidence Proposal
O1 One fused CPU pass: scale the gradient (loss scale and clip factor), run Adam, write the bf16 copy for the GPU ZeRO-Offload Algorithm 2 (Adam and the fp16 copy, one tile at a time; no gradient scaling); ReFlow's fused kernel; #8841 in the ZeRO-3 default path; #9021 yes (#8841: weights bitwise equal to master) #8841, Qwen2.5-32B, 1 node of 8 H200: −3.5% to −3.9% per step. ReFlow paper Table 5, TFLOPS per GPU against DeepSpeed v0.18.1 (older than #8840 and #8841): 166.41 → 297.59 on 1 B200, 366.40 → 458.34 on 4, 420.36 → 504.09 on 8 default in ZeRO-1/2 too; one kernel family in csrc/adam/ for all instruction sets, through the shared SIMD code, with fallback
O2 bf16 gradients sent to the CPU once, converted to fp32 inside the kernel ReFlow; #9021 yes, when gradients are reduced in bf16 (the conversion is exact) ReFlow paper Table 5, adding low-precision gradients: 297.59 → 354.01 on 1 B200, 458.34 → 494.46 on 4, 504.09 → 531.91 on 8. From the code, with gradient_accumulation_steps 1, ZeRO-3 today copies each bf16 gradient into the CPU buffer and straight back to the GPU (stage3.py:2251-2255), then sends it as fp32 at the boundary (stage3.py:1571): 8 bytes per element, against 2 default when gradients are reduced in bf16. A smaller exact fix goes first (M1)
O3 Gradient accumulation on the CPU across micro-steps, instead of copying the CPU buffer to the GPU, adding there and copying back (stage3.py:2258-2266) ReFlow. ZeRO-1/2 accumulation was rewritten in #9018 and #9044 yes, if the CPU adds bf16 values exactly as the GPU does: fp32 add, round to nearest even, the same order. A test must show it. fp32 accumulation needs an fp32 CPU buffer (the BLOOM point on #8697) ReFlow paper, OPT-30B, 8 GPUs: the round trip costs 1,063 ms per extra micro-step default for gradient_accumulation_steps > 1, with an fp32 CPU accumulator when grad_accum_dtype is fp32
O4 Copy-back of updated weights piece by piece, through pinned double buffers, while the next piece is updated ZeRO-Offload Algorithm 2; #8840 and #8841 restored it for ZeRO-3 (stage3.py:3122); ReFlow yes #8840, Qwen2.5-32B, 1 node of 8 H200, all offloaded: 12.08 → 9.42 s per step (−22.0%) default everywhere: restore it in ZeRO-1/2 (disabled at stage_1_and_2.py:3091-3094 and 3212-3217). SuperOffload gets it at cleanup, when it becomes a preset of the default path
O5 (a) CPU Adam thread count set from the rank's cores. (b) The CPU step in a worker thread of the training process, with the GIL released (a) master only warns (#8938, merged 2026-11-17; deepspeed/ops/adam/cpu_adam.py:16-35, logged at :116-119). (b) ReFlow; #9021. GIL release: #9035 releases it only in adam_update, and #9021 in adam_update, adam_rescale_step and adam_rollback. Neither covers adam_update_scaled or adam_update_scaled_copy, which the ZeRO-3 default path calls (deepspeed/ops/adam/cpu_adam.py:214-220), so O5(b) adds them yes (a) GLM-5.2, 64 H200: optimizer step 62.9 s with the torchrun default of 1 OpenMP thread, 14.8 s with 12 (+22% tokens/s). (b) has no gain on its own; it is what O3, O6 and O7(a) need. It also avoids SuperOffload's separate process, which receives the fp32 weights and gradients through shared memory and keeps one more fp32 gradient buffer; the ReFlow paper reports that setup going past a 400 GB budget at 70B on 8 B200 (a) default, keeping an explicit OMP_NUM_THREADS. (b) default together with the first ingredient that needs it. Core pinning only when the user asks. #7478 (open) asks for automatic core binding instead; that is a separate decision
O6 Early step per sub-group during backward (ZeRO-3 only) SuperOffload introduced it; ReFlow's exact form; #9021's rescale-and-undo form ReFlow's form: yes. Rescale-and-undo: no (#9021's rescale subtracts the old update and clamps the second moment at 0) ReFlow paper Table 5, the early bf16 weights: 366.61 → 671.29 TFLOPS per GPU on 1 B200, 530.67 → 681.18 on 4, 574.71 → 673.81 on 8. The head-to-head results conflict (section 1). Cost estimate below measure first, then option, then default. Before M3, ReFlow is run with and without its early step (section 5); M3 is built only if that shows a gain. The exact form then becomes the default if the same comparison in the default path also shows a gain. The rescale-and-undo form can only be an option, documented as not exact
O7 Overlap in the step that waits for the norm: (a) step the GPU-resident sub-groups (ratio < 1) at the same time as the CPU ones; (b) no wait at the end of each sub-group for its last copy not done: one loop visits GPU and CPU sub-groups in turn (stage3.py:3225-3253), and the copy-back waits on an event recorded on the same stream (stage3.py:3106-3108, and :3159-3161 in the fused path), so it also waits for the GPU sub-groups' work queued before it (from reading) yes not measured. O7 cannot hide the CPU Adam compute; only O6, or a delayed update, can default. Check in a profile whether a separate copy stream is enough before adding the worker thread for it
O8 Streaming (non-temporal) stores for the bf16 weight copy that the kernel writes: these stores go to memory through write-combining buffers, with no read first and without keeping the line in the cache. A normal store to a line that is not in the cache first reads the line from memory (read for ownership). The bf16 copy goes into a pinned buffer that is not in the cache (two buffers of 2^26 elements, stage3.py:261, :3131-3134; between two writes to the same buffer the kernel goes through about 2 GB of other data), so each write costs an extra read. The weight and both moments gain little: the kernel reads them just before writing them, so their lines are already in the cache x86: ReFlow (#8719; at 09a8ab753 for the bf16 weights written in Ready, csrc/includes/reflow_cpu_adam.h:337, :364, with _mm_sfence at the end of each thread's loop, csrc/includes/reflow_ready.h:207, :222). ARM SVE on master already uses them for the weights and both moments (csrc/includes/sve.h:91-93). The x86 stores in the shared csrc/includes/simd.h are normal stores: SIMD_STORE for fp32 (:37, :100), and store_16_f32_as_bf16_nearest, which writes the bf16 copy with memcpy (:89) yes (the values written are the same) st-bang97 on #8719 (2026-11-20), in ReFlow: "only a few percent" on the original B200 setup, and "exceeding 10%" under heavier memory contention and more constrained memory bandwidth. Not measured in the default path. Estimate from counting bytes, not measured: the extra read is 2 of 32 bytes per element in the default fused kernel with fp32 gradients (2 of 30 with bf16 gradients), so at most about 6-7% of the CPU Adam time, and only when that time is limited by memory bandwidth. In ReFlow's Ready step, which writes only the bf16 weight, it is 2 of 18 bytes (about 11%) option first; the default if the benchmark shows a gain. Add streaming-store helpers to simd.h and use them for the bf16 copy in the shared kernel, with a fence at the end of each thread's loop, before the GPU copy of the piece starts, so callers need no change. Its PR reports the per-PR rows and one memory-limited setup, such as the single-socket node of the full set (section 5). Open question for st-bang97: did the ReFlow gain come from the bf16 output alone, or also from streaming the state? SuperOffload gains little: its worker calls the shared DeepSpeedCPUAdam (deepspeed/runtime/superoffload/superoffload_utils.py:76, :145), but that call writes only the fp32 weight and moments, with no bf16 copy

The O6 trade, in CPU memory traffic per element. This is an estimate from each kernel's loads and stores, plus
the read of the copy sent to the GPU, with bf16 gradients and fp32 state; it was not measured. It leaves out the read
before each bf16 write (O8): 2 more bytes for each pass that writes a bf16 copy. Today's code reads fp32 gradients, 2
bytes more than the first row.

Form Unclipped step Extra on a clipped step, after the norm Exact
today: fused step after backward (#8841) 30 bytes after backward (28 in the kernel, 2 read by the bf16 copy to the GPU) 0 yes
Ready/Persist (ReFlow) 18 during backward (16 + 2) + 26 during the next forward = 44 18 (Ready again) yes
early step + rescale (#9021) 30 during backward (26 in the kernel, which writes no bf16 copy, + 4 read by the fp32 copy to the GPU) about 30 (rescale 26 + 4) no

Against today, the exact form moves 14 more bytes per element on every step, and 18 more on a clipped step (Ready
again). In return, its CPU work runs during backward and the next forward instead of after backward. It should win when
the CPU has spare memory bandwidth and the GPU work is long enough to cover the CPU work. It can lose with little memory
bandwidth per GPU, a short forward and backward, or frequent clipping. Against #9021's rescale form, it also costs 14
more bytes on every step, and it saves about 12 on a clipped step. That fits both authors' explanations of their
results on #8719.

3. What can be low priority

# Item Why it can wait
L1 ZenFlow's column-selective update It changes the update rule, so it cannot be a default. It stays as an option of the default path, off by default. At cleanup (M5), ZenFlow's lines move out of the base classes into that option; two TODOs ask for this (stage_1_and_2.py:229, 3100). Note: its ZeRO-3 path transposes every 2-D parameter at start-up (deepspeed/runtime/zenflow/engine_stage3.py:85)
L2 Where to convert: gradients bf16 → fp32, and weights fp32 → bf16 Depends on the link. On GH200/GB200, NVLink-C2C makes sending fp32 cheap. Start with the CPU side on PCIe nodes; choose by link speed once GH200 numbers exist
L3 Automatic offload_optimizer.ratio The manual setting works; #8973 (merged 2026-11-20) fixed its learning-rate and checkpoint handling
L4 NVMe with O2-O7 Few users combine NVMe with these methods
L5 Muon with these optimizations Its own RFC, #8463 (jinyouzhi); coordinate there
L6 A running gradient norm kept on the GPU while gradients go to the CPU (raised on #8697) Not measured, and it can change the rounding of the norm
L7 Undo-based early step Drop it if the exact form is as fast. Otherwise keep it as an option, documented as not exact
L8 One-step delayed parameter update (ZeRO-Offload §5.2) It changes the math. Only ZenFlow's overlap_step uses a form of it today

4. How to bring them into the main path

Principles
  1. The default path first. Each idea goes into the default path and is made to work there, for every offload user.
    ZenFlow, SuperOffload and ReFlow are deprecated at cleanup (M5). Until then, a default-path change must not break
    them or make them slower, but it does not need to make them faster. Their open PRs and bug fixes still merge.
  2. The methods are the reference, outside CI. Where a default-path change does what a method already does, the PR
    author compares the two (bitwise where both are exact, and in speed) and reports the result in the PR. A method's
    cleanup can start once the default path matches it.
  3. Small exact wins go first, and they are independent of each other.
  4. One owner orders the PRs that touch partition_grads and step. The optimizer RFC (one optimizer interface,
    one copy of the norm, clip and loss-scale code) changes the same ZeRO base class. The two RFCs need one order.
  5. Each default-path change has one internal off switch until cleanup (M5), rather than a new public config key.
  6. Cleanup has its own target date, so that the extra copies during the work do not become permanent.
  7. Each PR brings its own tests and numbers: a few tier-1 cases in the existing offload test files, and its
    benchmark results in the PR description, without the benchmark code (section 5).
What the early step needs in the base optimizer

The early step (O6) and the worker thread (O5b) need three pieces of logic in the default path. They are written
directly into the base partition_grads and step, in the PRs that need them.

  1. Knowing when a sub-group's gradients are complete (early-step PR). This is not always known inside
    partition_grads:
    • padding-only partitions get no gradient, so they are not counted;
    • unused parameters are filled only at the end of backward (the #8981 rules);
    • a parameter can get more than one gradient in one backward (reentrant checkpointing, tiled compute). A sub-group
      with such a parameter is complete only at the end of backward. How the code knows this is for the early-step PR to
      settle;
    • DeepCompile writes the partitions itself and never calls partition_grads (stage3.py:1626-1629).
  2. Keep, redo or skip in step (early-step PR), once the gradient norm and the overflow check are known.
  3. One wait for pending CPU work (worker-thread PR, the first change that leaves CPU work running after a call
    returns). Everything that reads or changes optimizer state calls it first.
partition_grads, per reduce bucket, at the accumulation boundary:
    remaining[i] -= real-data parameters of sub-group i in this bucket
    if remaining[i] == 0 and no parameter of sub-group i can get another gradient:
        record an event on the reduce stream; start the early step of sub-group i after that event
end of backward, after the missing partitions are filled:
    start the early step of every sub-group not yet started
step, once the norm and the overflow check are known, for each sub-group i:
    factor 1 and no overflow: keep the early result
    another factor:           redo the step from the untouched fp32 master
    overflow:                 skip the step
before state_dict, save, offload_states, safe_get/set_*, get_full_hp_param, destroy, and the next step:
    wait for the pending CPU work

Rules that go with it:

  • Wait on a device event; never synchronize a whole stream.
  • Read the learning rate, betas, eps and weight decay when the step keeps or redoes the early result, or redo if
    they changed. #8972 item 7: SuperOffload's worker kept the initial betas, eps and weight decay.
  • A gradient set with safe_set_* between backward and step forces a redo.
  • With DeepCompile on (out of scope), nothing runs early: the step works as it does today.
Milestones (about 16 PRs)

Owners are suggestions, to discuss. Each PR brings its own tier-1 tests and its benchmark numbers (section 5), so there
is no separate test or benchmark milestone. One kernel PR covers all instruction sets through DeepSpeed's shared SIMD
code, as #8841 did. Two items are left out of the PR count: the rescale-and-undo form of the early step (L7) and Muon
(L5, its own RFC #8463).

Milestone PRs Suggested owners
M1. Quick exact wins, independent (1) CPU Adam thread count from the rank's cores, keeping an explicit OMP_NUM_THREADS (O5a); (2) skip the bf16 copy to the CPU buffer and back when the first micro-step is also the last (stage3.py:2251-2255); (3) ZeRO-1/2 on #8841's fused kernel and the piece-by-piece copy-back (O1, O4) pengdurice; review of (3) by sfc-gh-truwase
M2. Exact speedups in the default path (4) one kernel family with bf16-gradient input, with fallback (O1, O2); (5) bf16 gradients sent once, and CPU-side accumulation in bf16 and fp32 (O2, O3); (6) worker thread with the GIL released (O5b), and the one wait for pending CPU work (see above); (7) GPU and CPU sub-groups at the same time, and no wait between sub-groups (O7); (8) streaming-store helpers in simd.h, used for the bf16 copy in the shared kernel, off at first, and the default if the benchmark shows a gain (O8) st-bang97 (4, 5, 8; with a named person to run benchmarks); xylian86 (6); pengdurice (7)
M3. Early step Starts only if the measurement before M3 (section 5, O6 benchmark step 1) shows a gain. (9) the exact form on the shared kernel and worker, as an option, written into the base partition_grads and step (see above); the author compares it bitwise with ReFlow's early step (#8719) and reports the result in the PR; (10) the exact form becomes the default if the controlled benchmark (section 5), run outside CI, shows a gain st-bang97, xylian86; benchmark run by a third person
M4. Other stages (11) ZeRO-1/2 gradient accumulation on the CPU (O3); (12) partial offload (ratio < 1) on the same path (11) with sfc-gh-truwase, who rewrote that code in #9018 and #9044; (12) xylian86, who fixed it in #8973
M5. Cleanup (13) reflow becomes a preset of the default path, with its sub-keys mapped, and ReFlow's subclass is removed; (14) the same for super_offload and SuperOffload's subclass; (15) ZenFlow's column-selective update becomes an option of the default path, off by default, and its lines move out of the base classes (L1); (16) one CPU-offload documentation page, and the internal off switches removed after the window per method

Q4 2026 subset: M1, the three quick wins, each with its tests. On its own, it leaves the code better than today.
The measurement before M3 can also run in Q4, since it needs no default-path code.

Time. Comparable offload PRs took 14 (#8840), 27 (#8841), 27 (#8843) and 16 (#8981) days to merge, and #8719 has
been open for 53 days (on 2026-11-23). The longest chain here is about 5 PRs in a row (4, 6, 9, 10, 13: kernel, worker thread,
early step, the switch of the default, first cleanup PR), so M2 to M4 take most of the first half of 2027.
M5 follows, on its own target date.

Open PRs, in merge order. The open PRs for the three methods merge after their normal review, out of respect for
that work, instead of being moved onto the default path first. The default-path PRs then bring the ideas in.

  1. #8972 as it is: all nine SuperOffload fixes.
  2. #9021: on top of #8972. It contains #8972 by merge.
  3. #8719: as agreed on #8697, once its blocking review comments are fixed. It stays as it is until cleanup and is the
    reference for M2 and M3.

Other open PRs that touch the same code:

  • #9035 (GIL release in native CPU Adam, adam_update only);
  • #8774 (ZenFlow CPU affinity on Slurm masks and multi-node runs);
  • #8963 (overflow flag kept on the device);
  • #8970 (clip factor at full precision);
  • #8714 (CPU optimizer results written back to non-contiguous parameters), in csrc/adam/cpu_adam_impl.cpp, the same
    file as M2 PR (4);
  • #9136, draft (optional bf16 stochastic rounding of parameters from fp32 masters, ZeRO-1/2 with or without CPU
    offload): with it on, the bf16 copy that M1 PR (3) writes on the CPU must round the same way, or fall back;
  • #9133, draft (ZeRO-1/2 gradient bucket stream ordering): the same code as M1 PR (3) and M4 PR (11);
  • #8875 (ZeRO-3 external parameter discovery): changes ZenFlow's hooks and adds ZenFlow tests.

Related: #9152 (RFC, 2026-11-23) asks for offload_states() and reload_states() for every engine configuration,
including an offloaded optimizer; the one wait for pending CPU work (section 4) must cover them. #9137 fixes Muon
momentum across loss-scale changes (L5).

5. Test plan

Where tests live. Each change has some unit tests, but not too many:

  • tier-1 cases go into the existing offload test files (for example tests/unit/v1/zero/test_zero.py, which has
    #8841's ZeRO-3 CPU Adam tests, tests/unit/v1/zero/test_zero_cpu_offload_grad_accum.py and
    tests/unit/v1/zero/test_offload_states.py), not a new suite;
  • no separate test suite is added for ZenFlow, SuperOffload or ReFlow, since they are deprecated at cleanup. Their
    existing tests, and the tests their open PRs bring, keep running where CI runs them today. On master f1d37eb2b:
    • ZenFlow has tests/unit/runtime/zenflow/test_zf.py, which runs only overlap_step: false. It trains only in the
      AMD nightly (.github/workflows/amd-mi200.yml:64): the NVIDIA nightly aws-torch-latest-full skips it
      (--ignore=unit/runtime/zenflow, .github/workflows/aws-torch-latest-full.yml:431), modal-torch-latest runs
      only tests/unit/v1/, and on CPU the test returns before training (test_zf.py:127-128);
    • SuperOffload has no test file of its own. Its only tests are the 4 cases of TestSuperOffloadTrainsKeptParamsInFp32
      (tests/unit/v1/half_precision/test_keep_in_fp32_modules.py:487-506): ZeRO-3, bf16, one step, clipping at its
      default 1.0, so the early step never runs. #8972 adds tests/unit/v1/zero/test_superoffload.py;
    • ReFlow brings its own in #8719 (tests/unit/v1/zero/test_reflow.py, tests/unit/v1/ops/test_reflow_cpu_optimizers.py).

This leaves a gap: a change to the base classes (M1 PR 3, and M2 to M4) can break SuperOffload or ZenFlow, including
ZenFlow with overlap_step: true, or make them slower, and no test on master would catch it: SuperOffload's 4 cases never run its early step,
and ZenFlow's test trains only in the AMD nightly. The author of such a PR runs, by hand,
one job of each method that uses the changed code (SuperOffload on ZeRO-3; ZenFlow on the changed stage, with
overlap_step: true), and reports the result and the step time in the PR.

Correctness, two tiers. A bitwise comparison with a run without offload can never pass: CPU Adam and GPU Adam are
different kernels. So the tests have two tiers.

Tier What it compares Pass rule When it runs
1 the new path against its own off switch, on the same build (or against outputs saved from master) bitwise committed with the PR: 1-2 ranks, only a pairwise subset of the matrix cases the change touches
2 offload against no offload stated tolerance run by hand on the full matrix by the author of each M2 to M4 PR, and once before cleanup; reported in the PR, not a CI job

Both tiers compare weights, both Adam moments, the step count and the reported gradient norm, over 2-3 steps.

Matrix (3 stages × 3 dtypes × 2 clipping settings × 3 accumulation settings = 54 base cases, plus the special cases).
It is a checklist for the author, not 54 new CI cases:

Dimension Values
ZeRO stage 1, 2, 3
dtype fp32, bf16, fp16 with the dynamic loss scale
gradient_clipping 0 and 1.0, with steps where clipping triggers and steps where it does not
gradient_accumulation_steps 1, 2, 4

Special cases:

  • an injected inf/NaN gradient: the step is skipped and nothing moves (weights, moments, step count);
  • a parameter no rank uses in a step (the #8981 rules);
  • parameters kept in fp32 (#8843);
  • AutoEP experts, which have their own partition groups;
  • Muon;
  • tied weights;
  • reentrant activation checkpointing;
  • ratio < 1;
  • pin_memory: false;
  • offload_param: cpu and DeepCompile (out of scope): each new default falls back, and the result is bitwise the same
    as today;
  • safe_get/set_* between backward and step, and while work is still pending;
  • learning rate, betas, eps or weight decay changed between backward and step;
  • destroy() with work pending;
  • checkpoint save, load, and universal-checkpoint conversion;
  • offload_states() / reload_states();
  • the non-CUDA CI jobs (AMD, Gaudi, XPU, CPU) for tier 1.

The committed tier-1 cases go under tests/unit/v1/, which the modal-torch-latest nightly runs every day. It passed
on 2026-11-14, 11-15 and 11-18, and failed on 11-16, 11-17 and every day from 11-19 to 11-23; it must pass for the
tier-1 cases to mean anything. The other GPU nightly, aws-torch-latest-full, runs tests/unit/ without the ZenFlow
tests. It has been cancelled every day from 2026-09-22 to 2026-11-22, and its last success was 2026-07-31.

Convergence. Only if an option that changes the math is built: the rescale-and-undo early step (L7). Moving
ZenFlow's column-selective update into the default path (M5) is compared bitwise against ZenFlow instead.

  1. Qwen2.5-7B fine-tuned on MetaMathQA with GSM8K evaluation, as xylian86 ran it on #8719.
  2. A pre-training-like run with warmup and frequent clipping, against the run without offload.

Benchmark rules.

  • No benchmark in CI. The PR author runs the benchmark and reports the results in the PR. The benchmark code and
    results are not checked in.
  • Per PR:
    • 1 node; a 7B model and Qwen2.5-32B; at least 20 steps; mean of the steady-state steps;
    • a change must not be more than 2% slower on any row (xylian86's ReFlow runs over four bucket and worker settings differed by at most 0.6%, 6.96-7.00 s, each a median
      of steps 3-5);
    • also one single-GPU workstation row (1 GPU, 8-16 cores), a common offload setup.
  • Full set, only for the O6 decision and before cleanup (M5): also an x86 single-socket node at about 12 cores per GPU, a
    dual-socket node, and a multi-node MoE run.
  • GH200/GB200: reported when someone can run it, not required.
  • Reported each time: step time, optimizer time on the critical path, GPU idle time, host and pinned memory.
  • PCIe bytes are counted from the code, not measured.

The O6 benchmark, in two steps. Only the exact form can become a default, so both steps compare the exact form
turned on against turned off:

  1. Before M3, to decide whether to build it: ReFlow (#8719) with and without its early step. #8719 at 09a8ab753
    has no config switch for this, so st-bang97 adds one; the ReFlow paper's Table 5 has the same comparison on B200. It runs on
    at least one x86 node of 8 H200, and on B200 if someone can run it; st-bang97 no longer has a multi-GPU
    machine (said on #8719). A run of #8719 against #9021 as they
    are does not answer this question: it compares two whole implementations, not the early step alone.
  2. In M3 PR (10), to decide the default: the default path with the exact form turned on against turned off.

Rules for both steps:

  • fix the hardware rules first: cores per GPU, one socket per 4 GPUs (st-bang97 agreed this is typical on #8719,
    2026-11-10), and the STREAM memory bandwidth per GPU, reported;
  • vary batch × sequence length; report clipped and unclipped step times and the clip rate;
  • a third person runs it and publishes the logs;
  • agree on the decision rule and the noise threshold before running. "Chosen per node automatically" is an allowed
    outcome.

6. Deprecation and cleanup

Config: the method names stay. Each method's code goes, but its key stays as a permanent preset, so user configs
keep working and the published methods keep their names.

Key today After cleanup (M5)
offload_optimizer.super_offload: true preset: turns on the default path's early step if M3 is built (otherwise the default path as it is), and the GH200 settings
zero_optimization.reflow: {...} preset: turns on the matching default-path options (most are then on by default; the early step only if M3 is built)
zero_optimization.zenflow: {...} preset: turns on the column-selective update, an option of the default path that is off by default. It stays an option, not a default, because it changes the math
sub-keys: cpuadam_cores_perc, pt_reserved_cores_perc; ReFlow's CPU keys num_threads, enable_cpu_affinity, main_thread_cores, main_thread_core_type, pin_main_thread, worker_core_type, bucketwise_worker_affinity, bucketwise_cores_per_worker, state_update_cores, state_update_backward_cores; ReFlow's h2d_chunk_size_mib the CPU keys map to the one core-split setting; h2d_chunk_size_mib maps to the copy-back piece size (fixed today at 2^26 elements, stage3.py:261). Under the #8489 rule, a key that is not mapped fails at parse time

Window. DeepSpeed released v0.19.7 on 2026-09-16, v0.19.8 on 10-20, v0.19.9 on 10-29 and v0.20.0 on 11-12. So
"two releases" is only about 3 to 6 weeks (23 days from v0.19.8 to v0.20.0, 43 days from v0.19.7 to v0.19.9). Proposal:

  • at least two minor versions and three months;
  • every internal off switch stays until cleanup (M5).

Warnings. Python hides DeprecationWarning by default outside __main__. Use a FutureWarning, or a warning
logged on rank 0. Write the rule down in CONTRIBUTING.md as part of M5. GOVERNANCE.md gives the approval of
deprecations to the Technical Steering Committee.

Code to remove (counts on master f1d37eb2b; #9021 and #8719 change them, so recount at cleanup):

  • SuperOffload's 7 method overrides and its separate worker process.

  • ReFlow's subclass (29 overrides), and its separate CPU optimizer builders if the shared kernel family covers them.

  • ZenFlow's 19 functions attached to the ZeRO-3 optimizer at run time, and the lines in the base classes that use
    self.zenflow (11 in stage_1_and_2.py, 9 in stage3.py, 8 in engine.py), plus the other ZenFlow code in those
    files, such as create_zenflow_hooks (stage3.py:624-642) and its calls (lines naming ZenFlow at all: 22, 30 and
    28). What the column-selective option (L1) needs moves out of the base classes into that option; the rest is
    removed.

  • The repeated pieces:

    Piece Copies today
    ZeRO-3 partition_grads 3 (4 with ReFlow)
    Python loop over parameters in CPU Adam 4
    CPU worker 2 (3 with ReFlow)
    copy of the master back to the device 7

Docs. One CPU-offload page with a table of:

  • what is on by default;
  • what each option and preset changes;
  • the hardware each one helps.

The ZenFlow and SuperOffload tutorials and blogs link to it.

Done when:

  • no optimizer subclass overrides step, partition_grads or the copy-back to implement an offload method;
  • each repeated piece above exists once;
  • each change's tier-1 cases run in CI, and the tier-2 run before cleanup is reported.

Code references are to master f1d37eb2b (2026-11-23), #8719 at 09a8ab753 and #9021 at b2b46ae93. Paper
references are to the ZeRO-Offload paper (arXiv 2101.06840), the SuperOffload paper (arXiv 2509.21271) and the ReFlow
camera-ready. Items marked "from reading" or "estimate" were not run. AI assistance was used to survey the code and
draft this text.

Ngôn ngữ chính
Python
Star
43.3k
Fork
5.1k
Merge trung bình
5 ngày 10 giờ
Pull request đã merge (30 ngày)
85

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của deepspeedai/DeepSpeed

Tất cả issue của deepspeedai/DeepSpeed

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.