LM Studio Unload Model
A polite 'please free my VRAM' node — with a pass-through so it never breaks your chain
- images
- system_prompt
- user_prompt
- images
- generated_texts
LM Studio is a great way to run a local LLM, but its models like to sit in memory after you're done with them - and if you're on the same GPU that's also trying to run diffusion, that's VRAM you don't have to spare. LM Studio Unload Model is the companion node to LM Studio Query that kicks a loaded model out of memory when you're finished with it.
The clever bit isn't the unloading, it's the passthrough. The node takes in your system_prompt, user_prompt, images, and generated_texts and returns all four unchanged, so you can drop it into the middle of a chain without rewiring anything. It unloads the model and lets the data keep flowing to whatever comes next. That's the difference between a node you have to design around and a node you just insert.
How it works
You give it model_ref - the exact model key that LM Studio uses, the same model_ref that LM Studio Query outputs - and server_url. It derives the host:port from the URL and calls LM Studio's SDK to unload that model by key. If the SDK isn't installed, the model reference is empty, or the server is unreachable, it logs a warning and still passes everything through. Failures are loud-ish in the log but never fatal to your graph.
The inputs and outputs
- model_ref - the model to unload. This is required, but if it's empty the node just passes through.
- server_url - defaults to
http://localhost:1234. - system_prompt, user_prompt, images, generated_texts - optional passthroughs, all returned untouched.
Outputs: the same four, in order: system_prompt, user_prompt, images, generated_texts. Yes, you read that right - the outputs are named identically to the inputs, because they are the inputs.
Installing it
This is the one node in the pack with a real extra dependency: the lmstudio SDK is how it actually unloads. It's in the pack's requirements.txt:
cd ComfyUI/custom_nodes
git clone https://github.com/Pirog17000/Pirogs-Nodes
pip install -r Pirogs-Nodes/requirements.txt
If you skip that step, the node still exists and passes data through - it just can't unload anything and tells you so in the console.
Gotchas
model_ref must match LM Studio's key for the loaded model exactly - a partial or fuzzy name won't unload. The cleanest way to guarantee it matches is to wire model_ref from LM Studio Query's output rather than typing it. And if your workflow has no chain to pass through, this node still needs its required inputs satisfied, so wire the prompt/image outputs from the query node in even if you don't care about them. It's a "nice to place at the end of your LLM segment" node, not a "forget it exists" node.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| model_ref | STRING | Reference to the model name to unload from LM Studio | |
| server_url | STRING | http://localhost:1234 | LM Studio server URL |
| system_promptopt | STRING | Passthrough for system prompt | |
| user_promptopt | STRING | Passthrough for user prompt | |
| imagesopt | IMAGE | Passthrough for images | |
| generated_textsopt | STRING | Passthrough for generated texts |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| system_prompt | STRING | Passthrough system prompt |
| user_prompt | STRING | Passthrough user prompt |
| images | IMAGE | Passthrough images |
| generated_texts | STRING | Passthrough generated texts |