[PR #666] [CLOSED] setup, serve: the image encoder's device as its own role (--vision-device) #2754

Closed
opened 2026-11-04 02:02:53 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/666
Author: @hireymage
Created: 10/3/2026
Status: ❌ Closed

Base: main ← Head: vision-device


📝 Commits (10+)

  • cc97fcd setup: AMD layer splits with --gpus (every chosen card a supported AMD arch; the engine compiled for each)
  • e9e2ba3 pinned (#243 follow-up): the shared-memory-budget cap on the sliced pin is opt-in (STRATA_ARENA_PIN_GIB=auto) - by default the arena pins as in 0.1.30; on this 64 GB PC the cap pinned 26 instead of 30 GiB and cost ~20% prompt speed and 2-4% IQ3_S decode
  • cacffa9 CS-T speed: the file tier fetched in parallel, PCIe planning without file reads, a partial pin of the RAM tier, bit-exact AVX2 multi-token kernels for Q4_K / Q5_1 / Q8_0 experts, decode-only tier stats
  • a348c7a Merge branch 'f-131-srv' into r131-q4
  • b93a00c Merge branch 'f-q4-on242' into r131-q4
  • 8f5148c CS-T: the partial pin at most 24 GiB (STRATA_PARTIAL_PIN_GIB), the Q4_K/Q5_1/Q8_0 multi-token kernels from two tokens on
  • 5ffda19 CS-T: the GGUF-in-place prefetch asks Windows for all of a layer's missed slices at once (PrefetchVirtualMemory)
  • ed6c124 #253: the 8 GiB arena pin cap only under WDDM; STRATA_ARENA_PIN_GIB; the split's prompt chunk steps down
  • 450149d --split-skip-if-fits (opt-in): an auto split runs on the main card alone when it holds every profiled expert + KV
  • 6926e0b Merge branch 'f-131-amd' into r131-amd

📊 Changes

8 files changed (+315 additions, -30 deletions)

View changed files

📝 docs/AI_SETUP.md (+3 -1)
📝 docs/DETAILS.md (+18 -0)
📝 docs/MULTI_GPU.md (+6 -0)
📝 serve/server.py (+20 -7)
📝 serve/test_server.py (+27 -0)
📝 setup.py (+98 -20)
📝 tools/test_setup_choices.py (+131 -0)
📝 tools/vision/CMakeLists.txt (+12 -2)

📄 Description

What

A third placement role for the picture encoder, beside the engine's GPUs (--vision-device):

  • --vision-device auto — a spare card (the one with the most VRAM) when one exists, else the engine's main card as before;
  • --vision-device cpu — the pictures read on the CPU (#304's path);
  • --vision-device 1 / cuda:1 — pinned to a card, numbered like nvidia-smi (the same numbering the engine's device report uses);
  • flag absent — nothing changes (the encoder stays on the engine's first card).

Why this shape

The image encoder is not in the engine: strata-vision is a process of its own, and the engine reads the embeddings it wrote from the disk. So the placement lives at the layer that owns the vision compute, and the implementation reuses what is already merged rather than adding a parallel mechanism:

  • #408: a cuda_device in the "vision" config — this branch writes that same key, and vision_env() does the rest (CUDA_VISIBLE_DEVICES, PCI-bus order) unchanged.
  • #304: the CPU encoder — --vision-device cpu simply routes into the existing --vision cpu path.
  • Setup validates the card against the same GPU list the engine's choices use (and the HIP list when the backend is HIP), warns when the encoder must share a card with the engine (the expert cache there is sized after the encoder's VRAM), and serve states the placement at start-up (the image encoder runs on GPU 1 (its own card)).

Cross-card, the handoff is by construction the same as every existing vision run: the .sve embeddings go through the disk, so no card-to-card path is involved on any mix of GPUs, and P2P is never required.

Nothing changes when the flag is absent; no engine (C++) code is touched.

Testing

  • tools/test_setup_choices.py: 10 new tests for the flag (auto/cpu/card/share/missing-card/refusals) — 41 green; serve/test_server.py: the new start-up role line — 119 green.
  • Validated on a 2× GTX 1080 Ti (Pascal, sm_61) rig against the real encoder binary: with cuda_device: 1 the encoder's VRAM lands on GPU 1 alone (GPU 0 delta 0 MiB, GPU 1 +1192 MiB through the serve path), the second encode of the same image hits the disk cache, and the CPU run produces the same-size output. Pascal is affected only by proxy — no engine code changed.

Docs

docs/AI_SETUP.md, docs/DETAILS.md (0.1.38 paragraph) and docs/MULTI_GPU.md describe the flag and the placement rules.


Follow-up in this PR: the encoder on Vulkan or SYCL GPUs (--vision-backend vulkan|sycl)

The image encoder is its own llama.cpp process, so unlike the engine it can run on a GPU whose backend the engine
doesn't speak. --vision-backend vulkan builds strata-vision for Vulkan (any Vulkan GPU, an Intel or AMD iGPU
included) and --vision-backend sycl for Intel GPUs through oneAPI; the device is named through that backend's own
variable and its own device list:

--vision-backend encoder's device variable where --vision-device's numbers come from
(default, CUDA) CUDA_VISIBLE_DEVICES nvidia-smi
vulkan GGML_VK_VISIBLE_DEVICES vulkaninfo --summary
sycl ONEAPI_DEVICE_SELECTOR="level_zero:N" sycl-ls (dGPUs first, iGPUs at the end)

tools/vision/CMakeLists.txt gains the two backend options (one GPU backend at a time), the config keeps
"backend" in "vision", and changing the backend rebuilds the encoder. --vision-device auto is refused with a
non-CUDA backend: these backends number devices differently than nvidia-smi, so name the device.

Validation limits: no Intel iGPU was available to test on. The Vulkan build+pin path was validated on a 2x GTX
1080 Ti rig as a proxy (Vulkan encoder, GGML_VK_VISIBLE_DEVICES pinning to card0/card1, VRAM placement via
nvidia-smi); the SYCL path is unit-tested only.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/666 **Author:** [@hireymage](https://github.com/hireymage) **Created:** 10/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `vision-device` --- ### 📝 Commits (10+) - [`cc97fcd`](https://github.com/Niko1221/Strata/commit/cc97fcde526e1b2d4cbee39ba21e54a0ef7505b1) setup: AMD layer splits with --gpus (every chosen card a supported AMD arch; the engine compiled for each) - [`e9e2ba3`](https://github.com/Niko1221/Strata/commit/e9e2ba31abdc211a618b5faf7226732d40bbcf2b) pinned (#243 follow-up): the shared-memory-budget cap on the sliced pin is opt-in (STRATA_ARENA_PIN_GIB=auto) - by default the arena pins as in 0.1.30; on this 64 GB PC the cap pinned 26 instead of 30 GiB and cost ~20% prompt speed and 2-4% IQ3_S decode - [`cacffa9`](https://github.com/Niko1221/Strata/commit/cacffa95aff016939edd7c15534c0067ec0ee93c) CS-T speed: the file tier fetched in parallel, PCIe planning without file reads, a partial pin of the RAM tier, bit-exact AVX2 multi-token kernels for Q4_K / Q5_1 / Q8_0 experts, decode-only tier stats - [`a348c7a`](https://github.com/Niko1221/Strata/commit/a348c7a4ed64f5f7f24ce3f1cba2d1439f673fed) Merge branch 'f-131-srv' into r131-q4 - [`b93a00c`](https://github.com/Niko1221/Strata/commit/b93a00c65a21fcc5b6431b8091e348d2976259f0) Merge branch 'f-q4-on242' into r131-q4 - [`8f5148c`](https://github.com/Niko1221/Strata/commit/8f5148c14d34c404e8a2d6a45188088714f3c9bb) CS-T: the partial pin at most 24 GiB (STRATA_PARTIAL_PIN_GIB), the Q4_K/Q5_1/Q8_0 multi-token kernels from two tokens on - [`5ffda19`](https://github.com/Niko1221/Strata/commit/5ffda19098202b82943fc80281ce0eb34d8e08a3) CS-T: the GGUF-in-place prefetch asks Windows for all of a layer's missed slices at once (PrefetchVirtualMemory) - [`ed6c124`](https://github.com/Niko1221/Strata/commit/ed6c1244dcd31789007540cb9d8498fbd4134b7f) #253: the 8 GiB arena pin cap only under WDDM; STRATA_ARENA_PIN_GIB; the split's prompt chunk steps down - [`450149d`](https://github.com/Niko1221/Strata/commit/450149d3f248438d8a2526c600b5a75c3dbea6c6) --split-skip-if-fits (opt-in): an auto split runs on the main card alone when it holds every profiled expert + KV - [`6926e0b`](https://github.com/Niko1221/Strata/commit/6926e0b4f4f72cda4f95a0218a89500135af7e4e) Merge branch 'f-131-amd' into r131-amd ### 📊 Changes **8 files changed** (+315 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `docs/AI_SETUP.md` (+3 -1) 📝 `docs/DETAILS.md` (+18 -0) 📝 `docs/MULTI_GPU.md` (+6 -0) 📝 `serve/server.py` (+20 -7) 📝 `serve/test_server.py` (+27 -0) 📝 `setup.py` (+98 -20) 📝 `tools/test_setup_choices.py` (+131 -0) 📝 `tools/vision/CMakeLists.txt` (+12 -2) </details> ### 📄 Description ## What A third placement role for the picture encoder, beside the engine's GPUs (`--vision-device`): - `--vision-device auto` — a spare card (the one with the most VRAM) when one exists, else the engine's main card as before; - `--vision-device cpu` — the pictures read on the CPU (#304's path); - `--vision-device 1` / `cuda:1` — pinned to a card, numbered like nvidia-smi (the same numbering the engine's device report uses); - flag absent — nothing changes (the encoder stays on the engine's first card). ## Why this shape The image encoder is not in the engine: `strata-vision` is a process of its own, and the engine reads the embeddings it wrote from the disk. So the placement lives at the layer that owns the vision compute, and the implementation reuses what is already merged rather than adding a parallel mechanism: - **#408**: a `cuda_device` in the `"vision"` config — this branch writes that same key, and `vision_env()` does the rest (`CUDA_VISIBLE_DEVICES`, PCI-bus order) unchanged. - **#304**: the CPU encoder — `--vision-device cpu` simply routes into the existing `--vision cpu` path. - Setup validates the card against the same GPU list the engine's choices use (and the HIP list when the backend is HIP), warns when the encoder must share a card with the engine (the expert cache there is sized after the encoder's VRAM), and `serve` states the placement at start-up (`the image encoder runs on GPU 1 (its own card)`). Cross-card, the handoff is by construction the same as every existing vision run: the `.sve` embeddings go through the disk, so no card-to-card path is involved on any mix of GPUs, and P2P is never required. Nothing changes when the flag is absent; no engine (C++) code is touched. ## Testing - `tools/test_setup_choices.py`: 10 new tests for the flag (auto/cpu/card/share/missing-card/refusals) — 41 green; `serve/test_server.py`: the new start-up role line — 119 green. - Validated on a 2× GTX 1080 Ti (Pascal, sm_61) rig against the real encoder binary: with `cuda_device: 1` the encoder's VRAM lands on GPU 1 alone (GPU 0 delta 0 MiB, GPU 1 +1192 MiB through the serve path), the second encode of the same image hits the disk cache, and the CPU run produces the same-size output. Pascal is affected only by proxy — no engine code changed. ## Docs `docs/AI_SETUP.md`, `docs/DETAILS.md` (0.1.38 paragraph) and `docs/MULTI_GPU.md` describe the flag and the placement rules. --- ## Follow-up in this PR: the encoder on Vulkan or SYCL GPUs (`--vision-backend vulkan|sycl`) The image encoder is its own llama.cpp process, so unlike the engine it can run on a GPU whose backend the engine doesn't speak. `--vision-backend vulkan` builds `strata-vision` for Vulkan (any Vulkan GPU, an Intel or AMD iGPU included) and `--vision-backend sycl` for Intel GPUs through oneAPI; the device is named through that backend's own variable and its own device list: | `--vision-backend` | encoder's device variable | where `--vision-device`'s numbers come from | | --- | --- | --- | | *(default, CUDA)* | `CUDA_VISIBLE_DEVICES` | `nvidia-smi` | | `vulkan` | `GGML_VK_VISIBLE_DEVICES` | `vulkaninfo --summary` | | `sycl` | `ONEAPI_DEVICE_SELECTOR="level_zero:N"` | `sycl-ls` (dGPUs first, iGPUs at the end) | `tools/vision/CMakeLists.txt` gains the two backend options (one GPU backend at a time), the config keeps `"backend"` in `"vision"`, and changing the backend rebuilds the encoder. `--vision-device auto` is refused with a non-CUDA backend: these backends number devices differently than nvidia-smi, so name the device. **Validation limits:** no Intel iGPU was available to test on. The Vulkan build+pin path was validated on a 2x GTX 1080 Ti rig as a proxy (Vulkan encoder, `GGML_VK_VISIBLE_DEVICES` pinning to card0/card1, VRAM placement via nvidia-smi); the SYCL path is unit-tested only. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:02:53 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2754
No description provided.