mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5272] [Engine] AMD Zen CCX dynamic load balancer and zero-dependency Linux io_uring direct I/O #5370
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#5370
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/5272
Author: @jailsonMMB
Created: 11/5/2026
Status: 🔄 Open
Base:
main← Head:pr-linux-uring-ccx📝 Commits (4)
8e686e6[Engine] Zen CCX L3 topology sharding and native Linux io_uring storage prefetch6616d0aMerge branch 'Niko1221:main' into pr-linux-uring-ccx5094726fix(engine,platform): dynamic CCX rebalancing, opt-in DMA lock, and clang-format adherencefdeb9e4refactor(cpu): isolate CCX dynamic rebalance and opt-in latency lock without formatting noise📊 Changes
11 files changed (+698 additions, -5 deletions)
View changed files
📝
CMakeLists.txt(+99 -1)➕
include/strata/kernels/cpu/ccx_shard.hpp(+36 -0)📝
include/strata/kernels/cpu/pool.hpp(+5 -0)📝
include/strata/platform/direct_file.hpp(+4 -2)➕
include/strata/platform/uring_reader.h(+22 -0)📝
src/core/expert_source.cpp(+87 -1)📝
src/kernels/cpu/pool.cpp(+114 -1)📝
src/platform/direct_file.cpp(+73 -0)➕
src/platform/uring_reader.c(+153 -0)➕
tests/platform/ccx_shard_test.cpp(+43 -0)➕
tests/platform/uring_bench.cpp(+62 -0)📄 Description
Problem and result
On multi-CCX AMD Zen architectures (such as Ryzen 3000/5000 and EPYC Milan/Rome), unpinned CPU thread scheduling during Mixture-of-Experts (MoE) evaluation causes cross-CCX cache line bouncing over the Infinity Fabric, invalidating local L3 caches when different cores touch the same expert weights. Furthermore, rigid static parity sharding (
expert_id % 2) can suffer from severe worker starvation whenever context prompts activate predominantly even or odd expert indices.Additionally, standard synchronous POSIX
preadcalls in the weight streaming pipeline induce continuous user/kernel context switches and thread serialization, creating PCIe/NVMe delivery stalls during active token decode steps.Result after this change:
|ccx_0 - ccx_1| \le 1) on skewed activations with zero allocations and zero mutexes on the hot path.io_uringengine interfaces directly with kernel rings via bare syscalls (__NR_io_uring_setup,__NR_io_uring_enter), backed by explicit compiler atomic acquire/release memory barriers. Async read throughput reaches 1,079.28 MiB/s (vs 774.73 MiB/s onpread, a +39.3% improvement) while completely avoiding GPU execution stream bubbles.Related discussion
Supersedes and refines the initial implementation in PR #5272.
Approach
/sys/devices/system/cpu/cpu*/topology. When detected and uninhibited, pins worker threads to their physical CCX clusters usingpthread_setaffinity_np.src/kernels/cpu/pool.cpp(run_split_multi_native), initial dispatch maps by parity, followed immediately by anO(1)rebalancing loop ensuring neither CCX core group starves. Nostd::mutex, heap queues, or futex wakeups are introduced to the decode loop.src/platform/uring_reader.c, ring buffer head/tail indexes are guarded via__atomic_load_n(__ATOMIC_ACQUIRE) and__atomic_store_n(__ATOMIC_RELEASE), ensuring race-free operation without requiring externalliburinglibraries.io_uringsetup fails (-ENOSYS,-EPERM, or kernel< 5.1),DirectFilefalls back automatically to multi-threaded POSIXpread./dev/cpu_dma_latency) is strictly opt-in viaSTRATA_LOCK_DMA_LATENCY=1to prevent battery drain or unwanted C-state locking on standard desktop machines.Validation
Passed:
ctest -R "strata_ccx_shard_test|direct_file_async_test"(Revision50947260, Linux 6.18.2, AMD Ryzen 5 3600, NVIDIA RTX 5060 Ti / CUDA 13.3):strata_ccx_shard_test:CCX plan 3+3 and pthread affinity OK (CPU 0)(Passed, 0.00s)direct_file_async_test:direct_file_async: passed queued reads, short EOF, wake, close drain, reopen(Passed, 0.00s)python3 bench/bench_stream.py --port 8080 --tokens 128:io_uringprefetch and active CUDA GEMV streams.clang-format -i.Failed:
Not run:
#ifdefstubs).Limits
>2CCXs gracefully retain default NUMA/unpinned scheduler behavior without regressions.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.