LLM_Save_State
Freeze the model's brain mid-conversation
- LLM
- STATE
Here's a nice trick most of the pack's simple workflow builders never discover: you can freeze an LLM's state mid-run and restore it later. LLM_Save_State takes the model and returns a STATE object - a snapshot of everything the model is currently thinking, which in practice means its full context (the KV cache of tokens it's processed so far). Think of it as a save file for a conversation.
Why would you want that? Because in this pack, context is everything and cheap to lose. Every time you run a graph with a different prompt, you're usually wiping the model's context and starting fresh. With state, you can process a long prompt once, save the state, and then run a dozen different follow-up branches - each starting from the exact same mental position instead of re-tokenizing and re-evaluating from scratch. It's the difference between reloading a savegame at a branching point and replaying the whole game for every choice.
Inputs and output
- LLM - the loaded model whose current context you want to snapshot.
The output is STATE - another pack-custom type, like LLM. It only plugs into this pack's LLM_Load_State node, and it carries no visible text of its own. If you're wondering where the state lives or how big it is: it's the model's context buffer, so a big context means a big state object.
How it fits
The intended pattern is a fork: build up context (via LLM_Eval or a Call node), then LLM_Save_State at the point you care about. Wire that STATE into multiple LLM_Load_State branches - each one restores the same context onto a fresh path. Since LLM_Load_State has no outputs of its own, each branch then continues with the pack's generation or token nodes.
There are real limitations to be aware of. This is a state save, not a checkpoint of the weights - it only works on the same model it was taken from, and it's tied to that model's context configuration. And like everything else in this pack, there's no built-in looping, so "restore the state, generate one step, save again" automation is manual. Still, for exploratory work - same context, many possible continuations - it's exactly the right tool.
Install
The shared pack steps: 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 go in ComfyUI/custom_nodes/ComfyUI-Llama/models, restart, Ctrl+F5, and the nodes live under the LLM menu.
Bottom line: LLM_Save_State is a niche but genuinely useful node - the one that lets you treat a model's context like a savegame and explore branches instead of repeating setup. If you never use it, you're not missing core functionality. If you've ever rebuilt a long context by hand, you'll wonder why every LLM pack doesn't have one.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| LLM | LLM | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STATE | STATE | — |