{"record":{"id":"bf16d976ee5145cf","repo":"unslothai/unsloth","slug":"unsupported-transformer-cache-value-use-one-o","errorCode":null,"errorMessage":"Unsupported transformer_cache '{value}'. Use one of: off, auto, {', '.join(TC_MODES)}.","messagePattern":"Unsupported transformer_cache '(.+?)'\\. Use one of: off, auto, (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/diffusion_cache.py","lineNumber":49,"sourceCode":"DEFAULT_FBCACHE_THRESHOLD = 0.08\nQUANT_FBCACHE_THRESHOLD = 0.12\n\n# Auto step-count bar: FBCache's win scales with step count, so auto engages only at 20+ steps (\"dev\" schedules qualify, distilled turbo never does).\nFBCACHE_MIN_STEPS = 20\n\n\ndef normalize_transformer_cache(value: Optional[str]) -> Optional[str]:\n    \"\"\"Lower/strip a cache mode; None / \"\" / \"none\" / \"off\" -> None, \"auto\" -> TC_AUTO (loader\n    decides from step count). Raises ValueError for an unsupported value.\"\"\"\n    if value is None:\n        return None\n    normalized = str(value).strip().lower().replace(\"-\", \"_\")\n    if not normalized or normalized in (\"none\", \"off\"):\n        return None\n    if normalized == TC_AUTO:\n        return TC_AUTO\n    if normalized not in TC_MODES:\n        raise ValueError(\n            f\"Unsupported transformer_cache '{value}'. Use one of: off, auto, \"\n            f\"{', '.join(TC_MODES)}.\"\n        )\n    return normalized\n\n\ndef _invalidate_child_registry_cache(transformer: Any) -> None:\n    \"\"\"Drop the HookRegistry's cached child-registry list after (un)installing hooks.\n\n    ``cache_context`` propagates state through ``_get_child_registries``, which diffusers 0.39\n    caches on first use. An uncached generation already calls it, creating an EMPTY cached child\n    list -- so a later ``enable_cache`` installs block hooks ``_set_context`` never reaches and the\n    first cached forward dies with \"No context is set\". Invalidate so the next ``cache_context``\n    rebuilds it over the freshly hooked blocks. Best-effort.\"\"\"\n    registry = getattr(transformer, \"_diffusers_hook\", None)\n    if registry is not None and getattr(registry, \"_child_registries_cache\", None) is not None:\n        try:\n            registry._child_registries_cache = None","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion_cache.py#L31-L67","documentation":"normalize_transformer_cache() normalises the transformer_cache setting (lowercase, strip, hyphens to underscores) and accepts: None/''/'none'/'off' -> disabled, 'auto' -> loader decides from step count, or one of TC_MODES (currently just 'fbcache', first-block cache). Anything else raises ValueError so a typo'd mode fails at request time, not silently mid-generation.","triggerScenarios":"Passing transformer_cache='fbcach', 'fb_cache', 'first-block', 'full', or any string not in {off, none, auto, fbcache}. Note 'fb-cache' is fine (hyphen normalised) but other spellings are not aliases.","commonSituations":"Guessing cache mode names from docs or other engines; renaming drift across versions; config files copied between projects with different accepted vocabularies.","solutions":["Use one of: 'off' (or 'none'/null/''), 'auto', or 'fbcache'.","Hyphenated 'fb-cache' also works since '-' is normalised to '_'.","Omit the setting entirely to keep the default (disabled)."],"exampleFix":"# before\nengine.load(repo, transformer_cache=\"first_block_cache\")\n# after\nengine.load(repo, transformer_cache=\"fbcache\")  # or \"auto\"","handlingStrategy":"validation","validationCode":"TC_VALID = {\"off\", \"none\", \"auto\", \"fbcache\"}\n\ndef valid_transformer_cache(v) -> bool:\n    return v is None or str(v).strip().lower().replace(\"-\", \"_\") in TC_VALID","typeGuard":"def is_valid_cache_mode(v) -> bool:\n    return v is None or str(v).strip().lower().replace(\"-\", \"_\") in {\"off\", \"none\", \"auto\", \"fbcache\"}","tryCatchPattern":"try:\n    engine.load(repo, transformer_cache=mode)\nexcept ValueError as e:\n    if \"Unsupported transformer_cache\" in str(e):\n        engine.load(repo, transformer_cache=\"auto\")\n    else:\n        raise","preventionTips":["Limit the config enum to off/auto/fbcache (fb-cache also normalises).","Omit the setting when caching is not intentional — the default is disabled."],"tags":["diffusion","cache","validation","configuration"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}