[PR #2] [CLOSED] [DRAFT] Barebones ROCM support #53

Closed
opened 2026-10-26 22:24:09 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-aimdo/pull/2
Author: @asagi4
Created: 2/5/2026
Status: ❌ Closed

Base: master ← Head: hack/rocm-support


📝 Commits (10+)

  • 639124d Add platform-specific defines to enable compilation with HIP
  • 659b3dc HIP async support needs access to the original functions on Linux
  • 3bff535 Simultaneous cuda+rocm support
  • d53839b Assume nvidia if autodetection fails
  • 34557d9 ROCm build script
  • a81e95f HIP: Windows support
  • 349e73b Add Windows ROCm build script
  • 7421008 Safely handle lib cleanup in model_vbar
  • c6b8f27 Improve validation and error handling in Windows ROCm build script
  • faea564 Fix windows build script

📊 Changes

15 files changed (+310 additions, -22 deletions)

View changed files

📝 .gitignore (+4 -0)
➕ build-rocm-local (+6 -0)
➕ build-rocm-local_win.ps1 (+65 -0)
📝 comfy_aimdo/control.py (+57 -6)
📝 comfy_aimdo/model_vbar.py (+2 -1)
📝 pyproject.toml (+1 -1)
➕ src-posix/detour-hip.c (+42 -0)
📝 src-posix/model-mmap.c (+1 -1)
📝 src-win/cuda-detour.c (+22 -4)
📝 src-win/shmem-detect.c (+24 -1)
📝 src/model-vbar.c (+1 -0)
📝 src/plat.h (+9 -7)
➕ src/plat_cuda.h (+7 -0)
➕ src/plat_hip.h (+63 -0)
📝 src/vrambuf.c (+6 -1)

📄 Description

Contribution Agreement

  • I agree that my contributions are licensed under the GPLv3.
  • I grant Comfy Org the rights to relicense these contributions as outlined in CONTRIBUTING.md.

This is not really intended for merging as is, but for reference. hipify-clang can convert the CUDA code to HIP code pretty easily with a few fixes, and it actually allows you to run aimdo on ROCM.

You might have to make sure your Python venv is using your system ROCM libraries for this to work.

It does not work perfectly (I'm still getting pytorch OOMs when it should be freeing memory) but workflows can run and produce good output.

I am not able to test, but the HIP code should be compilable as is on nvidia platforms too. If you run build-rocm on an nvidia platform, hipcc and hipconfig should set it up to link against cuda instead of ROCM and the result should be basically identical to the CUDA implementation.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-aimdo/pull/2 **Author:** [@asagi4](https://github.com/asagi4) **Created:** 2/5/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `hack/rocm-support` --- ### 📝 Commits (10+) - [`639124d`](https://github.com/Comfy-Org/comfy-aimdo/commit/639124d64ed490568dfeb3f5243f9c458d21f525) Add platform-specific defines to enable compilation with HIP - [`659b3dc`](https://github.com/Comfy-Org/comfy-aimdo/commit/659b3dcc32c5b9a4c9a07148be375cf5000d1f3c) HIP async support needs access to the original functions on Linux - [`3bff535`](https://github.com/Comfy-Org/comfy-aimdo/commit/3bff53543ded7c09b321114b361998e3b1a86f07) Simultaneous cuda+rocm support - [`d53839b`](https://github.com/Comfy-Org/comfy-aimdo/commit/d53839b9a089dcc9728be01eb9f835b846b38bdd) Assume nvidia if autodetection fails - [`34557d9`](https://github.com/Comfy-Org/comfy-aimdo/commit/34557d977d1507f90e2aebd9bbbcf2c69464d66a) ROCm build script - [`a81e95f`](https://github.com/Comfy-Org/comfy-aimdo/commit/a81e95f94b9bcf40f0a78e7322b1c024f186c553) HIP: Windows support - [`349e73b`](https://github.com/Comfy-Org/comfy-aimdo/commit/349e73b93d2cbbf9b64d6e7fffb4dcb11f4b3649) Add Windows ROCm build script - [`7421008`](https://github.com/Comfy-Org/comfy-aimdo/commit/742100801c98caf2531f3347dc28c6d76f70f71b) Safely handle lib cleanup in model_vbar - [`c6b8f27`](https://github.com/Comfy-Org/comfy-aimdo/commit/c6b8f27b67fe214b6edc530597f7dd546613a22a) Improve validation and error handling in Windows ROCm build script - [`faea564`](https://github.com/Comfy-Org/comfy-aimdo/commit/faea564d2317de2f5414b4b222d4f0605a384923) Fix windows build script ### 📊 Changes **15 files changed** (+310 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+4 -0) ➕ `build-rocm-local` (+6 -0) ➕ `build-rocm-local_win.ps1` (+65 -0) 📝 `comfy_aimdo/control.py` (+57 -6) 📝 `comfy_aimdo/model_vbar.py` (+2 -1) 📝 `pyproject.toml` (+1 -1) ➕ `src-posix/detour-hip.c` (+42 -0) 📝 `src-posix/model-mmap.c` (+1 -1) 📝 `src-win/cuda-detour.c` (+22 -4) 📝 `src-win/shmem-detect.c` (+24 -1) 📝 `src/model-vbar.c` (+1 -0) 📝 `src/plat.h` (+9 -7) ➕ `src/plat_cuda.h` (+7 -0) ➕ `src/plat_hip.h` (+63 -0) 📝 `src/vrambuf.c` (+6 -1) </details> ### 📄 Description ### Contribution Agreement - [x] I agree that my contributions are licensed under the GPLv3. - [x] I grant **Comfy Org** the rights to relicense these contributions as outlined in [CONTRIBUTING.md](./CONTRIBUTING.md). This is not really intended for merging as is, but for reference. hipify-clang can convert the CUDA code to HIP code pretty easily with a few fixes, and it actually allows you to run aimdo on ROCM. You might have to make sure your Python venv is using your system ROCM libraries for this to work. It does not work perfectly (I'm still getting pytorch OOMs when it should be freeing memory) but workflows can run and produce good output. I am not able to test, but the HIP code should be compilable as is on nvidia platforms too. If you run build-rocm on an nvidia platform, hipcc and hipconfig should set it up to link against cuda instead of ROCM and the result should be basically identical to the CUDA implementation. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 22:24:09 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-aimdo#53
No description provided.