ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

AMD RDNA3 PERFORMANCE FIX SOLUTION FOUND

Open Reber01Good opened this issue 1 year ago • 16 comments

Custom Node Testing

Expected Behavior

Run fast, no OOM

Actual Behavior

Run slow, OOM

Steps to Reproduce

torch.backends.cudnn.enabled=False -> BAD torch.backends.cudnn.enabled=True -> GOOD

Env Vars: MIOPEN_FIND_MODE=2 MIGRAPHX_MLIR_USE_SPECIFIC_OPS="attention" FLASH_ATTENTION_TRITON_AMD_ENABLE="TRUE" FLASH_ATTENTION_TRITON_AMD_AUTOTUNE="FALSE TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 (TunableOP tuning is faster and better than FA autotune)

Launch: --preview-size 1024 --reserve-vram 0.9 --async-offload --use-flash-attention --fp32-vae --disable-smart-memory

System specs and software can be found in the main comment.

Debug Logs

Nothing useful here:

[START] Security scan
[ComfyUI-Manager] Using uv as Python module for pip operations.
Using Python 3.12.11 environment at: .pyenv/versions/3.12.11
[DONE] Security scan
## ComfyUI-Manager: installing dependencies done.
** ComfyUI startup time: 2025-10-24 06:25:50.486
** Platform: Linux
** Python version: 3.12.11 (main, Oct 16 2025, 06:37:22) [GCC 13.3.0]
** Python executable: /home/alex/.pyenv/versions/3.12.11/bin/python
** ComfyUI Path: /home/alex/ComfyUI
** ComfyUI Base Folder Path: /home/alex/ComfyUI
** User directory: /home/alex/ComfyUI/user
** ComfyUI-Manager config path: /home/alex/ComfyUI/user/default/ComfyUI-Manager/config.ini
** Log path: /home/alex/ComfyUI/user/comfyui.log
Using Python 3.12.11 environment at: .pyenv/versions/3.12.11
Using Python 3.12.11 environment at: .pyenv/versions/3.12.11

Prestartup times for custom nodes:
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/rgthree-comfy
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-easy-use
   0.4 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-manager

Checkpoint files will always be loaded safely.
Total VRAM 24560 MB, total RAM 63903 MB
pytorch version: 2.10.0.dev20251017+rocm7.0
Set: torch.backends.cudnn.enabled = False for better AMD performance.
AMD arch: gfx1100
ROCm version: (7, 0)
Set vram state to: NORMAL_VRAM
Disabling smart memory management
Device: cuda:0 Radeon RX 7900 XTX : native
Using async weight offloading with 2 streams
Using Flash Attention
Python version: 3.12.11 (main, Oct 16 2025, 06:37:22) [GCC 13.3.0]
ComfyUI version: 0.3.66
ComfyUI frontend version: 1.30.1
[Prompt Server] web root: /home/alex/.pyenv/versions/3.12.11/lib/python3.12/site-packages/comfyui_frontend_package/static
### Loading: ComfyUI-Manager (V3.37)
[ComfyUI-Manager] network_mode: public
### ComfyUI Revision: 4113 [560b1bdf] *DETACHED | Released on '2025-10-21'
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/alter-list.json
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/github-stats.json
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json
------------------------------------------
Comfyroll Studio v1.76 :  175 Nodes Loaded
------------------------------------------
** For changes, please see patch notes at https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/blob/main/Patch_Notes.md
** For help, please see the wiki at https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki
------------------------------------------
[/home/alex/ComfyUI/custom_nodes/comfyui_controlnet_aux] | INFO -> Using ckpts path: /home/alex/ComfyUI/custom_nodes/comfyui_controlnet_aux/ckpts
[/home/alex/ComfyUI/custom_nodes/comfyui_controlnet_aux] | INFO -> Using symlinks: False
[/home/alex/ComfyUI/custom_nodes/comfyui_controlnet_aux] | INFO -> Using ort providers: ['CUDAExecutionProvider', 'DirectMLExecutionProvider', 'OpenVINOExecutionProvider', 'ROCMExecutionProvider', 'CPUExecutionProvider', 'CoreMLExecutionProvider']
DWPose: Onnxruntime with acceleration providers detected
Device configuration: GPU=cuda, CPU=cpu
[ComfyUI-Easy-Use] server: v1.3.4 Loaded
[ComfyUI-Easy-Use] web root: /home/alex/ComfyUI/custom_nodes/comfyui-easy-use/web_version/v2 Loaded
ComfyUI-GGUF: Allowing full torch compile
### Loading: ComfyUI-Impact-Pack (V8.25.1)
### Loading: ComfyUI-Impact-Subpack (V1.3.5)
[Impact Pack/Subpack] Using folder_paths to determine whitelist path: /home/alex/ComfyUI/user/default/ComfyUI-Impact-Subpack/model-whitelist.txt
[Impact Pack/Subpack] Ensured whitelist directory exists: /home/alex/ComfyUI/user/default/ComfyUI-Impact-Subpack
[Impact Pack/Subpack] Loaded 0 model(s) from whitelist: /home/alex/ComfyUI/user/default/ComfyUI-Impact-Subpack/model-whitelist.txt
[Impact Pack] Wildcards loading done.
[Impact Subpack] ultralytics_bbox: /home/alex/ComfyUI/models/ultralytics/bbox
[Impact Subpack] ultralytics_segm: /home/alex/ComfyUI/models/ultralytics/segm
### Loading: ComfyUI-Inspire-Pack (V1.22.2)
LIGER kernel not found. The option to enable it will be disabled.
[MultiGPU Core Patching] Patching mm.soft_empty_cache for Comprehensive Memory Management (VRAM + CPU + Store Pruning)
[MultiGPU Core Patching] Patching mm.get_torch_device, mm.text_encoder_device, mm.unet_offload_device
[MultiGPU DEBUG] Initial current_device: cuda:0
[MultiGPU DEBUG] Initial current_text_encoder_device: cuda:0
[MultiGPU DEBUG] Initial current_unet_offload_device: cpu
[MultiGPU] Initiating custom_node Registration. . .
-----------------------------------------------
custom_node                   Found     Nodes
-----------------------------------------------
ComfyUI-LTXVideo                  N         0
ComfyUI-Florence2                 Y         2
ComfyUI_bitsandbytes_NF4          N         0
x-flux-comfyui                    N         0
ComfyUI-MMAudio                   N         0
ComfyUI-GGUF                      Y        18
PuLID_ComfyUI                     N         0
ComfyUI-WanVideoWrapper           N         0
-----------------------------------------------
[MultiGPU] Registration complete. Final mappings: CheckpointLoaderAdvancedMultiGPU, CheckpointLoaderAdvancedDisTorch2MultiGPU, UNetLoaderLP, UNETLoaderMultiGPU, VAELoaderMultiGPU, CLIPLoaderMultiGPU, DualCLIPLoaderMultiGPU, TripleCLIPLoaderMultiGPU, QuadrupleCLIPLoaderMultiGPU, CLIPVisionLoaderMultiGPU, CheckpointLoaderSimpleMultiGPU, ControlNetLoaderMultiGPU, DiffusersLoaderMultiGPU, DiffControlNetLoaderMultiGPU, UNETLoaderDisTorch2MultiGPU, VAELoaderDisTorch2MultiGPU, CLIPLoaderDisTorch2MultiGPU, DualCLIPLoaderDisTorch2MultiGPU, TripleCLIPLoaderDisTorch2MultiGPU, QuadrupleCLIPLoaderDisTorch2MultiGPU, CLIPVisionLoaderDisTorch2MultiGPU, CheckpointLoaderSimpleDisTorch2MultiGPU, ControlNetLoaderDisTorch2MultiGPU, DiffusersLoaderDisTorch2MultiGPU, DiffControlNetLoaderDisTorch2MultiGPU, Florence2ModelLoaderMultiGPU, DownloadAndLoadFlorence2ModelMultiGPU, UnetLoaderGGUFDisTorchMultiGPU, UnetLoaderGGUFAdvancedDisTorchMultiGPU, CLIPLoaderGGUFDisTorchMultiGPU, DualCLIPLoaderGGUFDisTorchMultiGPU, TripleCLIPLoaderGGUFDisTorchMultiGPU, QuadrupleCLIPLoaderGGUFDisTorchMultiGPU, UnetLoaderGGUFDisTorch2MultiGPU, UnetLoaderGGUFAdvancedDisTorch2MultiGPU, CLIPLoaderGGUFDisTorch2MultiGPU, DualCLIPLoaderGGUFDisTorch2MultiGPU, TripleCLIPLoaderGGUFDisTorch2MultiGPU, QuadrupleCLIPLoaderGGUFDisTorch2MultiGPU, UnetLoaderGGUFMultiGPU, UnetLoaderGGUFAdvancedMultiGPU, CLIPLoaderGGUFMultiGPU, DualCLIPLoaderGGUFMultiGPU, TripleCLIPLoaderGGUFMultiGPU, QuadrupleCLIPLoaderGGUFMultiGPU
/home/alex/.pyenv/versions/3.12.11/lib/python3.12/site-packages/timm/models/layers/__init__.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
  warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.layers", FutureWarning)
Using Flash Attention
(RES4LYF) Init
(RES4LYF) Importing beta samplers.
FETCH ComfyRegistry Data: 5/101
(RES4LYF) Importing legacy samplers.

[rgthree-comfy] Loaded 48 magnificent nodes. 🎉

[save_image_extended] AVIF is not supported. To add it: pip install pillow pillow-avif-plugin
[save_image_extended] JXL is not supported. To add it: pip install jxlpy
[save_image_extended]                       You will need a valid MSVC env to build the wheel
[save_image_extended] version: 2.64
/home/alex/ComfyUI/custom_nodes/kaytool/api/clean_vram.py:8: FutureWarning: The pynvml package is deprecated. Please install nvidia-ml-py instead. If you did not install pynvml directly, please report this to the maintainers of the package that installed pynvml for you.
  import pynvml
WAS Node Suite: OpenCV Python FFMPEG support is enabled
WAS Node Suite Warning: `ffmpeg_bin_path` is not set in `/home/alex/ComfyUI/custom_nodes/was-node-suite-comfyui/was_suite_config.json` config file. Will attempt to use system ffmpeg binaries if available.
WAS Node Suite: Finished. Loaded 220 nodes successfully.

	"Dream big and dare to fail." - Norman Vaughan

no module 'xformers'. Processing without...
no module 'xformers'. Processing without...

Import times for custom nodes:
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/websocket_image_save.py
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/test.py
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/image-resize-comfyui
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/Ttl_ComfyUi_NNLatentUpscale
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI_Cutoff
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/promptoptimizer
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-detail-daemon
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-imageautotone
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-visualarea-nodes
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/exit
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI-Align
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui_ttp_toolset
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-fbcnn
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/euler-smea-dyn-sampler
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-interactive
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-clip-with-break
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/cg-use-everywhere
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/Comfyui-Resolution-Master
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui_steudio
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/stablediffusion-dpmpp_2m_alt-sampler
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI_restart_sampling
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/save-image-extended-comfyui
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/rocm-ninodes
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI-DGLS
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui_densediffusion
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-automaticcfg
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI-GGUF
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI-TiledDiffusion
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI-VFI
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI-Extra-Samplers
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI-mxToolkit
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui_essentials
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/teacache
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/RyuuNoodles
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-custom-scripts
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-frame-interpolation
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-florence2
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-image-saver
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui_ultimatesdupscale
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-multigpu
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/qwen3-vl-nsfw
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI_Mira
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/Comfyui-Superprompt-Unofficial
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-kjnodes
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/gguf
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/SwarmComfyCommon
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/rgthree-comfy
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/basic_data_handling
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui_jc2
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/kaytool
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI-Flowty-LDSR
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui_controlnet_aux
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-inspire-pack
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-sam2
   0.0 seconds: /home/alex/ComfyUI/custom_nodes/SwarmComfyExtra
   0.1 seconds: /home/alex/ComfyUI/custom_nodes/data-analysis
   0.1 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-manager
   0.1 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-impact-pack
   0.1 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-rk-sampler
   0.1 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-impact-subpack
   0.1 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-openvino
   0.1 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-logicutils
   0.1 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-rgt
   0.2 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-videohelpersuite
   0.2 seconds: /home/alex/ComfyUI/custom_nodes/ComfyUI_Comfyroll_CustomNodes
   0.3 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-supir
   0.3 seconds: /home/alex/ComfyUI/custom_nodes/RES4LYF
   0.7 seconds: /home/alex/ComfyUI/custom_nodes/was-node-suite-comfyui
   0.9 seconds: /home/alex/ComfyUI/custom_nodes/bjornulf_custom_nodes
   1.8 seconds: /home/alex/ComfyUI/custom_nodes/comfyui-easy-use

Context impl SQLiteImpl.
Will assume non-transactional DDL.
No target revision found.
Starting server

To see the GUI go to: http://127.0.0.1:8188

Other

I FOUND OUT WHAT IS CAUSING ISSUES ON RDNA 3, IT IS "torch.backends.cudnn.enabled" (MIOpen)

For an entire year I have been wondering why sometimes my 7900XTX is struggling at Unet, VAE, upscale and tunableop. Sometimes it worked perfectly and I had performance close to a RTX 4090, other times it either got OOM or ran like a RTX 4080. Turns out it was torch.backends.cudnn.enabled. It needs to be enabled on RDNA3 so that MIOpen works. The issue happened randomly due to various factors like custom nodes, comfyui updates, me updating python, etc. It was impossible to pinpoint it to torch.backends.cudnn.enabled.

I found this while looking in the changelog for v0.3.65, namely "Improve AMD performance. by @comfyanonymous in https://github.com/comfyanonymous/ComfyUI/pull/10302". I decided to edit model_management.py line 335 myself to override it to True, and the issue is fixed.

What was mentioned about needing to disable it on RDNA4 applies ONLY to RDNA4. MIOpen might be bugged there, but it is very stable and necessary on RDNA3. Also, the patch to default VAE to bf16 on all AMD gpus is also bad, it is slower on RDNA3 than RDNA4. RDNA3 fp16 and fp32 VAE run at the same speed and vram consumption (with torch.backends.cudnn.enabled=True), and fp32 avoids all black images.

This could have just slipped and remained hard-coded to False, which would have most likely ruined RDNA3 performance on ComfyUI forever.

Please patch ASAP!


Benchmarks:

SDXL BASE, default workflow, 1024x1024, 20 steps euler, vae decode (not tiled), max fan speed, not initial run, avg of 3 runs

CLIP speed: 0.066s -> 0.054s CLIP mem: 1.74gb -> 2.8gb (the only downgrade) UNET speed: 5.414s -> 4.392s UNET mem: 5.94gb -> 5.5gb VAE speed: 2.093s -> 0.186s (x10 improvement bruh) VAE mem: 17.35gb -> 1.74gb (x10 improvement bruh) UNET speed (2048x2048): 26.543s -> 21.831s UNET mem (2048x2048): 8.76gb -> 6.92gb VAE speed (2048x2048): no -> 40.631s VAE mem (2048x2048): no -> 8.47gb TunableOP tuning speed: 5min + oom on vae -> 20s TunableOP improvement (full workflow time): ~0.3s, scales more with heavier workflow

I also quickly tested WAN 2.2, VAE improvement is massive, UNET maybe slightly faster. Tiled VAE at 1024x1024 is perfect for everything.


System and parameters: Ubuntu 24.04.3 LTS CPU AMD R9 7950X3D RAM 4x16gb 6000MT CL32 GPU RX 7900XTX (OC)

ComfyUI v0.3.66 ROCM 7.0.2 Python 3.12.11 Pytorch 2.10.0.dev20251017+rocm7.0 flash_attn from "pip install -U git+https://github.com/FeepingCreature/flash-attention-gfx11@gel-crabs-headdim512 --no-build-isolation" (still faster than official)

Env Vars: MIOPEN_FIND_MODE=2 MIGRAPHX_MLIR_USE_SPECIFIC_OPS="attention" FLASH_ATTENTION_TRITON_AMD_ENABLE="TRUE" FLASH_ATTENTION_TRITON_AMD_AUTOTUNE="FALSE TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 (TunableOP tuning is faster and better than FA autotune) Launch: --preview-size 1024 --reserve-vram 0.9 --async-offload --use-flash-attention --fp32-vae --disable-smart-memory


Also, just some gpu comparisons to show how trash one of them is (at time of my purchase): RTX 4090, 3.61s, 2289€ RX 7900XTX, 4.39s, 1189€ RTX 4080, 6.46s , 1309€ <- only 16gb, worse value than 60 class The entire world was saying 4080 better because "it renders cp2077 rt at 360p faster", what a joke, glad I dodged this bullet

Reber01Good avatar Oct 24 '25 04:10 Reber01Good

It works better on my machine. Try removing all your env vars and using default comfy with no launch options.

comfyanonymous avatar Oct 24 '25 05:10 comfyanonymous

I have attempted running no env vars with no launch options in my search for the issue, it made no difference. I can 100% confirm that changing it between True/False has the immediate effect I described.

I just tested again, "vanilla" configuration. It is 10% slower with pytorch or split attention. The other env vars had no major impact except MIOPEN_FIND_MODE=2 making TunableOP tuning 2x faster and TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 giving a few ms speed boost. torch.backends.cudnn.enabled still causes the major issue and has to be set to True. Are you getting within ±0.2s of my time on the KSampler node on the same workflow? Is your VAE vram usage/speed similar? How long does it take for you to generate TunableOP on a KSampler (I take around 5s)?

If you don't believe me I can screen record it happening.

Reber01Good avatar Oct 24 '25 12:10 Reber01Good

If you still can't replicate the behavior I described it would still be a good idea to add a launch argument for toggling torch.backends.cudnn.enabled alongside with a warning for amd users to check this setting and find what works best. It is very likely that MIOpen will get fixed on RDNA4 and will provide those gpus with similar benefits. RX 9070 XT should beat the RX 7900 XTX judging by gpu architecture, but right now it clearly isn't doing that.

Reber01Good avatar Oct 24 '25 12:10 Reber01Good

I have another idea, I know a friend with a similar setup as me. I can ask him to let me install ubuntu and comfy on it, then to test my findings. It would be a perfectly clean test, that computer never ran linux or any ROCM workload. I can document every step from the installation of the os down to the testing.

Just let me know if you want that.


Also, if there are other tests or information you want me to share just ask.

Reber01Good avatar Oct 24 '25 15:10 Reber01Good

Windows 11 25H2 (native, not using WSL at all) 7900xt with the 25.9.1 drivers pytorch 2.10.0a0+rocm7.10.0a20251023 torch.backends.cudnn.enabled = True No flash-attention, since this is native Windows

run.bat:

set MIOPEN_FIND_MODE=2
set MIGRAPHX_MLIR_USE_SPECIFIC_OPS="attention"
set MIOPEN_LOG_LEVEL=3
set TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1
.\python_embeded\python.exe -s ComfyUI/main.py --disable-smart-memory --async-offload --use-pytorch-cross-attention --fp32-vae
pause

(not sure if the set MIGRAPHX_MLIR_USE_SPECIFIC_OPS="attention" is really needed or not, but I'll have to test to see and the log level is just to reduce spam)

Doing this, my VRAM usage is way lower and with CFG>1.0 models, my GPU Compute 0 usage stays redlined at 100% the whole time, rather than doing the two spikes------->two spikes-------->two spikes thing. The it/s is a little better, but mostly, the VRAM usage is far lower. EDIT: Buuuuuut, then Wan vae decode performance tanks...

I tested this when the original commit happened and commented my findings about it in that thread, but it's comfyanonymous's ship and rules. Ideally, there would be a launch arg for it like --force-cudnn-enabled or --use-cudnn 1/0 or something like that.

RandomGitUser321 avatar Oct 24 '25 21:10 RandomGitUser321

Windows 11 25H2 (native, not using WSL at all) 7900xt with the 25.9.1 drivers pytorch 2.10.0a0+rocm7.10.0a20251023 torch.backends.cudnn.enabled = True No flash-attention, since this is native Windows

run.bat:

set MIOPEN_FIND_MODE=2
set MIGRAPHX_MLIR_USE_SPECIFIC_OPS="attention"
set MIOPEN_LOG_LEVEL=3
set TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1
.\python_embeded\python.exe -s ComfyUI/main.py --disable-smart-memory --async-offload --use-pytorch-cross-attention --fp32-vae
pause

(not sure if the set MIGRAPHX_MLIR_USE_SPECIFIC_OPS="attention" is really needed or not, but I'll have to test to see and the log level is just to reduce spam)

Doing this, my VRAM usage is way lower and with CFG>1.0 models, my GPU Compute 0 usage stays redlined at 100% the whole time, rather than doing the two spikes------->two spikes-------->two spikes thing. The it/s is a little better, but mostly, the VRAM usage is far lower. EDIT: Buuuuuut, then Wan vae decode performance tanks...

I tested this when the original commit happened and commented my findings about it in that thread, but it's comfyanonymous's ship and rules. Ideally, there would be a launch arg for it like --force-cudnn-enabled or --use-cudnn 1/0 or something like that.

You mean this also fixes the same slowdowns and explosive VAE on the Windows pytorch experimental build that released recently? I don't understand what you want to say with "two spikes ...". Did it also improve your unet or upscale computation times?

About MIGRAPHX_MLIR_USE_SPECIFIC_OPS="attention", I use it because I have the Migraphx compile node, this variable does the same thing as MIOPEN_FIND_MODE=2 does for TunableOP. Not necessary if you don't use Migraphx.

Here are some other env variables you can try, maybe one of them does something for you, but I'm not sure all work on Windows:

  • PYTORCH_HIP_ALLOC_CONF=expandable_segments: #True or False
  • HSA_ENABLE_SDMA= #0 or 1
  • HIP_FORCE_DEV_KERNARG= #0 or 1
  • HIPBLAS_WORKSPACE_CONFIG=:0:0 #Read more at https://docs.pytorch.org/docs/stable/notes/hip.html#hipblas-workspaces

Reber01Good avatar Oct 24 '25 22:10 Reber01Good

Same issue: https://github.com/comfyanonymous/ComfyUI/issues/10447. This mentions only upscaling performance, which is one of the many components affected by this.

If 3 people have shown that cudnn and MIOPEN_FIND_MODE=2 are both necessary on RDNA3, I think this warrants the small necessary change in the code of model_management.py and also it should be brought up in the ComfyUI readme's amd gpu section (setting MIOPEN_FIND_MODE=2).

Reber01Good avatar Oct 25 '25 01:10 Reber01Good

that's why on my zluda fork it is disabled when starting and there is a node to toggle it on and off otherwise it is benefical for some amd gpu's and causes problems for others.

patientx avatar Oct 25 '25 13:10 patientx

that's why on my zluda fork it is disabled when starting and there is a node to toggle it on and off otherwise it is benefical for some amd gpu's and causes problems for others.

Absolutely true, I saw that when I tried your zluda fork a while back.

Reber01Good avatar Oct 25 '25 14:10 Reber01Good

What if disable optimisation logic at all? And create loadable profiles for different cards, models and software?

Pytorch_2_60_RX7900_Flux.profile:

ParamA = "True"
ParamB =  "False"
ParamC = "FP32"

Pytorch_2_90_RTX4090_WAN_2_2.profile:

ParamA = "False"
ParamB =  "True"
ParamC = "BF16"

e.t.c.

So any user can choose optimal profile for his configuration?

zlobniyshurik avatar Oct 25 '25 15:10 zlobniyshurik

What if disable optimisation logic at all? And create loadable profiles for different cards, models and software?

Pytorch_2_60_RX7900_Flux.profile:

ParamA = "True"
ParamB =  "False"
ParamC = "FP32"

Pytorch_2_90_RTX4090_WAN_2_2.profile:

ParamA = "False"
ParamB =  "True"
ParamC = "BF16"

e.t.c.

So any user can choose optimal profile for his configuration?

Yes, very good idea. Every possible performance related setting in one file for every card. It could also have short descriptions for what they do and what kind of behavior was observed with it on the specific card. This way anyone can experiment more easily and for a newcomer it won't be necessary to do hours of searching through the internet to find these settings.

I think the most important part is that ComfyUI tells new users to engage with the feature and find out what the optimal settings for their system are. We just need all possible settings in one configurable place. Hard coding them in random places like they are now seems like a nightmare to manage/update and it is also hidden from users.

Reber01Good avatar Oct 25 '25 17:10 Reber01Good

Update:

I noticed the latest model_management.py has implemented a code skeleton for setting various parameters for different gfx architectures. Right now it seems RDNA2 and older are the only complete ones, with the rest probably getting finished in a future release. RDNA2 and older are not getting the "torch.backends.cudnn.enabled = False" line. For them this parameter is not set anywhere, I would assume pytorch defaults it to True. Every other amd gpu is getting "torch.backends.cudnn.enabled = False", so this is still wrong for RDNA3, until the section is completed (it will overwrite it).

This is great, I still suggest making all of these parameters "public" for users, just so they know these exist. It is far easier for one person (the user) to experiment and find the optimal settings for their hardware instead of having @comfyanonymous (the developer) finding and coding them for all amd, nvidia and intel gpus.


I know ComfyUI should come with good default settings so it can offer that nice quick setup, but sometimes the user should also spend some time changing a few settings.

Options like "smart_memory", "async_offload", torch mmap, everything in "--fast", cache settings, precision settings, attention upcasting, device, "torch.backends.cudnn.enabled" and other torch params all fall under the same category of performance/quality settings. There may be more, I don't know because there is no information anywhere on the internet about this.

Reber01Good avatar Nov 02 '25 18:11 Reber01Good

Until last week I used only Pytorch 2.60 + ROCm 6.4.xx/7.0.yy combination on my 7900XT. Because with torch >=2.70 I got OOM or/and color noise instead of picture.

Three day ago I tried nightly version from pytorch.org/get-started/locally/ and something changed to better. No OOM anymore, ungarbled picture on output and SPEED! On Chroma I got 3s per iteration vs 5s per iteration before.

All with basic start command TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 python main.py

zlobniyshurik avatar Nov 03 '25 01:11 zlobniyshurik

Until last week I used only Pytorch 2.60 + ROCm 6.4.xx/7.0.yy combination on my 7900XT. Because with torch >=2.70 I got OOM or/and color noise instead of picture.

Three day ago I tried nightly version from pytorch.org/get-started/locally/ and something changed to better. No OOM anymore, ungarbled picture on output and SPEED! On Chroma I got 3s per iteration vs 5s per iteration before.

All with basic start command TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 python main.py

Yes 2.10 (nightly) in combination with ROCm 7 is slightly faster. I noticed the biggest gains on heavy models, flux almost doubled in speed. For LLMs using ROCm is also better, but vulkan still wins there. All versions since 2.6 worked well for me, especially 2.7, I found that to be the most stable memory wise, but 2.10 feels even better.

Reber01Good avatar Nov 03 '25 15:11 Reber01Good

My performance seems a lot better now that I've gotten triton-windows and flash attention 2 working on my gfx1151.

rwfsmith avatar Jan 23 '26 00:01 rwfsmith

@comfyanonymous

It has been 6 months and nothing has been done about this situation. It is a clear issue affecting multiple users which requires modifying the code every time you update ComfyUI just to get proper performance. I agree with "comfy-ovum" that just because it works better for your system like this it doesn't mean that it works better on everyone's system.

There have been multiple pytorch and rocm versions released since I opened this issue and nothing has changed. There is clear proof that for RDNA3 and maybe RDNA3.5 cudnn (miopen) must be enabled. "It works better on my machine." is honestly a lazy, terrible and unprofessional response coming from the owner, creator and maintainer of ComfyUI. I mean no offense to you, but what I and others have said is the truth.

The code already has amd gpu architecture detection implemented, and for RDNA3 nothing has been added to the if statement in model_management to address this major issue.

If you really don't want to change 1 default value (1 line of code), why not provide a launch parameter for it? There are already countless parameters for all sorts of random stuff, including DirectML, which has been dead for years!!! Is a cudnn toggle really so much to ask for?

ComfyUI takes pride in supporting every OS and every GPU, yet this issue goes against that. It is still labelled as "Potential Bug", which is a joke, because it is a real bug confirmed by multiple people with data to prove it. Do you not trust your community on reporting bugs? I guarantee less than 1% of ComfyUI users have ever opened the git repo and opened an issue, let alone provide thorough explanation of the bug and the solution for it.

I hope this issue gets addressed soon, it is very infuriating and also a spit in the face that it is being ignored.

Reber01Good avatar May 03 '26 01:05 Reber01Good