[PR #1517] [CLOSED] Adaptive tier: evictions reach the device's residency table before the next window when the tier does not wait (fix) #3504

Closed
opened 2026-11-07 14:41:57 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1517
Author: @sergqwer
Created: 10/8/2026
Status: ❌ Closed

Base: main ← Head: pr/tier-evict-sync


📝 Commits (1)

  • eb47960 decode: the adaptive tier's evictions reach the device's residency table before the next window when the tier does not wait (STRATA_ADAPT_NOWAIT=1, STRATA_ADAPT_LAG > 1)

📊 Changes

7 files changed (+292 additions, -9 deletions)

View changed files

📝 include/strata/core/expert_source.hpp (+12 -0)
📝 include/strata/core/verify.hpp (+12 -2)
📝 include/strata/kernels/verify_kernels.hpp (+3 -0)
📝 src/core/expert_source.cpp (+7 -0)
📝 src/core/verify.cpp (+4 -0)
📝 src/kernels/cuda/verify_kernels.cu (+10 -0)
📝 src/program/generate.cpp (+244 -7)

📄 Description

When the adaptive tier does not wait for its copies (STRATA_ADAPT_NOWAIT=1, or STRATA_ADAPT_LAG > 1), the CPU can compute an evicted expert from a stale activation.

The bug, as the code runs it:

  • adapt() marks an evicted expert non-resident in host_res at once.
  • d_res follows in apply_pending, once the round's copies have landed. Without the wait, the next window runs before that.
  • doorbell_publish_res reads d_res and sees the evicted expert as still resident. When every routed expert of a layer looks resident, it does not publish the layer's activation.
  • The pool plans from host_res, so it computes the evicted expert on the CPU, from the activation published for an earlier layer or window.

Measured with a new check, STRATA_ADAPT_CHECKRES=1. Before each window it reads the device tables back, compares them with host_res, and counts the layer-windows that computed a CPU expert with no activation published. RTX 5090, IQ2_XS, --expert-cache 12000, 32K explain prompt, 600 tokens:

tier mode windows with mismatched tables layer-windows with no activation published
STRATA_ADAPT_NOWAIT=1 34 of 222 (2,470 entries) 1
STRATA_ADAPT_NOWAIT=1, this PR 0 of 223 0
STRATA_ADAPT_LAG=2 55 of 223 (3,222 entries: every swap) 5
STRATA_ADAPT_LAG=2, this PR 0 of 218 0

LAG=2 is reproducible: two runs of each arm give the same tokens. The fix changes its answer from token 228 on.

The change:

  • Every verifier launch (run, run_slot_rows, batch_launch, pl_launch; a layer split's stages too) runs a pre-launch hook. The hook patches the device tables from a list of the changed entries (res_patch, a small kernel on the verifier's stream that reads mapped memory). The whole table is uploaded instead when the list overflows, or when a device does not map it at the host's address.
  • A failed whole-table upload in apply_pending leaves its entries to the hook. A failed patch fails the window instead of launching with stale tables.
  • It applies only where the tier does not wait.
  • --batch-groups with a layer split publishes every activation instead (set_always_publish, which now also turns E-6's device plan off). --pipeline-windows keeps its fence.
  • STRATA_ADAPT_EVICT_SYNC=0 restores the old behaviour.

Default identity: with the default (the tier waits) no hook is installed. Tokens and first-token logits are identical to d5ea7133 (p2k, 200 tokens; 32K explain, 600 tokens; --expert-cache 12000 --pcie-frac 0.25).

Cost under STRATA_ADAPT_NOWAIT=1, 6,297 slots, 3 interleaved pairs: ms a round -1.1% (chat) and -1.2% (32K explain), i.e. noise.

Not measured: multi-GPU layer split and peer / helper tiers (one card here; the hook runs per stage and per device, and each device's mapped alias is checked).

Found while working on an opt-in that admits the PCIe share's blobs into the VRAM tier: STRATA_ADAPT_FETCH, branch pr-main/tier-fetch-admission. It builds on this fix and will follow as its own PR. On IQ2_XS with a 6,000-slot cache it measured chat +8% and 32K +4% decode.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio


🔄 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/1517 **Author:** [@sergqwer](https://github.com/sergqwer) **Created:** 10/8/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/tier-evict-sync` --- ### 📝 Commits (1) - [`eb47960`](https://github.com/Niko1221/Strata/commit/eb479604517481d0392e8d64c8c50da7dea216c9) decode: the adaptive tier's evictions reach the device's residency table before the next window when the tier does not wait (STRATA_ADAPT_NOWAIT=1, STRATA_ADAPT_LAG > 1) ### 📊 Changes **7 files changed** (+292 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/expert_source.hpp` (+12 -0) 📝 `include/strata/core/verify.hpp` (+12 -2) 📝 `include/strata/kernels/verify_kernels.hpp` (+3 -0) 📝 `src/core/expert_source.cpp` (+7 -0) 📝 `src/core/verify.cpp` (+4 -0) 📝 `src/kernels/cuda/verify_kernels.cu` (+10 -0) 📝 `src/program/generate.cpp` (+244 -7) </details> ### 📄 Description When the adaptive tier does not wait for its copies (`STRATA_ADAPT_NOWAIT=1`, or `STRATA_ADAPT_LAG` > 1), the CPU can compute an evicted expert from a stale activation. **The bug, as the code runs it:** - `adapt()` marks an evicted expert non-resident in `host_res` at once. - `d_res` follows in `apply_pending`, once the round's copies have landed. Without the wait, the next window runs before that. - `doorbell_publish_res` reads `d_res` and sees the evicted expert as still resident. When every routed expert of a layer looks resident, it does not publish the layer's activation. - The pool plans from `host_res`, so it computes the evicted expert on the CPU, from the activation published for an earlier layer or window. **Measured** with a new check, `STRATA_ADAPT_CHECKRES=1`. Before each window it reads the device tables back, compares them with `host_res`, and counts the layer-windows that computed a CPU expert with no activation published. RTX 5090, IQ2_XS, `--expert-cache 12000`, 32K explain prompt, 600 tokens: | tier mode | windows with mismatched tables | layer-windows with no activation published | |---|---|---| | `STRATA_ADAPT_NOWAIT=1` | 34 of 222 (2,470 entries) | 1 | | `STRATA_ADAPT_NOWAIT=1`, this PR | 0 of 223 | 0 | | `STRATA_ADAPT_LAG=2` | 55 of 223 (3,222 entries: every swap) | 5 | | `STRATA_ADAPT_LAG=2`, this PR | 0 of 218 | 0 | `LAG=2` is reproducible: two runs of each arm give the same tokens. The fix changes its answer from token 228 on. **The change:** - Every verifier launch (`run`, `run_slot_rows`, `batch_launch`, `pl_launch`; a layer split's stages too) runs a pre-launch hook. The hook patches the device tables from a list of the changed entries (`res_patch`, a small kernel on the verifier's stream that reads mapped memory). The whole table is uploaded instead when the list overflows, or when a device does not map it at the host's address. - A failed whole-table upload in `apply_pending` leaves its entries to the hook. A failed patch fails the window instead of launching with stale tables. - It applies only where the tier does not wait. - `--batch-groups` with a layer split publishes every activation instead (`set_always_publish`, which now also turns E-6's device plan off). `--pipeline-windows` keeps its fence. - `STRATA_ADAPT_EVICT_SYNC=0` restores the old behaviour. **Default identity:** with the default (the tier waits) no hook is installed. Tokens and first-token logits are identical to d5ea7133 (p2k, 200 tokens; 32K explain, 600 tokens; `--expert-cache 12000 --pcie-frac 0.25`). **Cost** under `STRATA_ADAPT_NOWAIT=1`, 6,297 slots, 3 interleaved pairs: ms a round -1.1% (chat) and -1.2% (32K explain), i.e. noise. **Not measured:** multi-GPU layer split and peer / helper tiers (one card here; the hook runs per stage and per device, and each device's mapped alias is checked). Found while working on an opt-in that admits the PCIe share's blobs into the VRAM tier: `STRATA_ADAPT_FETCH`, branch `pr-main/tier-fetch-admission`. It builds on this fix and will follow as its own PR. On IQ2_XS with a 6,000-slot cache it measured chat +8% and 32K +4% decode. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:41:57 +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#3504
No description provided.