Repository navigation
Description
Audit of main @ beb6db8 (first measured at 27c6b7b) on an R9700 (ROCm 10.1, gfx1201), with the import-time ROCm allocator default max_split_size_mb:256,garbage_collection_threshold:0.7. Items 2–4 are generic (not HIP-specific).
1. [ROCm] AWQ clip-search scratch defeats the 256 MiB split cap: reserved VRAM grows ~256 MiB per module within each layer (3× allocated on dense models, 10.9 GiB on MoE); #4342 is incomplete (medium)
looper/awq_processor.py:3103-3136 sizes scratch_prod up to MSEConfig.resolve_budget_bytes, which defaults to 256 MiB on GPU (quantization/config.py:1773). token_chunk floor-divides the budget, so for many shapes the request lands just under 256 MiB: Qwen2.5-0.5B q/k/v/o/down request 255.94 / 255.31 MiB, and OLMoE expert down_proj about 255 MiB. The caching allocator rounds the request up to a 256 MiB segment. That is ≥ max_split_size_mb (_alloc_conf.py:48), and a free oversize segment can't serve a sub-256 MiB request, so every clip-eligible module mallocs a fresh 256 MiB segment. #4342 empties the cache only at the layer boundary (quantization/awq/quantize/scale.py:133-174), so within a layer reserved grows with the number of modules: 64 experts × 3 projections on MoE.
Qwen2.5-0.5B awq4, 6 layers: default budget peak alloc 0.479 GiB peak reserved 1.494 GiB
clip_grid_budget=250M peak alloc 0.473 GiB peak reserved 0.740 GiB
OLMoE-1B-7B awq4, 64 samples: default peak alloc 2.349 GiB peak reserved 10.887 GiB (layer 0: reserved 1.72 -> 9.72 GiB in 4 s
while allocated stays 0.79 GiB; 1 alloc retry; 263 hipMallocs by layer 1)
clip_grid_budget=250M peak alloc 2.344 GiB peak reserved 2.637 GiB (134 hipMallocs)
Llama-3.2-1B: requests are 250/240 MiB (under the cap) -> 1.746 vs 1.711 GiB, unaffected (shape-dependent)
Fix (any one):
- On ROCm, clamp the clip budget to
max_split - 2 MiBso segments stay splittable. - Allocate
scratch_prodonce per layer at max size and reuse it across modules/experts. - Release per module instead of per layer.
tests/test_awq_rocm_layer_cache_4313.py only mocks empty_cache; it needs a reserved-within-layer check on a MoE layer. Cross-layer growth (#4313) remains fixed, including bs=4.
2. MACaQ macaq_quantize_weight keeps the dead pre-scaled Hessian, rotated Hessian and pre-scaled weight alive through the flip sweep (medium-low)
After rotation, hessian and weight (the pre-scaled copies, quantization/macaq.py:543-544) are never read again. After flip_hessian = rotated_hessian.clone() (:557), rotated_hessian (:548-549) isn't read either, but all of them stay referenced until return. Together with the caller's H2, that's 4 C²-sized fp32 copies per module through the sweep, with all 7 modules of a layer running concurrently.
peak above inputs, current vs with `del hessian, weight` after rotation and `del rotated_hessian` after the clone:
2048x8192 weight: 2098 -> 1522 MiB 8192x2048: 1378 -> 1282 MiB packed output sha identical
Llama-3.2-1B macaq, 4 layers: peak allocated 5.025 -> 4.174 GiB (-17%), reserved 7.158 -> 6.746 GiB
At 8B, down_proj alone (C=14336, 784 MiB per copy) saves ~1.6 GiB per module. Fix: the two dels, or apply the pre-scale and ridge in place.
3. Shared-input Hessian dedup exists only in GPTQProcessor: QQQ, VPTQ (fp64), MACaQ and EXL3 accumulate identical Hessians for q/k/v and gate/up (low-medium)
The SharedInputPlan leader/follower path lives only in looper/gptq_processor.py:404-516. add_batch in quantization/qqq.py:558/640, vptq.py:309/332 and macaq.py:675/696 accumulates per module with no plan, and looper/exllamav3_processor.py:2158 builds plain GPTQ() capture tasks. Keying each add_batch input by pointer, shape and content:
Llama-3.2-1B, 2 layers: add_batch calls on an input another module already accumulated
qqq4 1152 / 2688 (43%) groups {(q,k,v): 384, (gate,up): 384}
vptq 1152 / 2688 (fp64: k+v+up ~7.0 s of 48 s add_batch time)
macaq 384 / 896
exl3_4 1152 / 2688
gptq4 (control) 0
That's 48 MiB (fp32) / 96 MiB (VPTQ fp64) of redundant Hessians per layer on 1B, and 192 / 384 MiB on 8B, plus the redundant accumulation matmuls. Fix: reuse GPTQProcessor's plan and Hessian adoption in these processors, avoiding the extra-C² adoption overhead of #4400 item 1. (GPTAQ/FOEM at bs>1 is #4391 item 4.)
4. pack_gpu (auto-selected whenever a GPU exists) packs the whole matrix in int64/fp32, a transient of ~15× the fp16 weight (low-medium)
nn_modules/qlinear/__init__.py:2227-2234 sets block_in=8192, which covers the whole input dimension for most layers. :2338-2362 then rounds in fp32, transposes in int32, converts .to(int64), shifts and sums, about 32 bytes per element live at once. utils/packing.py:99-111 auto-selects "gpu".
weight fp16 peak block_in=8192 block_in=1024 (output identical)
14336x4096 112 MiB 1656 MiB (14.8x) 578 MiB (5.2x) block_in=256: 253 MiB, same time
8192x2048 32 MiB 473 MiB (14.8x) 289 MiB
Llama-3.2-1B rtn4 whole run: peak allocated 0.530 GiB default -> 0.261 GiB with block_in=256
For GPTQ, packing is usually off the peak path, but overlapping packs pushed the Llama-1B peak from 1.420 to 1.539 GiB in one run. Fix: derive block_in from an element budget (e.g. out_features * blk ≤ 4M).
Measurements (ROCm, peak allocated / reserved GiB)
| method | Qwen2.5-0.5B | Llama-3.2-1B |
|---|---|---|
| gptq4 | 0.505 / 0.838 | 1.420 / 2.26 |
| gptaq4 | 1.27–1.39 / 2.12 | 2.807 / 5.305 |
| awq4 | 0.480 / 1.494 | 1.066 / 1.793 |
| qqq4 | 0.533 / 0.691 | 1.534 / 2.018 |
| vptq | 1.921 / 3.678 | — |
| exl3_4 | 3.049 / 5.916 | 4.936 / 14.19 (≈2.06 GiB is the #4391 tile scratch) |
| paro4 | 0.392 / 0.613 | 1.177 / 1.602 |
| macaq | 1.383 / 1.773 | 5.21 / 7.65 |
| rtn4 | 0.142 / 0.209 | 0.530 / 0.779 |
Checked, clean
- Allocated at layer boundaries: flat for every method.
- Reserved per layer: flat for gptq/qqq/paro/macaq/vptq/gguf/nf12.
- Scoped rocBLAS pin (fix(rocm): scope the deterministic BLAS pin and stage HIP sources (#4092) #4105/fix(rocm): pin every Hessian builder and serialize mixed BLAS scopes (#4123) #4141): entering and leaving it 5–20 times, or alternating rocBLAS/hipBLASLt, allocates 0 bytes, and non-torch VRAM stays flat (0.51 GiB) over 24 GPTQ layers.
- Triton/inductor caches during quantize: bounded (MACaQ compiles 73 kernels in 3 layers, then nothing more).
- After
del model: every method returns to 0 except EXL3 ([MEM] Quantize memory: EXL3 tile scratch never released (2-8 GiB pinned after quantize), VPTQ distance temporaries 3x budget and 8 fp64 Hessian copies + duplicate inverse, GPTAQ/FOEM bs>1 duplicate sibling inputs and Hessians #4391).
Plausible, not verified
- EXL3 reserved is 2.6–2.9× allocated on Llama-1B (14.2 vs 4.9 GiB, 5 alloc retries), barely changed without the split cap. The likely cause is the per-worker stream pools (
get_quant_stream). - Out-of-memory error not recognised: a card-full
AcceleratorError: hipErrorOutOfMemoryingar.invert_permlikely isn't matched by the fix(gptq): classify solver allocation failures for CPU fallback (#4350) #4359 CPU fallback (near [MEM] MoE/OOM: shared-input Hessian adoption keeps 3 C^2 per pair (+0.96 GiB/20% peak on Qwen1.5-MoE), quantized MoE reload materializes bf16 experts on host (12.2 vs 4.2 GiB RSS), OOM CPU fallback missing in QQQ/EXL3 and after GPTQ inverse #4400 item 3).
🤖 Generated with Claude Code
Activity
Qubitium commentedon Nov 16, 2026
Claimed by an AI agent: item 1 (ROCm AWQ clip scratch vs split cap) and item 4 (pack_gpu block_in transient). The MACaQ dead-copy item is already merged via #4431.
fix(awq,qlinear): keep clip scratch splittable and bound pack_gpu tra…
Qubitium commentedon Nov 16, 2026
Claimed by an AI agent: item 3 (shared-input Hessian dedup for QQQ/VPTQ/MACaQ/EXL3). Items 1, 2, 4 are merged (#4437, #4431).
Qubitium commentedon Nov 16, 2026
Claimed by an AI agent: item 3 (shared-input Hessian dedup for QQQ/VPTQ/MACaQ/EXL3). Branch
fix/sibling-hessian-dedup-4401; items 1, 2, 4 landed in #4437/#4431.fix(looper): dedup shared-input Hessians for QQQ/VPTQ/MACaQ/EXL3 and …