unslothai/unsloth · error · ValueError
Auto-unload idle seconds must be 0 (off) or at least {MIN_AU
Error message
Auto-unload idle seconds must be 0 (off) or at least {MIN_AUTO_UNLOAD_IDLE_SECONDS}. What it means
Raised by set_openai_auto_switch in openai_auto_switch_settings.py:297-301. idle_seconds must be either 0 (auto-unload disabled) or at least MIN_AUTO_UNLOAD_IDLE_SECONDS, which is 60 in this codebase. Any value strictly between 1 and 59 is rejected to prevent thrashing models in and out of memory.
Source
Thrown at studio/backend/utils/openai_auto_switch_settings.py:298
def set_openai_auto_switch(
enabled: Any,
idle_seconds: Any,
keep_kv: Any = None,
auto_download: Any = None,
api_only: Any = None,
media_idle_seconds: Any = None,
) -> tuple[bool, int, bool, bool, bool, int]:
"""One-transaction write; ``None`` leaves a stored value untouched."""
parsed_enabled = _coerce_bool(enabled)
if parsed_enabled is None:
raise ValueError("OpenAI auto-switch must be true or false.")
parsed_idle = None
if idle_seconds is not None:
parsed_idle = _coerce_int(idle_seconds)
if parsed_idle is None:
raise ValueError("Auto-unload idle seconds must be a non-negative integer.")
if 0 < parsed_idle < MIN_AUTO_UNLOAD_IDLE_SECONDS:
raise ValueError(
f"Auto-unload idle seconds must be 0 (off) or at least "
f"{MIN_AUTO_UNLOAD_IDLE_SECONDS}."
)
parsed_media_idle = None
if media_idle_seconds is not None:
parsed_media_idle = _coerce_int(media_idle_seconds)
if parsed_media_idle is None:
raise ValueError("Media auto-unload idle seconds must be a non-negative integer.")
if 0 < parsed_media_idle < MIN_AUTO_UNLOAD_IDLE_SECONDS:
raise ValueError(
f"Media auto-unload idle seconds must be 0 (off) or at least "
f"{MIN_AUTO_UNLOAD_IDLE_SECONDS}."
)
parsed_keep_kv = None
if keep_kv is not None:
parsed_keep_kv = _coerce_bool(keep_kv)
if parsed_keep_kv is None:
raise ValueError("Keep KV on idle unload must be true or false.")View on GitHub (pinned to 203007d190)
Solutions
- Use 0 to disable auto-unload, or any value >= 60 (e.g. 120)
- Clamp in the UI: slider minimum 60 with a separate 'off' option
- Update stale documentation or config files that suggest 30-second idles
- Programmatically normalize: value = 0 if value < 60 else value
Example fix
# before set_openai_auto_switch(enabled=True, idle_seconds=30) # after set_openai_auto_switch(enabled=True, idle_seconds=0) # off # or set_openai_auto_switch(enabled=True, idle_seconds=120)
Defensive patterns
Strategy: validation
Validate before calling
MIN_IDLE = 60
def valid_idle(v: int) -> bool:
return v == 0 or v >= MIN_IDLE Type guard
def is_valid_idle_seconds(v: object) -> bool:
if not isinstance(v, int) or isinstance(v, bool):
return False
return v == 0 or v >= 60 Try / catch
try:
set_openai_auto_switch(enabled=True, idle_seconds=idle)
except ValueError as exc:
if "at least" in str(exc):
idle = 0 if idle < 60 else idle # prompt user instead in real UI
raise Prevention
- Offer only 'off (0)' or values >= 60 in the UI
- Document the 60-second floor next to the setting
- Clamp old configs on migration: below 60 becomes 0 or 60
When it happens
Trigger: set_openai_auto_switch(enabled=True, idle_seconds=30) — any of 1..59 raises. idle_seconds=0 and idle_seconds>=60 are accepted; negatives were clamped to 0 by _coerce_int.
Common situations: Users trying aggressive unload timeouts like 10-30 seconds; UI sliders that allow sub-minute values; migrations from configs where the minimum used to be lower.
Related errors
- Media auto-unload idle seconds must be 0 (off) or at least {
- cfg_dropout must be between 0 and 1
- learning_rate must be > 0
- Embedding model must be a Hugging Face repo id (e.g. 'unslot
- Helper LLM startup pre-cache must be true or false.
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/8ac570268d5e308a.
Report an issue: GitHub.