{"record":{"id":"e0ac527d914650df","repo":"unslothai/unsloth","slug":"unsupported-text-encoder-quant-value-use-one","errorCode":null,"errorMessage":"Unsupported text_encoder_quant '{value}'. Use one of: {', '.join(TE_QUANT_MODES)}.","messagePattern":"Unsupported text_encoder_quant '(.+?)'\\. Use one of: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/diffusion_precision.py","lineNumber":78,"sourceCode":"\n\ndef normalize_te_quant(value: Optional[str]) -> Optional[str]:\n    \"\"\"Lower/strip a requested text-encoder quant; None / \"\" / \"none\" / \"off\" / \"auto\" -> None.\n\n    The three no-scheme spellings collapse here because no family quantises its encoder without\n    a named scheme. They stay distinct to the caller that cares: MiniMax-H3 reads the RAW request\n    as a tri-state (unset picks the hosted conditioner, \"none\"/\"off\" pin the released bf16 one)\n    BEFORE normalising, so folding them is what lets an opt-out reach that branch at all instead\n    of being rejected here.\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\", \"auto\"):\n        return None\n    if normalized not in TE_QUANT_MODES:\n        raise ValueError(\n            f\"Unsupported text_encoder_quant '{value}'. Use one of: {', '.join(TE_QUANT_MODES)}.\"\n        )\n    return normalized\n\n\ndef effective_te_quant(mode: Optional[str], family: Optional[str]) -> Optional[str]:\n    \"\"\"The text-encoder mode ``quantize_text_encoders`` will ACTUALLY attempt for ``family``.\n\n    An explicit int8 on a family with no keep-bf16 schedule is rewritten to layerwise fp8\n    before support is ever consulted -- a documented downgrade that reports ``fell_back`` and\n    needs no torchao. A caller that asks ``te_quant_supported`` about the raw request therefore\n    refuses loads the runtime would run: on Windows ROCm the torchao stub makes int8\n    unsupported while fp8 still works.\n    \"\"\"\n    normalized = normalize_te_quant(mode)\n    if normalized == TE_QUANT_INT8 and _TE_INT8_SKIP.get((family or \"\").lower()) is None:\n        return TE_QUANT_FP8\n    return normalized","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion_precision.py#L60-L96","documentation":"normalize_text_encoder_quant validates the text_encoder_quant request parameter: lowercase/strip/dash-to-underscore, 'none'/'off'/'auto' and empty collapse to None, otherwise the value must be in TE_QUANT_MODES (fp8, nvfp4, int8, fp8_dynamic). Unknown values raise ValueError for cheap 4xx rejection. Note MiniMax-H3 reads the raw tri-state before normalization, so 'none' is meaningful there.","triggerScenarios":"Request with text_encoder_quant set to something like 'q8', 'int4', 'bf16', or 'fp8-dynamic-tokens' — anything not in {fp8, nvfp4, int8, fp8_dynamic} after normalization.","commonSituations":"Clients guessing quant names from other ecosystems (llama.cpp suffixes, vLLM schemes); stale client sending a mode removed in this build; copy-paste from docs of a different product.","solutions":["Use one of: fp8, nvfp4, int8, fp8_dynamic (dashes accepted)","Send 'none', 'off', or omit the field to disable text-encoder quantization","Send 'auto' to take the family default"],"exampleFix":"// before\n{\"text_encoder_quant\": \"q8_0\"}\n// after\n{\"text_encoder_quant\": \"int8\"}","handlingStrategy":"validation","validationCode":"TE_MODES = {\"fp8\", \"nvfp4\", \"int8\", \"fp8_dynamic\"}\n\ndef valid_te_quant(v) -> bool:\n    if v is None:\n        return True\n    n = str(v).strip().lower().replace(\"-\", \"_\")\n    return n in (\"\", \"none\", \"off\", \"auto\") | TE_MODES","typeGuard":"def is_te_quant(v) -> bool:\n    return v is None or (isinstance(v, str) and str(v).strip().lower().replace(\"-\", \"_\") in {\"\", \"none\", \"off\", \"auto\", \"fp8\", \"nvfp4\", \"int8\", \"fp8_dynamic\"})","tryCatchPattern":"try:\n    normalize_text_encoder_quant(req.text_encoder_quant)\nexcept ValueError as e:\n    return JSONResponse(status_code=400, content={\"detail\": str(e)})","preventionTips":["Use the documented mode names; don't reuse llama.cpp quant suffixes","Remember 'none'/'off' are meaningful (disable), not invalid","Validate request enums at the client boundary"],"tags":["validation","quantization","text-encoder","api"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}