![[Request] add display "discrete_flow_shift", "timestep_sampling"](https://www.chat-gpts.plus/wp-content/uploads/2026/06/2383-e76fac8c.jpg)
[Request] add display “discrete_flow_shift”, “timestep_sampling”
快速结论:该请求在 Kohya SD Scripts 的训练日志中加入 timestep_sampling 和 discrete_flow_shift 的当前设置值显示,目的是让用户直观确认 discrete_flow_shift 是否实际生效。该功能已在合并的 PR 中按预期实现,无需额外命令即可在终端日志中查看。
问题场景
用户在使用 Kohya SD Scripts 训练 Anima 或 Flow Matching 模型(如 SD3、Flux 架构相关)时,配置了 discrete_flow_shift 但不确定该参数是否被正确使用。尤其是当 timestep_sampling 设置为 flux_shift 时,discrete_flow_shift 会被忽略,而用户没有直观的方式观察到这一状态。
报错原文
# 非错误,而是缺少 Info 日志。原讨论希望新增的输出格式示例:
INFO Timestep sampling: timestep_sampling=shift, discrete_flow_shift=3.0 flux_train_utils.py:565
(applied), sigmoid_scale=1.0
INFO Timestep sampling: timestep_sampling=flux_shift, flux_train_utils.py:565
discrete_flow_shift=3.0 (IGNORED for
timestep_sampling='flux_shift'; only 'sigma' and 'shift' use it),
sigmoid_scale=1.0
原因分析
这是一个功能请求,而非 Bug。原因在于:discrete_flow_shift 仅在 timestep_sampling 为 sigma 或 shift 时生效;当 timestep_sampling 为 flux_shift 时,该值被忽略。由于先前训练开始时没有明确的日志输出,用户无法轻松确认当前配置的生效状态,导致调试困难或误解设定是否起作用。
环境排查
- 确认 Kohya SD Scripts 的版本:该功能已在较新版本(2024年6月附近合并)中内置,需要更新至包含该日志输出的版本。
- 如果无法看到新增日志,检查是否使用了自定义或过时的脚本分支。
- 训练日志通常在终端(PowerShell / Terminal)输出,不需要额外命令行参数即可显示。
解决步骤
- 更新 sd-scripts 到最新版本: 拉取仓库最新提交,确保包含相关更改(涉及
flux_train_utils.py中的日志行)。 - 正常启动训练: 无需任何额外参数。运行训练命令(例如
accelerate launch train_flux.py ...)后,训练开始时会在日志中看到类似以下格式的输出:INFO Timestep sampling: timestep_sampling=shift, discrete_flow_shift=3.0 (applied), sigmoid_scale=1.0或
INFO Timestep sampling: timestep_sampling=flux_shift, discrete_flow_shift=3.0 (IGNORED for timestep_sampling='flux_shift'; only 'sigma' and 'shift' use it), sigmoid_scale=1.0 - 确认生效状态: 如果日志中显示
(applied),表示discrete_flow_shift值被使用;如果显示(IGNORED),则表示当前timestep_sampling设置不适用该参数,需要调整。
验证方法
启动训练后,在终端日志的前几行中定位到 “Timestep sampling:” 开头的信息。检查 discrete_flow_shift 后面是否显示 “applied” 或 “IGNORED”,并与你期望的配置比对。该行日志来自 flux_train_utils.py 文件。



