Skip to content

HIP: no device printf in the MoE expert prefix (stacked on #264) - #483

Open
LeoBorcherding wants to merge 1 commit into
unslothai:cuda-moe-prompt-kernelsfrom
LeoBorcherding:hip-no-printf-mm-ids-prefix
Open

LeoBorcherding wants to merge 1 commit into
unslothai:cuda-moe-prompt-kernelsfrom
LeoBorcherding:hip-no-printf-mm-ids-prefix

Conversation

@LeoBorcherding

Copy link
Copy Markdown

Stacked on #264. On AMD hosts without PCIe atomics, every MoE prompt of 512+ tokens aborts in the counting sort:

ROCm error: the operation cannot be performed in the present state
  current device: 0, in function launch_mm_ids_counting_sort at ggml/src/ggml-cuda/mmid.cu:513

mm_ids_expert_prefix calls device printf. HIP's printf goes through hostcall, and clr only allows hostcall when the CPU-GPU link reports PCIe atomics, so without them the kernel never launches and returns hipErrorIllegalState. This drops the printf on HIP and keeps the __trap, so out-of-range ids still stop the kernel. CUDA is unchanged.

Who hits it: GPU passthrough VMs (Proxmox/QEMU root ports usually don't advertise AtomicOps), plus some riser and Thunderbolt setups. Seen so far:

Repro on an RX 9060 XT (gfx1200), Linux Mint, hiding atomics with an LD_PRELOAD shim that clears atomic_support_* from the link info. Same model and flags, 1213-token prompt:

atomics hidden atomics on
#264 fd6fae5 abort at mmid.cu:513 OK
this PR OK (3/3) OK

Not run: a host that really lacks atomics. The failing dispatch and the error string match the reports. Workaround until this ships: GGML_CUDA_MM_IDS_SORT=0, or --ubatch-size under 512.

HIP's device printf needs hostcall, and hostcall needs PCIe atomics on the
CPU-GPU link. On a host without them mm_ids_expert_prefix fails to launch
(hipErrorIllegalState), so every MoE prompt of 512+ tokens aborts. Keep the
__trap, drop only the printf on HIP.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant