Skip to content

[REQUEST] Add ReFlow: Asynchronous CPU-Offloaded Optimizers for ZeRO-3 #8697

Open

Description

@st-bang97

Is your feature request related to a problem? Please describe.

CPU optimizer offloading substantially reduces GPU memory usage, but the offloaded gradient and optimizer path can become a major performance bottleneck.

In the conventional ZeRO-3 CPU-offload path, several sources of overhead accumulate around the optimizer update:

  • gradients are promoted from BF16 to FP32 on the GPU before offload;
  • the resulting FP32 gradients increase PCIe transfer volume;
  • a separate FP32 gradient buffer must be materialized and accessed on the CPU;
  • gradient accumulation can repeatedly retrieve previously offloaded gradients back to the GPU;
  • optimizer operations repeatedly materialize intermediate values in host memory; and
  • the host optimizer update remains largely serialized with respect to GPU execution.

I would like to contribute ReFlow, a new asynchronous CPU-offloaded optimizer path for ZeRO-3 that addresses these costs in two complementary ways:

  1. Reduce gradient-processing and CPU optimizer overhead itself, including gradient promotion, PCIe traffic, gradient-accumulation stalls, FP32 gradient materialization, and host-memory traffic.
  2. Overlap the remaining CPU optimizer execution with GPU backward computation.

Describe the solution you'd like

ReFlow introduces an asynchronous CPU-offloaded optimizer path for ZeRO-3 built around three main mechanisms: CPU-centric gradient processing, register-resident SIMD optimizer execution, and decoupled Ready/Persist scheduling.

1. CPU-centric gradient processing

ReFlow keeps gradients in BF16 across the GPU-CPU boundary instead of promoting them to FP32 on the GPU before transfer.

BF16-to-FP32 promotion is performed only when each gradient value is consumed inside the SIMD optimizer kernel. The promoted value stays in SIMD registers and is directly consumed by the optimizer computation rather than being materialized as a standalone FP32 gradient tensor.

This:

  • removes GPU-side BF16-to-FP32 gradient promotion;
  • reduces D2H gradient traffic from FP32 to BF16;
  • eliminates the standalone FP32 gradient buffer on the CPU;
  • removes the associated FP32 gradient reads and writes in host memory; and
  • folds precision promotion directly into the fused SIMD optimizer path.

ReFlow also performs intermediate gradient accumulation on the CPU.

In the conventional CPU-offload path, partial gradients may reside on the CPU while accumulation remains GPU-resident. Each additional micro-step therefore requires the previously offloaded gradient to be transferred back to the GPU for accumulation, introducing repeated blocking H2D transfers.

ReFlow instead retains the accumulated partial gradient on the CPU and accumulates subsequent BF16 partial gradients using a lightweight SIMD kernel. Intermediate micro-steps therefore form a one-way GPU-to-CPU gradient stream without repeatedly retrieving the accumulated gradient.

Only at the final micro-step is the accumulated CPU-side gradient transferred back to the GPU once. The GPU performs the final addition together with gradient-norm computation, after which the finalized gradient is transferred to the CPU for the optimizer update.

This eliminates repeated blocking PCIe transfers during intermediate accumulation steps while preserving the final GPU-side accumulation and gradient-norm semantics.

2. Register-resident SIMD optimizer execution

ReFlow reduces the CPU optimizer cost itself using fused AVX/SIMD kernels.

Instead of executing gradient scaling, precision conversion, optimizer arithmetic, parameter conversion, and state updates as separate tensor operations that repeatedly materialize intermediate values in host DRAM, ReFlow performs them inside a fused SIMD body.

Intermediate values remain in SIMD registers whenever possible across:

  • BF16-to-FP32 promotion;
  • gradient scaling;
  • optimizer arithmetic;
  • FP32-to-BF16 parameter conversion; and
  • selective output stores.

This reduces host-memory traffic and lowers the CPU optimizer execution cost that would otherwise remain exposed on the training critical path.

3. Ready/Persist scheduling and CPU-GPU overlap

ReFlow starts CPU optimizer work during GPU backward, as gradient buckets become available, instead of waiting for the entire backward pass and step-wide validation to complete.

To safely enable this overlap in mixed-precision training, ReFlow separates each optimizer update into two phases:

  • Ready: produce the low-precision parameter required by subsequent GPU execution while leaving the persistent FP32 master parameter and optimizer states unchanged.
  • Persist: after step-wide validation is finalized, commit the FP32 master parameter and optimizer states.

The low-precision parameter has an earlier deadline because it is required by subsequent GPU execution, while the FP32 master parameter and optimizer moments only need to be persistent before a future optimizer update consumes them.

Separating these deadlines allows latency-critical Ready work to overlap with GPU backward while the heavier FP32-state persistence proceeds later on the CPU.

4. Validation without FP32 optimizer-state rollback

ReFlow does not require rollback of FP32 optimizer state.

During the provisional Ready phase, the FP32 master parameter and optimizer moments remain unchanged.

If gradient clipping changes the finalized update, ReFlow discards the provisional low-precision output and re-executes only the lightweight Ready path using the finalized clipping factor.

If overflow invalidates the optimizer step, the provisional output is discarded and the low-precision parameter is restored from the unchanged FP32 master parameter.

Persistent FP32 optimizer state therefore never needs to be speculatively modified and rolled back.

Under deterministic GPU execution, ReFlow preserves baseline-visible update behavior and has been verified to produce bit-identical deterministic training results.

Proposed DeepSpeed integration

The implementation includes:

  • ReFlow Adam/AdamW and Lion CPU optimizers;
  • BF16 gradient transfer with point-of-use FP32 promotion inside SIMD registers;
  • CPU-resident gradient accumulation for intermediate micro-steps;
  • a single GPU-side final accumulation together with gradient-norm computation;
  • elimination of repeated blocking H2D gradient retrievals during accumulation;
  • register-resident AVX/SIMD optimizer kernels;
  • asynchronous bucket-wise CPU optimizer execution during GPU backward;
  • Ready/Persist scheduling and synchronization;
  • clipping and overflow handling without FP32 optimizer-state rollback;
  • zero_optimization.reflow configuration;
  • unit and training correctness tests;
  • example configurations; and
  • documentation.

Describe alternatives you've considered

One alternative is to optimize only the existing synchronous CPU optimizer path. This can reduce individual optimizer execution time, but the remaining host update still stays exposed on the training critical path.

Another approach is to speculatively modify persistent FP32 optimizer state while backward is still in progress and roll it back if step-wide validation later changes or invalidates the update.

ReFlow instead leaves the persistent FP32 master parameter and optimizer states untouched until validation has completed. This avoids FP32-state rollback entirely and limits clipping recovery to re-executing the much lighter Ready path.

Additional context

The ReFlow design and evaluation have been accepted to ASPLOS 2027 as:

ReFlow: Exposing Parallelism in CPU-Offloaded LLM Training via Register-Resident SIMD Fusion and Decoupled Update Scheduling

The paper is currently going through the publication process. Once it becomes publicly available, I will update this issue and the corresponding PR with the paper link and publish a technical blog covering ReFlow's design, usage, and evaluation.

The current implementation has already been evaluated for both performance and correctness.

For the standard AdamW training path on OPT-30B, ReFlow reduces the exposed optimizer update tail by more than 96.8% across the evaluated gradient-accumulation configurations and reduces total step time by up to 74.3%.

Representative OPT-30B results on NVIDIA B200 GPUs are:

Configuration ZeRO-Infinity ReFlow Speedup
1x B200 166.41 TFLOPS/GPU 671.29 TFLOPS/GPU 4.0x
4x B200 366.40 TFLOPS/GPU 681.18 TFLOPS/GPU 1.86x
8x B200 420.36 TFLOPS/GPU 673.81 TFLOPS/GPU 1.60x

The single-GPU result isolates the CPU-offloaded update path from distributed communication and demonstrates the efficiency improvement of the host-side execution itself.

The improvement also persists across GPU generations. On a single NVIDIA A100 at 15B, ReFlow achieves 1.7x higher throughput than ZeRO-Infinity.

ReFlow also removes the repeated blocking H2D retrievals caused by GPU-resident gradient accumulation. In our OPT-30B profiling, the conventional path incurred approximately 1,063 ms of blocking transfer per accumulation, causing the communication stall to grow approximately linearly with accumulation depth. CPU-resident accumulation removes these intermediate retrievals.

When gradient clipping is triggered, ReFlow retains its advantage without requiring FP32 optimizer-state rollback. For OPT-30B, the critical-path host update time of a clipped step decreases from:

2440 ms to 850 ms

which is a 65.2% reduction compared with ZeRO-Infinity.

The clipping evaluation triggers clipping frequently in order to obtain enough clipped steps for measurement. The reported values are the update costs of a step in which clipping occurs; ReFlow's normal optimizer-path optimization does not depend on frequent clipping.

Because persistent FP32 optimizer state has not been modified before validation, a clipped step only re-executes the lightweight Ready path and requires no FP32 optimizer-state rollback.

ReFlow is also not specific to AdamW. In a separate evaluation with Lion, ReFlow achieves 1.6x-4.4x higher throughput than ZeRO-Infinity-Lion across 1-8 GPUs.

The implementation has been tested across multiple GPU and CPU platforms, including:

  • NVIDIA B200
  • NVIDIA A100
  • NVIDIA RTX 5080
  • NVIDIA RTX A5000
  • NVIDIA RTX PRO 6000
  • AMD EPYC CPUs
  • Intel Xeon CPUs

Validation covers:

  • Adam/AdamW and Lion;
  • asynchronous CPU optimizer / GPU backward overlap;
  • BF16 gradient transfer and in-register FP32 promotion;
  • CPU-resident gradient accumulation;
  • gradient clipping;
  • gradient accumulation;
  • loss-scale overflow handling;
  • checkpointing;
  • learning-rate scheduling;
  • high-precision optimizer-state access;
  • single- and multi-GPU execution; and
  • deterministic baseline comparison.

Activity

  1. added
    enhancement
    on Sep 29, 2026
  2. sfc-gh-truwase commented on Oct 29, 2026

    @sfc-gh-truwase
    Collaborator

    @st-bang97 thanks for contributing this great work to DeepSpeed. I think the differentiated handling of CPU-based low-precision and higher-precision weights is a neat insight; kudos! I also appreciate the extensive validation and DSE PR. Congratulations on the ASPLOS acceptance, I look forward to reading the paper.

    1. Is NVMe offload enabled in the ZeRO-Infinity comparison?
    2. Did you consider on-the-fly grad norm computation on the GPU, by maintaining intermediate norm accumulations gradients stream to the CPU? If that is possible, then the final H2D/D2H round-trip could be avoidable.
  3. sfc-gh-truwase commented on Oct 29, 2026

    @sfc-gh-truwase
    Collaborator

    @st-bang97 thanks for contributing this great work to DeepSpeed. Congratulations on the ASPLOS acceptance, I look forward to reading the paper.

    I think the deadline-based handling of CPU-based low-precision and higher-precision weights is a neat insight; kudos! I also appreciate the extensive validation and DSE PR.

    1. Is NVMe offload enabled in the ZeRO-Infinity comparison?
    2. Did you consider on-the-fly grad norm computation on the GPU, by maintaining intermediate norm accumulations gradients stream to the CPU? If that is possible, then the final H2D/D2H round-trip could be avoidable.
    3. Rather than implementing ReFlow as an alternative, will you consider using the main insights to improve existing offload in DeepSpeed? I realize this requires more work, but the upside is greater impact as existing users will experience immediate benefits with minimal changes to their workflow.
  4. st-bang97 commented on Oct 29, 2026

    @st-bang97
    ContributorAuthor

    Thank you for the encouraging feedback and thoughtful suggestions!

    1. NVMe offload in the baseline comparison

    No, NVMe offloading was not enabled. We used ZeRO-3 with CPU offloading only.

    This was intentional to ensure a fair comparison and isolate the CPU optimizer and offloading overheads targeted by ReFlow, without introducing additional NVMe I/O latency.

    1. On-the-fly gradient norm computation

    We also considered computing the gradient norm on the CPU. However, in our experiments, CPU-side norm computation incurred more overhead than the final PCIe round-trip, which led us to retain GPU-side norm computation.

    I think your suggestion of incremental GPU-side norm computation is interesting and worth exploring further. Since ReFlow accumulates intermediate gradients on the CPU, we would need a more careful mathematical analysis of how intermediate norm computations can reproduce the norm of the final accumulated gradients.

    So far, ReFlow has prioritized bitwise-identical results with the baseline under deterministic execution. For this reason, we have not yet explored alternative numerical computation or reduction orders that could change the resulting bits.

    There may also be opportunities to improve overlap by processing the final gradient accumulation and norm computation in smaller chunks, similar to the fine-grained processing approach explored in SuperOffload.

    However, we would need additional profiling to determine whether repeated intermediate norm computations and finer-grained pipelining actually outperform the current approach, considering PCIe utilization, GPU computation overhead, and kernel launch costs.

    I think this would be a valuable direction for further discussion.

    1. Integration with existing DeepSpeed offload

    I agree that incorporating broadly applicable improvements into the existing DeepSpeed offload path would benefit more users.

    As I outlined in my "comment on the DeepSpeed Q4 2026 roadmap (#8672)" (#8672 (comment)), I plan to contribute these optimizations to the existing DeepSpeed CPU offload path through three smaller PRs:

    1. Fused CPUAdam kernel: Integrate gradient scaling/clipping and low-precision parameter generation.
    2. Low-precision gradient offloading: Transfer BF16/FP16 gradients directly to the CPU with FP32 promotion inside SIMD registers.
    3. CPU-side gradient accumulation: Reduce intermediate CPU–GPU round trips during gradient accumulation.

    Meanwhile, I would like to keep ReFlow as a separate PR for now, since its asynchronous workers, gradient buffers, and update scheduling are closely coupled.

    As these optimizations are integrated into the existing DeepSpeed path, I plan to further refine ReFlow and consolidate the shared code to reduce duplication and improve maintainability.

    1. Potential Superchip support

    One additional thought: I think it would be interesting to explore adapting ReFlow to Superchip architectures such as GH200 or GB200, especially given the different CPU–GPU interconnect characteristics highlighted in SuperOffload.

    Unfortunately, I currently don't have access to Superchip hardware for evaluation. Since you've worked on SuperOffload, I'd be interested in your thoughts on this direction and whether you might be interested in exploring it together if suitable hardware becomes available.

  5. sfc-gh-truwase commented on Oct 29, 2026

    @sfc-gh-truwase
    Collaborator

    @st-bang97 thanks for the clarifications.

    3. Integration with existing DeepSpeed offload

    Your plan sounds good to me. I have added ReFlow to the roadmap item you expressed interest in. I think it is important to eventually consolidate ReFlow and ZenFlow into default code paths for maintainability.

    4. Potential Superchip support

    Yes, this is a great idea. Can you please join the slack channel to coordinate this?

  6. sfc-gh-truwase commented on Oct 29, 2026

    @sfc-gh-truwase
    Collaborator

    @st-bang97, did you consider that bf16 gradient accumulation on CPU is sometimes inferior to fp32. And so the fp32 grad buffer on CPU is unavoidable. This observation was critical for the BLOOM model training.

  7. st-bang97 commented on Oct 30, 2026

    @st-bang97
    ContributorAuthor

    Thanks for adding ReFlow to the roadmap and supporting the Superchip direction! I've already joined the DeepSpeed Slack workspace as "st-bang97" and would be happy to coordinate there.

    Regarding BF16 accumulation, I agree that FP32 can provide better numerical accuracy, as demonstrated in BLOOM.

    My initial goal was to optimize DeepSpeed's existing mixedprecison training path while preserving its numerical behavior. Since BF16 is the default accumulation dtype for the training in DeepSpeed, I focused on improving that path first.

    Supporting FP32 accumulation in ReFlow should also be feasible, and I think offering both options would be a good direction for accommodating different numerical accuracy requirements.

  8. pengdurice commented on Oct 30, 2026

    @pengdurice
    Contributor

    @st-bang97 thank you for this Request, I think it is very valuable to add ReFlow and I agree with @sfc-gh-truwase that eventually we should fold this and ZenFlow to the default path since these are generally useful features. I will take a closer look at your PR.

  9. pengdurice commented on Oct 31, 2026

    @pengdurice
    Contributor

    9. @st-bang97 thanks for the clarifications.
    > 3. Integration with existing DeepSpeed offload

    Your plan sounds good to me. I have added ReFlow to the roadmap item you expressed interest in. I think it is important to eventually consolidate ReFlow and ZenFlow into default code paths for maintainability.
    > 4. Potential Superchip support
    
    
    Yes, this is a great idea. Can you please join the [slack channel](https://join.slack.com/t/deepspeedworkspace/shared_invite/zt-3a8pjd8dd-PCj2hMvR4Y2syPwVnjEoww) to coordinate this?
    

    @sfc-gh-truwase , want to hear your thoughts on if we should check in ReFlow individually or at this moment, work with @st-bang97 to break the pieces into the main path for maintainability while consolidating ZenFlow. I am not sure how frequent ZenFlow is being used. I feel if possible, we can have the pieces checked in to the main path early on and turn on optimizations that can be universally beneficial by default. WDYT?

  10. sfc-gh-truwase commented on Nov 1, 2026

    @sfc-gh-truwase
    Collaborator

    @pengdurice I think we should check in as so that it is immediately available to users. The consolidation if done properly can occur in the background with minimal impact on user-experience.

  11. pengdurice commented on Nov 4, 2026

    @pengdurice
    Contributor

    14. @pengdurice I think we should check in as so that it is immediately available to users. The consolidation if done properly can occur in the background with minimal impact on user-experience.

    SG, let's do that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions