okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

albedocmake: strata_kernels links strata_kernels_cpu (iq_kernels.cu reads the latent colscale table from expert_layout.cpp; strata-q36ref failed to link)a4af4df61

main
1 file

files

README.md4.5 KiB

RTX 5090: adaptive-overlap callback affinity (#1975)

Machine and engine

Mechanism and standalone reproduction

After the caller is pinned, CUDA's first host callback can lazily create a worker with that same single-CPU affinity. The host spinning for completion and the callback worker then compete on one logical CPU. Every layer's callback also holds back subsequent expert copies on its stream until the callback executes.

The standalone test needs Linux/x86, a CUDA toolkit, an NVIDIA GPU and CPU 0 in the process's allowed CPU set. From the repository root, inside the CUDA environment:

g++ -O2 -std=c++20 -I/usr/local/cuda/include bench/micro/cuda_callback_affinity.cpp \
  -L/usr/local/cuda/lib64 -Wl,-rpath,/usr/local/cuda/lib64 -lcudart \
  -o bench/micro/cuda_callback_affinity.bin
./bench/micro/cuda_callback_affinity.bin lazy
./bench/micro/cuda_callback_affinity.bin warm

Run the two modes as separate processes so the second does not reuse a callback worker from the first. Each measures 200 callback/spin handshakes, without profiling:

Callback worker initializedObserved affinityMedian latencyp95
After host pinningCPU 0984.51 us998.06 us
Before host pinningCPUs 0–314.01 us15.95 us

This is a scheduling reproducer, not an inference benchmark. Nsight separately showed callback bodies averaging 0.62 us but much longer dispatch gaps; profiler latencies should not be treated as unprofiled production measurements.

Opt-in warm-up and inference comparison

The warm-up is on by default (STRATA_ADAPT_CALLBACK_WARMUP=0 turns it off, for comparison). The candidate initializes and synchronizes a no-op CUDA host callback before constructing ExpertPool, leaving its worker free to run on the process's original allowed CPUs. It does not change swap selection, notifications, per-layer waits, residency commits, or GPU math. The flag is off by default and its code is guarded to Linux CUDA; overlap-off remains a valid workaround.

Four starts in normal/warm-up/warm-up/normal order. No competing inference workload: PiForge and the persistent Strata service stopped for the tests. Same binary and existing calibration, fixed --pcie-frac 0.4, auto expert cache, temperature 0, 512-token output caps. Calibration's three prompts were prefixed with synthetic sensor-record documents at 4K; only the code prompt at 100K. Each context had one warm-up round followed by two measured rounds per start.

CaseNormal callbacks, meanEarly warm-up, meanGainRequests per setting
4K, three prompts142.82 TPS207.75 TPS45.5%12
100K, warmed code prompt232.96 TPS252.19 TPS8.3%4

Across both starts, including warm-up, adaptive-gate waiting dropped from 15043.63 ms / 3453 active windows (4.357 ms/window) to 1.16 ms / 3378 windows (0.000343 ms/window). A matched 512-token 4K code output (token-array JSON SHA256 prefix 1956a5e9aec0) averaged 180.35 TPS normally (three measured requests) versus 236.08 TPS with early warm-up (two requests).

Validation limits