[PR #4844] [CLOSED] [Engine] fix lost experts when an adaptive round ends after the pipelined loop #5208

Closed
opened 2026-11-07 16:33:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4844
Author: @uvlad23
Created: 10/31/2026
Status: ❌ Closed

Base: main ← Head: fix-adaptive-round-after-pipeline-drain


📝 Commits (1)

  • 7faa5b9 Adaptive tier: mark a round's experts when it ends after the pipelined loop

📊 Changes

1 file changed (+4 additions, -0 deletions)

View changed files

📝 src/program/generate.cpp (+4 -0)

📄 Description

Problem and result

With --pipeline-windows 2 and --adapt-async 1 on a layer split, in the resident RAM mode, the engine slowly loses experts. A lost expert is in neither the GPU cache nor the RAM copy, so decode reads it from the GGUF. A fresh engine never does that.

On my machine this took decode from about 60 to about 40 tok/s over 4.5 days of agent use.

How it happens:

  1. An adaptive round starts during a pipelined decode.
  2. The reply ends before the round is done. Short replies make this common.
  3. The next request finishes the round in the serial path.
  4. The serial path marks the new experts as resident using a_lo/a_hi. The pipelined path never set them, so they still hold an older round's values.
  5. Step 4 gives each new expert's RAM place to the expert it replaced. Any new expert that was not marked is now lost.

The old range can also run past the end of aswaps.

The fix: the pipelined path sets a_lo = 0 and a_hi = a_bi = aswaps.size(), so the serial path marks exactly this round.

none

Approach

Two lines and a comment in the pipelined branch of step 2 (AState::CopyBack). A round that ends inside the pipelined loop works as before, because that path does not read a_lo/a_hi. The serial path and the arena are unchanged.

I did not compare tokens, because the adaptive tier is not bit-exact between runs (docs/DETAILS.md).

Validation

Setup: RTX 4070 12 GB + Tesla V100 32 GB, layer split 14, 64 GB RAM, Debian 13, driver 580. Qwen3.8-Flash-Next Q5_K_S with --resident-experts --resident-budget-gib 48 --pipeline-windows 2 --adapt-async 1 --spec 3.

Test: a scripted chat through the API with short replies (30 to 70 tokens), long prompts (up to 150K tokens) and conversation switches. Every 10 turns, a probe turn with a tiny prompt checks the blob reads from the file counter. On a fresh engine the probe reads 0. A debug build (not part of this PR) also counted lost experts after every round.

Passed:

  • Debug build of 0.2.6 without the fix: the first loss came on the 4th turn. One round lost 22 experts, and the experts in VRAM went from 10620 to 10597. Later probes read 6 to 19 blobs from the file.
  • Debug build of 0.2.6 with the fix: 28 rounds ended after the pipelined loop in 23 minutes. No expert was lost, and every probe read 0. Without the fix, 9 of those rounds would have read past the end of aswaps.
  • This branch (main c62d5e3) for CUDA: generate.cpp compiles with no errors and no new warnings.

Failed:

  • none observed

Not run:

  • HIP build. I have no HIP setup, so this stays a draft. Could someone build it for HIP?
  • Full link of this branch. The test machine was serving, and the last CUDA files ran out of RAM. The hardware runs above used 0.2.6 with the same two lines.
  • One-card setups, the arena, Windows. No speed claim.
Debug log without the fix: the round that lost 22 experts
LEAKDIAG request start: orphans 0 (was -1), dups 847, in VRAM 10620
LEAKDIAG swap: layer 8 in 279 out 199 slot 211 home 0 exchange 1 -> in vram 0 ram 0 (host_res -1), out vram 0 ram 1
... (21 more like this)
LEAKDIAG round committed: orphans 22 (was 0), dups 846, in VRAM 10597

Limits

  • An engine that has already lost experts needs a restart to get them back.
  • I did not check the arena with STRATA_ADAPT_ASYNC_BATCH.

🔄 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/4844 **Author:** [@uvlad23](https://github.com/uvlad23) **Created:** 10/31/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-adaptive-round-after-pipeline-drain` --- ### 📝 Commits (1) - [`7faa5b9`](https://github.com/Niko1221/Strata/commit/7faa5b9899532f9d1b8e43d48ccce6637f128941) Adaptive tier: mark a round's experts when it ends after the pipelined loop ### 📊 Changes **1 file changed** (+4 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/program/generate.cpp` (+4 -0) </details> ### 📄 Description ## Problem and result With `--pipeline-windows 2` and `--adapt-async 1` on a layer split, in the resident RAM mode, the engine slowly loses experts. A lost expert is in neither the GPU cache nor the RAM copy, so decode reads it from the GGUF. A fresh engine never does that. On my machine this took decode from about 60 to about 40 tok/s over 4.5 days of agent use. How it happens: 1. An adaptive round starts during a pipelined decode. 2. The reply ends before the round is done. Short replies make this common. 3. The next request finishes the round in the serial path. 4. The serial path marks the new experts as resident using `a_lo`/`a_hi`. The pipelined path never set them, so they still hold an older round's values. 5. Step 4 gives each new expert's RAM place to the expert it replaced. Any new expert that was not marked is now lost. The old range can also run past the end of `aswaps`. The fix: the pipelined path sets `a_lo = 0` and `a_hi = a_bi = aswaps.size()`, so the serial path marks exactly this round. ## Related discussion none ## Approach Two lines and a comment in the pipelined branch of step 2 (`AState::CopyBack`). A round that ends inside the pipelined loop works as before, because that path does not read `a_lo`/`a_hi`. The serial path and the arena are unchanged. I did not compare tokens, because the adaptive tier is not bit-exact between runs (docs/DETAILS.md). ## Validation Setup: RTX 4070 12 GB + Tesla V100 32 GB, layer split 14, 64 GB RAM, Debian 13, driver 580. Qwen3.8-Flash-Next Q5_K_S with `--resident-experts --resident-budget-gib 48 --pipeline-windows 2 --adapt-async 1 --spec 3`. Test: a scripted chat through the API with short replies (30 to 70 tokens), long prompts (up to 150K tokens) and conversation switches. Every 10 turns, a probe turn with a tiny prompt checks the `blob reads from the file` counter. On a fresh engine the probe reads 0. A debug build (not part of this PR) also counted lost experts after every round. **Passed:** - Debug build of 0.2.6 without the fix: the first loss came on the 4th turn. One round lost 22 experts, and the experts in VRAM went from 10620 to 10597. Later probes read 6 to 19 blobs from the file. - Debug build of 0.2.6 with the fix: 28 rounds ended after the pipelined loop in 23 minutes. No expert was lost, and every probe read 0. Without the fix, 9 of those rounds would have read past the end of `aswaps`. - This branch (main c62d5e3) for CUDA: `generate.cpp` compiles with no errors and no new warnings. **Failed:** - none observed **Not run:** - HIP build. I have no HIP setup, so this stays a draft. Could someone build it for HIP? - Full link of this branch. The test machine was serving, and the last CUDA files ran out of RAM. The hardware runs above used 0.2.6 with the same two lines. - One-card setups, the arena, Windows. No speed claim. <details><summary>Debug log without the fix: the round that lost 22 experts</summary> ``` LEAKDIAG request start: orphans 0 (was -1), dups 847, in VRAM 10620 LEAKDIAG swap: layer 8 in 279 out 199 slot 211 home 0 exchange 1 -> in vram 0 ram 0 (host_res -1), out vram 0 ram 1 ... (21 more like this) LEAKDIAG round committed: orphans 22 (was 0), dups 846, in VRAM 10597 ``` </details> ## Limits - An engine that has already lost experts needs a restart to get them back. - I did not check the arena with `STRATA_ADAPT_ASYNC_BATCH`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:33:29 +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#5208
No description provided.