You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MEM] cached_validate_once caches a kernel-validation exception whose __cause__ traceback pins the entire first-loaded model forever (e.g. GGUF without llama-cpp-python: 471 MiB VRAM never freed) #4465
Severity: medium. Kind: pre-existing (same at def6e61). A sibling of #4078 item 2, at a different site. Confirmed at 489aed6 on an RTX 4090.
Cause
gptqmodel/nn_modules/qlinear/__init__.py:592-600: exp.with_traceback(None) clears only exp.__traceback__, not the traceback of exp.__cause__ / __context__.
The cached exception comes from gguf_cpp.py:1436-1440 / 1600-1604 ("GGUFCppKernel requires llama-cpp-python"), raised from a ModuleNotFoundError.
The reference chain: lru_cache → exception → __cause__.__traceback__ → frames validate_once ← … ← make_quant (utils/model.py:680) ← loader.from_quantized:3494 ← auto.load:969. The model is a local in those frames.
Repro
In an environment without llama-cpp-python, quantize Qwen2.5-0.5B-Instruct with GGUFConfig(bits="q4_k_m") and save. Then in a fresh process:
Actual: 471.2 MiB, the whole model. gc finds the live Qwen2QModel with two retained loader frames as its only referrers.
Expected: 0. A GPTQ/Marlin checkpoint gives 0.0 MiB with the same script.
Any kernel whose validate_once raises with a chained cause can pin the first model loaded in the process the same way.
Fix direction: cache (False, str(exc)) instead of the exception object, or clear __cause__ / __context__ (and their tracebacks) before caching.
Found during an AI-assisted review (Claude Code, round 13) of 489aed6; repros were run at that commit (A/B against def6e61 where noted) on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.
Activity
fix: bound offload source-reference RSS and stop cached kernel-valida…