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] ROCm: transformers from_pretrained(device_map="auto") of an AWQ-GEMM ckpt that resolves to all-CPU keeps AwqGEMMTritonLinear (SUPPORTS_CPU_OFFLOAD skips the #5262 reselect) -> 'Pointer argument cannot be accessed from Triton' at first forward #5579
safeNo suspicious indicators found in the reviewed text; not a guarantee of safety.scannedAutomated static security screen completed on the issue text.
Found on main @ 8c71625, AMD Radeon AI PRO R9700 (gfx1201), torch 2.16 dev ROCm 10.1, transformers 5.23.0. The same failure is present at c03416c, so this is not a regression.
What is wrong
On ROCm, AutoModelForCausalLM.from_pretrained(<AWQ-GEMM ckpt>, device_map="auto", max_memory=...) crashes in the first forward when the resolved map puts the whole model on CPU. Two examples: max_memory={"cpu": "30GiB"}, or a GPU budget too small for any layer such as {0: "400MiB", "cpu": "30GiB"}. AUTO keeps AwqGEMMTritonLinear, and the Triton launch receives CPU tensors:
gptqmodel/nn_modules/qlinear/gemm_awq_triton.py:326 forward -> :122 forward
gptqmodel/quantization/awq/modules/triton/gemm.py:414 awq_gemm_triton
ValueError: Pointer argument (at 376736992) cannot be accessed from Triton (cpu tensor?)
The same load on CUDA works. There the bridge's hf_gptqmodel_reselect_offloaded_kernels (gptqmodel/utils/hf_load.py:683) rebuilds all 112 modules with TorchAtenAwqLinear (INFO Transformers/Optimum: rebuilding 112 CPU/disk-offloaded module(s)...). On ROCm the AUTO pick is AwqGEMMTritonLinear, which declares SUPPORTS_CPU_OFFLOAD = True (gemm_awq_triton.py:202, "the Triton kernel runs after Accelerate materializes the layer on the execution device"). The reselect filter at hf_load.py:721-726 therefore skips every module. That assumption holds only when there is a GPU execution device. When the map resolves to CPU only, transformers dispatches the model on CPU with no AlignDevicesHook, so nothing moves the layer to the GPU. tritonv2.TritonV2Linear declares the same flag.
Native GPTQModel.load(..., device_map="auto", max_memory={"cpu": "30GiB"}) on the same card picks TorchAtenAwqLinear and works. Only the HF bridge path is affected. Mixed placements ({0: "700MiB", "cpu": ...}, {0: "600MiB", "cpu": "200MiB", "disk": ...}) work on ROCm, because those layers get an AlignDevicesHook with execution device 0.
Repro (one ROCm GPU visible; with or without a prior import gptqmodel)
importtorch, gptqmodelfromtransformersimportAutoModelForCausalLM, AutoTokenizerP="AWQ-Llama-3.2-1B-g128-gemm"tok=AutoTokenizer.from_pretrained(P); ids=tok("The capital of France is", return_tensors="pt")
forkwin ({"device_map": "cpu"}, {"device_map": "auto", "max_memory": {"cpu": "30GiB"}}):
m=AutoModelForCausalLM.from_pretrained(P, dtype=torch.float16, **kw)
print(kw, {type(x).__name__forxinm.modules() if"Awq"intype(x).__name__})
print(tok.decode(m.generate(**ids, max_new_tokens=8, do_sample=False)[0]))
Output on ROCm:
{'device_map': 'cpu'} ['TorchCpuAvx512AwqLinear'] ' Paris.\nThe capital of France is Paris'
{'device_map': 'auto', 'max_memory': {'cpu': '30GiB'}} ['AwqGEMMTritonLinear'] ValueError: Pointer argument ... cannot be accessed from Triton (cpu tensor?)
On CUDA (RTX 4090), the second load gives ['TorchAtenAwqLinear'] ' Paris.\nThe capital of France is Paris'.
Suggested fix: SUPPORTS_CPU_OFFLOAD means "works when Accelerate offloads to a GPU execution device". In hf_gptqmodel_reselect_offloaded_kernels, when the resolved map has no GPU entry (every placement is cpu/disk), or when a module's placement is CPU with no GPU execution device, rebuild every module whose kernel does not list DEVICE.CPU in SUPPORTS_DEVICES, not only those without SUPPORTS_CPU_OFFLOAD. The #5262/#5395 CUDA paths only work because Marlin lacks the flag.
Which test should have caught it: tests/test_hf_bridge_thirdparty_offload_5262.py and test_hf_bridge_cpu_offload_5022.py cover only CUDA AUTO picks (Marlin) and only spills that keep a GPU execution device. Add a case with a CPU-only max_memory, and run the file on ROCm, where AUTO picks the Triton kernels.
Severity: low-medium. On ROCm, a plain transformers load with a max_memory that leaves no room on the GPU crashes at the first forward instead of running on CPU. Native load and CUDA are fine.
Fixed by #5657 (merged as 5cd9bb8). The reselect filter now honours SUPPORTS_CPU_OFFLOAD only when the resolved map has a non-CPU execution device; with an all-CPU/disk map it rebuilds every kernel that does not declare DEVICE.CPU/DEVICE.ALL, so the ROCm AUTO pick (AwqGEMMTritonLinear) is replaced before the first forward. Verified on CPU: 8 new filter tests pass (4 fail pre-fix); the two HF-bridge suites keep their pre-existing Marlin CUDA_HOME failures only. The gfx1201 end-to-end load was not re-measured here (no ROCm device).
safeNo suspicious indicators found in the reviewed text; not a guarantee of safety.scannedAutomated static security screen completed on the issue text.
Activity
Qubitium commentedon Nov 20, 2026
Agent claim released:
agent-fb5145b84190finished this issue.Pull request: #5657
ROCm HF-bridge reselect: make SUPPORTS_CPU_OFFLOAD skip only the offload path, not the CPU kernel reselect; CPU-testable with a fake device map
fix(hf): rebuild CUDA-only kernels for a CPU-only resolved map (#5579) (
Qubitium commentedon Nov 20, 2026
Fixed by #5657 (merged as 5cd9bb8). The reselect filter now honours
SUPPORTS_CPU_OFFLOADonly when the resolved map has a non-CPU execution device; with an all-CPU/disk map it rebuilds every kernel that does not declareDEVICE.CPU/DEVICE.ALL, so the ROCm AUTO pick (AwqGEMMTritonLinear) is replaced before the first forward. Verified on CPU: 8 new filter tests pass (4 fail pre-fix); the two HF-bridge suites keep their pre-existing Marlin CUDA_HOME failures only. The gfx1201 end-to-end load was not re-measured here (no ROCm device).Merge main into the Transformers 5 model ports