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] Regressions from the memory-fix commits: base-module offload re-reads embed_tokens into host RAM (+1 GiB RSS spike, 978c7c1), QQQ keeps the damped Hessian alive through the block pass (+C²·4 B VRAM, 5fbd636), sibling-share TLS cache pins activations after quantize (9626f50) #4463
Kind: regressions from #4395/#4400/#4391 fix commits. Confirmed at 489aed6 on an RTX 4090 (default allocator config), A/B against def6e61.
The old and new checkpoints are bitwise identical in every case (GPTQ with offload on and off, AWQ, GPTAQ, QQQ, RTN, EXL3). These are pure memory costs.
1. The base-module offload source-reference check reads full tensors into host RAM (medium, 978c7c1, #4395 item 4)
gptqmodel/utils/offload.py:435-515_module_source_reference_index, line 498, does the following for every base-module tensor:
handle.get_tensor(source_key) (a full owned copy through mmap);
torch.equal(source, tensor);
a full sha256 of the live tensor.
The noref path it replaced wrote from the live tensor and cost no extra RSS.
Inside the base-module offload_to_disk call (Llama-3.2-1B, GPTQ, offload_to_disk=True):
with the reference path: +1004 MiB peak (RssAnon 2324→2826, RssFile 455→957);
with _module_source_reference_index patched to return None: +0 MiB.
The disk saving shows the fix works, but it trades about 1× the embedding size in RSS for it. For Llama-3-8B that is about 1 GiB anonymous plus 1 GiB file-backed. Comparing in bounded chunks (get_slice), or trusting LazyTurtle provenance, would avoid the full copy.
2. QQQ keeps the input Hessian alive for the whole block pass (medium, 5fbd636, #4400 item 3)
Before:gptqmodel/quantization/qqq.py:821-853 rebound H = cholesky(H)…; Hinv = H, which dropped the input Hessian.
Now:_inverse_hessian(H) keeps the caller's H for the CPU retry, and nothing deletes it afterwards.
Measured:
A single QQQ.quantize() on a 2048×8192 layer: peak minus base 832 → 1088 MiB (+256 MiB = 8192²×4). Q is bitwise identical.
Fix direction: del H right after a successful inverse.
3. The sibling-input share cache pins the last batch's activation across the layer and after quantize() returns (low, 9626f50, #4391 item 4)
gptqmodel/looper/native_processor.py:91-110,146-168: process() bumps the epoch but does not drop tls.entries. They keep (inp, mask, entries) alive until the next capture on that thread or until the processor dies.
Qwen2.5-0.5B GPTAQ, bs=4, 32 samples, HEAD with sharing on vs _native_share_cache returning {}:
metric
sharing on
sharing off
max allocated
662.4 MiB
651.3 MiB
allocated at end of quantize()
22.7 MiB
11.6 MiB
RSS
3148 MiB
3110 MiB
At 128 samples, def6e61 → HEAD: allocated at quantize end 44.4 → 54.5 MiB; peak Qwen 717 → 727 MiB, Llama 2050 → 2069 MiB. The cost scales with batch × seq × hidden per worker thread.
(A separate review measured a 30% host-memory saving from sharing with CPU staging, so the cache does pay off in some setups. It just needs to be cleared when the layer finishes.)
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(gptq,qqq): exact OOM block retry, static_groups CPU fallback, rel…
fix: bound offload source-reference RSS and stop cached kernel-valida…
fix(moe): GPTAQ/FOEM flattened-row native split, share-cache release,…
Offload finalized modules as file-backed tensors instead of meta + ho…
tests: pin file-backed offload instead of meta + hook offload (#6471)
Remove accelerate: explicit WeightLoader for weight loading, placemen…