Nodes/ComfyUI_SGLDiffusion_Fix/SGLDiffusion Options
ComfyUI Node

SGLDiffusion Options

Where SGLang's server knobs leak into ComfyUI

By endman100·Created 5 months ago·Updated 5 months ago· 0
SGLDiffusion Options
    • sgld_options
    model_typeauto-detect
    enable_torch_compilefalse
    num_gpus1
    tp_size-1
    sp_degree-1
    ulysses_degree-1
    ring_degree-1
    dp_size1
    dp_degree1
    enable_cfg_parallelfalse
    attention_backend

    The config node you mostly ignore - until you need it

    SGLDiffusion Options is the Integrated Mode's control panel. It takes no inputs, has one output (sgld_options), and exists to feed launch settings into the SGLDUNETLoader before SGLang spins up. Every single input is optional, and that's the first thing to internalize: for a single GPU, default options, SGLang picks sensible values on its own. This node is there for when "sensible" isn't what you want.

    In Integrated Mode, the SGLDUNETLoader actually starts an SGLang Diffusion generator inside your ComfyUI process. That means all the flags you'd normally type when launching an SGLang server by hand get surfaced here as widgets instead. It's a translation layer between a serving stack and a node graph, and it shows.

    The inputs that actually matter

    • model_type - auto-detect by default, or qwen_image, qwen_image_edit, flux, lumina2. Auto-detect reads the checkpoint and figures it out; you only override it when detection gets it wrong or you're loading something ambiguous. lumina2 is SGLang's internal name for Z-Image, if you're wondering.
    • num_gpus - how many GPUs the integrated generator gets. Default 1. The single biggest lever if you have multiple cards.
    • tp_size - tensor parallelism: shards the model across GPUs. Default ‑1 means "SGLang decides." Set it when auto-detection picks something silly for your card count.
    • enable_cfg_parallel - runs the positive and negative CFG passes on separate devices, roughly doubling throughput on multi-GPU setups. Free speed if you have the hardware, pointless if you don't.
    • sp_degree / ulysses_degree / ring_degree - sequence-parallel knobs for long sequences (read: long video). All default to ‑1/auto. Leave them alone until you're chasing a specific memory or speed wall.
    • enable_torch_compile - compiles the model graph on load. Real speedup, real load-time hit, occasional compatibility pain. Benchmark before you adopt it.
    • attention_backend - string, default empty. Lets you force a backend (e.g., FlashAttention) when you have an opinion; empty means SGLang picks.
    • dp_size / dp_degree - data-parallel settings for batching. Not something the typical single-user ComfyUI session needs.

    How to use it

    Wire the sgld_options output into the optional input on SGLDUNETLoader, set num_gpus to match your hardware, and resist touching the rest until you hit a wall. The honest advice: 90% of users should leave everything at default and revisit only if generation is slower than it should be or a model fails to initialize. When it does fail to initialize, the model_type override and a manual attention_backend are the first two things worth trying.

    Install

    Shared with the pack - clone, restart, and install SGLang yourself since the pack carries no requirements:

    cd ComfyUI/custom_nodes
    git clone https://github.com/endman100/ComfyUI_SGLDiffusion_Fix
    pip install sglang[diffusion]
    

    One warning that applies here more than anywhere: these options get baked into the SGLang process when the model loads. Change num_gpus or tp_size and the generator may need to be re-created rather than picking it up live - when in doubt, restart ComfyUI after a big config change.

    CategorySGLDiffusion

    Inputs (11)

    NameTypeDefaultDescription
    model_typeoptCOMBOauto-detect5 options: auto-detect, qwen_image, qwen_image_edit, flux, lumina2
    enable_torch_compileoptBOOLEANfalse
    num_gpusoptINT1
    tp_sizeoptINT-1
    sp_degreeoptINT-1
    ulysses_degreeoptINT-1
    ring_degreeoptINT-1
    dp_sizeoptINT1
    dp_degreeoptINT1
    enable_cfg_paralleloptBOOLEANfalse
    attention_backendoptSTRING

    Outputs (1)

    NameTypeDescription
    sgld_optionsSGLD_OPTIONS