RTX 4090 Optimizer ⚡
RTX 4090 Optimizer Flips torch Flags — Some of Which Do Nothing on a 4090
- status
RTX 4090 Optimizer is a set of toggles that tweak PyTorch's backend settings and hand you a status report saying what it did. It's not a magic speed button - it's a dashboard that flips torch.backends.cuda flags at the moment the node runs. Some of those flags genuinely help. Others are either already in effect, irrelevant to how ComfyUI actually runs, or riskier than the README's "2x speedup" language suggests.
What it actually does
Reading the source, the node does four real things (plus one that's decorative):
- Sets
torch.backends.cuda.matmul.allow_tf32andtorch.backends.cudnn.allow_tf32 - Enables
torch.backends.cudnn.benchmark(and disablesdeterministic) - Calls
torch.cuda.set_per_process_memory_fraction(memory_fraction) - Calls
torch.set_num_threads(num_threads)
The enable_amp toggle only appends "✅ AMP enabled for mixed precision" to the status string. It doesn't wrap anything in an autocast context, so that one's purely cosmetic - mixed precision in ComfyUI happens at the model level (most checkpoints already load fp16), not because this node flipped it on.
The takes, one input at a time
The four toggles that actually do something are the booleans enable_tf32, enable_cudnn_benchmark, enable_amp, plus memory_fraction and num_threads. But not all of them earn their spot:
- cuDNN benchmark (the one genuinely useful default). It makes cuDNN spend a little extra time on the first run picking the fastest convolution kernel for your GPU, then reuse it. Mostly harmless, sometimes a real speedup. Keep it on.
- TF32. The README's "2x speedup on matrix operations" is marketing from data-center-land. TF32 affects fp32 matmuls, and ComfyUI's heavy inference is already fp16 for most models, so this flag rarely touches anything on a 4090. It also costs a little precision when it does engage. I'd leave it on since it's the default and it's not going to hurt, but don't expect a 2x.
- memory_fraction (default 0.95). This is the one to be careful with.
set_per_process_memory_fractioncaps how much VRAM PyTorch is allowed to grab. ComfyUI already does its own VRAM caching, and locking the process to 95% can cause out-of-memory errors on a busy graph where it previously ran fine - especially if something else (a second process, a browser with hardware accel) holds VRAM. If you start seeing "CUDA out of memory" after turning this on, drop it to 0.9 or disable it. - num_threads (default 48). The default is tuned for the author's Threadripper, and the README says as much ("RTX 4090 + Threadripper"). Set this to your actual CPU core count. Forcing 48 threads on an 8-core machine doesn't speed anything up - it oversubscribes and can make CPU-side work slower. The 4090 does the heavy lifting anyway.
Wiring it in
It has exactly one output: status, a STRING with a bulleted report of what got enabled plus your GPU's name and total VRAM. You can feed it to a text display node or just read it in the UI when the workflow runs. There's no real reason to branch logic off it - it's informational.
One thing to know: these are process-wide settings, and they apply the moment this node executes, affecting every node that runs after it in the queue. So drop it near the start of your workflow, once.
Install and expectations
Same story as the rest of the pack - ComfyUI Manager (search "comfyui-rtx4090-nodes") or:
cd ComfyUI/custom_nodes
git clone https://github.com/joe002/comfyui-rtx4090-nodes.git
Restart, and you're done. No models to fetch, dependencies are just torch and psutil.
Is it worth adding? It's a convenient way to flip cuDNN benchmark on without digging into environment variables, and the status output is nice for beginners who want to see their GPU being recognized. Just don't expect a measurable speedup on top of what ComfyUI already does, and treat memory_fraction and num_threads as levers that can hurt more than they help unless they match your hardware.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| enable_tf32 | BOOLEAN | true | — |
| enable_cudnn_benchmark | BOOLEAN | true | — |
| enable_amp | BOOLEAN | true | — |
| memory_fraction | FLOAT | 0.950.1–1 | — |
| num_threads | INT | 481–64 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| status | STRING | — |