Nodes/ComfyUI-Llama/Load LLM Model Advanced
ComfyUI Node

Load LLM Model Advanced

The llama.cpp settings panel, wrapped in a ComfyUI node

By HairlessPrimate·Created 3 years ago·Updated 2 years ago· 71
Load LLM Model Advanced
    • LLM
    Model
    n_gpu_layers0
    split_modeLLAMA_SPLIT_LAYER
    main_gpu0
    tensor_split0.00
    vocab_onlyfalse
    use_mmaptrue
    use_mlockfalse
    seed-1
    n_ctx512
    n_batch512
    n_threads
    n_threads_batch
    rope_scaling_typeLLAMA_ROPE_SCALING_UNSPECIFIED
    rope_freq_base0.00
    rope_freq_scale0.00
    yarn_ext_factor-1.00
    yarn_attn_factor1.00
    yarn_beta_fast32.00
    yarn_beta_slow1.00
    yarn_orig_ctx0
    mul_mat_q0
    logits_allfalse
    embeddingfalse
    offload_kqvfalse
    last_n_tokens_size64
    lora_base
    lora_scale0.00
    lora_path
    numafalse
    chat_formatllama-2
    verbosetrue

    Load LLM Model Basic will get you a working graph in about four clicks. This is the node you switch to when Basic stops being enough - it exposes nearly every argument from llama-cpp-python's Llama.__init__ as a widget. Which is great when you know what you're doing, and a wall of thirty inputs when you don't.

    Here's the honest framing: on a typical setup you'll touch maybe five of these, leave the rest alone, and never notice. This node is the escape hatch, not the daily driver.

    The inputs that actually matter

    • n_gpu_layers - the big one. How many model layers get offloaded to your GPU. 0 (the default) is pure CPU inference, which is painfully slow on anything past a 1B model. Raise it to fit your VRAM; on a 12GB card you can usually offload a large chunk of a small model and leave the rest to system RAM.
    • n_ctx - context window in tokens, default 512. Same as Basic, but here the pattern is explicit: it's a token budget, and it costs RAM.
    • n_batch - how many tokens are evaluated per pass. Higher is faster but greedier with memory. 512 is a sane default.
    • n_threads / n_threads_batch - CPU thread counts. Useful if you're doing pure CPU inference and want to pin them; otherwise ComfyUI and the OS will sort it out.
    • use_mmap / use_mlock - memory-mapping (default on) lets the OS lazily page the model file instead of loading it fully; mlock pins it in RAM. If you have the RAM, use_mlock can smooth out stalls.
    • seed - -1 (default) means random initialization. Fix it if you want reproducible noise for the model itself.

    The rest of the list - split_mode, main_gpu, tensor_split for multi-GPU, rope_scaling_type and the whole yarn_* family for context extension, mul_mat_q, logits_all, embedding, lora_base/lora_path/lora_scale for LoRA adapters, chat_format, verbose - is a pass-through of llama.cpp options. If you don't know what YARN scaling is, you don't need it yet. The author's own documentation is the llama-cpp-python init reference, and the parameter names here match it one-for-one, so you can look anything up there.

    What's disabled

    Be aware that two things from that reference don't work here, per the README's known-issues list: kwargs and chat_handler. The author wired the fields he could reach through ComfyUI's node system and left the rest on the floor. Don't go hunting for a hidden chat template dropdown - there isn't one, and chat_format only takes you so far.

    Setting it up

    Install is the pack-standard path: ComfyUI Manager (search "ComfyUI-Llama") or

    cd ComfyUI/custom_nodes
    git clone https://github.com/daniel-lewis-ab/ComfyUI-Llama
    

    with pip install llama-cpp-python if you went manual. Your .gguf models go in ComfyUI/custom_nodes/ComfyUI-Llama/models, restart ComfyUI, hard-refresh the browser with Ctrl+F5, and the nodes live under the LLM menu.

    The one genuine trap specific to Advanced: llama-cpp-python doesn't ship official wheels for the Python version ComfyUI uses, so pip may try to build it from source - which means a working C++/CUDA toolchain, and that's where "it won't install" posts come from. If you hit that, grab a prebuilt wheel from a community mirror like JamePeng's llama-cpp-python releases rather than fighting a source build. It's the most common reason people bounce off this pack entirely, and it's fixable in five minutes.

    CategoryLLM

    Inputs (32)

    NameTypeDefaultDescription
    ModelCOMBO0 options:
    n_gpu_layersoptINT0
    split_modeoptCOMBOLLAMA_SPLIT_LAYER3 options: LLAMA_SPLIT_NONE, LLAMA_SPLIT_LAYER, LLAMA_SPLIT_ROW
    main_gpuoptINT0
    tensor_splitoptFLOAT0.000–1
    vocab_onlyoptBOOLEANfalse
    use_mmapoptBOOLEANtrue
    use_mlockoptBOOLEANfalse
    seedoptINT-1
    n_ctxoptINT512
    n_batchoptINT512
    n_threadsoptINT
    n_threads_batchoptINT
    rope_scaling_typeoptCOMBOLLAMA_ROPE_SCALING_UNSPECIFIED4 options: LLAMA_ROPE_SCALING_UNSPECIFIED, LLAMA_ROPE_SCALING_NONE, LLAMA_ROPE_SCALING_LINEAR, LLAMA_ROPE_SCALING_YARN
    rope_freq_baseoptFLOAT0.000–1
    rope_freq_scaleoptFLOAT0.000–1
    yarn_ext_factoroptFLOAT-1.00
    yarn_attn_factoroptFLOAT1.000–1
    yarn_beta_fastoptFLOAT32.00
    yarn_beta_slowoptFLOAT1.000–1
    yarn_orig_ctxoptINT0
    mul_mat_qoptINT0
    logits_alloptBOOLEANfalse
    embeddingoptBOOLEANfalse
    offload_kqvoptBOOLEANfalse
    last_n_tokens_sizeoptINT64
    lora_baseoptSTRING
    lora_scaleoptFLOAT0.000–1
    lora_pathoptSTRING
    numaoptBOOLEANfalse
    chat_formatoptSTRINGllama-2
    verboseoptBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    LLMLLM