mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #679] Feature Request: Load/Offload/Swap mmproj dynamically from RAM to VRAM when used #317
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#317
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 @Interpause on GitHub (Oct 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/679
mmproj is only used when images are attached, and AFAIK all images can be encoded to image tokens first before prompt processing with the rest of the text tokens. As such, swapping mmproj from RAM to VRAM only when used is a way to reduce VRAM use and hence keep more experts in VRAM.
See discussion on llama.cpp for ideas on how this can be done optimally for max speed: https://github.com/ggml-org/llama.cpp/discussions/20246
@ampersandru commented on GitHub (Oct 3, 2026):
Depends on your RAM and CPU but I found mmproj running on CPU already extremely fast with qwen3.8, where the latency of having it load to vram, then process it, would negate any speed differences
@ukrolelo commented on GitHub (Oct 3, 2026):
strata allows to use mmproj through CPU? please advice ^^
@ampersandru commented on GitHub (Oct 3, 2026):
Yeah, use --vision cpu instead of true
@Interpause commented on GitHub (Oct 4, 2026):
would you mind sharing your timing? I assume you are using the default settings which means 1024 max image tokens... 3 months ago on mainline llama.cpp for qwen3.6 27B's mmproj encode stage, 1024 took about 3s per image for me. Is your time roughly in that ballpark?
EDIT: ill test tmrw
@jinkang06 commented on GitHub (Oct 4, 2026):
Brilliant idea!
@ampersandru commented on GitHub (Oct 4, 2026):
It's about 3 seconds on CPU (14600k with ddr4) and right under 2 seconds with mmproj on vram. Id be interested what the total time would be to have it on ram then load it into vram, but I'm assuming it's going to equal out to be very similar
@boorad64 commented on GitHub (Oct 4, 2026):
I changed my json to have "--vision cpu", and it quit with an error: "unknown argument: --vision cpu"
Any advice? the "usage" statement doesn't show vision taking any arguments
@ampersandru commented on GitHub (Oct 4, 2026):
Im using docker, so its either
VISION=cpu
VISION=yes
for docker commandline, it should be -e VISION=no\yes\cpu
https://github.com/Niko1221/Strata/blob/main/docs/INSTALL.md
@sinand99 commented on GitHub (Oct 4, 2026):
This would be very useful for low VRAM cards
@talisp commented on GitHub (Oct 5, 2026):
Some numbers for the VRAM side of this, from a 48 GB card (NVIDIA L40S vGPU, ~42 GiB usable, 0.1.38/0.1.39,
--vision gpu, the BF16 mmproj, 1024 image tokens):So on a big card the resident encoder is nearly free; the case for swapping it in and out is the small cards (12–16 GB), where 1.5 GiB is a much bigger share of the cache.
@boorad64:
--vision cpuis a setup option, not an engine argument, which is why the engine said "unknown argument". Run setup again with--vision cpu(setup.py --setup --vision cpu), or instrata-<model>.jsonkeep the bare"--vision"flag inargsand set the separate section, which is what setup writes:@ampersandru commented on GitHub (Oct 7, 2026):
heres my test with vision on VRAM vs vision on CPU (14600k with 3200Mhz DDR4):
IQ3_S comparison using the same images, with K8V4 cache in VRAM:
CPU vision averaged 0.20 seconds longer in the displayed request timings,
but generated approximately 12.5% more output tokens. Decode speed was
approximately 3.6% lower, with essentially unchanged expert-cache hit rate.
For these images, the displayed timings show only a small difference.
These are five-request samples, and the monitor's duration may not include
the separate image-encoding step, so this does not establish total
end-to-end image-processing latency.
Im going to keep vision on CPU so i can free up some VRAM for other things
@Niko1221 commented on GitHub (Oct 7, 2026):
Thanks. We have no plan to swap the encoder between RAM and VRAM on demand. The choice is made at setup: --vision gpu keeps it in VRAM, --vision cpu keeps it in RAM, and as you measured, 1.5 GiB for the encoder costs about 4% of expert slots and does not change decode. Closing with that answer.
@dany4ok commented on GitHub (Nov 6, 2026):
Additional exploratory measurement: CPU vision encoder resident in RAM vs elastic idle-unload, while generating text only
This is a small, single-machine observation relevant to whether keeping the mmproj/vision process resident has a measurable cost. It is not a standard Strata benchmark, and the rates below are client-observed end-to-end rates, not engine decode throughput.
Environment: Windows 11 Pro build 26200; RTX 5070 Ti (16 GiB, driver 621.01, configured 252 W power limit); Ryzen 7 7700X; 31.6 GiB installed RAM visible to Windows. Strata engine 0.1.57 (Windows x86_64 CUDA 13). Local Gyro-Gyro-S / Qwen3.8-Flash-Next-TQ1_0 model. BF16 mmproj, vision encoder on CPU, 8 threads, elastic idle timeout 30 s. While resident, strata-vision.exe used ~1,108 MiB working set (~1,349 MiB private bytes). During text-only generation the encoder was idle.
Method: same text-only chat-completions request, max_tokens=2000, four requests per state per cycle. The model naturally stopped at 759–826 completion tokens. Encoder residency/unload was checked by process; unload was the configured elastic idle-down. Reported rate = API completion_tokens divided by full HTTP request elapsed time, so it includes prompt processing and request overhead. The Strata community benchmark guide correctly says this must not be called decode tok/s; engine timing lines were not captured. Prompt/cache state and GPU clocks were not controlled, and the comparison is underpowered.
*First request after starting the encoder; the ~22 s includes encoder-start overlap and is not a steady-state comparison.
Warm medians: cycle A 110.3 tok/s resident vs 120.7 unloaded; cycle B 142.0 resident vs 135.8 unloaded. Direction reverses between cycles; these data do not establish a consistent steady-state penalty from RAM residency. The first request overlapping startup was slower in both cycles.
Limitations / failures: encoder was triggered using an invalid 8x8 PNG; image request returned HTTP 400 (cannot read image), although the encoder process did start and remain resident. No successful image correctness check was performed. Exact Strata app/source revision, model hash, background load and engine timing logs were not recorded. Per-run observations above were transcribed from the test output; no structured results JSON was saved.
Takeaway: on this setup, leaving the CPU vision encoder resident in RAM showed no consistent steady-state text-generation penalty in this small sample. A follow-up using the engine's decode/prompt timing fields, more order-swapped trials, and saved structured results would be needed for a comparable benchmark. No configuration change is proposed.