Skip to content

fix: stop forcing max_split_size_mb on CUDA allocator config (#4389) - #4419

Merged
Qubitium merged 1 commit into
mainfrom
pr/4389
Nov 16, 2026
Merged

Qubitium merged 1 commit into
mainfrom
pr/4389

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Root cause: gptqmodel/_alloc_conf.py installed PYTORCH_ALLOC_CONF='expandable_segments:True,max_split_size_mb:256,garbage_collection_threshold:0.7' on every backend, including CUDA. max_split_size_mb:256 caps the largest block the allocator is willing to split, so a freed 256 MiB block cannot serve the next layer's slightly smaller request. GPTQ's per-layer Hessian/workspace churn then maps new pages instead of reusing the cache: reserved VRAM grows per layer while active memory stays flat (measured 1.23 GiB allocated vs 5.40 GiB reserved; expandable_segments:True alone reserves 1.67 GiB).

What Changed

  • CUDA default is now expandable_segments:True only; max_split_size_mb is removed. Expandable segments is the knob that actually removes the fragmentation cliff.
  • garbage_collection_threshold:0.7 is dropped rather than paired with a memory fraction: it is a ratio of the device's total memory (0.7 on a 48 GiB card only collects above ~33 GiB), so it never fired during the reported run. Setting a process memory fraction would cap the allocator and trade the reservation for OOMs.
  • ROCm default is unchanged (max_split_size_mb:256,garbage_collection_threshold:0.7, no expandable_segments): [BUG] AWQ quantization grows reserved VRAM by ~1 GiB per layer on ROCm (256 MiB segments never reused), starving other processes on the GPU #4313's regression tests pin this exact value and the ROCm path already mitigates the 256 MiB split cap with a per-layer empty_cache(). Changing it is a separate ROCm decision.
  • default_alloc_conf(backend=None) now accepts an explicit "cuda"/"rocm" so the policy is unit-testable without a device; the no-arg detection used by the import-time hook is unchanged.
  • A caller-provided PYTORCH_ALLOC_CONF / PYTORCH_CUDA_ALLOC_CONF (and PYTORCH_HIP_ALLOC_CONF on ROCm) still wins; the new test pins that.
  • docs/rocm-default-environment.md updated to describe the CUDA default.

Tests

cd /root/work/gptq-new3/a4389
export GPTQ_BYPASS_SAFETY_CHECKS=1 PYTHONPATH=$PWD CUDA_VISIBLE_DEVICES=
python3 -m pytest tests/test_cuda_alloc_conf_4389.py tests/test_alloc_conf.py tests/test_rocm_default_env.py tests/test_awq_rocm_layer_cache_4313.py -q
  -> 26 passed, 7 skipped in 14.99s

python3 -m pytest tests/test_cuda_alloc_conf_4389.py -v
  -> 5 passed in 5.19s

ruff check gptqmodel/_alloc_conf.py tests/test_cuda_alloc_conf_4389.py
  -> All checks passed!
ruff format --check gptqmodel/_alloc_conf.py tests/test_cuda_alloc_conf_4389.py
  -> 2 files already formatted

The 7 skips are the device-only tests in those files (no CUDA/ROCm device here).

End-to-end env check in a fresh interpreter:

{"PYTORCH_ALLOC_CONF": "expandable_segments:True", "PYTORCH_CUDA_ALLOC_CONF": "expandable_segments:True"}

What could not be run

Model Support / Module Plan

N/A — no new model types or registry entries.

Fixes #4389

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant