Nodes/ComfyUI PyramidFlow Wrapper/PyramidFlow Torch Compile Settings
ComfyUI Node

PyramidFlow Torch Compile Settings

Free speed if your torch cooperates

By kijai·Created 2 years ago·Updated 2 years ago· 363
PyramidFlow Torch Compile Settings
    • torch_compile_args
    backendinductor
    fullgraphfalse
    modedefault
    compile_whole_modelfalse
    single_blockstrue
    double_blockstrue
    embedderstrue
    compile_resttrue
    dynamo_cache_size_limit64

    PyramidFlow Torch Compile Settings is a configuration node - it produces no latents and no images. What it makes is a settings bundle you can hand to the model loader so that, while loading, the transformer gets torch.compiled for speed. Think of it as the "build optimized binaries" flag for your diffusion model. Done right it shaves a meaningful chunk off sampling time on supported GPUs. Done wrong it fails to load entirely and you spend an hour figuring out why.

    The node's own description is the honest one: "when connected to the model loader, torch.compile of the selected layers is attempted. Requires Triton and torch 2.5.0 is recommended." Two things to hear in that sentence. First, Triton must be installed or none of this works. Second, Kijai wrote "recommended," not "required" - torch 2.5.0 is where the setup he tested against lives.

    The inputs that matter

    • backend - inductor (default) or cudagraphs. Inductor is the safe general-purpose choice. cudagraphs alone is usually worse; leave it.
    • mode - default, max-autotune, max-autotune-no-cudagraphs, reduce-overhead. max-autotune is the aggressive speed setting with longer compile times and more VRAM during compilation. Start with default.
    • compile_whole_model - if you flip this on, it overrides the block toggles below and compiles everything as one graph. This is the point where most people's PyTorch versions give up, because the full model is a big, dynamic graph.
    • single_blocks / double_blocks / embedders / compile_rest - the surgical alternative: compile just the transformer blocks, the embedders, and/or the projection layers. Defaults have all of them on, which is a decent middle ground. Turn blocks off one at a time to narrow down a failure.
    • fullgraph - false by default. Enabling it demands the whole graph be capturable in one go, which is stricter and more brittle. Leave it off unless you know what you're doing.
    • dynamo_cache_size_limit - a passthrough to torch._dynamo.config.cache_size_limit. Default 64 is fine; raise it only if you see cache-limit warnings.

    The output

    torch_compile_args (PYRAMIDFLOW_COMPILEARGS) goes into the optional compile_args socket on PyramidFlow Transformer Loader (or the VAE loader). No other node consumes it.

    One subtlety worth knowing: the loader compiles with dynamic=True deliberately, because the pyramid's multi-stage generation changes tensor shapes between stages. That's why whole-model compile is fragile here - the graph isn't static.

    The honest advice

    For a beginner this node is optional, full stop. The default settings give you the speed-up without much ceremony, and if the first run throws a Triton or graph-capture error, the move is: turn compile_whole_model off, or pull the node off the loader entirely and run un-compiled. "Free speed" isn't free when it costs you an hour of debugging. Also amusing: like the Text Encode node, this one's category reads MochiWrapper - leftover labels from Kijai's other packs. Search "PyramidFlow Torch Compile Settings" and ignore the folder it lands in.

    Install

    Ships with the pack: ComfyUI Manager → "PyramidFlow Wrapper", or git clone https://github.com/kijai/ComfyUI-PyramidFlowWrapper into custom_nodes and restart. No model files of its own. The only real dependency is Triton being importable in your ComfyUI environment - check with python -c "import triton" in the venv your ComfyUI uses before blaming the node.

    CategoryMochiWrapper

    Inputs (9)

    NameTypeDefaultDescription
    backendCOMBOinductor2 options: inductor, cudagraphs
    fullgraphBOOLEANfalseEnable full graph mode
    modeCOMBOdefault4 options: default, max-autotune, max-autotune-no-cudagraphs, reduce-overhead
    compile_whole_modelBOOLEANfalseCompile the whole model, overrides other block settings
    single_blocksBOOLEANtrueCompile single_blocks
    double_blocksBOOLEANtrueCompile transformer blocks
    embeddersBOOLEANtrueCompile embedders
    compile_restBOOLEANtrueCompile the rest of the model (proj and norm out)
    dynamo_cache_size_limitINT640–1024torch._dynamo.config.cache_size_limit

    Outputs (1)

    NameTypeDescription
    torch_compile_argsPYRAMIDFLOW_COMPILEARGS