mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2271] [CLOSED] --shared-expert-arena: one engine loads the file, the others wait and attach #3953
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#3953
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/2271
Author: @i-Vladimir-i
Created: 10/13/2026
Status: ❌ Closed
Base:
main← Head:shared-arena📝 Commits (3)
a21c7e7--shared-expert-arena: one engine loads the file, the others wait and attachd5e1cee--shared-expert-arena: the engine that loads the file asks for 2 MiB pages under the #2126 rule (free 2 MiB blocks for half of it, STRATA_ARENA_THP=1 asks anyway; not on hugetlbfs)12e85a1--shared-expert-arena: the Linux-only parts behind linux (the Mac engine compiles pinned.cu)📊 Changes
9 files changed (+1142 additions, -172 deletions)
View changed files
➕
bench/results/2026-10-13-community-r9700-shared-expert-arena/README.md(+71 -0)➕
bench/results/2026-10-13-community-r9700-shared-expert-arena/arena_probe.cpp(+542 -0)📝
docs/DETAILS.md(+64 -0)📝
include/strata/core/expert_source.hpp(+3 -0)📝
include/strata/core/pinned.hpp(+11 -4)📝
src/core/expert_source.cpp(+46 -34)📝
src/core/pinned.cu(+261 -88)📝
src/core/pinned_shared_test.cpp(+133 -40)📝
src/program/generate.cpp(+11 -6)📄 Description
--shared-expert-arena: one engine loads the file, the others wait and attach#129 added the shared arena as a primitive and left two things to the caller: who loads the file ("no
leader/follower population protocol yet") and its lifetime. Today every engine that names the file reads the whole
pack into it again at start - 55 GiB for UD-IQ4_XS, written into pages another engine may be reading - and nothing
keeps two loads apart. This adds that part, inside the engine, so two engines of one pack (one per GPU, each with its
own expert cache and K/V; #1461's pair is one such setup) keep one RAM copy and load it once.
What it changes (
src/core/pinned.cu,pinned.hpp,expert_source.cpp/.hpp,generate.cpp; the selftest;DETAILS.md; measurements inbench/results/2026-10-13-community-r9700-shared-expert-arena/)when an engine exits or dies). FILL is held by the engine that loads the file until the load passed its checks; an
engine started meanwhile waits on it (
shared arena ...: engine N is loading it, waiting) and then attaches - noread of the pack,
attached 55.43 GiB another engine loaded, nothing read. USER is held shared while an engine mapsthe file.
engine that dies while loading leaves the file to the next one, which loads it again. A file of another pack, size or
format is replaced when no engine maps it (USER taken exclusively, then unlinked - never truncated under a mapping)
and refused while one does.
hugetlbfs can hold it (the V1 comment said it could not). V1 files are replaced like any other format when unused.
posix_fallocate: a tmpfs smaller than the arena is an error naming thesize, not a SIGBUS part-way through the load), mapped before the GPU registration (
MADV_POPULATE_*, Linux 5.14),and the loading engine makes its 2 MiB pages whole with
MADV_COLLAPSE(Linux 6.1) while they are still empty. Thestart reports
N of M GiB on 2 MiB pages; on AMD, when part of it is on 4 KB pages, it says why that matters.hipHostRegisterdoes not pin host memory on ROCm 7.14.1 (VmPin0); thekernel's compaction moves 4 KB pages, and every move stops the process's GPU queues while the driver maps the range
again. With 16 GiB registered, one forced compaction: 194-295 ms of stopped queues on 4 KB pages, 0-18 ms on a tmpfs
huge=always; CPU reads and host->device copies were the same on both (table inDETAILS.md, method and the otherbackings - hugetlbfs,
hipHostMalloc,hipMemCreateon the host - in the bench folder).What it leaves alone: without
--shared-expert-arenanothing changes -PinnedArenawithout a file takes the oldpath,
shared_publish()is a no-op, andArenaExpertSource's load is the same code one level deeper. The SYCL treekeeps its own V1 copy of the option: a V1 engine refuses a V2 file (size and header do not match) rather than
misreading it, and since it takes no locks its V1 file counts as unused here - unlinked, not truncated, so it keeps
its mapping. Linux only: the code is under
__linux__; on Windows (as before) and on other platforms, macOSincluded, a shared file is refused with "implemented on Linux only".
Checked
ple_parityas before (needs the Q2_0 model).pinned_shared_test, rewritten for the protocol, runs the other engines as child processes: the second waits whilethe first loads and attaches once it publishes; an attach in the same process; another pack and another size
refused while mapped; a restart attaches; a file of another pack held by another process refused, replaced once
that process is gone; a loader killed before publishing leaves the file to the next one. Run on
/dev/shmand on ahugetlbfs mount (
STRATA_TEST_ARENA_DIR): both report the file whole on 2 MiB pages. CUDA: builds and links withnvcc 13.4.92, sm_120, 0 errors; not run on an NVIDIA GPU.
--spec 4 --mtp, 48 greedy tokens, tmpfssize=58G,huge=always,noswap:STRATA_VERIFY_ARENA=1)The load itself is about 32 s here (1.7-1.8 GiB/s from the file cache); the rest of a start is the same either way.
With the smaller caches the tokens differ from the reference from the 6th on, both engines alike - which experts a
card holds changes the rounding, as the docs say for other cache sizes. The fresh file of the second run was on 2 MiB
pages for 50.6 of 55.4 GiB (the machine had just freed a 55 GiB arena;
MADV_COLLAPSEcould not make the restwhole), the fourth for all of it after
MADV_COLLAPSE.the experts in RAM (69 GB of 125 GB still available with both running), 512 greedy tokens each:
huge=alwaysvm.nr_overcommit_hugepages)Same checksum everywhere; each engine's tokens the same alone and in the pair. A forced compaction during the pair's
decode stopped the x16 engine's queues 0 ms in three of four runs and the x4 engine's 0.6-0.7 s in each, on tmpfs and
hugetlbfs alike - memory other than the arena, not traced here. The hugetlbfs pages (28,384) went back to the system
when the file was deleted. The engine runs on hugetlbfs were made before a fix of the start line's count (hugetlb
pages are in
Shared_Hugetlb, notRss: it said 0 of 55.44 GiB); the selftest on a hugetlbfs mount(
STRATA_TEST_ARENA_DIR) now shows the file whole on 2 MiB pages.Not tested: NVIDIA at run time (
cudaHostRegisterpins the file's pages there); the server (serve/) running twoengines (#1461's desk is one); kernels older than 6.1 (
MADV_COLLAPSEthen reports itself unavailable in the startline).
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.