FlowMatchSFTLoss: BF16 timestep rounding silently zeros Wan training loss
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
調査の方向性
Start with diffsynth/diffusion/flow_match.py and the FlowMatchSFTLoss code that casts scheduler.timesteps[timestep_id] before calling add_noise and training_weight. Reproduce the CPU example in the issue, then trace how both scheduler methods look up the timestep. Done when the sampled ID 1 retains its nonzero weight under BF16 model compute and a regression test covers the case.
索引モデルが issue の本文から書いたものです。
説明
Summary
In Wan FlowMatch SFT with a BF16 pipeline, a sampled timestep with a nonzero training weight can silently become a zero-loss step. The sampled FP32 timestep is converted to BF16 before FlowMatchScheduler.training_weight() looks it up again by value. Near 1000, several distinct schedule entries round to 1000 and resolve to index 0, whose training weight is zero.
This is related to #1499's BF16 timestep rounding, but that fix changed DDIMScheduler's out-of-range indexing. This report concerns FlowMatchScheduler's silent zero weight in Wan training.
Minimal reproduction (CPU; no model weights needed)
import torch
from diffsynth.diffusion.flow_match import FlowMatchScheduler
scheduler = FlowMatchScheduler("Wan")
scheduler.set_timesteps(1000, training=True)
sampled_id = torch.tensor([1])
fp32_timestep = scheduler.timesteps[sampled_id]
bf16_timestep = fp32_timestep.to(torch.bfloat16)
sampled_weight = scheduler.linear_timesteps_weights[sampled_id]
effective_weight = scheduler.training_weight(bf16_timestep)
print("sampled_id:", sampled_id.item())
print("fp32_timestep:", fp32_timestep.item())
print("bf16_timestep:", bf16_timestep.item())
print("sampled_weight:", sampled_weight.item())
print("effective_weight:", effective_weight.item())
assert sampled_weight.item() > 0
assert effective_weight.item() == 0
Observed: sampled_id=1, FP32 timestep 999.7998046875, BF16 timestep 1000.0, sampled weight 0.0012814513, effective weight 0.0. With the Wan schedule and BF16 conversion, sampled IDs 0..9 all resolve to weight index 0.
Training observation
In an 8-GPU Wan2.2-I2V-A14B high-noise SFT run (min_timestep_boundary=0, max_timestep_boundary=0.358, BF16, seed 3407), rank 0 recorded loss 0.0 at steps 86 and 89. A diagnostic rerun with only logging added to FlowMatchSFTLoss reproduced both steps:
| Step | Sampled ID | Unweighted MSE | Effective weight | Final loss |
|---|---|---|---|---|
| 86 | 1 | 0.01783781499 | 0.0 | 0.0 |
| 89 | 1 | 0.02866772749 | 0.0 | 0.0 |
The nonzero MSE rules out a perfect prediction. The loss code currently casts scheduler.timesteps[timestep_id] to pipe.torch_dtype before calling add_noise and training_weight; both scheduler methods locate the nearest entry from the rounded value. set_training_weight() subtracts the minimum weight, making index 0 exactly zero for this 1000-step Wan schedule.
Expected behavior / possible fix
Keep the original sampled schedule entry or index for scheduler calculations, including add_noise and training-weight lookup. Cast the timestep for model compute separately if required. A regression test could check that sampled ID 1 retains its nonzero weight under BF16 model compute; currently it silently maps to ID 0.
- 主要言語
- Python
- スター
- 13.5k
- フォーク
- 1.3k
- 平均マージ
- 1日 13時間
- マージ済み PR(30日)
- 46
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelscope/DiffSynth-Studio のほかの issue
-
Partial download surfaces as "Cannot detect the model type" rather than a download error再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
modelscope/DiffSynth-Studio#1668 ·
メンテナーはふだん 1 日以内に返信
-
bfloat16训练时段错误: 数组越界的一种方案再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelscope/DiffSynth-Studio#1499 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
modelscope/DiffSynth-Studio#1373 · コメント 5 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
蒸馏后 Edit 能力下降オープン
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
modelscope/DiffSynth-Studio#1881 ·
メンテナーはふだん 1 日以内に返信
-
TrajectoryImitationLoss: the regularization term (loss_2) has no gradient path to the student対応中かも @shizuku-desir7e が今日担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
modelscope/DiffSynth-Studio#1875 ·
メンテナーはふだん 1 日以内に返信
modelscope/DiffSynth-Studio の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choice対応中かも @beartester34 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
modelscope/evalscope#2330 ·
メンテナーはふだん 1 日以内に返信
-
Distribution plot crashes when a numeric feature is constant in the train or test set対応中かも @adembilge が今日担当しました。 オープンbug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 10 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 2 日以内に返信
-
namespace team:operations
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
EclipseFdn/open-vsx.org#16738 ·
メンテナーはふだん 1 日以内に返信