ComfyUI: High-Performance Model Loading and DGX Spark Optimizations

Hello everyone,

I have published a forked version of ComfyUI that introduces several low-level performance optimizations, specifically tailored for NVIDIA/CUDA Unified Memory Architecture (UMA) environments.

Repository Link: https://github.com/stardust7700/ComfyUI.git

Key Features

  1. High-Performance mmap Loading: Implements native mmap with madvise hints and page cache warmup (TLB touching) to maximize I/O throughput.

  2. CUDA UMA Optimizations: Prevents redundant weight backups to RAM that typically occur when LoRAs are applied. By disabling these backups and enabling direct weight assignment, we fix the “memory doubling” issue where extra copies were created in host memory, significantly reducing the total memory footprint.

  3. Enhanced Memory Monitoring: Integrates direct /proc/meminfo tracking for accurate real-time reporting of allocatable memory in UMA systems.

How to Use

You can try these optimizations by cloning the forked repository and running ComfyUI with the following CLI arguments:

git clone https://github.com/stardust7700/ComfyUI.git
cd ComfyUI
python main.py --fast-mmap-load --cuda-uma --fast-unload-models
  • --fast-mmap-load: Enables the optimized mmap loading logic.

  • --cuda-uma: Activates UMA-specific memory management and zero-copy patching.

  • --fast-unload-models: Immediately releases models from VRAM/cache.

Implementation Note

Regarding the --fast-unload-models flag: this implementation effectively clears the active model cache, but it does not return the system’s total available memory exactly to its pre-workflow baseline. Please consider this a known limitation of the implementation in its current state.

Best regards,

Hello, thanks for work. Maybe you can provide full setup instruction?
python main.py --fast-mmap-load --cuda-uma --fast-unload-models
Traceback (most recent call last):
File "/home/pont/git/ComfyUI/main.py", line 14, in <module>
from app.assets.seeder import asset_seeder
File "/home/pont/git/ComfyUI/app/assets/seeder.py", line 11, in <module>
from app.assets.scanner import (
File "/home/pont/git/ComfyUI/app/assets/scanner.py", line 7, in <module>
from app.assets.database.queries import (
File "/home/pont/git/ComfyUI/app/assets/database/queries/__init__.py", line 1, in <module>
from app.assets.database.queries.asset import (
File "/home/pont/git/ComfyUI/app/assets/database/queries/asset.py", line 1, in <module>
import sqlalchemy as sa
ModuleNotFoundError: No module named 'sqlalchemy'

It looks like you’re missing some core dependencies in your environment. The error ModuleNotFoundError: No module named 'sqlalchemy' indicates that the required Python packages haven’t been fully installed yet.

For a complete, step-by-step setup guide—including how to properly configure the environment and handle the specific flags you’re using—please refer to the official instructions here:

https://build.nvidia.com/spark/comfy-ui/instructions

GREAT !!! I am a ComfyUI poweruser and I am already testing your fork. I will do a very deep trsting with my set of workflow. I am now with Qwen 2512, full precision with two loras, and yes, it is MUCH faster and less memory footprint for sure. As said, I will keep it testing in the next days, this for me is a real game changer. thanks man !