Nodes/ComfyUI-WorkflowGenerator/1. WorkflowGenerator
ComfyUI Node

1. WorkflowGenerator

The LLM That Turns a Sentence Into a Node Graph (Step 1)

By DanielPFlorian·Created 9 months ago·Updated 9 months ago· 41
1. WorkflowGenerator
    • workflow_edges
    • instruction
    instruction
    model_pathworkflow-generator-q8_0.gguf
    dtypeauto
    device_preferenceauto
    attn_implementationauto
    auto_gpu_layerstrue
    n_gpu_layers-1
    max_new_tokens8192
    context_size4096
    use_mmaptrue
    use_mlockfalse
    n_batch512
    n_threadsAuto
    temperature0.95
    top_p0.70
    allow_primitive_nodesfalse
    seed0

    This is the node that does the actual "AI" part of this pack: it reads a plain-English description of a workflow and writes out a structured plan for one. It's labeled "1. WorkflowGenerator" because it's the first stage of a three-node chain (generate → validate → build), part of DanielPFlorian's implementation of the ComfyGPT research paper. If you just want results, skip straight to the WG_Pipeline node, which chains all three stages for you. Reach for this one only when you want to see and edit the intermediate diagram before it gets compiled.

    How it works

    The WorkflowGenerator runs a fine-tuned Qwen2.5-14B model that was trained on FlowDataset - roughly 13,000 workflow-description pairs from the ComfyGPT paper. The model is not instruction-tuned in the usual sense; it was fine-tuned on a specific prompt template, and the node reproduces that exact format ("generate a JSON example of the required ComfyUi workflow. description:") so the output matches what it learned.

    The clever bit, borrowed from the paper: it doesn't try to generate an entire workflow at once. It emits a JSON list of edges - tuples of the form (source node, source output, target node, target input) - which is a much smaller, more learnable unit than a full graph, and far easier for the next two stages to validate. The GGUF q8_0 quantization means a 14B model that stays in a reasonable amount of VRAM; q8 is effectively fp16 at half the size.

    The inputs that matter

    There are sixteen inputs, but only a few you'll touch:

    • instruction - your description, in a multiline box. This is the whole job. More detail = better graph: mention the checkpoint, the sampler, the upscaler, anything you'd care about in a real workflow.
    • allow_primitive_nodes - off by default and you should keep it off. Primitive nodes (CLIP Text Encode, Load Image, that sort of thing) get inlined as widget values, leaving a cleaner diagram. Turn it on only if you specifically want every input as an explicit node.
    • seed - same seed, same instruction, same output. Change it to re-roll a bad result instead of rewriting your prompt.
    • model_path - dropdown of whatever's in ComfyUI/models/LLM/, defaulting to workflow-generator-q8_0.gguf.
    • temperature / top_p / max_new_tokens - sampling knobs. Defaults (0.95 / 0.7 / 8192) are fine; lower temperature if you want more deterministic output.

    The rest split into two families: the GGUF knobs (auto_gpu_layers, n_gpu_layers, context_size, use_mmap, use_mlock, n_batch, n_threads) and the HuggingFace-family knobs (dtype, attn_implementation, device_preference) which only apply if you load a full-precision model instead of a GGUF. auto_gpu_layers is on by default so the model doesn't OOM your card - leave it.

    Outputs

    • workflow_edges - the generated diagram as a JSON string. Wire this into NodeValidator (Step 2) or straight into WorkflowBuilder (Step 3) if you want to skip validation.
    • instruction - a pass-through of your original text. Wire it into NodeValidator's instruction input so the validator knows the context when it corrects node names.

    Install & expectations

    Clone the pack into custom_nodes, run pip install -r requirements.txt, install llama-cpp-python separately (it's not in the requirements - CUDA builds often need compiling from source; the repo wiki has the steps), and drop the GGUF plus its tokenizer folder into ComfyUI/models/LLM/. Run UpdateNodeCatalog before your first generation so downstream stages know what nodes exist.

    Then set your expectations: the model is biased toward the workflow patterns it trained on (mostly SD 1.5 / SDXL / SVD), so it will happily hallucinate node names for custom packs released after 2024. That's not a bug in your setup - it's what Step 2 exists for. If a diagram comes out wrong, re-roll the seed or reword the instruction rather than fighting the output; and remember the README's own caveat that this is an accelerator, not an oracle. You're supervising a draft, not getting a finished workflow.

    CategoryWorkflowGenerator

    Inputs (17)

    NameTypeDefaultDescription
    instructionSTRINGDescription of the desired ComfyUI workflow.
    model_pathCOMBOworkflow-generator-q8_0.ggufModel file (GGUF) or directory (HuggingFace).
    dtypeCOMBOautoData type (HuggingFace only).
    device_preferenceCOMBOautoDevice preference (cuda/cpu).
    attn_implementationCOMBOautoAttention implementation (HuggingFace).
    auto_gpu_layersBOOLEANtrueAuto-calculate GPU layers based on available VRAM (prevents OOM errors) (GGUF).
    n_gpu_layersINT-1-1–1000Number of GPU layers (GGUF). -1 for all.
    max_new_tokensINT81921–32768Max tokens to generate.
    context_sizeINT4096512–131072Context window size (GGUF).
    use_mmapBOOLEANtrueUse memory-mapped loading (GGUF).
    use_mlockBOOLEANfalseLock memory to prevent swapping (GGUF).
    n_batchINT51232–2048Batch size for prompt processing (GGUF).
    n_threadsCOMBOAutoCPU threads for inference (GGUF).
    temperatureFLOAT0.950–2Sampling temperature.
    top_pFLOAT0.700–1Top-p sampling.
    allow_primitive_nodesBOOLEANfalseInclude primitive nodes in diagram. False (recommended) removes them for cleaner workflows.
    seedINT00–4294967295Random seed.

    Outputs (2)

    NameTypeDescription
    workflow_edgesSTRINGGenerated workflow diagram (JSON).
    instructionSTRINGOriginal instruction text (pass to Step 2).