[PR #2522] [Engine] #533: elastic VRAM per GPU of a layer split (VRAM <reserve_mib> [device]) #4094

Open
opened 2026-11-07 15:33:09 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2522
Author: @GonzMartinez
Created: 10/15/2026
Status: 🔄 Open

Base: main ← Head: feature/vram-split-reserve


📝 Commits (9)

  • 61a47c7 engine, server: #533 elastic VRAM per GPU of a layer split (VRAM <reserve_mib> [device])
  • fe1c2f1 engine, server: #533 the per-card handoff works: VRAM - [device], and the reserve lands
  • 67f3a50 engine, server: #533 the two points from the branch review
  • 8a3e31c docs: the per-card handoff on a layer split, and the slot rows measured on 2x RTX 3090
  • e3388d2 sycl: parse 'VRAM - [device]' as the CUDA engine does
  • 9e31bb8 server: label POST /v1/vram's GPUs in the engine's card order and count one replica's cards
  • 069a8b4 engine: the VRAM command's error paths upload the residency table and relend the prompt's loan
  • 0fb5ad9 verify: revert #2522's refresh_residency and the ungated refresh_ar
  • 9a54a13 engine, docs, tools: #533 the dash gives each card its own start reserve

📊 Changes

15 files changed (+1135 additions, -192 deletions)

View changed files

📝 docs/BATCHING.md (+22 -0)
📝 docs/DETAILS.md (+18 -4)
📝 docs/MULTI_GPU.md (+37 -0)
📝 docs/VRAM_ELASTIC.md (+9 -6)
📝 include/strata/core/expert_cache.hpp (+4 -0)
➕ include/strata/program/vram_rules.hpp (+63 -0)
📝 serve/runconfig.py (+4 -0)
📝 serve/server.py (+118 -44)
📝 serve/test_server.py (+24 -10)
📝 serve/test_vram.py (+184 -21)
📝 src/core/expert_cache.cpp (+8 -0)
📝 src/program/generate.cpp (+219 -97)
📝 sycl/src/program/generate.cpp (+43 -9)
📝 tests/core/expert_cache_segmented_test.cpp (+110 -1)
➕ tools/comfy_vram_handoff.py (+272 -0)

📄 Description

Problem and result

#533 sizes the VRAM reserve once at start and gives the whole run one number, so on a layer split there is no way to hand one card's experts to another program while the run keeps serving: the other program takes the VRAM and the engine's decode collapses (the eviction case in #516). This makes the reserve per card on a split.

Result on this box (2x RTX 3090, Swift 1.5 IQ3_XXS, layers 0-23 / 24-47, "parallel": 2, --vram-reserve-mib 700, 512-token greedy decode):

  • With ComfyUI's Qwen-Image 2.1 on the second card: GPU 1 went from 16380 to 1024 MiB of cache (559 of 8833 experts, the prompt chunk 8192 -> 512) and left 15200 MiB free, where the image model's measured peak at 1024x1024 with DynamicVRAM is 15240 MiB. With ComfyUI holding 15240 MiB on GPU 1 and that card's cache at 3072 MiB, the engine answered a request in 1.1 s.
  • With the cache whole on both cards, "vram_elastic": true and false give the same cache (20 091 slots, 33 037 MiB) and 106.6 vs 106.4 tok/s - the segments cost nothing while nothing is handed away.
  • A second CUDA client costs 305 MiB before it allocates anything (torch.cuda.init() and its first tensor took the card from 23505 to 23810 MiB used); it fails in cuDevicePrimaryCtxRetain with CUDA_ERROR_OUT_OF_MEMORY at 80 MiB free and attaches at 613.

Approach

  • engine: --vram-elastic no longer refuses a layer split; every card's expert cache is segmented (512 MiB), and VRAM <reserve_mib> [device] moves one card's cache (device = the engine's number, 0 = the main card, the --split-device numbering) or every card of the run. Shrink/grow run on that card against its own free VRAM, the eviction scan is scoped to that stage's layers (slot numbers are per cache), and the prompt loan is re-lent at the largest chunk every card can still lend. One report line per card, then VRAM-DONE.
  • engine: after the first card moves, a failed shrink, fill or sync used to return before the residency table was uploaded and the prompt's loan re-lent, so the device tables could name slots the shrink had released and the loan could reach past the end of a cache. The round now finishes on every exit path (TacoTakumi's finding 2; include/strata/program/vram_rules.hpp holds the rules so the test can drive them).
  • verify: back to main's. The branch had added Verifier::refresh_residency and ungated refresh_ar(); that moves the default path of every run, also with --vram-elastic off (measured by TacoTakumi on 2x RTX 3090: the branch prints "have experts out of VRAM" for both stages with the flag off, the reverted build prints nothing). main already handles a shrink per window - each window's refresh_ar() (#871) reads the host residency table, so a stage that was 100% resident at init switches to the doorbell graph once the table shows an expert out of VRAM - so verify.cpp, verify.hpp and the handler's call are gone. qiuzan2001's point 1 is given back with them.
  • server: POST /v1/vram takes gpu (validated against the run's cards), answers with one entry per card in gpus plus the totals over them, and still works with an engine that answers one line and no VRAM-DONE. With no device it sends a bare VRAM, so it keeps working against an engine from before this change (qiuzan2001's point 2); the dash is sent only when a device follows. min_free_vram_mib reads every card the run will use and names the busy ones. The numbers it prints are the engine's own card order (ordered_gpus, the faster card last), and with replicas they are one engine's cards, not every replica's (TacoTakumi's finding 4).
  • a lone dash names the start's reserve so a device can follow it (VRAM - 1): a number in the first slot IS the reserve, so reserve_mib: null with a gpu used to send VRAM 1 - a 1 MiB reserve on EVERY card, not the start's reserve on GPU 1. VRAM -1 is still refused. On a split the dash now means each card's OWN start reserve - --vram-reserve-mib for the main card, --vram-reserve-later-mib for the later ones, the rule the sizing at start already uses - so a bare VRAM gives every card back its own number (ca22c998).
  • shrink keeps whole segments and rounds its keep UP, so a reserve asked for arrived up to one segment short and a need under one segment freed nothing at all; segment_floor rounds the keep DOWN to a segment boundary (12000 asked from 8292 free lands 12384, not 11872).
  • SYCL port: the same command syntax and report lines, the dash included, so VRAM - 1 parses there as it does on CUDA (TacoTakumi's finding 3); the segmented cache stays CUDA-only, so it refuses the resize. Its copy drives one cache, so the per-card rule is nothing to do there: that card's start reserve is its own.
  • vram_elastic and vram_segment_mib are editable keys (from the next start), and tools/comfy_vram_handoff.py drives the whole handoff: reserve, queue, wait, /free, restore.

What it leaves alone. The default path is byte-identical to the last release: vram_elastic is opt-in, and with it off a split runs as before. Single-card runs, the helper caches, --peer-device and the resident low-RAM mode are untouched. The split itself never moves: a card keeps its dense weights, its session and its KV, and nothing is reloaded.

https://github.com/Niko1221/Strata/issues/533 - closed 2026-10-04 with the single-GPU form; this is the per-card extension for a layer split, with #516 as the same pain on Linux. No maintainer agreement on scope for this branch. The branch review (qiuzan2001, 2026-10-15) raised the two points; its comment is read-only ("the engine was not built or run"), and the measurements here are ours on this box.

The four findings in the thread (TacoTakumi, 2026-10-25) are taken as their own commits, with them as the author: the verify revert, the error-path guard, the SYCL parse and the server card order. i-Vladimir-i's note about #2398 and its HIP parent #2399 is not implemented here: the admission guard still requires a segmented cache, so a shared --kv-grow arena and this path stay separate; their reading was marked static analysis and the combination is untested here.

Validation

Rebased on the latest main (v0.2.11 + 3 = 9f7d977d); the head is now b817ab7c. The rows that name eccbb0d0, ca22c998 and e76b2724 were run there - the two builds, the SYCL build, the gate and the hardware runs of 2026-10-26, -27 and -30; the top block below was run on b817ab7c on this box. Environment for everything run on this box: 2x RTX 3090 (PCIe, sm_86), Linux, driver 595.71.05. The measurements in Problem and result are from the pre-rebase branch faef4490 on this box, on the model named there; they have not been re-run on this revision.

Passed:

  • CUDA build on b817ab7c on this box (arch 86, setup's pinned flags STRATA_MMQ_KQUANTS and STRATA_Q6K_EXPERTS, CUDA 13.0 nvcc): 578/578 targets, configures and links clean.

  • python -m unittest serve.test_vram on b817ab7c: 18 tests OK; python tools/test_setup_config.py: 16 tests OK.

  • python -m unittest serve.test_server on b817ab7c: 374 tests, one failure - GpuChoice.test_hip_ordinal, which fails the same way on clean main built with the same flags, checked in a second worktree, so it is not this change. Two of its #4352 tests patch free_vram_mib and now give it the card index, because the guard reads every card the run will use; the file's other mocks already did, and the test that checks a two-card run is this branch's own.

  • the ctest tier for the code this branch touches on b817ab7c (-DSTRATA_BUILD_TESTS=ON on the same flags): expert_cache_per_layer_test, expert_cache_segmented_test, expert_cache_slot_guard_test, expert_profile_save_test, expert_profile_version_test - 5 of 5, including the segmented test's injected fill failure and sync failure, which check the device table against the host table. The other names the v0.2.6 row lists are no longer registered on this base; the tier is what main has.

  • the GPU parity/residency tier on b817ab7c, both arms, same flags, one run each, the box's lease held for the window: 11 of 12 on this branch and 11 of 12 on clean main - the one failure is expert_parity on both arms (its pack/full/experts.bin is not in the worktree), so it is the box, not the patch. pdl_parity, dma_batch_parity, decode_cluster_parity, fusions_parity, batch_rows_parity, cuda_device_selftest, verify_parity, spec_verify_parity, route_resident_parity, resident_plan_parity, verify_batch_parity pass on both arms.

  • the changed path re-run on the hardware on the canary at b817ab7c (the tree's config: vram_elastic: true, gpu [0, 1], layer_split auto, parallel 2, this box's model): {"reserve_mib": 8192, "gpu": 1} moved only GPU 1 (7682 -> 3986 slots, 8580 MiB free, one report line for that card); a bare {} gave each card its own start reserve - GPU 0 reported 896 (1135 MiB free) and GPU 1 reported 1134 (1378 MiB free); {"reserve_mib": null, "gpu": 1} alone reported 1134; the tool's vram 12288 --gpu 1 moved GPU 1 alone (1987 slots, the prompt chunk 8192 -> 4096); a second per-card call and a second bare call answered the same. A request answered after each of the six calls.

  • the staged gate on the rebased tree, on b817ab7c against live prod (bench-0210-ab1e574e), both on this box: PASS (report results/gate/2026-11-05-1445-44) - canary loaded in 24 s, speed 122.5 tok/s median of 113/122.8/122.5 against prod's live column (median 118.8, stored clean baseline 108.2, floor 86.6) - inside the ~8% noise floor this box has between the gate's two columns, so: no change measured; cache hit 99.1% on the branch, 98.4% on prod's column; needle 3/3 at 32k, depths 10/50/90; probes 10/10 correct in every run, every probe its own majority (2 of 3); 0 fatal lines. Verdict PASS, prod restored.

  • CUDA build on eccbb0d0 on this box (sm_86, setup's pinned flags STRATA_MMQ_KQUANTS and STRATA_Q6K_EXPERTS): configures and links clean; the binary measured below is be2545581066....

  • SYCL build on eccbb0d0 in the strata-sycl-dev image per docs/INTEL.md (SPIR-V, no AOT): configure and build clean - BUILD EXIT 0, errors: 0, 134 targets, linked strata.

  • python -m unittest serve.test_vram on ca22c998: 18 tests OK in 4.3 s - the line with a device, the bare line with no device, per-card aggregation, the old engine, refusals, the route, a reserve kept for an unloaded engine, and the two tests from the fork (a reordered gpu list, two replicas).

  • python -m unittest serve.test_server on ca22c998: 353 tests, one failure - GpuChoice.test_hip_ordinal, which fails the same way on clean main on this box (checked in a second worktree), so it is not this change. Its free-VRAM guard takes the per-card reading and checks a two-card run.

  • python tools/test_setup_config.py on ca22c998: 16 tests OK (vram_elastic and vram_segment_mib are editable keys).

  • ctest --test-dir build-tests -R '^(expert_cache_per_layer_test|expert_cache_segmented_test|expert_cache_slot_guard_test|vmm_test|host_graph_launch_test|batch_telemetry_test|batch_read_test|adapt_async_default_test|split_ring_test|batch_rows_test|batch_groups_test)$' (built with -DSTRATA_BUILD_TESTS=ON): 11 of 11 passed, on eccbb0d0 and again on ca22c998, including the segmented test's injected fill failure and sync failure, which check the device table against the host table.

  • the residency and verify parity tests on ca22c998: 6 of 7 passed (verify_parity, spec_verify_parity, route_resident_parity, resident_plan_parity, verify_batch_parity, dma_batch_parity); the one failure is under Failed. On eccbb0d0 it was 5 of 7, the second failure the same out-of-memory kind.

  • the canary gate on eccbb0d0 against the shipping release (bench-0231-b9a2f398), both on this box: speed 107.6 tok/s median of 99.4/107.6/122 against a clean baseline of 116.4 (floor 93.1; one sample retried because a second request ran with it) - inside the ~8% noise floor this box has between the gate's two columns, so: no change measured; cache hit 99.6% on both columns; needle 3/3 at 32k, depths 10/50/90; probes 10/10 correct in every run, every probe its own majority (2 of 3); 0 fatal lines. Verdict PASS, prod restored.

  • the changed path run on the hardware, on the canary at eccbb0d0 (the tree's config: vram_elastic: true, gpu [0, 1], layer_split auto, parallel 2, this box's model): {"reserve_mib": 8192, "gpu": 1} moved only GPU 1 (7820 -> 3986 of 7820 slots, 8610 MiB free, 32 ms, one report line for that card); {"reserve_mib": null, "gpu": 1} grew only GPU 1 back (3986 -> 7480 slots, 567 ms); {"reserve_mib": 4000, "gpu": 5} answered 400 with the run's card count; the tool's vram 12288 --gpu 1 moved GPU 1 alone (7480 -> 1987 slots, the prompt chunk 8192 -> 4096, 46 ms); {"reserve_mib": null} with no gpu moved both cards, one line each (GPU 0 9179 -> 8883 slots, GPU 1 1987 -> 7480, 894 ms). A request answered after each of the five calls.

  • the dash on ca22c998, same box and config: {"reserve_mib": 8192, "gpu": 1} moved only GPU 1 (3986 of 7819 slots, 8406 MiB free) and reported 8192; a bare {} then gave each card its own start reserve - GPU 0 reported 896 (8883 of 9177 slots, 995 MiB free) and GPU 1 reported 1134 (7480 of 7819, 1238 MiB free); {"reserve_mib": null, "gpu": 1} alone reported 1134 on GPU 1. Both calls repeated and answered the same, and a request answered after them.

  • POST /v1/vram with no gpu against an engine from before this change is pinned by serve/test_vram.py (the bare line); it was not run against a real older engine here.

Failed:

  • batch_rows_parity (malloc: out of memory) on this box with the server holding both cards and the RAM (45 GiB free of 156); it says nothing about the change and was not run on the pre-rebase branch either. dma_batch_parity, which failed the same way on eccbb0d0, passed on ca22c998. Both pass on b817ab7c, on this branch and on clean main.

Not run:

  • HIP build: no AMD toolchain and no AMD card on this box, so the shared src/ files here are unverified on HIP.
  • Metal build: no Mac.
  • the SYCL runtime: no Intel card here, so the parse fix is a compile check only.
  • tools/test_setup_golden.py: not run on this revision; it fails 48 tests on a clean checkout on this box, so it says nothing here.

Limits

  • The segmented cache is CUDA-only; the SYCL port carries the syntax and refuses the cache work. The per-card path keeps #533's other limits: no helper caches, no --peer-device, no resident low-RAM mode, NVIDIA only.
  • A shrink or grow only runs between requests, and nothing resizes on its own (the issue's agreed shape).
  • tools/comfy_vram_handoff.py waits for the queue to empty before it asks for the reserve; a busy run will not hand anything away.
  • A reserve under-arrives by up to one segment (whole segments unmap): on ca22c998 the dash left GPU 0 at 995 MiB free against the 896 asked and GPU 1 at 1238 against 1134.

🔄 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/2522 **Author:** [@GonzMartinez](https://github.com/GonzMartinez) **Created:** 10/15/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feature/vram-split-reserve` --- ### 📝 Commits (9) - [`61a47c7`](https://github.com/Niko1221/Strata/commit/61a47c77f8705a82254f61915eb589704ca59f66) engine, server: #533 elastic VRAM per GPU of a layer split (VRAM <reserve_mib> [device]) - [`fe1c2f1`](https://github.com/Niko1221/Strata/commit/fe1c2f1d77c9a99cf8e7f2ee8f55cf400b9b26d4) engine, server: #533 the per-card handoff works: VRAM - [device], and the reserve lands - [`67f3a50`](https://github.com/Niko1221/Strata/commit/67f3a50d85cb2c4cba3f96057e870d2b1eea4444) engine, server: #533 the two points from the branch review - [`8a3e31c`](https://github.com/Niko1221/Strata/commit/8a3e31c62a412e2c80f35097cbd6f89647247471) docs: the per-card handoff on a layer split, and the slot rows measured on 2x RTX 3090 - [`e3388d2`](https://github.com/Niko1221/Strata/commit/e3388d21f331f5b9976467297b3d385dab666623) sycl: parse 'VRAM - [device]' as the CUDA engine does - [`9e31bb8`](https://github.com/Niko1221/Strata/commit/9e31bb86faefd796efb49ba4fae5f61cda8178e9) server: label POST /v1/vram's GPUs in the engine's card order and count one replica's cards - [`069a8b4`](https://github.com/Niko1221/Strata/commit/069a8b4424bfcdbdb08990414c13010ce9bf0be3) engine: the VRAM command's error paths upload the residency table and relend the prompt's loan - [`0fb5ad9`](https://github.com/Niko1221/Strata/commit/0fb5ad94eccf8c76d8ef371bf923f62e79f77c98) verify: revert #2522's refresh_residency and the ungated refresh_ar - [`9a54a13`](https://github.com/Niko1221/Strata/commit/9a54a13ffb508c61302b915507d9e8d7a212609b) engine, docs, tools: #533 the dash gives each card its own start reserve ### 📊 Changes **15 files changed** (+1135 additions, -192 deletions) <details> <summary>View changed files</summary> 📝 `docs/BATCHING.md` (+22 -0) 📝 `docs/DETAILS.md` (+18 -4) 📝 `docs/MULTI_GPU.md` (+37 -0) 📝 `docs/VRAM_ELASTIC.md` (+9 -6) 📝 `include/strata/core/expert_cache.hpp` (+4 -0) ➕ `include/strata/program/vram_rules.hpp` (+63 -0) 📝 `serve/runconfig.py` (+4 -0) 📝 `serve/server.py` (+118 -44) 📝 `serve/test_server.py` (+24 -10) 📝 `serve/test_vram.py` (+184 -21) 📝 `src/core/expert_cache.cpp` (+8 -0) 📝 `src/program/generate.cpp` (+219 -97) 📝 `sycl/src/program/generate.cpp` (+43 -9) 📝 `tests/core/expert_cache_segmented_test.cpp` (+110 -1) ➕ `tools/comfy_vram_handoff.py` (+272 -0) </details> ### 📄 Description ## Problem and result `#533` sizes the VRAM reserve once at start and gives the whole run one number, so on a layer split there is no way to hand one card's experts to another program while the run keeps serving: the other program takes the VRAM and the engine's decode collapses (the eviction case in #516). This makes the reserve per card on a split. Result on this box (2x RTX 3090, Swift 1.5 IQ3_XXS, layers 0-23 / 24-47, `"parallel": 2`, `--vram-reserve-mib 700`, 512-token greedy decode): - With ComfyUI's Qwen-Image 2.1 on the second card: GPU 1 went from 16380 to 1024 MiB of cache (559 of 8833 experts, the prompt chunk 8192 -> 512) and left 15200 MiB free, where the image model's measured peak at 1024x1024 with DynamicVRAM is 15240 MiB. With ComfyUI holding 15240 MiB on GPU 1 and that card's cache at 3072 MiB, the engine answered a request in 1.1 s. - With the cache whole on both cards, `"vram_elastic": true` and `false` give the same cache (20 091 slots, 33 037 MiB) and 106.6 vs 106.4 tok/s - the segments cost nothing while nothing is handed away. - A second CUDA client costs 305 MiB before it allocates anything (`torch.cuda.init()` and its first tensor took the card from 23505 to 23810 MiB used); it fails in `cuDevicePrimaryCtxRetain` with CUDA_ERROR_OUT_OF_MEMORY at 80 MiB free and attaches at 613. ## Approach - engine: `--vram-elastic` no longer refuses a layer split; every card's expert cache is segmented (512 MiB), and `VRAM <reserve_mib> [device]` moves one card's cache (device = the engine's number, 0 = the main card, the `--split-device` numbering) or every card of the run. Shrink/grow run on that card against its own free VRAM, the eviction scan is scoped to that stage's layers (slot numbers are per cache), and the prompt loan is re-lent at the largest chunk every card can still lend. One report line per card, then `VRAM-DONE`. - engine: after the first card moves, a failed shrink, fill or sync used to return before the residency table was uploaded and the prompt's loan re-lent, so the device tables could name slots the shrink had released and the loan could reach past the end of a cache. The round now finishes on every exit path (TacoTakumi's finding 2; `include/strata/program/vram_rules.hpp` holds the rules so the test can drive them). - verify: back to `main`'s. The branch had added `Verifier::refresh_residency` and ungated `refresh_ar()`; that moves the default path of every run, also with `--vram-elastic` off (measured by TacoTakumi on 2x RTX 3090: the branch prints "have experts out of VRAM" for both stages with the flag off, the reverted build prints nothing). `main` already handles a shrink per window - each window's `refresh_ar()` (#871) reads the host residency table, so a stage that was 100% resident at init switches to the doorbell graph once the table shows an expert out of VRAM - so `verify.cpp`, `verify.hpp` and the handler's call are gone. qiuzan2001's point 1 is given back with them. - server: `POST /v1/vram` takes `gpu` (validated against the run's cards), answers with one entry per card in `gpus` plus the totals over them, and still works with an engine that answers one line and no `VRAM-DONE`. With no device it sends a bare `VRAM`, so it keeps working against an engine from before this change (qiuzan2001's point 2); the dash is sent only when a device follows. `min_free_vram_mib` reads every card the run will use and names the busy ones. The numbers it prints are the engine's own card order (`ordered_gpus`, the faster card last), and with replicas they are one engine's cards, not every replica's (TacoTakumi's finding 4). - a lone dash names the start's reserve so a device can follow it (`VRAM - 1`): a number in the first slot IS the reserve, so `reserve_mib: null` with a `gpu` used to send `VRAM 1` - a 1 MiB reserve on EVERY card, not the start's reserve on GPU 1. `VRAM -1` is still refused. On a split the dash now means each card's OWN start reserve - `--vram-reserve-mib` for the main card, `--vram-reserve-later-mib` for the later ones, the rule the sizing at start already uses - so a bare `VRAM` gives every card back its own number (`ca22c998`). - `shrink` keeps whole segments and rounds its keep UP, so a reserve asked for arrived up to one segment short and a need under one segment freed nothing at all; `segment_floor` rounds the keep DOWN to a segment boundary (12000 asked from 8292 free lands 12384, not 11872). - SYCL port: the same command syntax and report lines, the dash included, so `VRAM - 1` parses there as it does on CUDA (TacoTakumi's finding 3); the segmented cache stays CUDA-only, so it refuses the resize. Its copy drives one cache, so the per-card rule is nothing to do there: that card's start reserve is its own. - `vram_elastic` and `vram_segment_mib` are editable keys (from the next start), and `tools/comfy_vram_handoff.py` drives the whole handoff: reserve, queue, wait, /free, restore. **What it leaves alone.** The default path is byte-identical to the last release: `vram_elastic` is opt-in, and with it off a split runs as before. Single-card runs, the helper caches, `--peer-device` and the resident low-RAM mode are untouched. The split itself never moves: a card keeps its dense weights, its session and its KV, and nothing is reloaded. ## Related discussion https://github.com/Niko1221/Strata/issues/533 - closed 2026-10-04 with the single-GPU form; this is the per-card extension for a layer split, with #516 as the same pain on Linux. No maintainer agreement on scope for this branch. The branch review (qiuzan2001, 2026-10-15) raised the two points; its comment is read-only ("the engine was not built or run"), and the measurements here are ours on this box. The four findings in the thread (TacoTakumi, 2026-10-25) are taken as their own commits, with them as the author: the verify revert, the error-path guard, the SYCL parse and the server card order. i-Vladimir-i's note about #2398 and its HIP parent #2399 is not implemented here: the admission guard still requires a segmented cache, so a shared `--kv-grow` arena and this path stay separate; their reading was marked static analysis and the combination is untested here. ## Validation Rebased on the latest `main` (`v0.2.11` + 3 = `9f7d977d`); the head is now `b817ab7c`. The rows that name `eccbb0d0`, `ca22c998` and `e76b2724` were run there - the two builds, the SYCL build, the gate and the hardware runs of 2026-10-26, -27 and -30; the top block below was run on `b817ab7c` on this box. Environment for everything run on this box: 2x RTX 3090 (PCIe, sm_86), Linux, driver 595.71.05. The measurements in *Problem and result* are from the pre-rebase branch `faef4490` on this box, on the model named there; they have not been re-run on this revision. **Passed:** - CUDA build on `b817ab7c` on this box (arch 86, setup's pinned flags `STRATA_MMQ_KQUANTS` and `STRATA_Q6K_EXPERTS`, CUDA 13.0 nvcc): 578/578 targets, configures and links clean. - `python -m unittest serve.test_vram` on `b817ab7c`: 18 tests OK; `python tools/test_setup_config.py`: 16 tests OK. - `python -m unittest serve.test_server` on `b817ab7c`: 374 tests, one failure - `GpuChoice.test_hip_ordinal`, which fails the same way on clean `main` built with the same flags, checked in a second worktree, so it is not this change. Two of its `#4352` tests patch `free_vram_mib` and now give it the card index, because the guard reads every card the run will use; the file's other mocks already did, and the test that checks a two-card run is this branch's own. - the ctest tier for the code this branch touches on `b817ab7c` (`-DSTRATA_BUILD_TESTS=ON` on the same flags): `expert_cache_per_layer_test`, `expert_cache_segmented_test`, `expert_cache_slot_guard_test`, `expert_profile_save_test`, `expert_profile_version_test` - 5 of 5, including the segmented test's injected fill failure and sync failure, which check the device table against the host table. The other names the `v0.2.6` row lists are no longer registered on this base; the tier is what `main` has. - the GPU parity/residency tier on `b817ab7c`, both arms, same flags, one run each, the box's lease held for the window: 11 of 12 on this branch and 11 of 12 on clean `main` - the one failure is `expert_parity` on both arms (its `pack/full/experts.bin` is not in the worktree), so it is the box, not the patch. `pdl_parity`, `dma_batch_parity`, `decode_cluster_parity`, `fusions_parity`, `batch_rows_parity`, `cuda_device_selftest`, `verify_parity`, `spec_verify_parity`, `route_resident_parity`, `resident_plan_parity`, `verify_batch_parity` pass on both arms. - the changed path re-run on the hardware on the canary at `b817ab7c` (the tree's config: `vram_elastic: true`, `gpu [0, 1]`, `layer_split auto`, `parallel 2`, this box's model): `{"reserve_mib": 8192, "gpu": 1}` moved only GPU 1 (7682 -> 3986 slots, 8580 MiB free, one report line for that card); a bare `{}` gave each card its own start reserve - GPU 0 reported 896 (1135 MiB free) and GPU 1 reported 1134 (1378 MiB free); `{"reserve_mib": null, "gpu": 1}` alone reported 1134; the tool's `vram 12288 --gpu 1` moved GPU 1 alone (1987 slots, the prompt chunk 8192 -> 4096); a second per-card call and a second bare call answered the same. A request answered after each of the six calls. - the staged gate on the rebased tree, on `b817ab7c` against live prod (`bench-0210-ab1e574e`), both on this box: **PASS** (report `results/gate/2026-11-05-1445-44`) - canary loaded in 24 s, speed 122.5 tok/s median of 113/122.8/122.5 against prod's live column (median 118.8, stored clean baseline 108.2, floor 86.6) - inside the ~8% noise floor this box has between the gate's two columns, so: no change measured; cache hit 99.1% on the branch, 98.4% on prod's column; needle 3/3 at 32k, depths 10/50/90; probes 10/10 correct in every run, every probe its own majority (2 of 3); 0 fatal lines. Verdict PASS, prod restored. - CUDA build on `eccbb0d0` on this box (sm_86, setup's pinned flags `STRATA_MMQ_KQUANTS` and `STRATA_Q6K_EXPERTS`): configures and links clean; the binary measured below is `be2545581066...`. - SYCL build on `eccbb0d0` in the `strata-sycl-dev` image per docs/INTEL.md (SPIR-V, no AOT): configure and build clean - `BUILD EXIT 0`, `errors: 0`, 134 targets, linked `strata`. - `python -m unittest serve.test_vram` on `ca22c998`: 18 tests OK in 4.3 s - the line with a device, the bare line with no device, per-card aggregation, the old engine, refusals, the route, a reserve kept for an unloaded engine, and the two tests from the fork (a reordered `gpu` list, two replicas). - `python -m unittest serve.test_server` on `ca22c998`: 353 tests, one failure - `GpuChoice.test_hip_ordinal`, which fails the same way on clean `main` on this box (checked in a second worktree), so it is not this change. Its free-VRAM guard takes the per-card reading and checks a two-card run. - `python tools/test_setup_config.py` on `ca22c998`: 16 tests OK (`vram_elastic` and `vram_segment_mib` are editable keys). - `ctest --test-dir build-tests -R '^(expert_cache_per_layer_test|expert_cache_segmented_test|expert_cache_slot_guard_test|vmm_test|host_graph_launch_test|batch_telemetry_test|batch_read_test|adapt_async_default_test|split_ring_test|batch_rows_test|batch_groups_test)$'` (built with `-DSTRATA_BUILD_TESTS=ON`): 11 of 11 passed, on `eccbb0d0` and again on `ca22c998`, including the segmented test's injected fill failure and sync failure, which check the device table against the host table. - the residency and verify parity tests on `ca22c998`: 6 of 7 passed (`verify_parity`, `spec_verify_parity`, `route_resident_parity`, `resident_plan_parity`, `verify_batch_parity`, `dma_batch_parity`); the one failure is under Failed. On `eccbb0d0` it was 5 of 7, the second failure the same out-of-memory kind. - the canary gate on `eccbb0d0` against the shipping release (`bench-0231-b9a2f398`), both on this box: speed 107.6 tok/s median of 99.4/107.6/122 against a clean baseline of 116.4 (floor 93.1; one sample retried because a second request ran with it) - inside the ~8% noise floor this box has between the gate's two columns, so: no change measured; cache hit 99.6% on both columns; needle 3/3 at 32k, depths 10/50/90; probes 10/10 correct in every run, every probe its own majority (2 of 3); 0 fatal lines. Verdict PASS, prod restored. - the changed path run on the hardware, on the canary at `eccbb0d0` (the tree's config: `vram_elastic: true`, `gpu [0, 1]`, `layer_split auto`, `parallel 2`, this box's model): `{"reserve_mib": 8192, "gpu": 1}` moved only GPU 1 (7820 -> 3986 of 7820 slots, 8610 MiB free, 32 ms, one report line for that card); `{"reserve_mib": null, "gpu": 1}` grew only GPU 1 back (3986 -> 7480 slots, 567 ms); `{"reserve_mib": 4000, "gpu": 5}` answered 400 with the run's card count; the tool's `vram 12288 --gpu 1` moved GPU 1 alone (7480 -> 1987 slots, the prompt chunk 8192 -> 4096, 46 ms); `{"reserve_mib": null}` with no `gpu` moved both cards, one line each (GPU 0 9179 -> 8883 slots, GPU 1 1987 -> 7480, 894 ms). A request answered after each of the five calls. - the dash on `ca22c998`, same box and config: `{"reserve_mib": 8192, "gpu": 1}` moved only GPU 1 (3986 of 7819 slots, 8406 MiB free) and reported 8192; a bare `{}` then gave each card its own start reserve - GPU 0 reported 896 (8883 of 9177 slots, 995 MiB free) and GPU 1 reported 1134 (7480 of 7819, 1238 MiB free); `{"reserve_mib": null, "gpu": 1}` alone reported 1134 on GPU 1. Both calls repeated and answered the same, and a request answered after them. - `POST /v1/vram` with no `gpu` against an engine from before this change is pinned by `serve/test_vram.py` (the bare line); it was not run against a real older engine here. **Failed:** - `batch_rows_parity` (`malloc: out of memory`) on this box with the server holding both cards and the RAM (45 GiB free of 156); it says nothing about the change and was not run on the pre-rebase branch either. `dma_batch_parity`, which failed the same way on `eccbb0d0`, passed on `ca22c998`. Both pass on `b817ab7c`, on this branch and on clean `main`. **Not run:** - HIP build: no AMD toolchain and no AMD card on this box, so the shared `src/` files here are unverified on HIP. - Metal build: no Mac. - the SYCL runtime: no Intel card here, so the parse fix is a compile check only. - `tools/test_setup_golden.py`: not run on this revision; it fails 48 tests on a clean checkout on this box, so it says nothing here. ## Limits - The segmented cache is CUDA-only; the SYCL port carries the syntax and refuses the cache work. The per-card path keeps #533's other limits: no helper caches, no `--peer-device`, no resident low-RAM mode, NVIDIA only. - A shrink or grow only runs between requests, and nothing resizes on its own (the issue's agreed shape). - `tools/comfy_vram_handoff.py` waits for the queue to empty before it asks for the reserve; a busy run will not hand anything away. - A reserve under-arrives by up to one segment (whole segments unmap): on `ca22c998` the dash left GPU 0 at 995 MiB free against the 896 asked and GPU 1 at 1238 against 1134. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#4094
No description provided.