Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: fix the AttributeError that 500s every planned GGUF load (#9821)

Daniel Han4147f80c60be
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index 130ef72365a..7b760f16768 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -24178,7 +24178,8 @@ class LlamaCppBackend:
+ self._PIPELINE_PER_DEVICE_OVERHEAD_MIB * 1024 * 1024
+ int(inputs.get("ctx_compute_per_device") or 0)
),
- host_ram_headroom_bytes = self._HOST_RAM_HEADROOM_MIB * 1024 * 1024,
+ # Module-level, unlike the line above, so not reachable through self.
+ host_ram_headroom_bytes = _HOST_RAM_HEADROOM_MIB * 1024 * 1024,
# -nkvo is not a reason to decline: it moves the cache and the
# recurrent state OUT of VRAM, so the deficit is smaller, not
# larger.
diff --git a/studio/backend/tests/test_offload_planner_seam.py b/studio/backend/tests/test_offload_planner_seam.py
index 35802a03b5f..8abaa5db350 100644
--- a/studio/backend/tests/test_offload_planner_seam.py
+++ b/studio/backend/tests/test_offload_planner_seam.py
@@ -61,10 +61,14 @@ def sparse_adapter(tmp_path_factory):
class _Stub:
- """Only what the seam touches."""
+ """Only what the seam touches.
+
+ Must NOT declare _HOST_RAM_HEADROOM_MIB: that constant is module-level, so
+ declaring it here let the double supply what the real backend lacked, hiding an
+ AttributeError on every planned load.
+ """
_PIPELINE_PER_DEVICE_OVERHEAD_MIB = 1024
- _HOST_RAM_HEADROOM_MIB = 2048
# Discrete by default, so every existing case here is a discrete host. The
# unified answer is the APU's, and it is exercised deliberately below.
_unified = False
@@ -189,6 +193,25 @@ def _plan(
# ------------------------------------------------------------------ the gate
+def test_the_seam_reads_no_attribute_the_real_backend_lacks():
+ """The planner is default-on, so every GGUF load runs this seam against the REAL
+ class, not the double above.
+
+ _planned_tensor_spill read the headroom as self._HOST_RAM_HEADROOM_MIB, but that
+ constant is module-level, so every planned load 500'd with AttributeError (seen on
+ a 67.6 GB GGUF, Colab T4 high-RAM). The suite stayed green only because the double
+ declared it."""
+ import inspect
+
+ for name in ("_HOST_RAM_HEADROOM_MIB",):
+ assert not hasattr(_Stub, name), (
+ f"the double declares {name}, so it can hide a missing attribute on the "
+ "real backend again"
+ )
+ source = inspect.getsource(LlamaCppBackend._planned_tensor_spill)
+ assert "self._HOST_RAM_HEADROOM_MIB" not in source
+
+
def test_the_planner_is_on_by_default():
"""No env, a plan. The flag is now opt-OUT."""
assert smart_offload_enabled({}) is True