{"record":{"id":"b848a5463ead0b43","repo":"unslothai/unsloth","slug":"cfg-dropout-must-be-between-0-and-1","errorCode":null,"errorMessage":"cfg_dropout must be between 0 and 1","messagePattern":"cfg_dropout must be between 0 and 1","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/training/diffusion_train_common.py","lineNumber":1166,"sourceCode":"                try:\n                    flow_shift = float(flow_shift)\n                except ValueError as exc:\n                    raise ValueError(\n                        f\"flow_shift must be a positive number or 'auto', got {self.flow_shift!r}\"\n                    ) from exc\n        if not isinstance(flow_shift, str):\n            flow_shift = float(flow_shift)\n            # isfinite as well as positive: JSON accepts 1e309, which floats to inf and would poison every sampled sigma while progress looks normal.\n            if not math.isfinite(flow_shift) or flow_shift <= 0:\n                raise ValueError(\n                    \"flow_shift must be a finite number > 0 (1.0 disables the shift), or 'auto'\"\n                )\n        try:\n            cfg_dropout = float(self.cfg_dropout or 0.0)\n        except (TypeError, ValueError) as exc:\n            raise ValueError(f\"cfg_dropout must be a number, got {self.cfg_dropout!r}\") from exc\n        if not 0.0 <= cfg_dropout <= 1.0:\n            raise ValueError(\"cfg_dropout must be between 0 and 1\")\n        weighting_scheme = str(self.weighting_scheme or \"none\").strip().lower()\n        if weighting_scheme not in (\"none\", \"bell\"):\n            raise ValueError(\"weighting_scheme must be one of none / bell\")\n        # 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.\n        if self.snr_gamma is not None and float(self.snr_gamma) <= 0:\n            raise ValueError(\"snr_gamma must be > 0, or null to disable min-SNR weighting\")\n        # learning_rate can arrive as a string (\"1e-4\") from the Studio config path, so coerce it before AdamW sees it.\n        try:\n            learning_rate = float(self.learning_rate)\n        except (TypeError, ValueError) as exc:\n            raise ValueError(f\"learning_rate must be a number, got {self.learning_rate!r}\") from exc\n        if learning_rate <= 0:\n            raise ValueError(\"learning_rate must be > 0\")\n        alpha = self.lora_alpha if self.lora_alpha is not None else self.lora_rank\n        targets = tuple(self.lora_target_modules) or DEFAULT_LORA_TARGETS\n        # A blank Hub token (the Studio default when none is configured) must load anonymously, not as an explicit empty credential.\n        token = self.hf_token.strip() if isinstance(self.hf_token, str) else self.hf_token\n        from core.inference.diffusion_families import (","sourceCodeStart":1148,"sourceCodeEnd":1184,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/training/diffusion_train_common.py#L1148-L1184","documentation":"cfg_dropout is a probability and must lie in [0.0, 1.0]. Values outside that range are meaningless as dropout rates and are rejected before training starts.","triggerScenarios":"cfg_dropout = 10 (percent instead of fraction), -0.1, or 1.5 in the training config.","commonSituations":"Users entering 10 for '10%'; percent/fraction confusion is by far the most common cause.","solutions":["Express the dropout as a fraction: 10% -> 0.1, 100% -> 1.0.","If the value arrives as a percentage from a UI, divide by 100 before assigning."],"exampleFix":"# before\ncfg = DiffusionLoraConfig(cfg_dropout=10)\n# after\ncfg = DiffusionLoraConfig(cfg_dropout=0.10)","handlingStrategy":"validation","validationCode":"def clamp_dropout(v, default=0.0):\n    v = float(v) if v is not None else default\n    if not 0.0 <= v <= 1.0:\n        raise ValueError('cfg_dropout must be a fraction in [0,1]')\n    return v","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always express dropout as a fraction; divide percentages by 100 at input time.","Range-check every probability field in one shared validator."],"tags":["training","config","validation","range-check","cfg"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}