Repository navigation
Conversation
…the share and shares only while that is faster (Niko1221#1282) auto balanced the CPU's time per expert against the GPU's per streamed expert, both measured with the share on, so nothing compared a layer with and without it. On jase100k's RX 7900 GRE + Ryzen 7 5700X3D the host's time per streamed expert rose 107 -> 200 us with auto (0.47): the streaming side saved nothing (0.53 x 1.87 = 0.99) and the CPU's work came on top, -4.5%. Now every eligible layer is timed with CUDA events from before its routing sync to its combine, per non-resident expert; adjacent layers alternate no share / the measured share until three ratios are in, then auto shares while the median of the last five is below 1, with one layer in 29 in the other arm. Layers with a one-time cost and the first layer are left out. STRATA_DBG_CPU_GATE=1 prints each measurement. RTX 5090 + 9950X3D, IQ2_XS, 250 / 600 / 900 tokens against off: DMA streaming -9.8/-9.9/-10.4% -> -8.8/-9.1/-10.5%; an emulated host-copied stream -18.0/-16.7/-14.4% -> -16.1/-15.2/-13.0%; one core + one worker (where the old auto lost up to +11.5%) +1.4..+2.4% -> +2.0..+2.3%, the cost of the first measurements. Unset: byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio
Owner
DarthCY-K
pushed a commit
to DarthCY-K/Strata
that referenced
this pull request
Oct 20, 2026
…ork's defaults, the contention gate Niko1221#1379, the chunked recurrence from 128 tokens) - README, docs/NVFP4.md and the bundle version Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1282 (in 0.1.40.2 as an opt-in). @jase100k measured
STRATA_PREFILL_CPU_SHAREon an RX 7900 GRE with a Ryzen 7 5700X3D (ROCm), and every share was slower than off: 0.10 by 2.1%, 0.20 by 3.5%,auto(0.47) by 4.5%. Their report also had the number that explains it. This PR makesautocheck that sharing pays before it keeps sharing.Why
autolostautobalances two measurements: the CPU's time per expert (c) and the GPU's time per streamed expert (g). It gives the CPU g / (c + g) of the experts, the point where both sides end together. Both c and g are measured with the share on, so nothing compares the layer against the same layer without the share. The CPU's share is not free for the streaming side, and jase100k's numbers show by how much:auto(0.47)With the CPU busy, issuing each streamed expert cost the host 87% more. At a share of 0.47 the streaming side keeps 0.53 of the experts at 1.87 times the cost each: 0.53 x 1.87 = 0.99. So the share saved the streaming side nothing. The CPU's work, the copy of the layer's input to the host, the CPU's rows back to the GPU and the join came on top.
I reproduced the rise here by emulating a host-side H2D copy. The emulation is a test patch, below, that memcpys each pinned blob into a pinned bounce slot before the DMA. It ran with the AVX2 kernels and 4 cores / 8 threads (affinity
0xFF, 7 workers), with a memory-bandwidth hog on the other CCD. Host time per streamed expert rose from 70 us to 130 us (+86%) withautoon. The CPU here is fast enough to take 0.73 of the experts, so 0.27 x 1.86 = 0.50 and sharing still won. Whether it pays depends on that product, and only a measurement without the share can tell.The gate
Every layer where the share can apply is timed with CUDA events, from before its routing sync to its combine. That window holds everything the share changes: the input copy to the host, the GPU's experts, the wait for the CPU, and the CPU's rows going back. The time is divided by the layer's non-resident experts.
autoshares while the median of the last five ratios is below 1.Why adjacent layers and not a running mean per arm. I forced each arm on every layer and timed the windows. The window time per expert differs up to 8x between layers (layer 8 takes 30 ms where most take 4-6), and each layer's time repeats within a few percent from run to run. A mean per arm therefore follows whichever layers each arm happened to land on: the first version of this gate did, and it settled on "off" where sharing won by 10%. The same forced runs show the windows hold the whole effect. At 600 tokens the sum of the windows moved by -51.0 ms with the share against -51.4 ms of prompt time (DMA), and by +43.0 ms against +45.6 ms (the one-core case below).
How the constants were chosen. I replayed the schedule on those forced-arm windows with 4% noise per reading, 300 runs each. "Every layer" is
autobefore this PR. The last two columns scale the effect down to 0.3, about the size of the report's loss.What the gate costs.
autocannot know whether sharing pays on a machine until it has tried it. That trial is now bounded:Measured
RTX 5090 + Ryzen 9 9950X3D, IQ2_XS,
--expert-cache 12000. Prompt ms, 3 interleaved rounds of off /autobefore /autoafter; the median is in parentheses. "CPU" is the experts the CPU took over a run.DMA (the default path; every streamed expert is DMA'd from the pinned arena):
autobeforeautoafterHost copy (the emulated host-side H2D: bounce memcpy, AVX2, 4C/8T with 7 workers, bandwidth hog). The last column is host time per streamed expert.
autobeforeautoafterWhere sharing wins, the gate keeps about 90% of the gain (89-101%).
A case where
autoloses here. I could not make this machine lose by as much as the report. The closest is the whole process on one core, two threads (affinity0x3). That case is noisy: its result moves with whatever else the machine is doing. In this session,autobefore measured from -4.7% to +11.5% against off. The gate measured from -1.4% to +2.3%:autobeforeautoafterautobefore does (one run each)In the one-worker runs the gate stopped sharing after its exploration in 4 of 9 runs (108-180 experts on the CPU), part of the way in 2 (821 and 944) and kept sharing in 3 (1,086-1,742, where
autobefore took 1,342-1,961). The +2% that remains is the exploration's layers. In these runsautobefore had settled at a share that cost about as much. I expect the report's machine to look like the "effect x0.3" column of the replay. I cannot run that machine, though, so @jase100k's numbers would settle it.Identity
The default (unset) path is unchanged. Against the 0.1.40.2 engine (this branch is on main
e8ca9afd), at IQ2_XS 2K with--expert-cache 12000, the first-token logits are the same bytes and the 32 greedy tokens are the same, 3 of 3 pairs. A fixed share is unchanged too:STRATA_PREFILL_CPU_SHARE=0.4at 600 tokens gave the same logits in 7 of 8 runs across both builds. The eighth differed by at most 0.19 with the same tokens, which is the engine's own run-to-run drift: 0.1.40.2 itself gave one such run in 7 at 2K. Withauto, which layers share now differs, so the output differs fromautobefore in the last bits, asautoalready did against off.STRATA_DBG_CPU_GATE=1prints each reading and the decision, one line per layer. For example:cpu gate: layer 5 shared, 58 non-resident, 2.89 ms (0.0499 a expert) -> share.The host-copy emulation (a test patch, not in this PR)
In
stage_one, the pinned branch:The runs used
STRATA_DBG_STREAM_BOUNCE=1 STRATA_FORCE_AVX2=1 --pool-workers 7under affinity0xFF, with 6 memcpy threads on CPUs 16-31 while each run held the GPU.🤖 Generated with Claude Code
https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio