[Bug] DeepSpeedEngine.step leaves _running_engine_step=True permanently on exception, corrupting is_gradient_accumulation_boundary()
Maintainer thường phản hồi trong vòng 2 ngày
@its-amann đang làm issue này rồi.
Từ ngày 29/11/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Bắt đầu trong deepspeed/runtime/engine.py tại DeepSpeedEngine.step() và is_gradient_accumulation_boundary(), sử dụng bản tái hiện độc lập trong issue để kích hoạt ngoại lệ về các hàng theo giai đoạn. Thêm quy trình dọn dẹp an toàn khi xảy ra ngoại lệ cho _running_engine_step, sau đó xác minh cờ là false và ranh giới trả về False sau khi thất bại. Issue chỉ ra tệp và các phương thức bị ảnh hưởng, nhưng không có tệp kiểm thử hồi quy hiện có nào được nêu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
In deepspeed/runtime/engine.py:3656-3659,3796-3888 (commit a695f646974c6c92da2a9028bbafde8bb28bad1e), DeepSpeedEngine.step() sets self._running_engine_step = True at line 3796 and only resets self._running_engine_step = False at line 3888 with no try ... finally: guard:
# Unmanaged mode: step() is the accumulation boundary.
self._running_engine_step = True
...
if any(dw_staging.has_staged_rows for dw_staging in getattr(self, "_autoep_dw_stagings", ())):
raise RuntimeError("Expert weight gradients are still staged at an optimizer step...")
...
self._take_model_step(lr_kwargs)
...
self._running_engine_step = False
Meanwhile, DeepSpeedEngine.is_gradient_accumulation_boundary() (lines 3656-3659) returns self._running_engine_step directly when managed_gradient_accumulation() is False:
if not self.managed_gradient_accumulation():
# Unmanaged mode: step() is the accumulation boundary (set only while step() runs).
return self._running_engine_step
If any exception is raised inside step() (e.g., the staged-rows RuntimeError at line 3816, a checkpoint commit failure, an optimizer step error, or a transient OOM) and caught by a caller/recovery loop, self._running_engine_step stays permanently True. Every subsequent backward() query to is_gradient_accumulation_boundary() will falsely report True even though step() is not running, corrupting gradient reduction/partitioning decisions in unmanaged gradient accumulation mode. (Contrast with DeepSpeedEngine.backward(), which wraps _running_engine_backward_count in try ... finally.)
Affected Location
- Repository:
deepspeedai/DeepSpeed(a695f646974c6c92da2a9028bbafde8bb28bad1e, present atHEAD) - File & lines:
deepspeed/runtime/engine.py:3656-3659(is_gradient_accumulation_boundary),3796-3888(step)
Minimal Standalone Reproduction
eng = DeepSpeedEngine.__new__(DeepSpeedEngine)
eng.inside_no_sync_ctxt = False
eng._is_gradient_accumulation_boundary = None
eng._running_engine_step = False
eng.zenflow = False
eng.micro_steps = 0
eng.global_steps = 0
eng.global_rank = 0
eng.enable_backward_allreduce = False
eng.memory_breakdown = lambda: False
eng.flops_profiler_enabled = lambda: False
eng.managed_gradient_accumulation = lambda: False
eng.zero_optimization_partition_gradients = lambda: True
# Minimal collaborator objects triggering line 3816 RuntimeError in upstream step()
eng.engine_timers = type("T", (), {"step_timers": []})()
eng.optimizer = type("Opt", (), {"finalize_gradient_accumulation_boundary": lambda self: None})()
eng.checkpoint_engine = type("Ckpt", (), {"is_decoupled": lambda self: False})()
eng._autoep_dw_stagings = (type("Stage", (), {"has_staged_rows": True})(),)
print("boundary_before_step:", eng.is_gradient_accumulation_boundary())
try:
eng.step()
except RuntimeError as exc:
print("step_error:", exc)
print("running_engine_step_after_exception:", eng._running_engine_step)
print("boundary_after_exception:", eng.is_gradient_accumulation_boundary())
Observed behavior / output:
boundary_before_step: False
step_error: Expert weight gradients are still staged at an optimizer step, which would apply them one step late. deferred_dw_flush_period needs the backward that closes each gradient accumulation window to run through the engine.
running_engine_step_after_exception: True
boundary_after_exception: True
Suggested Fix
Wrap the self._running_engine_step = True .. self._running_engine_step = False region in DeepSpeedEngine.step() inside a try: ... finally: self._running_engine_step = False block so _running_engine_step is always cleared even when step() exits via an exception.
- 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] 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
-
init_inference rejects dtype=torch.int8 on every acceleratorCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
deepspeedai/DeepSpeed#8577 ·
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