mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3624] [Engine] Linux: read the experts from the GGUF with O_DIRECT under STRATA_UNBUFFERED_LOAD=1 #4721
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4721
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3624
Author: @akivajp
Created: 10/21/2026
Status: 🔄 Open
Base:
main← Head:linux-odirect-gguf-load📝 Commits (1)
c947561[Engine] Linux: read the experts from the GGUF with O_DIRECT under STRATA_UNBUFFERED_LOAD=1📊 Changes
1 file changed (+104 additions, -0 deletions)
View changed files
📝
src/core/expert_source.cpp(+104 -0)📄 Description
Problem and result
On Linux,
load_experts_ggufalways reads through the page cache: itfreads into a buffer, thenmemcpys. The Windows branch has an unbuffered reader (FILE_FLAG_NO_BUFFERING), but Linux has no equivalent. There,STRATA_UNBUFFERED_LOAD=1only raises the reader count to 16, and the load still runs at the page-cache path's speed.On a 3-drive NVMe RAID0 that reads 18.8 GB/s, the expert load holds at ~5.7 GiB/s whatever the reader count. With this change and
STRATA_UNBUFFERED_LOAD=1, it reads at ~12.0 GiB/s and the server is ready ~4 s sooner. The default path is unchanged.Related discussion
None: the change is opt-in and leaves the default alone. Related: #3237 (the Linux file tier's choice between the file cache and unbuffered reads).
Approach
A Linux branch that mirrors the Windows one: the same 16-expert reads into a sector-aligned buffer and the same per-expert copies, with
O_DIRECTin place ofFILE_FLAG_NO_BUFFERING. It handles short reads andEINTR. If the first shard cannot be opened withO_DIRECT, it logs this and falls back to the buffered readers.It runs only when
experts_unbuffered()returns true, which on Linux happens only throughSTRATA_UNBUFFERED_LOAD=1. The buffered code is not touched, and macOS is not affected (#elif defined(__linux__)).Validation
Revision
c947561c(on011c9e60).Passed:
Build:
docker build --build-arg CUDA_ARCHITECTURES=89 --build-arg BUILD_VISION=0 --build-arg STRATA_COMMIT=<sha> ., with no warnings inexpert_source.cpp. To get the build through, I addedARG/ENV STRATA_COMMITto the root Dockerfile's terminal stage locally. That edit is not in this PR (reported separately).Environment: Ryzen 9 9950X3D, 96 GB RAM, RTX 4090 (
GPU=0), Ubuntu 26.04.1, kernel 7.0.0-38. btrfs RAID0 over 3 x Crucial T500 2 TB (PCIe 4.0 x4). Qwen3.8-Flash-Next IQ3_S GGUF viaMODEL_PATH, withCONTEXT=64k,TUNE=skipandVISION=off.Load speed: the same image, runs alternating. Before each start, I dropped the GGUF's page cache (
posix_fadvise(DONTNEED)). "Ready" is the time fromdocker runto/health200.loaded 46.84 GiB atSTRATA_UNBUFFERED_LOAD=1Correctness: with
STRATA_VERIFY_ARENA=1, both modes printexpert arena checksum 8ae1446c68dc969b (46.84 GiB).HIP build (compile only, no AMD card):
rocm/dev-ubuntu-24.04:7.14.1-full(ROCm 7.14.1, HIP clang 23.0.0), with the cmake options ofpackaging/build_hip_linux.shandCMAKE_HIP_ARCHITECTURES=gfx1100;gfx1201.cmake --build --target stratapassed forc947561c. There are no warnings in the added lines. The file's other warnings are the existing-Wunused-resultones onhipError_telsewhere inexpert_source.cpp.The same change on 0.1.45 (
477ac13): 5.83–5.95 GiB/s before, 12.04–12.15 GiB/s after, same checksum.Failed: none observed.
Not run:
expert_source.cpp, which this PR does not touch.O_DIRECTis refused: I had no such filesystem at hand.Limits
The change is opt-in only. An unbuffered load does not fill the page cache, so a warm restart cannot reuse it. Whether Linux should choose this automatically, as #285 does on Windows, is for you to decide.
Raw logs and a small C reproduction of the loader are in https://github.com/akivajp/nvme-raid-bench. The reproduction is
scripts/loader_bench.c; on the same RAID0, bufferedfread+memcpygives 5.9 GiB/s andO_DIRECT+memcpygives 11.8 GiB/s.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.