Nodes/ComfyUI-Llama/LLM_Load_State
ComfyUI Node

LLM_Load_State

Restore a saved model context — the restore-half of the snapshot pair

By HairlessPrimate·Created 3 years ago·Updated 2 years ago· 71
LLM_Load_State
  • LLM
  • STATE

    This is the restore-half of the pack's save/load pair. LLM_Save_State freezes a model's context into a STATE object; LLM_Load_State shoves that frozen state back onto a model, putting it right back where it was. Same model, same context, same mid-thought position - as if the graph had been interrupted and you hit "continue."

    Like its sibling, it's a side-effect node: no outputs at all. Its whole job is to change the state of the LLM input. If you expected a state-out or a model-out, that's not what's happening - the node mutates the model's context in place, and the work continues on whatever nodes come after the LLM wire.

    Inputs

    • LLM - the model to restore state onto.
    • STATE - the saved context, from LLM_Save_State. That's it. Two inputs, no outputs.

    How it actually works, and the gotchas

    Under the hood this maps to the same idea as llama.cpp's state save/load - the context buffer, including the KV cache, serialized and re-injected. What that buys you is the fork pattern: build a context once, save it, and load it onto several parallel paths so each branch starts from the identical mental state. In a pack with no built-in looping, this is also the closest thing to "pause a generation and resume later."

    Two gotchas that will bite you:

    1. It must be the same model. A saved state is a dump of one model's context, and it's tied to that model's tokenizer and architecture. Loading it onto a different model isn't just meaningless - it can crash or produce nonsense. If you change the loader, you must re-save the state.
    2. State is not weights. Saving doesn't train or fine-tune anything; it captures where the model's inference is, not what it knows. If that distinction seems obvious, good - but it's the most common way people misjudge this node.

    Install

    The pack-standard setup: 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 on manual installs. GGUF models into ComfyUI/custom_nodes/ComfyUI-Llama/models, restart, then Ctrl+F5. Nodes are under the LLM menu.

    Is LLM_Load_State worth learning? Only if you're doing branchy, exploratory work with the pack's low-level nodes. If you're just generating strings with Call LLM nodes, skip it - it won't add anything to a simple graph. But if you're building the "same context, many continuations" pattern with LLM_Save_State, this is the node that completes it, and it does exactly one thing correctly: put the model's head back where you left it.

    CategoryLLM

    Inputs (2)

    NameTypeDefaultDescription
    LLMLLM
    STATESTATE

    Outputs (0)

    No outputs