[GH-ISSUE #5126] [Engine] dsv41: layer-major prompt runs can take a unified-memory PC down to 8 GiB free on a long cold prompt #2398

Open
opened 2026-11-04 01:58:58 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @xaler5 on GitHub (Nov 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5126

Area

[Engine] (speed, kernels, models, the server and API)

Desktop app, Terminal or source?

Docker

What happened

An agent client (Hermes) sends a long conversation. When the engine has to read it cold (a fresh engine, or a conversation that no longer matches the state), MemAvailable drops by 5 to 9 GiB within seconds of the start of the read:

Read MemAvailable during the read
Cold 42k prompt flat, about 17 GiB
Cold 72k prompt 13.4 GiB, then 9.2 GiB
Cold 100k prompt 13.6 GiB, then 7 GiB
Same conversation grown 42k to 138k, 8k new tokens a turn flat, about 16.5 GiB
Cold 100k prompt with DS4_LAYER_MAJOR=0 flat, about 17 GiB, 605 tok/s

The engine's RssShmem grows by about 6 GB on the cold 72k read and stays flat when layer-major is off.

Where it comes from
In lm_begin (ds4_model.cu), a run of several chunks goes layer-major. It then:

  • pins the state of every chunk of the run in host memory (run.T.size() * chunk_hand_bytes(), roughly 70 to 95 KB per prompt token). This size is not checked against the RAM free, so it grows with the prompt and would not fit at all near 1M tokens;
  • sizes the layer cache to leave only kRamMargin (8 GiB) free beside that state.

On a unified-memory machine that also runs a desktop, 8 GiB free is very little. With layer-major off, the 100k cold read still runs at 605 tok/s here, in line with the ~586 tok/s we measured on a 143k prompt earlier. Most experts are already on the GPU and the rest stream from two NVMe drives, which may be why layer-major gains nothing on this machine.

We now run with DS4_LAYER_MAJOR=0.

Smallest steps or command that reproduce it

  1. Start the server with the settings below.
  2. Send a 72k or 100k token conversation that the engine has to read cold (a fresh engine, or a conversation that no longer matches the cached state).
  3. Watch MemAvailable during the first seconds of the read: it drops by 5 to 9 GiB.
  4. Restart with DS4_LAYER_MAJOR=0 and send the same prompt: MemAvailable stays flat.

Reproduction status

Reproduced locally

Strata version

Strata 0.2.9, strata-dsv41 branch, built from source into a local Docker image

Graphics card, memory and system

AMD Strix Halo (gfx1151, HIP build), 128 GB unified memory, Linux. An external watchdog stops the server when MemAvailable falls under 10 GiB.

Model, size and settings

DeepSeek-V4.1-Flash UD-Q2_K_XL pack, --serve --vision on --max-context 1048576 --prefill-chunk 8192 --ssd-cache 6 --dspark on --experts 6, GPU budget 85 GB.

Logs

No response

Originally created by @xaler5 on GitHub (Nov 3, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5126 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Docker ### What happened An agent client (Hermes) sends a long conversation. When the engine has to read it cold (a fresh engine, or a conversation that no longer matches the state), MemAvailable drops by 5 to 9 GiB within seconds of the start of the read: | Read | MemAvailable during the read | |---|---| | Cold 42k prompt | flat, about 17 GiB | | Cold 72k prompt | 13.4 GiB, then 9.2 GiB | | Cold 100k prompt | 13.6 GiB, then 7 GiB | | Same conversation grown 42k to 138k, 8k new tokens a turn | flat, about 16.5 GiB | | Cold 100k prompt with `DS4_LAYER_MAJOR=0` | flat, about 17 GiB, 605 tok/s | The engine's RssShmem grows by about 6 GB on the cold 72k read and stays flat when layer-major is off. **Where it comes from** In `lm_begin` (ds4_model.cu), a run of several chunks goes layer-major. It then: - pins the state of every chunk of the run in host memory (`run.T.size() * chunk_hand_bytes()`, roughly 70 to 95 KB per prompt token). This size is not checked against the RAM free, so it grows with the prompt and would not fit at all near 1M tokens; - sizes the layer cache to leave only `kRamMargin` (8 GiB) free beside that state. On a unified-memory machine that also runs a desktop, 8 GiB free is very little. With layer-major off, the 100k cold read still runs at 605 tok/s here, in line with the ~586 tok/s we measured on a 143k prompt earlier. Most experts are already on the GPU and the rest stream from two NVMe drives, which may be why layer-major gains nothing on this machine. We now run with `DS4_LAYER_MAJOR=0`. ### Smallest steps or command that reproduce it 1. Start the server with the settings below. 2. Send a 72k or 100k token conversation that the engine has to read cold (a fresh engine, or a conversation that no longer matches the cached state). 3. Watch MemAvailable during the first seconds of the read: it drops by 5 to 9 GiB. 4. Restart with `DS4_LAYER_MAJOR=0` and send the same prompt: MemAvailable stays flat. ### Reproduction status Reproduced locally ### Strata version Strata 0.2.9, strata-dsv41 branch, built from source into a local Docker image ### Graphics card, memory and system AMD Strix Halo (gfx1151, HIP build), 128 GB unified memory, Linux. An external watchdog stops the server when MemAvailable falls under 10 GiB. ### Model, size and settings DeepSeek-V4.1-Flash UD-Q2_K_XL pack, `--serve --vision on --max-context 1048576 --prefill-chunk 8192 --ssd-cache 6 --dspark on --experts 6`, GPU budget 85 GB. ### Logs _No response_
Author
Owner

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

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6606898762 --> @github-actions[bot] commented on GitHub (Nov 3, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
bsakaguchi changed title from [GH-ISSUE #5126] dsv41: layer-major prompt runs can take a unified-memory PC down to 8 GiB free on a long cold prompt to [GH-ISSUE #5126] [Engine] dsv41: layer-major prompt runs can take a unified-memory PC down to 8 GiB free on a long cold prompt 2026-11-07 14:37:39 +07:00
Author
Owner

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

Thanks, this follows the format now.

<!-- gh-comment-id:6668450979 --> @github-actions[bot] commented on GitHub (Nov 5, 2026): Thanks, this follows the format now.
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#2398
No description provided.