Repository navigation
Description
-
Did you update?
pip install --upgrade --force-reinstall --no-cache-dir unsloth unsloth_zoo— Current Studio code, installed viaunsloth.ai/install.shon 2026-06-28. -
Colab/Kaggle/Local or Cloud? — Local. NVIDIA DGX Spark — GB10 (Grace Blackwell, sm_121), 128 GB unified memory, aarch64.
-
Number GPUs — 1 (unified memory: CPU and GPU share one physical RAM pool, no dedicated VRAM).
-
Which notebook? Please link! — N/A; this is Studio inference, loading a GGUF model. No notebook involved.
-
Which Unsloth version, TRL version, transformers version and PyTorch version? — unsloth 2026.6.9, unsloth_zoo 2026.6.7, trl 0.23.1, transformers 4.57.6, torch 2.10.0+cu130 (CUDA 13.0).
-
Which trainer?
SFTTrainer,GRPOTraineretc — N/A; Studio inference / model loading.
Loading any GGUF model in Studio on the DGX Spark, the Context Length control shows "Exceeds estimated VRAM capacity (4,096 tokens)" for any context above 4096, and the auto-fit caps the context there — even though ~60 GB of memory is actually free.
Total VRAM is detected correctly (121.69 GB everywhere). The problem is the free figure the context fit relies on.
Minimal reproduction
On a unified-memory NVIDIA host (GB10 / DGX Spark), the three figures the fit logic depends on:
import subprocess, torch, psutil
# 1. nvidia-smi cannot report VRAM on unified memory -> [N/A]
print(subprocess.run(
["nvidia-smi", "--query-gpu=index,memory.free,memory.total",
"--format=csv,noheader,nounits"],
capture_output=True, text=True).stdout.strip())
# -> 0, [N/A], [N/A]
# 2. torch fallback reports raw MemFree, not MemAvailable
free, total = torch.cuda.mem_get_info(0)
print(f"mem_get_info: free={free/1024**3:.2f}GB total={total/1024**3:.2f}GB")
# -> free=1.56GB total=121.69GB
# 3. ...but ~62GB is actually available (reclaimable page cache)
vm = psutil.virtual_memory()
print(f"system: available={vm.available/1024**3:.2f}GB total={vm.total/1024**3:.2f}GB")
# -> available=61.85GB total=121.69GB
# Clean way to tell this device apart from a discrete card:
print("is_integrated:", torch.cuda.get_device_properties(0).is_integrated)
# -> 1Where it goes wrong
(line numbers from the 2026-06-28 install; file studio/backend/core/inference/llama_cpp.py)
_get_gpu_memory() (l. 2169) runs the nvidia-smi --query-gpu=index,memory.free,memory.total probe (l. 2189). On the GB10 both columns are [N/A], so free_mib = int(parts[1]) (l. 2218) raises, the GPU is dropped, and the probe falls through to the torch.cuda.mem_get_info fallback — which returns free≈1590 MiB, total≈124610 MiB. mem_get_info's "free" tracks raw MemFree, not MemAvailable, so it ignores the ~62 GB of reclaimable page cache.
_fit_context_to_vram (l. 2926) then takes that ~1.5 GB as the budget, can't fit a larger KV cache, and floors the context at min_ctx=4096 (l. 2932). The callers are at l. 5189 and l. 5245. That floor is the "4,096 tokens" in the warning.
The notable part is that Studio already has the correct handling for unified memory — _available_system_memory_mib() (l. 2274, "On a unified-memory APU this, not the ROCm-reported VRAM, is the real ceiling") and GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 — but it's gated behind _amd_apu_wants_unified_memory() (l. 2031), which returns False for anything that isn't an AMD HIP build (torch.version.hip is None) on a gfx1150/gfx1151 part. The GB10 is the same class of device (one RAM pool shared by CPU and GPU, no dedicated VRAM) but never qualifies, so it's treated as a discrete card with 1.5 GB free.
To be clear, this is not the GH200/GB200 case: those datacenter parts have dedicated GPU HBM, so nvidia-smi reports a real memory.free for them. The GB10 is genuinely unified, which is why nvidia-smi returns [N/A].
Suggested fix: treat integrated NVIDIA GPUs the way AMD APUs already are — fall back to available system RAM as the ceiling instead of mem_get_info's free. CUDA exposes cudaDeviceProp.integrated ("Device is integrated as opposed to discrete"), surfaced by PyTorch as torch.cuda.get_device_properties(idx).is_integrated; on this GB10 it reads 1, so it's a clean condition to extend the unified-memory path (_amd_apu_wants_unified_memory / l. 2031) to NVIDIA. Alternatively: when nvidia-smi reports [N/A] free, use system-RAM-available rather than mem_get_info free.
Activity
Imagineer99 commentedon Jun 30, 2026
Thanks, this looks valid. I reproduced the detection path with a mocked GB10-style CUDA device, will investigate further.
make the unified-memory cgroup clamp accurate (path, cache, total)
danielhanchen commentedon Sep 15, 2026
Fixed! Integrated CUDA parts like the GB10 are detected properly now and their budget comes from available system memory rather than the free figure, so the context isn't capped at 4096 on DGX Spark any more. Please update and reopen if you still see the cap!
To update: Studio is
unsloth studio update, Unsloth Desktop updates from its update banner, and in Docker it'sdocker exec <container> unsloth-studio-update.