[GH-ISSUE #4168] [Engine] Lend part of the expert cache's VRAM to another program while requests run (layer split, opt-in) #1827

Open
opened 2026-11-04 01:54:24 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @TacoTakumi on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4168

Area

[Engine]

What do you want to do?

I run Strata on a layer split over two RTX 3090 cards, and other programs on the same box need GPU memory from time to time: an image model, a vision encoder, a training job. Today the only choices are to unload the model or to start it with less cache for good. I would like another program to borrow part of one card's expert cache while Strata keeps serving, and give it back when it is done.

The contract is three HTTP routes on the server and three lines on the engine's stdin. It is written up as an engine-neutral spec, with a second engine (a GLM-5.3-Flash fork of Strata) already implementing it:

  • POST /vram/lend {"gpu": "", "mib": N} answers a lease id once the memory is free in the driver
  • POST /vram/return {"id": ...} gives it back
  • GET /vram/state lists lendable and lent per GPU and the open leases
  • Spec: https://github.com/TacoTakumi/vram-lend (docs/api.md, docs/engine-protocol.md, docs/implementing.md)

On Strata it builds on #533's segmented expert cache and on #2522's per-GPU caches on a layer split. A lease takes whole 512 MiB segments from a band between the cache's floor and the prompt path's loan, so the prompt path never meets a hole. The segments chosen are the coldest by the expert profile. The lend is answered between decode windows, between prompt chunks and when idle, and the return refills the experts in the background. It is opt-in ("vram_lend": true, engine flag --vram-lend). With it on, the VRAM command, POST /v1/vram and the elastic image encoder are refused, and --pipeline-windows and --batch are turned off with one line each, because they keep work in flight with no safe point for an unmap.

Branch: https://github.com/TacoTakumi/Strata/tree/vram-lend, now on v0.2.12. It has the 9 commits of #2522's current head (author kept, rebased onto v0.2.12, with the 4 fixes I described on #2522) and the 17 VRAM Lend commits.

My LLM helped me break out these data points for you. All on 2x RTX 3090 (one on a 6.1 GB/s link), Swift 1.5 IQ4_XS, vision on, through the server. The rows below were measured on v0.2.6. The re-test on 0.2.12 is after them.

Passed:

  • 8 GiB lend on each card while a request streams, 3 runs each: answered in 0.04 to 0.05 s, the process drops by exactly 8192 MiB, largest token gap 0.056 s
  • return: answered in 0.01 to 0.03 s, back to the same size, largest token gap 0.074 s
  • a lend on one card leaves the other card and the unused GPUs unchanged
  • lendable after a return equals lendable before, also for the full lendable
  • two leases on one card, lent A then B and returned A then B, each step matching the memory, over-lendable answers 409 with the max, a return while another process holds the memory answers 409 retry and keeps the lease, an engine restart drops the leases and old ids answer 404
  • 50 lend and return cycles of 2 to 8 GiB on alternating cards during streaming requests: no CUDA error, no non-finite warning, every answer correct
  • quality suite with 8 GiB lent on each card: coding 16/16, math 12/12
  • a lend sent during an 80K token prompt read is answered at the next chunk boundary, 7.7 to 10.9 s after it is sent, so the server's 30 s wait never runs out and the late-lease case does not happen on this engine (the server's give-back for it is covered by unit tests)
  • full lendable lent on the fast-link card: a 24K prompt reads at 0.985 to 0.997 of the rate with nothing lent
  • option off: same bench rows as v0.2.6 within 3%, the routes answer 501

Failed:

  • full lendable (12 GiB) lent on the 6.1 GB/s card: a 24K prompt reads at 0.69 to 0.73 of the normal rate against a 90% target. The lent experts are uploaded again for each prompt chunk over the slow link. I accept that as the link's cost for now. A link-aware cap on lendable would fix it. Not built.

Measured:

  • decode with 8 GiB lent: -6% on the fast-link card, -10 to -11% on the slow one

Not run:

  • HIP and SYCL builds (no toolchains here). The new VMM code sits behind the same guards as #533, and the server starts the SYCL engine without the flag.

Re-tested on 0.2.12 (Strata 0.2.12, engine 0.1.58, the branch above):

  • 8 GiB lend and return on each card through the server, with a chat while lent and after the return: every answer 200 and correct
  • lendable after the returns equals lendable before: 12288 MiB on the first card, 11776 MiB on the second
  • 0 CUDA errors and 0 non-finite warnings in the engine log
  • server unit tests: 1591 of 1592 pass, and the one failure (test_keepawake, a timing test) passes 3 of 3 runs alone, on this branch and on plain v0.2.12
  • not re-run on 0.2.12: the token gaps while streaming, the 50 cycles, the quality suite, the lend during an 80K prompt, the prefill and decode rows

System: Ubuntu 26.04.1, kernel 7.0, NVIDIA driver 615.71.10, CUDA 13.3, 2x RTX 3090 24 GB for Strata, 125 GB RAM.

Full results: https://github.com/TacoTakumi/vram-lend/blob/main/bench/results/strata.md

Is this something you would take in, and if so, in what shape? I can split it into smaller PRs (the segment-set unmap and map in ExpertCache first, then the lend lines, then the server routes), or keep it on the fork if it is out of scope.

What do you do today instead?

I unload the model when the other program needs the card, or I start Strata with a smaller cache for good. #533's VRAM command shrinks the cache between requests, but it waits for the running request and is not meant for a borrower that comes and goes while requests run.

Originally created by @TacoTakumi on GitHub (Oct 25, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4168 ### Area [Engine] ### What do you want to do? I run Strata on a layer split over two RTX 3090 cards, and other programs on the same box need GPU memory from time to time: an image model, a vision encoder, a training job. Today the only choices are to unload the model or to start it with less cache for good. I would like another program to borrow part of one card's expert cache while Strata keeps serving, and give it back when it is done. The contract is three HTTP routes on the server and three lines on the engine's stdin. It is written up as an engine-neutral spec, with a second engine (a GLM-5.3-Flash fork of Strata) already implementing it: - POST /vram/lend {"gpu": "<PCI address>", "mib": N} answers a lease id once the memory is free in the driver - POST /vram/return {"id": ...} gives it back - GET /vram/state lists lendable and lent per GPU and the open leases - Spec: https://github.com/TacoTakumi/vram-lend (docs/api.md, docs/engine-protocol.md, docs/implementing.md) On Strata it builds on #533's segmented expert cache and on #2522's per-GPU caches on a layer split. A lease takes whole 512 MiB segments from a band between the cache's floor and the prompt path's loan, so the prompt path never meets a hole. The segments chosen are the coldest by the expert profile. The lend is answered between decode windows, between prompt chunks and when idle, and the return refills the experts in the background. It is opt-in ("vram_lend": true, engine flag --vram-lend). With it on, the VRAM command, POST /v1/vram and the elastic image encoder are refused, and --pipeline-windows and --batch are turned off with one line each, because they keep work in flight with no safe point for an unmap. Branch: https://github.com/TacoTakumi/Strata/tree/vram-lend, now on v0.2.12. It has the 9 commits of #2522's current head (author kept, rebased onto v0.2.12, with the 4 fixes I described on #2522) and the 17 VRAM Lend commits. My LLM helped me break out these data points for you. All on 2x RTX 3090 (one on a 6.1 GB/s link), Swift 1.5 IQ4_XS, vision on, through the server. The rows below were measured on v0.2.6. The re-test on 0.2.12 is after them. Passed: - 8 GiB lend on each card while a request streams, 3 runs each: answered in 0.04 to 0.05 s, the process drops by exactly 8192 MiB, largest token gap 0.056 s - return: answered in 0.01 to 0.03 s, back to the same size, largest token gap 0.074 s - a lend on one card leaves the other card and the unused GPUs unchanged - lendable after a return equals lendable before, also for the full lendable - two leases on one card, lent A then B and returned A then B, each step matching the memory, over-lendable answers 409 with the max, a return while another process holds the memory answers 409 retry and keeps the lease, an engine restart drops the leases and old ids answer 404 - 50 lend and return cycles of 2 to 8 GiB on alternating cards during streaming requests: no CUDA error, no non-finite warning, every answer correct - quality suite with 8 GiB lent on each card: coding 16/16, math 12/12 - a lend sent during an 80K token prompt read is answered at the next chunk boundary, 7.7 to 10.9 s after it is sent, so the server's 30 s wait never runs out and the late-lease case does not happen on this engine (the server's give-back for it is covered by unit tests) - full lendable lent on the fast-link card: a 24K prompt reads at 0.985 to 0.997 of the rate with nothing lent - option off: same bench rows as v0.2.6 within 3%, the routes answer 501 Failed: - full lendable (12 GiB) lent on the 6.1 GB/s card: a 24K prompt reads at 0.69 to 0.73 of the normal rate against a 90% target. The lent experts are uploaded again for each prompt chunk over the slow link. I accept that as the link's cost for now. A link-aware cap on lendable would fix it. Not built. Measured: - decode with 8 GiB lent: -6% on the fast-link card, -10 to -11% on the slow one Not run: - HIP and SYCL builds (no toolchains here). The new VMM code sits behind the same guards as #533, and the server starts the SYCL engine without the flag. Re-tested on 0.2.12 (Strata 0.2.12, engine 0.1.58, the branch above): - 8 GiB lend and return on each card through the server, with a chat while lent and after the return: every answer 200 and correct - lendable after the returns equals lendable before: 12288 MiB on the first card, 11776 MiB on the second - 0 CUDA errors and 0 non-finite warnings in the engine log - server unit tests: 1591 of 1592 pass, and the one failure (test_keepawake, a timing test) passes 3 of 3 runs alone, on this branch and on plain v0.2.12 - not re-run on 0.2.12: the token gaps while streaming, the 50 cycles, the quality suite, the lend during an 80K prompt, the prefill and decode rows System: Ubuntu 26.04.1, kernel 7.0, NVIDIA driver 615.71.10, CUDA 13.3, 2x RTX 3090 24 GB for Strata, 125 GB RAM. Full results: https://github.com/TacoTakumi/vram-lend/blob/main/bench/results/strata.md Is this something you would take in, and if so, in what shape? I can split it into smaller PRs (the segment-set unmap and map in ExpertCache first, then the lend lines, then the server routes), or keep it on the fork if it is out of scope. ### What do you do today instead? I unload the model when the other program needs the card, or I start Strata with a smaller cache for good. #533's VRAM command shrinks the cache between requests, but it waits for the running request and is not meant for a borrower that comes and goes while requests run.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6660101500 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Author
Owner

@TacoTakumi commented on GitHub (Nov 7, 2026):

/reopen

I rebased the branch onto 0.2.12 and re-ran the lend smoke and the unit tests on it. The issue body has the results and says what I did not re-run.

<!-- gh-comment-id:6707032641 --> @TacoTakumi commented on GitHub (Nov 7, 2026): /reopen I rebased the branch onto 0.2.12 and re-ran the lend smoke and the unit tests on it. The issue body has the results and says what I did not re-run.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 7, 2026):

Reopened, thank you. A maintainer will pick it up from here.

<!-- gh-comment-id:6707034195 --> @github-actions[bot] commented on GitHub (Nov 7, 2026): Reopened, thank you. A maintainer will pick it up from here.
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#1827
No description provided.