You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG][multi-GPU] Closed #3826 partly reproduces: pre_quantize stages every layer on device 0 when only cuda:1 is allowed, and OOMs if GPU 0 is full #4233
Severity: medium. A whole decoder layer lands on a GPU the user excluded; if that GPU is busy, quantization crashes. Not ROCm-specific. Version: 7.11.0 @ 9dad249
Summary
models/base.py:3947-3957 (pre_quantize(), called from looper/stage_layer.py:~716) calls move_to(module, device=self.quantize_config.device). Its META branch calls shell_module_materialize(..., device=self.quantize_config.device).
quantize_config.device holds only the index-less family (DEVICE.CUDA / DEVICE.ROCM). as_torch_device turns that into "cuda", i.e. the current device, cuda:0.
compute_device_filter, which the loader builds from device=("cuda:1",) (models/loader.py:~1919-1929), is never consulted here.
docs/multi_gpu_quantization.md:59,105 documents device=("cuda:1",) as "Both use only cuda:1". #3826 named this exact pre_quantize staging in its trigger; only the forward-executor part was fixed.
Reproduce (2 GPUs)
importtorchfromtransformersimportAutoTokenizerfromgptqmodelimportGPTQModelfromgptqmodel.quantizationimportAWQConfig, FORMATMODEL="Qwen/Qwen2.5-0.5B-Instruct"torch.cuda.set_per_process_memory_fraction(1e-9, 0) # simulate a busy/full GPU 0tok=AutoTokenizer.from_pretrained(MODEL)
calib= [tok("The quick brown fox jumps over the lazy dog. "*8+str(i)) foriinrange(32)]
m=GPTQModel.load(MODEL, AWQConfig(bits=4, group_size=128, format=FORMAT.GEMM), device=("cuda:1",))
m.quantize(calib, batch_size=4)
# torch.OutOfMemoryError: ... GPU 0 ... (base.py pre_quantize -> move_to -> safe_module_to)
Without the memory-fraction line, torch.cuda.max_memory_allocated(0) is about 35 MiB (one decoder layer), and MemDiag shows cuda:0 reserved=0.04GiB for every layer, even though only cuda:1 was allowed.
Expected
No allocation on an excluded GPU: stage layers on the filtered or primary quantization device.
Found during an AI-assisted review (Claude Code) of 9dad249; repros were run on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.
Activity
fix: stage pre_quantize layers on the filtered quantization device (#…