[BUG] ZeRO-1 with fp32 grad accumulation rounds the window sum to the communication dtype
Maintainer thường phản hồi trong vòng 2 ngày
@kritikagarg đang làm issue này rồi.
Từ ngày 22/11/2026.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- distributed-systems, machine-learning
Hướng nghiên cứu
Start with DeepSpeedZeroOptimizer.allreduce_bucket and gradient_reduction_w_predivide, then trace how communication_data_type is selected for ZeRO-1 when grad_accum_dtype is fp32. Run tests/unit/v1/zero/test_zero_offload_accum_precision.py and compare the stage 1 and stage 2 window sums. Done means the sums match exactly while explicit communication dtype settings and the autocast and MoE paths retain their stated behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
With ZeRO-1, a 16-bit model, and grad_accum_dtype: fp32, the gradient window is summed in fp32 on each rank but then reduced in the communication dtype (bf16 by default for a bf16 model). The fp32 window sum is rounded once to bf16 before the all-reduce, so the extra accumulation precision is discarded at reduction.
ZeRO-2 with the same config reduces each micro-step and adds the result to an fp32 partition. For inputs that are exact in bf16, the window sum is then exact. ZeRO-1 is not.
Found while reviewing #9044 (the table row for stage 1, fp32 masters, fp32 accumulation).
Where it happens
- ZeRO-1 keeps the accumulated gradient in
param.grad_accum(fp32) viause_grad_accum_attribute. setup_bucketsand_gradient_reduction_buffer_dtypeallocate the IPG bucket in fp32, so the copy is exact.- At the boundary,
average_tensor/allreduce_bucketcast tocommunication_data_type(bf16 for a bf16 model) beforeall_reduce, so the sum is rounded there.
The cast is in DeepSpeedZeroOptimizer.allreduce_bucket and gradient_reduction_w_predivide. Our reading is that communication_data_type is not the same thing as the gradient accumulation dtype on this path.
Reproduction
tests/unit/v1/zero/test_zero_offload_accum_precision.py, 16 micro-steps with gradients exact in bf16, relative max error of the window sum read before step():
| stage | masters | accumulation | error |
|---|---|---|---|
| 2 | fp32 | fp32 | 0 |
| 1 | fp32 | fp32 | 2.4e-3 |
The same stage 1 value appears on a4c989b7, so this is pre-existing and not a regression from #9044.
Proposed change
When communication_data_type is not set explicitly, ZeRO-1 with fp32 accumulation on a 16-bit model reduces in gradient_accumulation_dtype (fp32). An explicit communication_data_type keeps its current meaning.
Costs and risks:
- All-reduce bytes double for these configs. The reduction runs once per window on ZeRO-1, so the cost is small next to ZeRO-2's per-micro-step reduce-scatter, but it is a visible change.
- Users can restore the old behavior with
communication_data_type: bf16. - Not checked yet: the autocast per-parameter comm dtype path and MoE expert groups. These should stay unchanged.
Acceptance
- Stage 1 and stage 2 window sums match exactly in the precision test for fp32 masters with fp32 accumulation.
- Existing ZeRO-1 offload, coalesced reduction, and gradient-safety suites still pass.
- B200 check of all-reduce time and step time, stage 1, one and two GPUs.
Open questions
- Default on, or opt-in?
- Should the explicit
communication_data_typesetting also be documented as the way to get the old rounding?
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của deepspeedai/DeepSpeed
-
[Bug] DeepSpeedEngine.step leaves _running_engine_step=True permanently on exception, corrupting is_gradient_accumulation_boundary()Có thể đã có người làm @its-amann đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
deepspeedai/DeepSpeed#9190 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug] PipelineEngine._exec_reduce_grads and _exec_optimizer_step leave _force_grad_boundary=True permanently after any exceptionCó thể đã có người làm @bantianyue đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
deepspeedai/DeepSpeed#9183 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
deepspeedai/DeepSpeed#9019 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
fp16 `hysteresis: 0` (or negative) makes DynamicLossScaler never lower the loss scale, so every overflowing step is skipped foreverCó thể đã có người làm @damienen đã nhận 26 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
deepspeedai/DeepSpeed#8982 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[BUG] OneCycle applies the minimum momentum to the first Adam updateCó thể đã có người làm @ai-yang đã nhận 30 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
deepspeedai/DeepSpeed#8951 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của deepspeedai/DeepSpeed
Issue tương tự
-
area/auth comp/agent P3 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#161417 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Dao-AILab/flash-attention#3251 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[New Check]: sqlserver_public_network_access_disabledCó thể đã có người làm @pouria-l đã nhận hôm nay. Đang mởfeature-request status/needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
prowler-cloud/prowler#13607 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
external langchain
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
langchain-ai/docs#8184 ·
Maintainer thường phản hồi trong vòng 1 ngày