{"record":{"id":"87daa2d579db6735","repo":"unslothai/unsloth","slug":"unsupported-diffusion-speed-mode-value-use-on","errorCode":null,"errorMessage":"Unsupported diffusion speed_mode '{value}'. Use one of: {', '.join(SPEED_MODES)}.","messagePattern":"Unsupported diffusion speed_mode '(.+?)'\\. Use one of: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/diffusion_speed.py","lineNumber":120,"sourceCode":"def _inductor_config() -> Any:\n    \"\"\"``torch._inductor.config`` or None. Read as attributes off the imported torch (not a\n    submodule import) so a stubbed/partial torch reports None instead of a stale sys.modules hit.\"\"\"\n    try:\n        import torch\n        return getattr(getattr(torch, \"_inductor\", None), \"config\", None)\n    except Exception:  # noqa: BLE001 — no inductor -> nothing to snapshot/set\n        return None\n\n\ndef normalize_speed_mode(value: Optional[str]) -> str:\n    \"\"\"Lower/strip a requested speed mode (dashes ok); None / \"\" -> off.\"\"\"\n    if value is None:\n        return SPEED_OFF\n    normalized = str(value).strip().lower().replace(\"-\", \"_\")\n    if not normalized:\n        return SPEED_OFF\n    if normalized not in SPEED_MODES:\n        raise ValueError(\n            f\"Unsupported diffusion speed_mode '{value}'. Use one of: {', '.join(SPEED_MODES)}.\"\n        )\n    return normalized\n\n\ndef resolve_speed_mode(\n    value: Optional[str],\n    *,\n    is_gguf: bool,\n    dense_default: str = SPEED_OFF,\n) -> str:\n    \"\"\"The effective speed mode when the caller leaves it UNSET (``None``).\n\n    GGUF defaults to ``default``: compiles only the hot dequant op chain (~70-80% of eager GGUF\n    time) for ~1.24-1.64x at a small compile, zero extra VRAM, perturbation below the quant noise\n    floor. Dense resolves to ``dense_default``: the image backend keeps ``off`` (bit-identical\n    first generations, deferred engagement), the video backend passes ``default`` (a clip denoise\n    amortises the compile within one generation). An explicit value (incl. ``\"off\"``) is honored.\"\"\"","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion_speed.py#L102-L138","documentation":"normalize_speed_mode validates the diffusion speed_mode parameter: None and empty string map to SPEED_OFF, dashes are normalized to underscores, and the result must be in SPEED_MODES ('off', 'eager', 'default', 'max'). Anything else raises ValueError so the route rejects the request before GPU work.","triggerScenarios":"Request with speed_mode like 'turbo', 'fastest', 'full', or a typo like 'defualt' — any string not normalizing to off/eager/default/max.","commonSituations":"UI dropdown out of sync with backend vocabulary; clients forwarding sampler-name or profile strings into speed_mode; version skew between client and server.","solutions":["Send one of: off, eager, default, max ('max' maps to full inductor compilation)","Omit speed_mode or send null/'' to run uncompiled (off)","Check the deployed backend's SPEED_MODES if the client is newer"],"exampleFix":"// before\n{\"speed_mode\": \"turbo\"}\n// after\n{\"speed_mode\": \"max\"}","handlingStrategy":"validation","validationCode":"SPEED = {\"off\", \"eager\", \"default\", \"max\"}\n\ndef valid_speed_mode(v) -> bool:\n    if v is None:\n        return True\n    n = str(v).strip().lower().replace(\"-\", \"_\")\n    return n in SPEED | {\"\"}","typeGuard":"def is_speed_mode(v) -> bool:\n    return v is None or (isinstance(v, str) and str(v).strip().lower().replace(\"-\", \"_\") in {\"\", \"off\", \"eager\", \"default\", \"max\"})","tryCatchPattern":"try:\n    normalize_speed_mode(req.speed_mode)\nexcept ValueError as e:\n    return JSONResponse(status_code=400, content={\"detail\": str(e)})","preventionTips":["Send only off/eager/default/max; null means off","Don't confuse speed_mode with sampler or profile names","Keep UI dropdown options generated from the backend's SPEED_MODES"],"tags":["validation","speed","diffusion","api"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}