mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6498] [Issue]: Excessive thrashing between local models for Local LLM + ComfyUI + llama-swap on single GPU system #3639
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3639
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JamesMowery on GitHub (Sep 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6498
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Note: I wanted to start this more as a general discussion and visibility more than report a conclusive/definitive issue, as logging hasn't been able to pinpoint exactly what is going on.
Using Marinara Engine on a single GPU setup to generate both LLM responses and ComfyUI generations is currently very difficult. Specifically in a situation where ideally the entire LLM's VRAM and ComfyUI's VRAM is made available for generation and then cleared before handing back. It gets really ugly and really difficult to debug when things go wrong.
Installing something like llama.cpp and ComfyUI on the same system with a limited amount of VRAM makes this near impossible. But freeing up VRAM and then generating the LLM request and/or Image Gen request works well. But neither llama.cpp or ComfyUI can talk to each other to figure out when that happens.
llama-swap helps alleviate this issue as it can evict the VRAM in a FIFO fashion for the given request. I recently learned it can also intelligently handle ComfyUI requests, which is greaat!
The problem then is that Marinara Engine can and will constantly ping llama-swap for information on job status, and llama-swap interprets that as a model switch requests and can cause a constant and endless back and forth of loading ComfyUI vs loading llama.cpp models. Add various agents to the mix and it gets crazier.
Expected behavior
Ideally a flow like this: Marinara Engine LLM responds > Marinara Agent requests an image > LLM is evicted from VRAM > ComfyUI is spun up to generate an image with full VRAM available > ComfyUI returns image > ComfyUI unloads VRAM > LLM loads back into VRAM -- conversation continues.
llama-swap operates like this. It operates on a FIFO system. But the problem is that a ComfyUI job does not "reserve" its spot in the queue and block future LLM requests from happening. llama-swap thinks it did its job since it fired off the request. Perhaps Marinara Engine is greedy in expecting ComfyUI to be working independently and doesn't consider a single GPU setup.
The request here (I think) is for Marinara Engine to give consideration for a single GPU setup for requesting local LLM, images, video, and embedding and have a proper queue/system that will allow those processes to finish before firing off more requests.
llama-swap, again, helps massively with this situation. But there are still probably issues with how Marinara Engine assumes that the generation requests for different media/situations (embedding, image gen, video gen) are being worked on independently.
Actual behavior
When using Marinara Engine locally with local LLM and local ComfyUI, there can be lots of issues (I believe) when requests come into the different models.
I, for example, have setup ComfyUI and llama.cpp to be handled via llama-swap (which can dynamically load models as needed and handles this as a FIFO process currently) on my RTX 5090.
This is just a small block from my llama-swap config to handle this:
Note that this "gate" script (which is attached further below in this post) does the following and solves the problem, according to AI:
This seems to work fine for Convo mode. Where most of the effort is LLM and maybe once in while it will request a selfie. Works great. Can get messy if multiple convos are happening at once at a fast pace.
But when you jump into Roleplay mode and have multiple agents doing multiple things all one after another, it quickly breaks down and can cause lots of errors and issues. I think the ordering of requests (and if done in a "dumb" way) can also impact things going wrong as well more often.
Steps to reproduce
Environment
Logs, screenshots, or video
Here is the entirety of this gate script that I had AI build to help solve the model thrashing:
comfy_gate.py
The problem is that issue still happen, mostly in RP wherein you have local LLM models vs embedding models vs image gen models and agents firing off things.
Additional context
The comfy_gate.py script I had AI built helps alleviate a lot of issues and makes single GPU LLM + image gen a possibility. But it feels very hackish.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Sep 21, 2026):
Not a local crowd here, I'm afraid, will ask around.
@SpicyMarinara commented on GitHub (Sep 22, 2026):
Thank you for explaining this in so much detail! Had a closer look, and there is a gap here: Marinara's text requests and image/video queue don't share one queue for a physical GPU. We keep an image job active until it finishes, but that doesn't prevent a separate LLM or embedding request from starting in the meantime.
For ComfyUI, we check
/history/<prompt_id>roughly once a second while a render is pending. So overlapping requests could explain the swapping you're seeing, but we still need to confirm which request actually causes each unload/reload before deciding where the fix belongs.Could you please add:
llama-swap also has a dedicated ComfyUI route now, with special handling for some polling paths. That isn't proof it fixes this particular overlap, so I wouldn't want to send you chasing another workaround blindly. Let's pin down one reproducible case first. Thank you! :>