fp16 `hysteresis: 0` (or negative) makes DynamicLossScaler never lower the loss scale, so every overflowing step is skipped forever
メンテナーはふだん 2 日以内に返信
@damienen がすでに取り組んでいます。
2026年11月2日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
不具合は deepspeed/runtime/fp16/loss_scaler.py の update_scale にあり、スケールを下げる分岐が delayed_shift == 1 or cur_hysteresis == 1 を判定しています。チェックアウトに対して issue の再現スクリプトを実行し、0 の場合が 65536 のまま変わらないことを確認してください。変更する前に、0 以下を 1 と同様に扱うか、設定で拒否するかを決めてください。issue と #7856 で方針が食い違っています。完了条件は、再現スクリプトで hysteresis=0 のときにスケールが下がり、既存の loss scaler のテストがすべて通ることです。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
With fp16.hysteresis set to 0 or a negative number, DynamicLossScaler (the scaler ZeRO stages 1, 2 and 3 use through CreateLossScaler) never lowers its loss scale after an overflow. Every overflowing step is then skipped, and the "Current loss scale already at minimum" exit never triggers because the scale never reaches the minimum.
update_scale tests self.delayed_shift == 1 or self.cur_hysteresis == 1. When the counter starts at 0 or below, it only moves further from 1, so the branch that lowers the scale is never taken. DeepSpeedFP16Config.hysteresis has no validator, so the config loads without complaint. The default (hysteresis: 2) is not affected. The stage 0 fp16 optimizers already back off when cur_hysteresis is not above 1, so the two paths disagree on what 0 means.
To Reproduce
The script loads deepspeed/runtime/fp16/loss_scaler.py as is, with small stand-ins for the few torch and deepspeed names it imports (update_scale is plain Python arithmetic). SRC is a checkout of the repo.
import os, sys, types, logging
src = os.environ.get("SRC", "./src")
def mod(n, **kw):
m = types.ModuleType(n); m.__dict__.update(kw); sys.modules[n] = m; return m
mod("torch", half="half", bfloat16="bf16", float32="f32")
ds = mod("deepspeed", __path__=[])
comm = mod("deepspeed.comm", get_rank=lambda: 0); ds.comm = comm
mod("deepspeed.utils", log_dist=lambda *a, **k: None, logger=logging.getLogger("x"))
mod("deepspeed.runtime", __path__=[])
mod("deepspeed.runtime.config_utils", DeepSpeedConfigObject=object)
mod("deepspeed.runtime.utils", has_inf_or_nan=lambda x: False)
code = open(os.path.join(src, "deepspeed/runtime/fp16/loss_scaler.py")).read()
ns = {"__name__": "ls"}
exec(compile(code, "loss_scaler.py", "exec"), ns)
for h in (1, 0):
s = ns["CreateLossScaler"]("half", 0, True, dict(init_scale=2**16, scale_window=1000, delayed_shift=h, consecutive_hysteresis=False, min_scale=1))
for _ in range(40):
try: s.update_scale(True)
except Exception: break
print(f"hysteresis={h}: scale after 40 overflows = {s.cur_scale}; expected < 65536")
Expected behavior
Both cases lower the scale. Output on main:
hysteresis=1: scale after 40 overflows = 1.0; expected < 65536
hysteresis=0: scale after 40 overflows = 65536; expected < 65536
A value of 0 or below should either behave like 1 (no delay) or be rejected when the config is loaded.
ds_report output
Not run. The script above loads the one file from a source checkout, and DeepSpeed was not installed.
Screenshots
None. The output is text, above.
System info (please complete the following information):
- OS: Linux container (x86_64)
- GPU count and types: none, CPU only
- Interconnects (if applicable): none
- Python version: 3.13
- Any other relevant info about your setup: deepspeedai/DeepSpeed main at
f818504999bdd57c3e771368aefc301290020d9a. The same code is in v0.19.8 (0eb3a8bcc6d9).
Launcher context
No launcher. The script calls the scaler directly, without deepspeed, MPI or a training run.
Docker context
A plain Python 3.13 container, not a DeepSpeed image.
Additional context
I have not run a ZeRO training job with this setting. The claim covers the scaler class, which ZeRO stages 1 to 3 build with CreateLossScaler.
This issue was prepared with AI assistance and reviewed by a human.
Related
#7856 (open) would reject fp16.hysteresis below 1 at config parse time. This change instead makes DynamicLossScaler treat 0 or less as no delay, matching the stage 0 optimizers from #8647.
- 主要言語
- Python
- スター
- 43.3k
- フォーク
- 5.1k
- 平均マージ
- 5日 10時間
- マージ済み PR(30日)
- 85
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
deepspeedai/DeepSpeed のほかの issue
-
[Bug] DeepSpeedEngine.step leaves _running_engine_step=True permanently on exception, corrupting is_gradient_accumulation_boundary()対応中かも @its-amann が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
deepspeedai/DeepSpeed#9190 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
[Bug] PipelineEngine._exec_reduce_grads and _exec_optimizer_step leave _force_grad_boundary=True permanently after any exception対応中かも @bantianyue が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepspeedai/DeepSpeed#9183 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
deepspeedai/DeepSpeed#9019 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
[BUG] OneCycle applies the minimum momentum to the first Adam update対応中かも @ai-yang が 30 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepspeedai/DeepSpeed#8951 ·
メンテナーはふだん 2 日以内に返信
-
init_inference rejects dtype=torch.int8 on every accelerator再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepspeedai/DeepSpeed#8577 ·
メンテナーはふだん 2 日以内に返信
deepspeedai/DeepSpeed の issue をすべて見る
似ている issue
-
area/auth comp/agent P3 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
NousResearch/hermes-agent#161417 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Dao-AILab/flash-attention#3251 ·
メンテナーはふだん 2 日以内に返信
-
[New Check]: sqlserver_public_network_access_disabled対応中かも @pouria-l が今日担当しました。 オープンfeature-request status/needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
prowler-cloud/prowler#13607 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
external langchain
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
langchain-ai/docs#8184 ·
メンテナーはふだん 1 日以内に返信