{"record":{"id":"c2eb8f166fab3a09","repo":"unslothai/unsloth","slug":"failed-to-export-gguf-model","errorCode":null,"errorMessage":"Failed to export GGUF model","messagePattern":"Failed to export GGUF model","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"studio/backend/routes/export.py","lineNumber":434,"sourceCode":"\n        if not success:\n            raise HTTPException(status_code = 400, detail = message)\n\n        return ExportOperationResponse(\n            success = True,\n            message = message,\n            details = await asyncio.to_thread(_export_details, output_path, refresh_index = True),\n        )\n    except HTTPException:\n        raise\n    except Exception as e:\n        from utils.transformers_version import SidecarSwapInProgress\n\n        if isinstance(e, SidecarSwapInProgress):\n            # Expected loss of the race against a sidecar install: retryable 409.\n            raise HTTPException(status_code = 409, detail = str(e))\n        logger.error(f\"Error exporting GGUF model: {e}\", exc_info = True)\n        raise HTTPException(\n            status_code = 500,\n            detail = \"Failed to export GGUF model\",\n        )\n\n\n@router.post(\"/export/lora\", response_model = ExportOperationResponse)\nasync def export_lora_adapter(\n    request: ExportLoRAAdapterRequest, current_subject: str = Depends(get_current_subject)\n):\n    \"\"\"Export only the LoRA adapter (if the loaded model is PEFT).\n\n    Wraps ExportBackend.export_lora_adapter.\n    \"\"\"\n    try:\n        await _ensure_export_supported()\n        backend = get_export_backend()\n        success, message, output_path = await asyncio.to_thread(\n            backend.export_lora_adapter,","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/export.py#L416-L452","documentation":"Generic 500 from the GGUF export endpoint's catch-all: an exception escaped backend.export_gguf (which normally returns failure tuples rather than raising) or the post-export _export_details call. HTTPExceptions pass through and SidecarSwapInProgress becomes a 409, so this 500 marks an unexpected crash; the real traceback is in the server log under 'Error exporting GGUF model:'.","triggerScenarios":"POST /export/gguf where the conversion subprocess dies unexpectedly (OOM during quantization, missing llama.cpp/conversion dependency, disk full mid-write), or _export_details failing on the produced output path.","commonSituations":"Large models quantized on memory-constrained hosts (OOM killer), missing gguf conversion tooling in the environment, disk exhaustion during a multi-format export, or push_to_hub with an invalid/revoked hf_token raising from the hub client.","solutions":["Check the backend log traceback for the exact exception; the HTTP detail is intentionally uninformative.","If OOM: free GPU/RAM, close other jobs, or choose a smaller quantization method.","Confirm gguf conversion dependencies are installed and the save volume has space for the full output.","If push_to_hub was set, verify hf_token is valid and repo_id is writable, or retry without pushing."],"exampleFix":"# before\nresp = client.post('/api/export/gguf', json={'push_to_hub': True, 'repo_id': 'me/model'})\n# 500 'Failed to export GGUF model'\n\n# after\nresp = client.post('/api/export/gguf', json={'push_to_hub': False})  # export locally first\n# then push separately once the local artifact is confirmed good","handlingStrategy":"try-catch","validationCode":"// preflight: free memory and disk before large quantizations\nconst mem = await getGpuMemory(); if (mem.freeMb < neededMb) throw new Error('Not enough memory to quantize');","typeGuard":null,"tryCatchPattern":"try { await exportGguf(body); }\ncatch (e) { if (e.status === 500) { await fetchBackendLogTail(); throw new ExportFailedWithLog(); } }","preventionTips":["Watch RAM/VRAM during quantization; prefer smaller methods on constrained hosts.","Ensure gguf conversion toolchain is installed before requesting GGUF exports.","Push to hub only after a local export succeeds."],"tags":["export","gguf","http-500","oom"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}