unslothai/unsloth · error · HTTPException

Failed to export merged model

Error message

Failed to export merged model

What it means

Catch-all HTTP 500 for export_merged_model: a non-HTTPException, non-SidecarSwapInProgress exception was raised during the merge (typically inside the export worker). The traceback is logged as 'Error exporting merged model'; the client sees only the generic message.

Source

Thrown at studio/backend/routes/export.py:344

        if not success:
            raise HTTPException(status_code = 400, detail = message)

        return ExportOperationResponse(
            success = True,
            message = message,
            details = await asyncio.to_thread(_export_details, output_path, refresh_index = True),
        )
    except HTTPException:
        raise
    except Exception as e:
        from utils.transformers_version import SidecarSwapInProgress

        if isinstance(e, SidecarSwapInProgress):
            # Expected loss of the race against a sidecar install: retryable 409.
            raise HTTPException(status_code = 409, detail = str(e))
        logger.error(f"Error exporting merged model: {e}", exc_info = True)
        raise HTTPException(
            status_code = 500,
            detail = "Failed to export merged model",
        )


@router.post("/export/base", response_model = ExportOperationResponse)
async def export_base_model(
    request: ExportBaseModelRequest, current_subject: str = Depends(get_current_subject)
):
    """Export a non-PEFT base model, optionally pushing to Hub.

    Wraps ExportBackend.export_base_model.
    """
    try:
        await _ensure_export_supported()
        backend = get_export_backend()
        success, message, output_path = await asyncio.to_thread(
            backend.export_base_model,

View on GitHub (pinned to 203007d190)

Solutions

  1. Read the server log traceback for 'Error exporting merged model'.
  2. Free memory (cleanup, close other processes) and retry, or export in a smaller dtype/4-bit.
  3. Ensure the save directory exists on a volume with sufficient free space.
Defensive patterns

Strategy: try-catch

Validate before calling

await assertDiskSpace(saveDirectory, estimatedMergeSize);

Try / catch

try {
  await api.post('/export/merged', body);
} catch (e) {
  if (e.status === 500) captureServerLogContext('Error exporting merged model');
  throw e;
}

Prevention

When it happens

Trigger: OOM during merge, disk-full while writing the output directory, safetensors save errors, or unexpected transformers exceptions during merge_and_unload.

Common situations: Merging large adapters on memory-constrained hosts; output directory on a full disk; transformers version incompatibility with the adapter.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/1ce5da5bb5b4c1cb. Report an issue: GitHub.