Skip to content

[MEM][ROCm] ROCm default PYTORCH_ALLOC_CONF keeps max_split_size_mb:256 (removed on CUDA by #4419): MACaQ on Llama-3.1-8B reserves 19.5 GiB for a 9.4 GiB working set (11.8 GiB without the cap, identical checkpoint) #5072

Closed

Description

@Qubitium

Found on main @ c2b0bf6, AMD Radeon AI PRO R9700 (gfx1201, 32 GB), torch 2.16 dev + ROCm 10.1, idle card, one process.

What is wrong

gptqmodel/_alloc_conf.py:73 installs ROCM_DEFAULT_ALLOC_CONF = "max_split_size_mb:256,garbage_collection_threshold:0.7" on every ROCm import. #4419 (fix of #4389) dropped max_split_size_mb from the CUDA default for exactly this reason: with the 256 MiB split cap, blocks of 256 MiB and larger are never split or reused for other sizes. The comment at _alloc_conf.py:70-72 keeps the ROCm value unchanged ("the ROCm path already mitigates the 256 MiB split cap with a per-layer empty_cache(). Changing it is a separate ROCm decision"). The per-layer empty_cache() does not help when the waste is within one layer. It does not help for MACaQ at all: the inflated reservation stays held after quantize() returns.

The cap wastes about 9 GiB of the 32 GB card on Llama-3.1-8B MACaQ. That is almost 2x the real working set, with no change in output.

Measurements

Same script, same seed and calibration (128 C4 rows), fp16, default MacaqConfig() unless noted. The only change is PYTORCH_ALLOC_CONF. The checkpoint tensor hashes are identical in every pair.

model / method conf peak allocated peak reserved reserved after quantize() quantize s
Llama-3.1-8B-Instruct (first 4 layers) / MACaQ ROCm default 9.44 GiB 19.52 GiB 19.52 GiB 250.7
same garbage_collection_threshold:0.7 9.37 GiB 11.83 GiB 11.83 GiB 230.7
Llama-3.2-1B-Instruct / MACaQ (3 runs default) ROCm default 3.03 GiB 5.51-5.60 GiB 5.51-5.60 GiB 140-145
same garbage_collection_threshold:0.7 3.02 GiB 3.64 GiB 3.64 GiB 141
Llama-3.2-1B-Instruct / EXL3 4-bit default -> gc-only 1.72 3.12 -> 2.71 399 -> 395
Llama-3.2-1B-Instruct / AWQ 4-bit default -> gc-only 0.95 1.68 -> 1.27
Llama-3.2-1B-Instruct / GPTAQ 4-bit default -> gc-only 2.59 5.05 -> 4.79
Llama-3.2-1B-Instruct / GPTQ 4-bit default -> gc-only 1.42 2.20 -> 2.10
Qwen3-0.6B / AWQ 4-bit (the #4313 case) default -> gc-only 0.54 / 0.56 1.03 -> 1.06, layer-start reserved flat 0.463 GiB in both 99 -> 98

Per-layer MemDiag on the 8B run: reserved is 19.52 GiB from layer 1 on with the default, and 10.30 GiB without the cap, while the per-layer peak allocated is 8.68 GiB in both. So this is per-layer churn above the 256 MiB cap (MACaQ's flip-sweep working set on 14336x4096 projections), not a leak. Removing the cap does not bring back #4313: the Qwen3-0.6B AWQ reservation stays flat in both configurations.

Repro

# identical except for the allocator conf; read torch.cuda.max_memory_reserved() after quantize()
python run.py --model Llama-3.1-8B-Instruct --layers 4 --method macaq            # ROCm default -> 19.52 GiB reserved
PYTORCH_ALLOC_CONF=garbage_collection_threshold:0.7 \
python run.py --model Llama-3.1-8B-Instruct --layers 4 --method macaq            # 11.83 GiB reserved, same checkpoint hash
# model dir = Llama-3.1-8B-Instruct copy with num_hidden_layers=4
m = GPTQModel.load(model_dir, MacaqConfig(), dtype=torch.float16)
torch.cuda.reset_peak_memory_stats()
m.quantize(CalibrationConfig(dataset=c4_rows[:128]))
print(torch.cuda.max_memory_allocated() / 2**30, torch.cuda.max_memory_reserved() / 2**30)

Suggested fix

Drop max_split_size_mb:256 from ROCM_DEFAULT_ALLOC_CONF, as #4419 did on CUDA. Keep the "no expandable_segments" rule from #4072. garbage_collection_threshold:0.7 is inert without a memory fraction, as _alloc_conf.py:52-58 already notes, so the ROCm default could be the torch default plus the documented exclusion. Then update the #4313 regression tests that pin the exact string. With the cap gone, nothing produces the 256 MiB-segment pattern those tests guard against: the #4313 model stays flat as shown above.

Test that should have caught it

tests/test_alloc_conf.py only checks the string that gets installed. A ROCm memory test should assert peak_reserved <= ~1.5 x peak_allocated for one MACaQ/EXL3 layer of a wide model. That is the check #4389 suggested for CUDA.

Severity

Medium on ROCm. It is the default for every ROCm quantization, and MACaQ on an 8B model reserves 19.5 GiB of a 32 GB R9700 for a 9.4 GiB working set. That starves any other process on the card, and larger models get close to OOM. The outputs are bit-identical and the run is slightly faster without the cap.

🤖 Generated with Claude Code

Activity

  1. ZX-ModelCloud commented on Nov 18, 2026

    @ZX-ModelCloud
    Collaborator

    Claimed. I'm working on this issue and will submit a fix PR. Please avoid duplicate work in the meantime.

  2. ZX-ModelCloud commented on Nov 18, 2026

    @ZX-ModelCloud
    Collaborator

    Agent claim: agent-98d33e793cae is working on this issue now.

    Started 2026-11-18T03:24:23Z. The claim expires 4.0h after this comment was last edited (heartbeat). Other agents: do not start this issue while the claim is live.

    Reproducing the ROCm max_split_size_mb reservation on a wide MACaQ layer, then dropping the cap from the ROCm default

  3. added a commit that references this issue on Nov 18, 2026
    249ec41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions