Repository navigation
Description
name: Unsloth Studio Bug
about: Another studio crash caught.
title: "[Studio Bug] Studio crashes when Claude Code takes too long to generate a response"
labels: bug
assignees: ""
Environment
Where are you using Unsloth?
- Studio desktop application
- Studio web UI (
unsloth studio) - Unsloth CLI
- Python package or notebook
- Colab or Kaggle
Operating system and version:
CachyOS Linux x86_64 (Arch based)
Kernel: Linux 7.1.8-1-cachyos-bore
DE/WM: KDE Plasma 6.7.4 / KWin (Wayland)
System Hardware:
- CPU: AMD Ryzen 9 9950X3D 16-Core @ 5.76 GHz
- Motherboard: Asus TUF GAMING X870-PLUS WIFI ATX AM5
- RAM: Corsair Vengeance RGB 96 GB (2x48 GB) DDR5-6000
- Cooler: Deepcool LE520
- PSU: Corsair RM1200x SHIFT 1200W 80+ Gold
GPU model(s) and accelerator backend:
Asus GeForce RTX 5090 32 GB ROG Astral (CUDA)
Versions and Environment:
- Python: 3.13.14
- Torch: 2.11.0+cu130
- Transformers: 5.5.0
- torchao: 0.18.0+cu130
- flash-attn: 2.8.1
- Uptime: 19h 1m
- Process memory: 1,067 MB
- Claude Code: 2.1.227
What happened?
Steps to reproduce:
- Launch Unsloth Desktop
- Load Qwen's GGUF model with the CLI command
unsloth start claude --model unsloth/Qwen3.8-27B-GGUF:UD-Q4_K_XL - Use Claude Code normally and wait until it sends a non-streaming chat request (
stream=false) via the/v1/messagesendpoint that requires a long time to generate (e.g., > 10-15 seconds). - Wait for your generation.
- Suddenly the studio watchdog kills the Python backend mid-request or immediately after.
Expected behavior:
The backend should successfully finish generating the text and return the response. The /api/health endpoint should remain responsive to the Tauri watchdog throughout the generation process.
Actual behavior:
The backend Python event loop is entirely blocked during the generation because _collect_anthropic_events(run_gen) synchronously executes list(run_gen()). This starves the ASGI event loop, causing the Tauri frontend's Health watchdog ping (/api/health) to time out. After 3 missed pings, the watchdog kills the backend process.
Model and operation involved:
- Inference via local GGUF
- Specifically observed using
Qwen3.8-27B-UD-Q4_K_XL.ggufover the/v1/messagesendpoint.
Diagnostics and logs
Desktop application
08:11:07 [INFO] [backend] {"timestamp": "2026-08-15T08:11:07.706578Z", "level": "info", "event": "request_completed", "method": "POST", "path": "/v1/messages", "status_code": 200, "process_time_ms": 17758.76}
08:11:22 [WARN] Health watchdog: failure 1/3 on port 8888
08:11:47 [WARN] Health watchdog: failure 2/3 on port 8888
08:11:53 [INFO] [backend] {"timestamp": "2026-08-15T08:11:53.673871Z", "level": "info", "event": "request_completed", "method": "POST", "path": "/v1/messages", "status_code": 200, "process_time_ms": 45921.29}
08:11:53 [INFO] [backend] {"timestamp": "2026-08-15T08:11:53.679233Z", "level": "info", "event": "request_completed", "method": "GET", "path": "/api/liveness", "status_code": 200, "process_time_ms": 0.5}
08:12:12 [WARN] Health watchdog: failure 3/3 on port 8888
08:12:12 [ERROR] Health watchdog: backend unresponsive, killing and declaring dead
08:12:12 [INFO] Stopping spawned backend process group (pid 919602)
08:12:13 [INFO] Backend exited with status: signal: 15 (SIGTERM)
Additional context
Root Cause Details:
In backend/routes/inference.py, the _collect_anthropic_events function drains the generator synchronously on the main thread:
def _collect_anthropic_events(run_gen) -> list:
try:
return list(run_gen())This prevents FastAPI/Uvicorn from handling /api/health pings during generation. It should be refactored to wrap list(run_gen()) in an async def function that utilizes asyncio.to_thread to prevent thread starvation, similar to other parts of the inference loop:
async def _collect_anthropic_events(run_gen) -> list:
def _drain():
return list(run_gen())
try:
return await asyncio.to_thread(_drain)
...
Activity
Imagineer99 commentedon Aug 18, 2026
Can confirm this is an bug, was able to reproduce on current main, I will work on a fix