{"record":{"id":"d48e5a7931dabce6","repo":"unslothai/unsloth","slug":"learning-rate-must-be-parseable-as-float-got-v-r","errorCode":null,"errorMessage":"learning_rate must be parseable as float (got {v!r})","messagePattern":"learning_rate must be parseable as float \\(got (.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":422,"severity":"error","filePath":"studio/backend/models/training.py","lineNumber":91,"sourceCode":"        # Require either IAM role auth or a full key pair so credentials are never half-configured.\n        if not self.use_iam_role and not (self.access_key_id and self.secret_access_key):\n            raise ValueError(\n                \"s3_config requires either use_iam_role=True or both \"\n                \"access_key_id and secret_access_key\"\n            )\n        return self\n\n\ndef _parse_lr(v: Any) -> float:\n    \"\"\"Parse learning_rate as a positive float strictly below _MAX_LR_VALUE.\"\"\"\n    if v is None:\n        raise ValueError(\"learning_rate is required\")\n    if isinstance(v, bool):\n        raise ValueError(\"learning_rate must be a number, not a bool\")\n    try:\n        lr = float(v)\n    except (TypeError, ValueError):\n        raise ValueError(f\"learning_rate must be parseable as float (got {v!r})\")\n    if not (lr > 0.0):\n        raise ValueError(f\"learning_rate must be > 0 (got {lr!r}); typical range is 1e-6 .. 1e-3\")\n    if lr >= _MAX_LR_VALUE:\n        raise ValueError(\n            f\"learning_rate must be < 1.0 (got {lr!r}); values that large always diverge training\"\n        )\n    return lr\n\n\nclass TrainingStartRequest(BaseModel):\n    \"\"\"Request schema for starting training\"\"\"\n\n    model_name: str = Field(\n        ..., description = \"Model identifier (e.g., 'unsloth/llama-3-8b-bnb-4bit')\"\n    )\n    project_name: Optional[str] = Field(\n        None,\n        max_length = 80,","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/models/training.py#L73-L109","documentation":"Raised by the _parse_lr parser when float(v) raises TypeError or ValueError, i.e. the supplied learning_rate is a string (or other object) that cannot be parsed as a float. The parser is deliberately lenient with numeric strings (it returns str(lr) for downstream call sites), but arbitrary strings like \"fast\" or \"1e-\" fail here. The message includes the repr of the offending value for debugging.","triggerScenarios":"POST a training start request with \"learning_rate\": \"fast\", \"auto\", \"1e-\", an empty string, or a dict/list. Numeric strings like \"0.0002\" or \"2e-5\" are fine; malformed numeric strings are not.","commonSituations":"UI free-text input for LR that is not validated; config values like \"auto\" or \"default\" intended to trigger server-side defaults that do not exist; locale-formatted numbers like \"0,0002\"; a prompt-style string field mistakenly mapped to learning_rate.","solutions":["Send a numeric or cleanly formatted numeric-string value, e.g. 0.0002 or \"2e-5\".","Validate with a numeric regex or parseFloat + round-trip check in the client before submit.","Strip whitespace and reject placeholder values like 'auto'/'default' in the request builder."],"exampleFix":"// before\nbody = { ..., learning_rate: \"auto\" }\n// after\nbody = { ..., learning_rate: 2e-5 }","handlingStrategy":"validation","validationCode":"def lr_parses(body: dict) -> bool:\n    v = body.get(\"learning_rate\")\n    if v is None or isinstance(v, bool):\n        return False\n    try:\n        float(v)\n        return True\n    except (TypeError, ValueError):\n        return False","typeGuard":"function lrParses(v: unknown): boolean {\n  if (typeof v === 'number') return Number.isFinite(v);\n  if (typeof v === 'string') return Number.isFinite(Number(v)) && v.trim() !== '';\n  return false;\n}","tryCatchPattern":null,"preventionTips":["Use a numeric input, not free text, for LR","Reject placeholder strings ('auto', 'default') client-side","Beware locale decimal separators when converting user input"],"tags":["pydantic","validation","training","parsing","hyperparameters"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}