Description
Found on main @ dba142d, x86-64 AVX512-BF16 host (CPU only).
What is wrong
ParoLinear (AUTO for Paro checkpoints on CPU) builds a second, kernel-layout copy of the packed weight on its first CPU forward and keeps it for the life of the module. The checkpoint qweight/qzeros/scales buffers stay resident next to it. Both CPU paths do this:
- bf16:
paro.py:621->AwqTorchLinear._forward_cpu_avx512->_ensure_cpu_packed(nn_modules/qlinear/torch_awq.py:315-361) stores_cpu_packed_qweight,_cpu_packed_qzeros,_cpu_packed_scales(fp32) and_cpu_packed_bias(fp32) as plain attributes. - fp16:
paro.py:500-560_forward_cpu_atenbuilds a hiddenTorchAtenAwqLinear(self._cpu_aten_layer), aliases the checkpoint tensors into it and callstransform_cpu. That rebinds the helper'sqweightto a new int4pack tensor (plusscales_and_zeros) while the module keeps the original.
This is the same 2x residency that #4395/#4532 removed for the GPTQ/AWQ CPU int4 kernels, here on a separate code path (see also #4783 and #4805).
Measured: Qwen2.5-0.5B-Instruct Paro 4-bit g128 (ckpt 443 MiB), device=cpu, AUTO = ParoLinear x168, tensor bytes after 3 forwards
model tensors quantized-linear tensors new attributes
bf16 (AVX512 path) 443.2 -> 629.6 MiB 183.4 -> 369.8 MiB (2.02x) _cpu_packed_qweight 170.6, _cpu_packed_scales 10.7 (fp32), _cpu_packed_qzeros 2.7, ...
fp16 (ATen path) 443.2 -> 635.1 MiB ~2.05x _cpu_aten_layer: qweight 170.6, scales_and_zeros 21.3, qzeros 10.7
The ratio is per weight, so an 8B Paro model would carry about +3.5 GiB, as with #4805.
Minimal repro
import torch
from gptqmodel import GPTQModel
m = GPTQModel.load("<Paro 4-bit checkpoint>", dtype=torch.bfloat16, device="cpu") # AUTO -> ParoLinear
mods = [x for x in m.model.modules() if type(x).__name__ == "ParoLinear"]
with torch.inference_mode():
m.model(torch.randint(100, 1000, (1, 8)))
mib = lambda ts: sum(t.numel() * t.element_size() for t in ts if t is not None) / 2**20
print(mib(x.qweight for x in mods), mib(x._cpu_packed_qweight for x in mods)) # 170.62 170.62Suggested fix
Keep one resident layout on CPU:
- after building the AVX512 / int4pack operands, release the checkpoint
qweight/qzeros/scales, and rebuild them onstate_dict()/save/device move using the verified-inverse flow from fix(cpu-int4): rebuild checkpoint qweight instead of keeping a clone (#4395) #4532 (unpack_hf_int4exists for the AVX512 layout, see [MEM] #4532 incomplete: CPU AUTO kernel TorchCpuAvx512Linear (and every desc_act ckpt on ATen/Fused) still keeps the full checkpoint qweight snapshot: Llama-3.1-8B GPTQ +3.4 GiB host RAM (+63%) after first forward; the inverse exists and is bitwise #4783); - or have
ParoLinearown the transformed buffers directly, the wayTorchCpuAvx512AwqLinear/TorchAtenAwqLineardo, instead of hiding a second copy in attributes or a helper layer.
Keep the cached scales/bias in the checkpoint dtype, or widen them per call. Restoring them from fp32 to fp16/bf16 is exact, but storing them in fp32 doubles their size.
Test that should have caught it
The Paro CPU tests check numerics only. A parametrized CPU residency test over every kernel would have caught it: tensor bytes after the first forward at most 1.1x of the checkpoint's quantized bytes.
Severity
Medium: about 2x host RAM for the quantized linears on the default CPU path for Paro.
🤖 Generated with Claude Code
Activity
Qubitium commentedon Nov 17, 2026
Agent claim released:
agent-53ba17eb4d83finished this issue.Pull request: #4832
Fixing: reproduce, root-cause, add regression test, keep existing suites green.
fix(paro): keep one packed CPU layout per layer (#4814) (#4832)
perf(paro): run the CPU int4 GEMM outside the process-wide transform …