Repository navigation
Conversation
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AWQ's clip search (
_compute_best_clip) pre-allocates ascratch_prodbuffer per clip-eligible module from the GPU MSE budget (MSEConfigdefaults to 256 MiB on GPU). For Qwen3-0.6B those requests are 255 MiB (v_proj,gate_proj,up_proj,down_proj) and 250 MiB (o_proj), which PyTorch rounds to 256.0 MiB and 250.0 MiB segments. On ROCm the defaultPYTORCH_ALLOC_CONF='max_split_size_mb:256,garbage_collection_threshold:0.7'makes the native caching allocator refuse to serve any request smaller thanmax_split_sizefrom a free block of at least that size (get_free_block: "Do not return an oversized block for a large request"), and it also refuses to split such a block. Each clip module therefore allocates a fresh 256 MiB segment that no later 255 MiB request can reuse.garbage_collection_thresholdis inert without a memory fraction, and AWQ never released the cache at layer boundaries, so reserved VRAM grew by ~1 GiB per decoder layer while active memory stayed flat.Evidence:
v/gate/up/downrequest 267,386,880 B = 255.00 MiB -> 256.0 MiB segment,o_proj262,144,000 B = 250.00 MiB -> 250.0 MiB segment: four 256 MiB + one 250 MiB segment per layer, matching the issue's snapshot.CUDA_VISIBLE_DEVICES=1, <1 GiB): alternating 255 MiB / 250 MiB requests grow reserved 258 -> 508 -> 764 -> 1020 MiB;memory_snapshot()showssegment_total=256.0 MiB,segment_allocated=0.0, oneinactiveblock, stream 0 - the exact signature in the issue. Withoutmax_split_size_mb:256(or with1024, or withexpandable_segments:True) reserved stays flat at 258 MiB for the same sequence.What Changed
apply_clip()now calls a small_release_rocm_layer_cache()helper once per AWQ layer.apply_clipis the once-per-layer boundary where all clip-search scratch has already been freed and the next layer has not allocated yet; releasing the unused cache there keeps reserved memory flat. The helper is ROCm-only (torch.version.hip is not None) and best-effort, so CUDA keeps its allocator cache and pays no extracudaMalloc, and a cleanup failure can never abort quantization.tests/test_awq_rocm_layer_cache_4313.pycovering: exactly one release per layer (two clipped modules -> one call), release on the resolved quantization device, no release on CUDA, no release without CUDA, and failure tolerance.Tests
Allocator probe (evidence only, not a committed test):
Model Support / Module Plan
N/A - no new model types or registry entries.
Fixes #4313