{"record":{"id":"6df747a67a91c5af","repo":"unslothai/unsloth","slug":"failed-to-load-checkpoint","errorCode":null,"errorMessage":"Failed to load checkpoint","messagePattern":"Failed to load checkpoint","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"studio/backend/routes/export.py","lineNumber":117,"sourceCode":"            approved_remote_code_fingerprint = request.approved_remote_code_fingerprint,\n            hf_token = request.hf_token,\n            subject = current_subject,\n        )\n\n        if not success:\n            raise HTTPException(status_code = 400, detail = message)\n\n        return ExportOperationResponse(success = True, message = message)\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 loading checkpoint: {e}\", exc_info = True)\n        raise HTTPException(\n            status_code = 500,\n            detail = \"Failed to load checkpoint\",\n        )\n\n\n@router.post(\"/cleanup\", response_model = ExportOperationResponse)\nasync def cleanup_export_memory(current_subject: str = Depends(get_current_subject)):\n    \"\"\"Cleanup export-related models from memory (ExportBackend.cleanup_memory).\"\"\"\n    try:\n        backend = get_export_backend()\n        success = await asyncio.to_thread(backend.cleanup_memory)\n\n        if not success:\n            raise HTTPException(\n                status_code = 500,\n                detail = \"Memory cleanup failed. See server logs for details.\",\n            )\n","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/export.py#L99-L135","documentation":"Catch-all HTTP 500 for load_checkpoint: any exception that is not an HTTPException and not SidecarSwapInProgress is logged (with traceback) and masked as 'Failed to load checkpoint'. The real cause is only visible in server logs via logger.error(..., exc_info=True).","triggerScenarios":"Unexpected backend failures: OOM during model load, corrupted safetensors, a bug inside ExportBackend.load_checkpoint, or filesystem permission errors on the checkpoint directory.","commonSituations":"CUDA out-of-memory on large checkpoints; partially downloaded/corrupt weights; disk full; version skew between installed transformers and the checkpoint format.","solutions":["Inspect the backend log for the 'Error loading checkpoint' entry — the traceback identifies the true cause.","Free VRAM/RAM (run /export/cleanup, close other model processes) and retry with a smaller model or load_in_4bit=True.","Re-download or re-export the checkpoint if the traceback shows weight-file corruption."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await api.post('/export/load-checkpoint', body);\n} catch (e) {\n  if (e.status === 500) captureServerLogContext('Error loading checkpoint');\n  throw e;\n}","preventionTips":["Always pair client 500s with a server-log lookup — the real traceback is only there.","Free GPU memory and verify checkpoint integrity before retrying."],"tags":["export","http-500","logging","checkpoint"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}