[PR #3761] [Engine] sycl: opt-in STRATA_MIRROR_DROP_CACHE=before for the --stream-experts mirror (#3681) #4770

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3761
Author: @phg1024
Created: 10/22/2026
Status: 🔄 Open

Base: main ← Head: sycl-mirror-drop-cache


📝 Commits (1)

  • bbdbe45 [Engine] sycl: opt-in STRATA_MIRROR_DROP_CACHE=before for the --stream-experts mirror (#3681)

📊 Changes

2 files changed (+45 additions, -0 deletions)

View changed files

📝 docs/INTEL.md (+18 -0)
📝 sycl/src/core/gguf_expert_source.cpp (+27 -0)

📄 Description

Problem and result

With --stream-experts, GgufExpertSource::mirror() pins the experts that miss VRAM in 2 GiB sycl::malloc_host chunks. Each chunk is one system-memory BO that the xe driver backs as it likes. The engine's start-up reads (weights, the VRAM expert fill) leave the GGUFs in the page cache, so on a host whose RAM is close to the model's size the chunks are allocated under reclaim. MemFree at that point was 0.7–0.9 GiB on every restart below, while the mirror needs 25.7 GiB.

On an Arc Pro B70, chunks allocated that way are read by the GPU at 55–85% of the bandwidth of chunks taken from free memory. CPU reads of the same chunks are unaffected. As a result, decode after a restart depends on what the page cache held. The details and microbenchmarks are in #3681.

  • Before: restarts decoded at 37.5–41.4 tok/s; first starts after a page-cache drop at 42.5–43.0.
  • After, with STRATA_MIRROR_DROP_CACHE=before: restarts decoded at 42.4–44.5 tok/s; first starts at 44.1–44.5. The mirror fill takes about 1 s longer (14.2–14.4 s against 13.2–13.4 s), because it now reads from NVMe.

#3681 (the report, the microbenchmarks and the engine A/B). There is no maintainer reply yet. The change is opt-in and confined to one function, so I am opening it as a focused fix; it is a draft until it gets a look.

Approach

  • STRATA_MIRROR_DROP_CACHE=before runs posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED) on the source's GGUF descriptors right before the chunks are allocated. The chunks then come from free memory instead of reclaim. It prints one line: mirror: STRATA_MIRROR_DROP_CACHE=before: MemFree X -> Y GiB (the mirror needs Z GiB).
  • It is off by default, and Linux only (#if !defined(_WIN32)). Without the variable, the default path executes no new code.
  • Why before and not after: dropping the mirrored ranges after the fill (my first attempt) was slower than off on restarts, 27.6–30.3 against 35.5–38.9 tok/s in two ABBA blocks (#3681). The variable therefore takes only before.
  • The mirror's own reads that follow come from the disk. They are 25.7 GiB here and cost about +1 s on NVMe. A slow disk would pay more, which is one reason this stays opt-in.
  • docs/INTEL.md has a short section with the numbers.

Validation

Passed:

  • Build: SYCL AOT, revision 011c9e6 plus this commit (its sycl/ tree is byte-identical to the one built; the docs were edited after the build). Configured with cmake -S sycl -B build -DCMAKE_BUILD_TYPE=Release -DSTRATA_SYCL_AOT=bmg-g31 -DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_Q6K_EXPERTS=ON -DSTRATA_SYCL_PARITY=ON, oneAPI 2026.1 (icpx), compute-runtime 26.31.39395.16 / IGC 2.40.16. Result: 0 errors, no warnings in gguf_expert_source.cpp.

  • Hardware: Arc Pro B70 32 GB at PCIe 4.0 x16 (0 AER during the runs), i7-12700K, 61 GiB RAM, Ubuntu 26.04, kernel 7.0.0-38 (xe).

  • Model and flags: Flash-Next IQ3_S native pack, --stream-experts --expert-cache auto --vram-reserve-mib 2048 --kv int8 --kv-resident 32768 --max-context 262144 --spec 4 --spec-min-p 0.5 --mtp ... --prefill 8192, STRATA_VERIFY_DEVICE_PLAN=1 STRATA_VERIFY_NO_HOST=1. The mirror holds 13,446 experts (25.71 GiB).

  • A/B, this build: blocks off, before, before, off. Each block drops the model files' page cache (posix_fadvise from a script), then makes 4 consecutive server starts with an unrelated 22 GB file read (cat file > /dev/null) between starts. Each start runs the repo's needle benchmark at 2K and 32K prompts, 512 tokens, temperature 0. Decode in tok/s as 2K / 32K:

    start off (block 1, block 4) before (block 2, block 3)
    1 42.5/42.9, 42.6/43.0 44.2/44.5, 44.1/44.5
    2 39.3/40.2, 41.0/41.4 42.4/42.5, 44.2/44.5
    3 38.6/39.4, 37.6/38.2 43.1/43.4, 44.2/44.5
    4 38.8/39.7, 37.5/38.2 43.1/43.3, 43.7/44.0
    • With before, MemFree went from 22.0 to 49.9 GiB at first starts and from 0.7–0.9 to 28.8–28.9 GiB at restarts.
    • Needles: 32/32. The answer texts are byte-identical across all 16 runs at each length, both arms included.
    • Mirror fill: off 13.2–13.4 s; before 14.2–14.4 s.
  • Earlier runs:

    • A measurement build whose before branch is the same code: 24 starts (off/before/both ×2), with every before start at 44.1–44.5 tok/s.
    • A 5-hour soak on a live service with 170 requests and 6 random restarts: 0 errors, and a 2K probe at 58.0–59.5 tok/s throughout. That soak had no control arm.

Failed: none observed.

Not run:

  • CUDA, HIP and Metal builds. The file is sycl/src/core/gguf_expert_source.cpp, which only the SYCL engine compiles.
  • A Windows build. The code is under #if !defined(_WIN32); the default path there is unchanged but not compiled here.
  • The SYCL ctest parity suite. No kernel or numeric code changed, and the outputs above are byte-identical across arms, but the suite itself was not run.
  • Other Intel cards (A-series, B60/B65) and other hosts. Single box only.

Limits

  • The variable only drops the page cache of the engine's own GGUFs. Page cache held by other processes still forces reclaim, and needs root-side compaction or something else.
  • I have not determined whether the GPU-side cost of reclaimed chunks comes from IOMMU translation (the host runs DMA-FQ) or from the GPU's page-table granularity on small pages. iommu=pt is untested.
  • Making this the default would need data from other hosts and disks. The +1 s fill on NVMe could be much larger on a SATA SSD or an HDD.

🤖 Generated with Claude Code


🔄 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/3761 **Author:** [@phg1024](https://github.com/phg1024) **Created:** 10/22/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `sycl-mirror-drop-cache` --- ### 📝 Commits (1) - [`bbdbe45`](https://github.com/Niko1221/Strata/commit/bbdbe456101e1b5bb7231e5d864289b05f435e2f) [Engine] sycl: opt-in STRATA_MIRROR_DROP_CACHE=before for the --stream-experts mirror (#3681) ### 📊 Changes **2 files changed** (+45 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/INTEL.md` (+18 -0) 📝 `sycl/src/core/gguf_expert_source.cpp` (+27 -0) </details> ### 📄 Description ## Problem and result With `--stream-experts`, `GgufExpertSource::mirror()` pins the experts that miss VRAM in 2 GiB `sycl::malloc_host` chunks. Each chunk is one system-memory BO that the `xe` driver backs as it likes. The engine's start-up reads (weights, the VRAM expert fill) leave the GGUFs in the page cache, so on a host whose RAM is close to the model's size the chunks are allocated **under reclaim**. MemFree at that point was 0.7–0.9 GiB on every restart below, while the mirror needs 25.7 GiB. On an Arc Pro B70, chunks allocated that way are read by the GPU at 55–85% of the bandwidth of chunks taken from free memory. CPU reads of the same chunks are unaffected. As a result, decode after a restart depends on what the page cache held. The details and microbenchmarks are in #3681. - **Before:** restarts decoded at 37.5–41.4 tok/s; first starts after a page-cache drop at 42.5–43.0. - **After, with `STRATA_MIRROR_DROP_CACHE=before`:** restarts decoded at 42.4–44.5 tok/s; first starts at 44.1–44.5. The mirror fill takes about 1 s longer (14.2–14.4 s against 13.2–13.4 s), because it now reads from NVMe. ## Related discussion #3681 (the report, the microbenchmarks and the engine A/B). There is no maintainer reply yet. The change is opt-in and confined to one function, so I am opening it as a focused fix; it is a draft until it gets a look. ## Approach - `STRATA_MIRROR_DROP_CACHE=before` runs `posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED)` on the source's GGUF descriptors right before the chunks are allocated. The chunks then come from free memory instead of reclaim. It prints one line: `mirror: STRATA_MIRROR_DROP_CACHE=before: MemFree X -> Y GiB (the mirror needs Z GiB)`. - It is off by default, and Linux only (`#if !defined(_WIN32)`). Without the variable, the default path executes no new code. - **Why before and not after:** dropping the mirrored ranges *after* the fill (my first attempt) was slower than off on restarts, 27.6–30.3 against 35.5–38.9 tok/s in two ABBA blocks (#3681). The variable therefore takes only `before`. - The mirror's own reads that follow come from the disk. They are 25.7 GiB here and cost about +1 s on NVMe. A slow disk would pay more, which is one reason this stays opt-in. - `docs/INTEL.md` has a short section with the numbers. ## Validation **Passed:** - **Build:** SYCL AOT, revision `011c9e6` plus this commit (its `sycl/` tree is byte-identical to the one built; the docs were edited after the build). Configured with `cmake -S sycl -B build -DCMAKE_BUILD_TYPE=Release -DSTRATA_SYCL_AOT=bmg-g31 -DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_Q6K_EXPERTS=ON -DSTRATA_SYCL_PARITY=ON`, oneAPI 2026.1 (icpx), compute-runtime 26.31.39395.16 / IGC 2.40.16. Result: 0 errors, no warnings in `gguf_expert_source.cpp`. - **Hardware:** Arc Pro B70 32 GB at PCIe 4.0 x16 (0 AER during the runs), i7-12700K, 61 GiB RAM, Ubuntu 26.04, kernel 7.0.0-38 (`xe`). - **Model and flags:** Flash-Next IQ3_S native pack, `--stream-experts --expert-cache auto --vram-reserve-mib 2048 --kv int8 --kv-resident 32768 --max-context 262144 --spec 4 --spec-min-p 0.5 --mtp ... --prefill 8192`, `STRATA_VERIFY_DEVICE_PLAN=1 STRATA_VERIFY_NO_HOST=1`. The mirror holds 13,446 experts (25.71 GiB). - **A/B, this build:** blocks `off, before, before, off`. Each block drops the model files' page cache (`posix_fadvise` from a script), then makes 4 consecutive server starts with an unrelated 22 GB file read (`cat file > /dev/null`) between starts. Each start runs the repo's needle benchmark at 2K and 32K prompts, 512 tokens, temperature 0. Decode in tok/s as 2K / 32K: | start | off (block 1, block 4) | before (block 2, block 3) | |---|---|---| | 1 | 42.5/42.9, 42.6/43.0 | 44.2/44.5, 44.1/44.5 | | 2 | 39.3/40.2, 41.0/41.4 | 42.4/42.5, 44.2/44.5 | | 3 | 38.6/39.4, 37.6/38.2 | 43.1/43.4, 44.2/44.5 | | 4 | 38.8/39.7, 37.5/38.2 | 43.1/43.3, 43.7/44.0 | - With `before`, MemFree went from 22.0 to 49.9 GiB at first starts and from 0.7–0.9 to 28.8–28.9 GiB at restarts. - Needles: 32/32. The answer texts are **byte-identical across all 16 runs** at each length, both arms included. - Mirror fill: off 13.2–13.4 s; before 14.2–14.4 s. - **Earlier runs:** - A measurement build whose `before` branch is the same code: 24 starts (`off/before/both` ×2), with every `before` start at 44.1–44.5 tok/s. - A 5-hour soak on a live service with 170 requests and 6 random restarts: 0 errors, and a 2K probe at 58.0–59.5 tok/s throughout. That soak had no control arm. **Failed:** none observed. **Not run:** - CUDA, HIP and Metal builds. The file is `sycl/src/core/gguf_expert_source.cpp`, which only the SYCL engine compiles. - A Windows build. The code is under `#if !defined(_WIN32)`; the default path there is unchanged but not compiled here. - The SYCL ctest parity suite. No kernel or numeric code changed, and the outputs above are byte-identical across arms, but the suite itself was not run. - Other Intel cards (A-series, B60/B65) and other hosts. Single box only. ## Limits - The variable only drops the page cache of the engine's own GGUFs. Page cache held by other processes still forces reclaim, and needs root-side compaction or something else. - I have not determined whether the GPU-side cost of reclaimed chunks comes from IOMMU translation (the host runs `DMA-FQ`) or from the GPU's page-table granularity on small pages. `iommu=pt` is untested. - Making this the default would need data from other hosts and disks. The +1 s fill on NVMe could be much larger on a SATA SSD or an HDD. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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#4770
No description provided.