unslothai/unsloth · error · ValueError
weighting_scheme must be one of none / bell
Error message
weighting_scheme must be one of none / bell
What it means
weighting_scheme selects the loss weighting strategy and only supports 'none' (uniform) and 'bell' (bell-shaped timestep weighting). Any other string after strip/lower normalization is rejected.
Source
Thrown at studio/backend/core/training/diffusion_train_common.py:1169
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")
# A zero/negative gamma would zero out (or invert) the min-SNR weight and silently train on a degenerate loss; None is the documented disable.
if self.snr_gamma is not None and float(self.snr_gamma) <= 0:
raise ValueError("snr_gamma must be > 0, or null to disable min-SNR weighting")
# learning_rate can arrive as a string ("1e-4") from the Studio config path, so coerce it before AdamW sees it.
try:
learning_rate = float(self.learning_rate)
except (TypeError, ValueError) as exc:
raise ValueError(f"learning_rate must be a number, got {self.learning_rate!r}") from exc
if learning_rate <= 0:
raise ValueError("learning_rate must be > 0")
alpha = self.lora_alpha if self.lora_alpha is not None else self.lora_rank
targets = tuple(self.lora_target_modules) or DEFAULT_LORA_TARGETS
# A blank Hub token (the Studio default when none is configured) must load anonymously, not as an explicit empty credential.
token = self.hf_token.strip() if isinstance(self.hf_token, str) else self.hf_token
from core.inference.diffusion_families import (
_is_local_path,
mirror_repo,
prefer_ungated_mirror,View on GitHub (pinned to 203007d190)
Solutions
- Use weighting_scheme='none' or 'bell'.
- If you ported a diffusers example config, drop its weighting_scheme value — the closest supported behavior here is 'bell'.
- Leave it unset; the default resolves to 'none'.
Example fix
# before cfg = DiffusionLoraConfig(weighting_scheme='zero_snr') # after cfg = DiffusionLoraConfig(weighting_scheme='bell')
Defensive patterns
Strategy: validation
Validate before calling
ALLOWED_WEIGHTING = {'none', 'bell'}
ws = str(weighting_scheme or 'none').strip().lower()
assert ws in ALLOWED_WEIGHTING, f'weighting_scheme must be one of {sorted(ALLOWED_WEIGHTING)}' Type guard
def is_valid_weighting_scheme(v) -> bool:
return str(v or 'none').strip().lower() in ('none', 'bell') Prevention
- Use a dropdown limited to 'none'/'bell' in the UI instead of free text.
- Strip unsupported weighting schemes when importing configs from other trainers.
When it happens
Trigger: weighting_scheme='simsnr', 'sigma-age', 'uniform', or any typo like 'bel' / 'Bell ' with stray characters that do not normalize to the two allowed values.
Common situations: Porting configs from other trainers (diffusers examples support schemes like 'sigma' or 'zero_snr' / 'zsnr') that this trainer does not implement.
Related errors
- snr_gamma must be > 0, or null to disable min-SNR weighting
- base_precision={base_precision!r} trains in bf16 compute; se
- flow_shift must be a positive number or 'auto', got {self.fl
- cfg_dropout must be a number, got {self.cfg_dropout!r}
- cfg_dropout must be between 0 and 1
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/fd62990ecc3ddb9b.
Report an issue: GitHub.