{"record":{"id":"d0f696cf9c01c19b","repo":"unslothai/unsloth","slug":"unsupported-transformer-quant-value-use-one-o","errorCode":null,"errorMessage":"Unsupported transformer_quant '{value}'. Use one of: {', '.join(TQ_MODES)}.","messagePattern":"Unsupported transformer_quant '(.+?)'\\. Use one of: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/diffusion_transformer_quant.py","lineNumber":437,"sourceCode":"    if \"GEFORCE\" in name or \"TITAN\" in name:\n        return True\n    if any(marker in name for marker in _PROFESSIONAL_GPU_MARKERS):\n        return False\n    tokens = set(re.split(r\"[^A-Z0-9]+\", name))\n    return not (tokens & _DATACENTER_GPU_TOKENS)\n\n\ndef normalize_transformer_quant(value: Optional[str]) -> Optional[str]:\n    \"\"\"Lower/strip a requested transformer quant; None / \"\" / \"none\" / \"off\" -> None.\n\n    Raises ValueError for an unsupported value so a bad request is rejected cheaply.\"\"\"\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 not in TQ_MODES:\n        raise ValueError(\n            f\"Unsupported transformer_quant '{value}'. Use one of: {', '.join(TQ_MODES)}.\"\n        )\n    return normalized\n\n\ndef dense_transformer_supported(target: Any) -> bool:\n    \"\"\"Whether the dense-source quant path is usable for ``target``: a CUDA device with bf16\n    dtype (the only config any torchao dynamic scheme accelerates). Cheap loader pre-check.\"\"\"\n    if getattr(target, \"device\", None) != \"cuda\":\n        return False\n    # The Windows-ROCm torchao stub's quantize_ is a no-op, so the smoke probe passes on a\n    # still-dense Linear and the transformer gets MARKED quantised without being quantised,\n    # giving the wrong VRAM budget and compile policy.\n    if is_stubbed(\"torchao\"):\n        return False\n    try:\n        import torch\n        return getattr(target, \"dtype\", None) is torch.bfloat16","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion_transformer_quant.py#L419-L455","documentation":"normalize_transformer_quant validates the transformer_quant parameter: None/''/'none'/'off' collapse to None, otherwise the value must be in TQ_MODES ('auto' plus the supported transformer quant schemes). Unknown values raise ValueError for cheap 4xx rejection before any model loading.","triggerScenarios":"Request with transformer_quant set to a scheme this build doesn't support — e.g. 'int8' when TQ_MODES only covers gguf-style/auto schemes, or a typo like 'fp8_dyn'.","commonSituations":"Reusing text_encoder_quant vocabulary for transformer_quant; client/server version mismatch; schemes gated behind optional torchao not listed in this build's TQ_MODES.","solutions":["Send 'auto' to let the loader pick, or a scheme listed in the error message","Send 'none'/'off' or omit the field to keep the transformer dense","If you need a specific scheme (e.g. fp8), confirm the backend build exports it in TQ_MODES"],"exampleFix":"// before\n{\"transformer_quant\": \"int8\"}\n// after\n{\"transformer_quant\": \"auto\"}","handlingStrategy":"validation","validationCode":"# Reflect the build's accepted modes rather than hardcoding\nfrom core.inference.diffusion_transformer_quant import TQ_MODES\n\ndef valid_tq(v) -> bool:\n    if v is None:\n        return True\n    n = str(v).strip().lower().replace(\"-\", \"_\")\n    return n in (\"\", \"none\", \"off\") or n in TQ_MODES","typeGuard":"def is_transformer_quant(v, allowed: set[str]) -> bool:\n    return v is None or (isinstance(v, str) and str(v).strip().lower().replace(\"-\", \"_\") in allowed | {\"\", \"none\", \"off\"})","tryCatchPattern":"try:\n    normalize_transformer_quant(req.transformer_quant)\nexcept ValueError as e:\n    return JSONResponse(status_code=400, content={\"detail\": str(e)})","preventionTips":["Use 'auto' unless a specific scheme is required","Derive the allowed set from the running backend, not from docs of another version","Don't mirror text_encoder_quant values into transformer_quant"],"tags":["validation","quantization","transformer","api"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}