unslothai/unsloth · error · ValueError
flow_shift must be a positive number or 'auto', got {self.fl
Error message
flow_shift must be a positive number or 'auto', got {self.flow_shift!r} What it means
flow_shift accepts a positive number or the string 'auto' (family-default dynamic shift). If a string is supplied that is neither 'auto' nor parseable by float(), the config raises with the original value echoed. Numbers pass through a separate finite/positive check.
Source
Thrown at studio/backend/core/training/diffusion_train_common.py:1151
# scheme cleared only for rendering reach a trainer.
from core.inference.diffusion_transformer_quant import _family_train_denied
if _family_train_denied(resolved_family, base_precision):
raise ValueError(
f"base_precision={base_precision!r} is not validated for training "
f"{resolved_family}. Use 'nf4', 'int8', 'bf16', or 'auto'."
)
# flow_shift: None resolves to the family default ("auto" only for qwen-image, whose scheduler skips its static shift under use_dynamic_shifting); an explicit value is validated and kept.
flow_shift = self.flow_shift
if flow_shift is None:
flow_shift = "auto" if resolved_family in AUTO_FLOW_SHIFT_FAMILIES else 1.0
if isinstance(flow_shift, str):
flow_shift = flow_shift.strip().lower()
if flow_shift != "auto":
try:
flow_shift = float(flow_shift)
except ValueError as exc:
raise ValueError(
f"flow_shift must be a positive number or 'auto', got {self.flow_shift!r}"
) from exc
if not isinstance(flow_shift, str):
flow_shift = float(flow_shift)
# isfinite as well as positive: JSON accepts 1e309, which floats to inf and would poison every sampled sigma while progress looks normal.
if not math.isfinite(flow_shift) or flow_shift <= 0:
raise ValueError(
"flow_shift must be a finite number > 0 (1.0 disables the shift), or 'auto'"
)
try:
cfg_dropout = float(self.cfg_dropout or 0.0)
except (TypeError, ValueError) as exc:
raise ValueError(f"cfg_dropout must be a number, got {self.cfg_dropout!r}") from exc
if not 0.0 <= cfg_dropout <= 1.0:
raise ValueError("cfg_dropout must be between 0 and 1")
weighting_scheme = str(self.weighting_scheme or "none").strip().lower()
if weighting_scheme not in ("none", "bell"):
raise ValueError("weighting_scheme must be one of none / bell")View on GitHub (pinned to 203007d190)
Solutions
- Set flow_shift to a positive float (e.g. 1.0) or the literal string 'auto'.
- Omit flow_shift (None) to take the family default: 'auto' for AUTO_FLOW_SHIFT_FAMILIES like qwen-image, 1.0 otherwise.
- If the value comes from user input, normalize locale decimal separators and strip whitespace before assigning.
Example fix
# before cfg.flow_shift = '1,5' # or 'default' # after cfg.flow_shift = 1.5 # or 'auto', or None for the family default
Defensive patterns
Strategy: type-guard
Validate before calling
def normalize_flow_shift(v):
if v is None:
return None
if isinstance(v, str):
s = v.strip().lower()
if s == 'auto':
return 'auto'
v = float(s) # raises here instead of inside the trainer
return float(v) Type guard
def is_valid_flow_shift(v) -> bool:
if v is None:
return True
if isinstance(v, str):
s = v.strip().lower()
if s == 'auto':
return True
try:
v = float(s)
except ValueError:
return False
return isinstance(v, (int, float)) Prevention
- Normalize locale-formatted numbers (replace ',' with '.') and strip whitespace before assigning flow_shift.
- Prefer passing a float or omitting the field; only send the string 'auto' explicitly.
When it happens
Trigger: Setting flow_shift to a non-numeric string such as 'default', '1,0' (locale decimal comma), or '' (empty string after strip/lower) in DiffusionLoraConfig.
Common situations: Studio UI or hand-edited YAML/JSON config with a typo'd or localized number; passing None-like placeholder strings; copy-pasting a scheduler name into the field.
Related errors
- base_precision={base_precision!r} trains in bf16 compute; se
- flow_shift must be a finite number > 0 (1.0 disables the shi
- cfg_dropout must be a number, got {self.cfg_dropout!r}
- cfg_dropout must be between 0 and 1
- weighting_scheme must be one of none / bell
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/e04430ebb1fe1124.
Report an issue: GitHub.