{"record":{"id":"73ed4b55c068443d","repo":"unslothai/unsloth","slug":"this-quantized-int8-fp8-load-was-built-without-l","errorCode":null,"errorMessage":"This quantized (int8/fp8) load was built without LoRA adapters. Reload the model with the adapter selection to bake it into the quantized transformer.","messagePattern":"This quantized \\(int8/fp8\\) load was built without LoRA adapters\\. Reload the model with the adapter selection to bake it into the quantized transformer\\.","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/diffusion.py","lineNumber":5105,"sourceCode":"        pipe: Any,\n        specs: list[tuple[str, float]],\n        current: tuple,\n        quant_baked: bool,\n        cancel: threading.Event,\n    ) -> None:\n        \"\"\"Generation-time LoRA handling for a torchao-quantized pipe.\n\n        The adapters (if any) were baked at load time, before quantize_ + compile, so the\n        module topology is immutable here. Allowed without a reload: weight tweaks on the\n        baked set and disabling everything (scale 0 reproduces the quantized base exactly;\n        set_adapters is value-level, so torch.compile guards absorb it). Anything that would\n        change topology (adding adapters to a bake-less load, or a different adapter set)\n        raises a clean 400 telling the client to reload with the new selection.\n        \"\"\"\n        if not quant_baked:\n            if not specs:\n                return  # no adapters baked, none requested\n            raise ValueError(\n                \"This quantized (int8/fp8) load was built without LoRA adapters. Reload the \"\n                \"model with the adapter selection to bake it into the quantized transformer.\"\n            )\n        if not specs:\n            # Disable every baked adapter: scale 0 reproduces the quantized base exactly.\n            names = [n for (n, _p, _w) in current]\n            if any(w != 0 for (_n, _p, w) in current):\n                pipe.set_adapters(names, adapter_weights = [0.0] * len(names))\n                pipe._unsloth_loras = tuple((n, p, 0.0) for (n, p, _w) in current)\n            return\n        desired = self._resolve_lora_set(\n            specs,\n            family = getattr(state.family, \"name\", None),\n            hf_token = state.hf_token,\n            cancel = cancel,\n        )\n        if desired == current:\n            return","sourceCodeStart":5087,"sourceCodeEnd":5123,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion.py#L5087-L5123","documentation":"Raised by `_adjust_baked_loras` for a torchao-quantized (int8/fp8) pipeline: on such builds, adapters are baked into the transformer at load time, BEFORE quantize_ + compile, making module topology immutable at generation time. If the load had no adapters baked (`quant_baked` False) but the generate request supplies specs, adding them now is impossible, so a clean ValueError tells the client to reload with the adapter selection. Weight tweaks on the baked set and full disable (scale 0) remain allowed without reload.","triggerScenarios":"Loading with transformer_quant int8/fp8 but an empty loras list, then calling generate() with a non-empty loras argument: `quant_baked` is False, `specs` is non-empty, so the raise fires.","commonSituations":"Users loading a quantized model 'clean' for speed, then toggling a LoRA on in the UI mid-session; API clients that add LoRAs per-request assuming hot-swap; workflows that separated load config from generate config.","solutions":["Reload the model with the adapter selection included in the load call so it bakes into the quantized transformer.","Or reload without transformer_quant (bf16/bnb-4bit, eager speed) if per-generation LoRA hot-swap is required.","Keep the LoRA list identical between load and generate in orchestrating code."],"exampleFix":"# before\ndiffusion.load(model=repo, transformer_quant=\"int8\")\ndiffusion.generate(prompt=\"...\", loras=[(\"my-lora\", 1.0)])  # raises\n# after\ndiffusion.load(model=repo, transformer_quant=\"int8\", loras=[(\"my-lora\", 1.0)])","handlingStrategy":"validation","validationCode":"# Quantized loads are bake-only: pass loras at load time\nload_kwargs = {\"transformer_quant\": \"int8\"}\nif session_loras:\n    load_kwargs[\"loras\"] = session_loras  # bake now, not later\nawait diffusion.load(model, **load_kwargs)","typeGuard":"def can_hotswap_lora(state) -> bool:\n    \"\"\"Non-quantized (or bake-less) loads can add adapters at generate time.\"\"\"\n    return state.transformer_quant is None","tryCatchPattern":"try:\n    diffusion.generate(prompt=p, loras=loras)\nexcept ValueError as e:\n    if \"built without LoRA adapters\" in str(e):\n        await diffusion.load(model, transformer_quant=\"int8\", loras=loras)  # reload + bake\n        return diffusion.generate(prompt=p)\n    raise","preventionTips":["For quantized loads, make the LoRA selection part of the load request.","Cache the load-time LoRA set in session state and reuse it on every generate.","Only weight tweaks and full-disable are generation-time operations on baked builds."],"tags":["diffusion","lora","quantization","torchao","model-loading"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}