{"record":{"id":"4ee0da6e79733743","repo":"unslothai/unsloth","slug":"learning-rate-must-be-0","errorCode":null,"errorMessage":"learning_rate must be > 0","messagePattern":"learning_rate must be > 0","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/training/diffusion_train_common.py","lineNumber":1179,"sourceCode":"        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 (\n            _is_local_path,\n            mirror_repo,\n            prefer_ungated_mirror,\n            upstream_is_gated,\n        )\n\n        if resolved_family == \"sdxl\":\n            fetch_base_model = self.base_model\n        else:\n            fetch_base_model = prefer_ungated_mirror(self.base_model, token or None)\n            # For a GATED upstream and no token, the cache preference has to be overridden: the\n            # credentials this run lacks are the credentials the fetch needs, so a partial\n            # snapshot cannot be completed and the start route's HEAD refuses even a complete","sourceCodeStart":1161,"sourceCodeEnd":1197,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/training/diffusion_train_common.py#L1161-L1197","documentation":"After successful float coercion, learning_rate must be strictly positive. A zero or negative learning rate would make AdamW a no-op (or diverge), so it is rejected at preflight rather than wasting a GPU-allocated run.","triggerScenarios":"learning_rate=0, -1e-4, or a string like '0' / '-0.0001'. Also '-0.0', which floats to -0.0 and fails the <= 0 check.","commonSituations":"Slider defaults at zero submitted without user input; a sign typo; configs templated with an unset placeholder of 0.","solutions":["Set a positive learning rate — LoRA on diffusion models typically uses 1e-4 to 5e-4.","If a UI produced 0, require the field to be filled before submission rather than defaulting to 0."],"exampleFix":"# before\ncfg = DiffusionLoraConfig(learning_rate=0)\n# after\ncfg = DiffusionLoraConfig(learning_rate=1e-4)","handlingStrategy":"validation","validationCode":"lr = float(learning_rate)\nif lr <= 0:\n    raise ValueError('learning_rate must be > 0 (typical LoRA range: 1e-4 to 5e-4)')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never let a slider default of 0 submit; require an explicit value.","Range-check learning rate against sane bounds (e.g. 1e-7..1e-2) in the UI."],"tags":["training","hyperparameters","validation","range-check"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}