mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1549] Prompt reading is 72x slower when experts come from the host mirror, and ~48x off the PCIe bound #618
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#618
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?
Originally created by @demetree on GitHub (Oct 8, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1549
The prompt path collapses when experts come from the host mirror, and not at the PCIe bound
The host mirror (plan item 2: experts that do not fit in VRAM read from pinned host memory over PCIe instead of the
SSD) works well for decode. It does not work for the prompt, and the gap is much larger than bandwidth can explain.
Arc Pro B70 32 GB, Windows, OpenCL backend, Qwen3.8-Flash-Next-GSQ-RCO,
--spec 4 --mtp, greedy, medians of twointerleaved runs where both rows are the same build:
Decode absorbs the misses - 30 tok/s with 28% of the experts over PCIe is a reasonable price, and the device-built
verify plan points the expert kernels straight at the mirror. The prompt does not: 1.03 tok/s is a 72x drop, and one
2,048-token prompt took 1,987,881 ms (33 minutes), of which 1,988,700 ms was the wait for the first token - it is all in
the prefill, which the 4,096-row chunk handles in one pass.
The ratio is the interesting part. If each layer simply streamed the mirrored experts it needed over PCIe, 11.15 GiB
per layer across 48 layers is ~535 GiB, which at the 13.3 GB/s host-to-device I measured on this machine is ~41 s, not
1,988 s. So the mirror's prompt reads are ~48x off the bandwidth bound: they do not look pipelined the way the decode
plan's are. For reference,
Prefill::prefill.cppalready carries a note that "part of the model in the host mirror ashort first chunk costs a whole extra pass of that stream", and
g_pinned_sharedrops the staging ring to 96 slots whenless than 90% of the streamed experts are pinned - the design expects streamed experts to go through a small host-copy
ring, so a fully pinned mirror may be hitting a path that was tuned for the other case.
What I checked
The mirror is wired into both paths, so this is not a missing wire:
resident_plan_set_mirror()gives the verify planits per-layer mirror addresses, and the prefill reads a mirrored expert with
m.src->pinned(l, e)->m.src->blob(l, e)rather than staging it. The engine also knows the difference is not bandwidth-sized - theexisting all-resident forced test in docs/INTEL.md measures 3.6 GiB of misses costing ~6% of decode, and 3.6 GiB here
would be a few percent, not 72x.
What would help
A profile of one prefill chunk with and without the mirror would say where the 48x goes - most likely either the
per-expert launches not being enqueued far enough ahead, or the chunk re-reading the same mirrored expert once per
row-block. The number that would confirm it is bytes moved per second over PCIe during the prefill: 535 GiB in 1,988 s
is 270 MB/s, about 2% of the link.
For anyone choosing a model on a card this size in the meantime: a model that fits entirely in VRAM is fine on both
paths, and one that does not is decode-usable and prompt-useless. That is worth knowing before choosing one.
@demetree commented on GitHub (Oct 8, 2026):
Not a general property of the mirror - my measurements were on the OpenCL/eager-replay backend
TeppeiLan1104 measured this on a machine whose driver exposes a user-mode Level Zero adapter (Windows 11, driver
32.0.101.8864, UR over Level Zero V2), so command graphs and oneMKL are both live there, and the prompt path with a
large mirror is fine:
So 648 tok/s with 16.1 GiB mirrored, against the 1.03 tok/s I measured. That is not the mirror - that is my backend,
and the difference between the two setups is graphs plus eager replay, not the mirror table.
What I measured is still real, and still worth something: with the OpenCL backend and
STRATA_VERIFY_EAGER=1(nocommand graphs, every window enqueued kernel by kernel), the prompt path with mirrored experts reads at 1.03 tok/s
against 74.7 tok/s with all experts resident - 33 minutes for a 2,048-token prompt. That combination is what the
Windows port ships today whenever the driver has no user-mode Level Zero adapter, which is the case on the machine I
measured on (driver 32.0.101.8976,
sycl-lslists onlyopencl:gpu).I also read the ratio as too large to be bandwidth: 11.15 GiB of mirrored experts per layer across 48 layers is
~535 GiB, and at the 13.3 GB/s host-to-device I measured that is ~41 s, not 1,988 s - about 2% of the link. So
something in that path serialises. Whether the eager replay is the cause or merely the condition, I have not isolated;
Teppei's numbers suggest the mirror mechanism itself is sound, so the useful question is narrower than the one I filed.
What would still help
A profile of one prefill chunk with and without the mirror on the OpenCL/eager path, since that is the combination
that has never been measured with misses: is it the per-expert launches not being enqueued far enough ahead, the chunk
re-reading the same expert per row-block, or
g_pinned_sharedropping the staging ring to 96 slots for a fully pinnedmirror (the ring is tuned for the unpinned case)?
For anyone choosing a model on a card this size in the meantime, the practical summary is unchanged on an OpenCL-only
setup and reversed with graphs: a model that fits entirely in VRAM is fastest on both paths; one that does not is
decode-usable everywhere, and prompt-useless without graphs.
@demetree commented on GitHub (Oct 8, 2026):
Not a general property of the mirror - my measurements were on the OpenCL/eager-replay backend
TeppeiLan1104 measured this on a machine whose driver exposes a user-mode Level Zero adapter (Windows 11, driver
32.0.101.8864, UR over Level Zero V2), so command graphs and oneMKL are both live there, and the prompt path with a
large mirror is fine:
So 648 tok/s with 16.1 GiB mirrored, against the 1.03 tok/s I measured. That is not the mirror - that is my backend,
and the difference between the two setups is graphs plus eager replay, not the mirror table.
What I measured is still real, and still worth something: with the OpenCL backend and
STRATA_VERIFY_EAGER=1(nocommand graphs, every window enqueued kernel by kernel), the prompt path with mirrored experts reads at 1.03 tok/s
against 74.7 tok/s with all experts resident - 33 minutes for a 2,048-token prompt. That combination is what the
Windows port ships today whenever the driver has no user-mode Level Zero adapter, which is the case on the machine I
measured on (driver 32.0.101.8976,
sycl-lslists onlyopencl:gpu).I also read the ratio as too large to be bandwidth: 11.15 GiB of mirrored experts per layer across 48 layers is
~535 GiB, and at the 13.3 GB/s host-to-device I measured that is ~41 s, not 1,988 s - about 2% of the link. So
something in that path serialises. Whether the eager replay is the cause or merely the condition, I have not isolated;
Teppei's numbers suggest the mirror mechanism itself is sound, so the useful question is narrower than the one I filed.
What would still help
A profile of one prefill chunk with and without the mirror on the OpenCL/eager path, since that is the combination
that has never been measured with misses: is it the per-expert launches not being enqueued far enough ahead, the chunk
re-reading the same expert per row-block, or
g_pinned_sharedropping the staging ring to 96 slots for a fully pinnedmirror (the ring is tuned for the unpinned case)?
For anyone choosing a model on a card this size in the meantime, the practical summary is unchanged on an OpenCL-only
setup and reversed with graphs: a model that fits entirely in VRAM is fastest on both paths; one that does not is
decode-usable everywhere, and prompt-useless without graphs.
@demetree commented on GitHub (Oct 8, 2026):
A second, cleaner reproducer: over-reserving the resident KV cache
This may be the same problem reached a different way, and it is much easier to isolate than the IQ3_XXS case because
nothing else changes between the working and the broken run.
Arc Pro B70 32 GB, Windows, OpenCL backend, eager replay, Coder IQ1_M with all 12,288 experts resident (23.42 GiB),
16,386-token prompt. Only
--kv-residentvaries:--kv-residentMedians of three interleaved runs for the first three; one run at 196,608.
Two things worth separating from the headline:
Within the range that works, the resident KV is nearly free. The expert cache is 12,288 slots / 23.42 GiB in every
one of those runs, and the prompt borrows almost the same number of slots throughout (1,036, 1,036, 969), so the cache
is not being squeezed. Decode does not fall off as the reservation grows either: 40.7 / 42.1 / 41.2 is inside the
run-to-run noise (individual runs 39.2-45.9). If a 128K KV cache costs a few percent of decode on this card, the usual
"about 3.6 GiB of VRAM to context for ~6% of decode" is not the rule - the expert pool is sized from the free VRAM,
so it is the KV that gets what is left rather than the reverse.
Past the ceiling it is not a hang and not an allocation failure. The Windows GPU counters (per-process
GPU Engineutilisation and
GPU Adapter Memorydedicated usage) show the card at 100% with 30.83 of 32.00 GiB dedicated memoryin use, with system RAM unremarkable, while the prefill makes no progress past its first chunk. The engine's own log
stops at the plain-SYCL prompt GEMM's banner, and the expert cache is still fully resident, so this is not the mirror
path.
Given that the expert mirror (the other way to have misses) shows the same shape - 100% busy, no progress - I suspect
one cause rather than two: the prompt path's expert staging on a backend without command graphs. What I would want to
profile is a single stalled chunk: bytes moved over PCIe per second (should be visible in the GPU Adapter Memory
counters), and whether the expert launches are enqueued far enough ahead.
TeppeiLan1104's IQ3_XXS with 16.1 GiB mirrored reads at 648 tok/s on a driver that exposes a user-mode Level Zero
adapter (command graphs live), and their IQ3_S with 23.4 GiB mirrored still reads at 570 tok/s - so both this report and
the mirror one are about the OpenCL/eager path, and both are consistent with graphs being the fix.
@demetree commented on GitHub (Oct 8, 2026):
Profile of the mirrored prefill: 95.8% of it is the expert GEMMs, and the copy waits are 34 ms
The profile this issue asked for. Arc Pro B70, Windows, OpenCL backend, eager replay, Qwen3.8-Flash-Next-GSQ-RCO IQ3_XXS (17,687 of 24,576 experts resident, 6,889 = 11.15 GiB mirrored in pinned RAM),
--spec 4 --mtp, greedy,STRATA_PREFILL_TIMING=1, on currentmainplus #1390.The bug still reproduces after the rebase: the 2,049-token prompt reads at 1.06 tok/s (1,924,555 ms), against the 1.03 tok/s originally reported here.
A 255-token prompt, phase-charged between device events:
So the 48x is not bandwidth, not staging, and not the mirror table. The two expert GEMM phases are 95.8% of the GPU timeline.
wait copy- the phase that waits for the host->device staging DMAs - is 34 ms of 957,283, and all host staging is 232 ms. The bytes arrive essentially free; the arithmetic on them does not. The 1,496 DMAs this run counted confirm the pinned path is doing whatexpert_source.hppdocuments ("the prompt path copies it by DMA"). (The0 by DMAa stream-all run reports is a counter artifact:prefill.cpp's stream-all arm issuesm.copy->memcpywithout incrementingstats_.experts_dma, unlike the routed arm.)The cost is per expert, not per token. Two prompts on the same build:
Marginal cost is (1,924,555 - 957,861) / (2,048 - 254) = 0.54 s per token, which leaves about 821 s fixed in the 254-token run - 48 layers, so ~17 s per layer before a single token is charged. That is the shape of one launch per expert rather than one grouped pass over the layer's experts, and it is why a longer prompt looks "less bad" per token: the fixed part amortises.
Where that comes from, structurally.
ring_slots()returns the 8-slotSTAGEring whenever the non-resident share is 10% or more:IQ3_XXS mirrors 28% of its experts, so its prompt takes that arm. And the grouped path is gated on the ring being bigger than
STAGE:So a mirror does not only shrink the staging ring - it turns off the grouped/fused expert pass, and every streamed expert is then its own GEMM launch, on a backend with no command graphs where each launch is enqueued individually. ~139 ms of gate/up + down per streamed expert, for experts serving ~15 tokens each, is what that costs here.
STRATA_PREFILL_STREAM_ALL=1does not lift it - measured, same build, 2,049-token prompt: 1.06 tok/s against the 1.03 default, i.e. nothing. And the walk never ran: it reportedexperts streamed 7552, which is the routed count, not the 6,889 x 48 = 330,672 a real stream-all walk would copy. Som.ringstayed atSTAGEdespite the override, and the gate above stayed shut. Whatever setsm.ringat layout time did not seeT >= stream_all_min(); I have not found which call site that is.What I did not test: a bigger ring forced through
STRATA_PREFILL_RING(it is still gated onT >= stream_all_min()at layout time, so I do not know it would engage); any change to the grouping itself; Level Zero, since this driver still exposes no user-mode adapter (separate thread on #1390). Runs here cost 20-35 minutes each because the bug is what makes them slow, so I stopped at the profile rather than sweep.The practical reading for anyone on a card this size is unchanged and now sharper: a model that does not fit in VRAM is decode-usable and prompt-useless on this backend, and the reason is the expert GEMM path losing its grouping, not PCIe.
@demetree commented on GitHub (Oct 8, 2026):
Correction: the stream-all walk did run. And the useful comparison is in
docs/INTEL.mdI argued above that
STRATA_PREFILL_STREAM_ALL=1leftm.ringatSTAGEbecause the run reportedexperts streamed 7552against an expected 6,889 x 48. That expectation was wrong and I withdraw the claim. 24,576 is the total (layer, expert) pair count -docs/UNSLOTH_Q4.mdsays the profile "ranks the same 48 x 512 experts" - so the non-resident set is 6,889 pairs in all, and the mirror is 11.15 GiB in all, not per layer. The same log supplies the rest of the number:6,889 + 663 = 7,552, exactly what that run reported. So the walk staged the complete non-resident set,
ring_slots()did return the big ring, and the gate I blamed was not shut. The structural claim - that a mirror forcesSTAGEand thereby switches off the grouped expert pass - is unsupported; I should not have posted it as a finding.The override result gets stronger, not weaker. The walk staged all 7,552 blobs for 2,662.7 ms of host time and the prompt still read 1.06 tok/s. A deep ring and a full stream-ahead are not the fix. That is consistent with the phase profile:
wait copy34 ms of 957,283, all host staging 232 ms, the two expert GEMM phases 95.8%.The comparison that matters: this same configuration is documented at ~1,000 tok/s on the xe backend
docs/INTEL.md, "Arc Pro B70 with a model that does not fit: Flash-Next IQ3_S", measures a pinned mirror of the same shape - the same 24,576 experts, 11.5k resident, the rest in a pinned host mirror the GPU reads over PCIe - on a B70 VM, xe driver, kernel 7.0, oneAPI 2026.1, engine 0.1.40-sycl:docs/INTEL.md)This is not a controlled A/B - a different quant, a different mirror size and a different prompt length - so I am not claiming the 950x. What carries across is the phase shares, which are properties of the backend's kernels: on xe the two expert GEMMs are a third of the timeline with dequant a fifth, and here they are 95.8% with dequant gone. Two readings of the dequant row are possible and I have not distinguished them: either the fallback charges dequantization inside the GEMM phases (so 20% + 34% collapses into 95.8%), or the dequant really does vanish and the GEMMs absorb the whole cost.
This build logs
prefill gemm: oneMKL SYCL BLAS is not usable on this backend; plain SYCL fallback. The controlled version of the comparison is already in this thread - TeppeiLan1104's Level Zero rows are the same two models:So the backend alone is worth ~10x on the all-resident prompt, which is what losing oneMKL and command graphs should cost. The mirror then costs a further 1.17x on Level Zero and 72x here, and that second factor is the bug this issue is about - it is not the general OpenCL gap. The shape says where to look: 254 tokens cost 957,861 ms and 2,048 tokens 1,924,555 ms, i.e. 0.54 s/token marginal and ~821 s fixed, about 17 s per layer over 48 layers. A large fixed cost per expert GEMM call in the fallback would produce exactly that, since the pass touched 6,583 experts for ~139 ms of gate/up + down each.
What still stands, measured
gemm gate/up(57.6%) +gemm down(38.2%);wait copyis 34 ms and all host staging 232 ms. The bytes are not the problem.0 by DMAon the stream-all arm is a counter artifact, with a sharper reason than I gave:gsrc != nullptr(--stream-experts) is tested before the pinned-mirror branch, so that arm re-reads the 6,889 experts from the GGUF instead of DMA'ing them from pinned RAM. It costs little here - the stager runs far ahead inside a 1,924 s pass - but the mirror is bypassed on that arm.What I did not test
The same phase profile on the all-resident Coder at the same chunk size, which would put a number on the fallback's per-call cost directly and separate "the fallback is slow per call" from "the streamed path calls it far more often". That is the next measurement and I have not run it. Nor have I tested anything on Level Zero: this driver still exposes no user-mode adapter (separate thread on #1390), so I cannot say whether oneMKL alone closes the gap.
@demetree commented on GitHub (Oct 8, 2026):
The mirror is not the cause: forcing one on the same pack costs nothing
The controlled test this issue needed. Same build, same pack (Coder IQ1_M), same 2,049-token prompt,
--prefill 4096,STRATA_PREFILL_TIMING=1, and only--expert-cachechanged, to push part of the same pack into the pinned host mirror:--expert-cache auto--expert-cache 8847--expert-cache 6144Mirroring 35% of the pack - 4,285 experts, 8.19 GiB read over PCIe, 2,779 DMAs from pinned RAM - leaves the per-expert GEMM cost at 2.05 ms and the prompt at 109 tok/s. There is no collapse, and the pinned DMA path is doing its job (2,779 of 3,080).
The mirrored arms read faster overall only because they run one chunk instead of two:
STRATA_PREFILL_FIRSTis 256 tokens only when the cache holds every expert, so the all-resident arm pays an extra pass of the stream. That is why the per-expert figure is the comparable column, and it does not move: 2.01, 1.83, 2.05.Against the IQ3_XXS run in my previous comment: 139.2 ms of GEMM per expert touched - 70x this. The variable that matters is not where the bytes come from.
What this means for the issue
The premise in the title does not hold on this backend. A model that does not fit in VRAM is not prompt-slow because it is mirrored - the two only happened together because IQ3_XXS is both the model that does not fit in 32 GB and the model whose expert kernels are slow here. Nothing that improves the mirror's PCIe path will touch this, which is worth knowing before anyone spends time on the staging ring, the copy stream or the pinned arena.
The practical reading flips, too: on this backend, mirroring up to 35% of a pack whose kernels are fast is free at the prompt (measured on the Coder). The constraint on choosing a model is the pack, not the fit.
What it is not
Both packs load the same way -
native pack: ... experts,302 canonical tensors skipped: served natively- so it is not the pack mechanism. And it is not blob size: IQ3_XXS's largest blob is 2.33 MB against IQ1_M's 2.66 MB, so the slow model has the smaller blob. It is also not the token count per expert: the IQ3_XXS pass served ~19 tokens per expert against the Coder's ~80, and a per-call fixed cost would make the smaller one cheaper, not 70x dearer.That leaves the pack's quant or its geometry - IQ3_XXS has 512 experts per layer against the Coder's 256 - or the expert-dot kernel each selects.
What I did not test
IQ3_XXS cannot be made all-resident on a 32 GB card (39.97 GiB of experts), so I cannot separate its quant from its 512-expert geometry directly. A model with 512 experts per layer and a quant this backend handles well would do it, and I do not have one. I have also not traced which expert-dot kernel each pack selects, which is the cheapest next step and does not need a GPU run.
@demetree commented on GitHub (Oct 8, 2026):
It is not the prompt length either: the Coder's per-expert cost is flat, and 66x cheaper at the same 254 tokens
My IQ3_XXS profile was a 254-token prompt and my first control was 2,048 tokens, so the comparison was not clean. The Coder at four prompt lengths, same build, same config,
STRATA_PREFILL_TIMING=1:At 254 tokens - the exact length of the IQ3_XXS profile - the Coder costs 2.12 ms of GEMM per expert against IQ3_XXS's 139.2 ms. Same backend, same prompt length, comparable expert counts (4,747 against 6,583), 66x apart.
So, with the previous comment: it is not the mirror (35% of the same pack mirrored costs nothing), and it is not the short prompt. It is specific to the IQ3_XXS configuration.
Note that both models show the same shape - a fixed per-expert cost that amortises as the prompt grows (Coder 8.5 -> 73.3 tok/s from 64 to 2,048 tokens; IQ3_XXS 0.27 -> 1.06). The mechanism is the same kind of cost. IQ3_XXS's is just 66x bigger.
A structural gap this exposes: the SYCL port has no grouped expert path at all
Tracing the dispatch,
use_mmqcomes frommmq_plan(), which is gated onmmq::built(). The SYCL build never definesSTRATA_PREFILL_MMQ-sycl/CMakeLists.txtdoes not mention it,sycl/src/prefill/moe_mmq.dp.cppis not in any target, and wheregemm.dp.cppuses the macro it is#if defined(STRATA_PREFILL_MMQ) && defined(__HIPCC__), HIP-only. Soprefill.cpp's#ifndef STRATA_PREFILL_MMQstub is what compiles:use_mmqis therefore false for every layer of every pack, and every expert product on this backend takes the per-expert FP16 arm: two dequant kernels, thenGemm::f16for gate/up and again for down - one launch pair per expert. A Coder prompt makes ~12,288 of those pairs, and its whole 28 s prefill is essentially that (23.1 s in the two GEMM phases).That matters for reading this issue: on CUDA,
mmq::supportedcovers the i-quants and Q2_0 but explicitly not IQ1_M (include/strata/prefill/moe_mmq.hpp: "IQ1_M is not covered"), and MMQ runs 16 experts per launch (MMQ_GROUP). So on CUDA the two packs in this comparison take different paths - IQ1_M per-expert FP16, IQ3_XXS grouped - while on SYCL both take the per-expert one. The port's loss falls entirely on the packs MMQ would have covered.I am not claiming that explains the 66x: both packs run the same arm here, with the same GEMM shapes (
ne x 1280 x Nandne x N x 640) and comparablene. It does explain why prompts on this backend are slow in general, and it is a gap worth its own thread.What I have not resolved
Why one per-expert call costs 66x more for IQ3_XXS. The only pack-dependent calls in that arm are the two dequant kernels, and they are indeed slower per expert - 1.25 ms against the Coder's 0.045 ms at 254 tokens, 28x - but their phase is 8,253 ms of 957,283, under 1%. The other 908 s is in the two GEMM phases, whose shapes do not depend on the pack.
The open question is whether that 908 s is GPU work or GPU idle.
STRATA_PREFILL_TIMINGcharges the gap between two marks to the first mark's phase, and its own comment says "a gap where the GPU waits (for the host's expert grouping, or for an expert's copy) lands on the phase that was waiting" - so a host-bound dispatch would present exactly as these two phases do. The phases sum to 957,284 ms against a 957,283 ms timeline, which confirms they tile it but cannot separate work from waiting.The measurement that would settle it is the GPU's compute utilisation during an IQ3_XXS prefill (busy = the kernels are slow; idle = the host cannot keep the queue fed), or
STRATA_PREFILL_SYNC=1, which waits at every mark. I have not run either - each needs a 15-20 minute IQ3_XXS pass, because the bug is what makes it slow.@demetree commented on GitHub (Oct 9, 2026):
The 48x follows VRAM occupancy, not the pack's data: same kernel calls, 43x faster with the cache smaller
Following the per-kernel trace in my last comment, the expert GEMMs are the naive fallback kernel on both packs, with the same shapes. I tested the candidates that could make the same call slower. Arc Pro B70, Windows, OpenCL, eager, 64-token prompt,
STRATA_PREFILL_TIMING=1andSTRATA_GEMM_STATS=1.1. Value classes of the FP16 inputs (
STRATA_DQ_STATS=1, first 300 experts). No subnormals in either pack, in the dequantized weights or the activations; every gate/up value is normal. The one real difference is the down projection's zeros, 27% for IQ3_XXS against 6% for the Coder. That is not a subnormal penalty, and I have no reason to think zeros cost time.2. The KV setting the two configs disagree on. The IQ3_XXS config uses
--kv-resident 32768and the Coder 131072. Coder at 64 tokens: 7,589 ms against 7,587 ms with 32768. No effect.3. VRAM occupancy. The IQ3_XXS config fills nearly all of the card: 17,687 cache slots, 28.8 GiB. I reran the same pack with
--expert-cache 8000(10,698 slots, 17.4 GiB):--expert-cacheThe calls, their shapes and their row counts are identical. Only the free VRAM changed, and the per-call cost fell to the Coder's ~2.3 ms. The mirror test in my earlier comment agrees: that run also left VRAM free, and it was fast with 35% of the pack mirrored. So the variable is how full VRAM is, not the mirror and not the pack's kernels.
What I have not verified: the mechanism. My guess is that when device allocations approach the card's capacity, the Windows driver moves some of them out to system memory, so the naive kernel's reads cross PCIe. That would appear as shared-memory use rising during the full-cache run. I have not sampled
GPU Adapter Memoryduring a slow pass yet. The smaller cache also changes the DMA count (1,923 against 626). The mirror test already showed DMA volume does not matter, but I have not isolated that here.Practical reading: on a 32 GB card the expert cache should leave headroom, and an IQ3_XXS config that fills nearly all of VRAM is slow at the prompt for a reason that has nothing to do with the mirror or the quant.
@demetree commented on GitHub (Oct 9, 2026):
Follow-up: the slow pass fills the card and spills into shared memory; the fast pass doesn't
Sampling
GPU Adapter Memory(dedicated and shared) and the compute engine every 3 s, during the same 64-token IQ3_XXS prefill, Arc Pro B70, Windows, OpenCL, eager:--expert-cache 8000(10,698 slots, 17.4 GiB)--expert-cache auto(17,687 slots, 28.8 GiB)In the full-cache pass, dedicated memory reaches the card's usable ~31.8 GiB, and shared memory climbs to about 17 GiB while the compute engine is busy. The 8,000-slot pass holds dedicated near 23 GiB and shared near 2 GiB. The kernel calls are the same in both (3,668 naive gate/up and down calls each).
Two caveats:
Practical reading: on this card the prompt path slows sharply when the expert cache leaves little dedicated memory free, and in this run the GPU was reaching a large amount of system memory during the prefill. Keeping free VRAM for the prompt's own buffers, or sizing the cache with that headroom, is the first thing to try on a 32 GB card.
@demetree commented on GitHub (Oct 9, 2026):
The dose-response has a cliff: the prompt is 50x slower from 14,704 to 15,382 expert-cache slots
Sweeping
--expert-cacheon the same pack, same build, same 64-token IQ3_XXS prompt, Arc Pro B70, Windows, OpenCL, eager.GEMM ms/callis the two expert GEMM phases over the 3,668 naive calls counted bySTRATA_GEMM_STATS.The split is categorical, not a slope: every size up to 14,704 slots reads at 2.3-2.4 ms per expert GEMM call, and every size from 15,382 slots up reads at 50-122 ms. Between those two rows the prompt goes 9,704 ms to 472,150 ms.
The kernel calls never change: 3,668 naive gate/up and 3,668 down calls at every cache size, same shapes. Only the dedicated memory left over changes.
Two qualifications:
The actionable part:
--expert-cache autolands at 17,687 slots on this 32 GB card, about 3,000 slots past the cliff. So the default sizing chooses the slow side. Keeping the cache at or below about 14,700 slots (23.9 GiB) leaves enough dedicated memory for the prompt path's own buffers and keeps the prompt at 9-10 s for the same 64 tokens. A 2,048-token prompt would scale the same way, since the cost is per expert GEMM call.This is measured for the IQ3_XXS pack on a B70. I have not checked other packs, other sizes of card, or whether the cliff moves with
--prefillor the KV reservation.@demetree commented on GitHub (Oct 10, 2026):
Measured on an RTX 5070 Ti: no cliff, and the reason is a check CUDA has and this port cannot read
The A/B on NVIDIA, so the knob's default can stay zero there. One card, Windows 11 (WDDM), driver
610.62, 16 GB, RTX 5070 Ti, this branch built with CUDA 13.1 and MSVC 19.44 for sm_120 (the
generate.cppchange compiles without errors). Setup's own Coder IQ1_M config,--expert-cache auto --prefill auto --spec 4 --kv int8 --kv-resident 32768 --vram-reserve-mib 700 --max-context 262144,23.42 GiB of experts. Three rounds with the arms' order alternating, the server restarted for every run,
6,345-token prompt:
2% on the prompt and 3% on decode, inside the spread of either arm. No cliff.
Why there is none: the CUDA path has a working post-write check. After the cache's slots are written
it reads the free VRAM again and shrinks the cache until
--vram-reserve-mibis really free. Withheadroom 0 that check fired twice in every run and settled the cache at 6.43-6.54 GiB; with 1/6 it fired
once in two runs out of three and settled at 6.21-6.66 GiB. Both arms end within 0.3 GiB of each other,
because the headroom changes the size the check starts from, not the size it ends at. That is why
the knob is a no-op on CUDA, and why its default is zero there.
And on the B70 the same check cannot fire at all
I checked what that check reads on this card, by printing it (Arc Pro B70, IQ3_XXS,
auto, both arms):After the cache has taken 28.82 GiB of VRAM,
device_free_bytes()still reports 31.00 GiB free - thefigure it gave before the allocation. It does not move. So the check, which breaks out when the free
figure is short of the reserve, breaks out on the first read in every case, and the cache is never
shrunk. That is consistent with the absence of its "only N MiB free once the slots are written" message
in every B70 log I have.
The query is
dpct::get_current_device().get_memory_info(), and the correction for drivers thatmisreport is
own_drm_local_bytes()- which reads the process's DRM fdinfo and is thereforeLinux-only. On Windows it returns 0 and the correction at
expert_cache.cppnever runs.So on this backend the post-write check is inert, and the only thing that constrains the cache size is
the arithmetic at sizing time. Which is what the headroom in #1549's earlier commits is for: it is the
only lever that works here.
Two corrections to what I wrote earlier in this issue
I withdraw the WDDM-paging explanation. I wrote that the ~15 GiB of shared memory in the slow arm
was the driver paging device memory to system RAM. The NVIDIA runs above suggest the likelier reading:
the shared figure is almost entirely the engine's own pinned arena mapped for the GPU (the 23.42 GiB
expert arena and 3.09 GiB of K/V), which is by design. On the B70 the ~15 GiB matches the 11.15 GiB
mirror plus the K/V and weights closely, and the fast arm held less shared while mirroring more
experts, which does not fit a spill. I presented that as "consistent, not proven" and it now looks wrong.
The mechanism is still unknown. What is measured and standing: the expert GEMM phases are 95.8% of
the GPU timeline,
wait copyis 34 ms of 957,283, the per-expert call costs 2.3 ms with the cache cutand 54-122 ms without it, the GPU is busy throughout, the calls and their shapes are identical in every
arm, and identical output tokens either way. What is now ruled out: the mirror, the prompt length,
subnormals, the KV setting, and now a failing memory check.
The next measurement that would help is what the driver is actually doing with 28.82 GiB of a 31.00 GiB
card - whether the GEMMs are slow because they are competing for memory bandwidth with eviction traffic,
or because of something about the working set at that size. The B70's own counters (
sycl/probe/) arethe place to look, and I have not run them.
@demetree commented on GitHub (Oct 10, 2026):
Why the post-write check cannot fire on this backend: the OpenCL path has no free-VRAM query at all
The open question from the previous comment was why the check never fires on the B70. I traced it, and it
is not the check.
sycl/include/dpct/device.hpp,get_memory_info, a port addition:So with
STRATA_DEVICE_FREE_MIBset the function returns that constant and returns - no query ismade, and the
ext_intel_free_memorybranch is never reached, which is also why the engine's log nevercarries that message.
sycl/setup_intel.pywrites the value once, from the registry, at setup time:That is exactly the figure my debug print saw:
31,744 MiB = 31.00 GiB, before the allocation and after it alike. It is not a stale cache that might
clear, and not a driver misreport: it is a setup-time constant passed through an environment variable.
The Linux path has
own_drm_local_bytes()as a correction, and it is Linux-only, so on Windows there isnothing that reads the card at all.
So the post-write check on this backend compares a constant to a threshold and therefore never
fires. Nothing in the engine protects a run from a cache that fills the card; the only constraint is
the arithmetic at sizing time, which is what the headroom in #1549 is for and why it belongs on the
SYCL side specifically. On CUDA
cudaMemGetInfois a live figure, the check works, and the knob is ano-op there - which is what the RTX 5070 Ti measurement above shows.
Two things this does not settle, and I am not claiming them:
card, a true free figure would have been short of the reserve and the check would have shrunk the
cache. But I have not run that, so "the cliff is caused by a missing query" is a hypothesis this
supports rather than a result.
comment's list: GEMM phases 95.8% of the timeline,
wait copy34 ms, identical calls and shapes, GPUbusy, identical output tokens. The memory counters sample Windows' adapter figures, not the driver's
own state, and I have not run
sycl/probe/'s own tools against it.I also left the probe that found this in the tree as
sycl/probe/vram_pressure.cpp, with avram_pressureCMake target: it times the engine's ownGemm::f16at the expert shapes with the cardempty and again with 28 GiB of it allocated and touched. It needs
ZEL_LIBRARY_PATHpointed at aLevel Zero loader to start on this machine, as the engine does. I had not run it to completion when this
was written - the bisect that isolated the queue crash is what produced the figures above, so the
GEMM-under-pressure number is still missing.
@demetree commented on GitHub (Oct 10, 2026):
Correction: the expert GEMMs are not slower when the card is full, so the 95.8% is mostly not GEMM work
I said above that 95.8% of the slow arm's GPU timeline is the two expert GEMM phases, and that is what
the timing prints - but the phase timing charges a gap to the first mark of the pair, and I did not
check how much of those phases is actual GEMM. I have now.
sycl/probe/vram_pressure.cpp(added, with avram_pressureCMake target) times the engine's ownstrata::prefill::Gemm::f16at the prompt path's two shapes and routed row counts (T=10), first withthe card otherwise empty and again after allocating and touching 28 GiB of it:
The pair costs 1.85 ms with the card empty and 1.84 ms with 28 GiB of it gone. Memory pressure does
not slow this kernel.
And the engine's own fast arm measured 2.32 ms per expert pair, which is the same kernel plus its
dequant - so the fast arm is within ~25% of what these two GEMMs cost. The slow arm measured 54-122 ms
per pair. A kernel that costs 1.85 ms under full memory pressure cannot cost 111 ms in situ, so the slow
arm's GEMM phases are almost entirely something other than the GEMMs, charged to them by the phase
timing's own rule ("a gap where the GPU waits ... lands on the phase that was waiting").
So, revising the accounting: ~6,583 expert pairs at 1.85 ms each is about 12 s of real GEMM work out
of 916 s charged to those phases in the 255-token run. Over 98% of it is elsewhere.
What is now established, and it is a short list: the plain-SYCL fallback GEMM is not the slow thing;
the OpenCL backend has no free-VRAM query, so the post-write check cannot fire; the headroom removes the
slowdown and changes nothing else about the run (identical tokens, identical calls, identical shapes,
and the mirror is not involved either way).
What is open, restated: where the ~900 s goes. The phase marks cannot separate work from waiting, and
my GPU-utilisation sampling was not a clean percentage (the counter sums over the process's GPU Engine
instances, so ~222 mean could be a little over two engines' worth, not "busy"). The measurement that
would settle it is
STRATA_PREFILL_SYNC=1, which waits at every mark and logs the phase that justfinished: real kernel times collapse, idle does not. I have not run it.
Two notes on getting here: the probe needs
ZEL_LIBRARY_PATHpointed at a Level Zero loader to starton this machine, as the engine does; and
bisect.cppinsycl/probe/is the scratch file that isolatedthat, which should be deleted before this is committed anywhere.
@demetree commented on GitHub (Oct 10, 2026):
STRATA_PREFILL_SYNC=1: the slowdown is spread across most kernels, not the expert GEMMs
Same build, same 65-token prompt,
STRATA_PREFILL_SYNC=1(the host waits at every phase mark, so thenumbers are what the GPU actually ran rather than spans that include waiting), headroom 0 against 1/6.
The expert count is the same in both arms (3,680 resident plus streamed), and the calls and their shapes
are identical:
gdngdn out projqsa projgemm gate/up+gemm downdequanthc readThe whole prefill is 36x slower with the same work, and it is not one kernel: the recurrent
gdnblock,which runs once per layer and never touches an expert, is 55x slower, as are the QSA projections and the
GDN output projection. At the level of an individual call that is
gdn171 ms per layer against 3.1 ms.So the trigger is not the expert path and not the GEMM: when the cache fills the card, a broad set of
kernels slows down by 20-55x. And the previous comment's probe says a flat 28 GiB allocation does not
slow the GEMM at all (0.99x), so it is not "the card is full" in the simple sense either.
What is still unexplained is what the engine's near-full working set does that a flat allocation does
not. The difference between the two is that the engine's 28.82 GiB is being read — by the expert
dequant, the projections and the KV — while the mirror's reads run concurrently, whereas the probe's fill
was written once and then never touched again. So the candidate is contention on the memory path between
VRAM traffic and the PCIe reads, but I have not measured it, and the memory counters I can sample are
Windows' adapter figures rather than the driver's own state.
Revised list of what is established. The headroom removes a real 36x slowdown and changes nothing
observable about the run (identical tokens, identical calls, identical shapes). The mirror is not
involved: 35% of a pack mirrored over PCIe costs nothing, and the slow arm streams fewer experts than
the fast one. The GEMM kernel is not intrinsically slow. The CUDA path is unaffected because
cudaMemGetInfois live there and its post-write check works.And what this issue is now about is not the expert path at all: a 20-55x slowdown across ordinary
kernels when the card's memory is nearly committed. That is a smaller and more specific question than
the issue's title, and it is the one worth answering next.
@demetree commented on GitHub (Oct 10, 2026):
The mechanism: the cliff is where the engine's total VRAM demand exceeds the card
Suggested on the tracker that the leftover 2 GiB is the display. It is, partly - but it is a small part,
and the arithmetic closes the question.
Per-process GPU memory right now, with the engine running the Coder config (
\GPU Process Memory,Dedicated Usage):
stratadwm(the display compositor)explorerOpenCodeSo the display holds 0.88 GiB. The engine's own non-expert VRAM is the large term: with a 23.42 GiB
expert cache the engine holds 30.22 GiB of dedicated memory, which is 6.8 GiB of weights, KV, the MTP
draft head, and the prompt and verify buffers.
And that closes the cliff exactly. The card is 31.16 GiB. A cache is safe while it plus the engine's
other 6.8 GiB stays under that, which puts the boundary at:
Measured on this card, same build, IQ3_XXS,
autoand hand-set sizes:The predicted boundary lands inside the measured gap. (The Coder and IQ3_XXS differ by a few hundred MiB
of weights and KV, so this is close rather than exact.)
So the cliff is not the mirror, not the expert path, not a kernel, and not the memory query: it is
total VRAM demand crossing the card, and the engine only slows down once the driver starts evicting.
Every kernel that touches an evicted page crawls, which is why
gdn(55x), the QSA projections (42x) andthe GDN output projection (53x) slow down along with the expert GEMMs - and why
wait copystays at 34ms, because the copies themselves never waited; the reads of what was copied did.
Why the sizing misses it.
STRATA_DEVICE_FREE_MIBis written once bysetup_intel.pyas(vram_gb - 1.0) * 1024= 31,744 MiB, anddpct'sget_memory_inforeturns that constant instead ofasking the driver - the OpenCL backend has no free-VRAM query. So the engine sizes the cache against the
whole card, as if the 0.88 GiB of display, its own 6.8 GiB of weights, KV, draft head and prompt buffers,
and anything else the desktop is running did not exist. It then allocates the cache on top of them.
A 1 GiB deduction was presumably meant to cover the display and got the order of magnitude right for that
alone. It does not cover the engine's own second allocation wave, which is the term that matters.
This predicts the fix and explains the two platforms.
autoon this card picks 28.82 GiB of experts,which is 28.82 + 6.8 = 35.6 GiB of demand against a 31.16 GiB card - 4.4 GiB over, so the driver evicts
and every request crawls. Cutting the cache to 23.8 GiB brings the total to 30.6 GiB, just inside the
card, and nothing is evicted. On CUDA the same check works because
cudaMemGetInfois live, so the cacheis shrunk after the fact and the RTX 5070 Ti saw no difference - both its arms settled within 0.3 GiB of
each other.
The one number that would still be worth having is the same per-process breakdown on the slow arm,
where I expect
strata's dedicated figure to sit at the card's limit with the missing 4.4 GiB appearing inits shared usage. I have the shared figure (about 15 GiB, of which the mirror is 11.15) but not the
per-process split of it.
@Niko1221 commented on GitHub (Oct 10, 2026):
Thank you for the profile plan and for the second comment that narrowed it to the OpenCL backend. We cannot reproduce the 72x on Windows / OpenCL (we have only a Linux B70, where the mirror reads are fine), and the Level Zero V2 measurements in your second comment (570-758 tok/s with 8.7-23 GiB mirrored) say it is not the mirror itself. The part of this report that is the PLE table (the n-gram reads on the prompt path) is changed in v0.1.42: see #1425 and #1629. For the OpenCL path we would need the profile you describe (bytes moved over PCIe per second during the prefill, with and without the mirror); if you can run
STRATA_VERIFY_PROFILE=1on a prompt with the mirror we would start there.@demetree commented on GitHub (Oct 10, 2026):
The profile you asked for: the mirror's PCIe traffic is 0.25% of the prefill, and 36% more of it moves the prompt by 1.3%
Arc Pro B70, Windows, OpenCL backend, eager, driver 32.0.101.8976, Flash-Next IQ3_XXS pack, 2,049-token
prompt,
STRATA_PREFILL_TIMING=1andSTRATA_VERIFY_PROFILE=1, engine 0.1.41 on this branch. IQ3_XXS is39.97 GiB of experts on a 31.16 GiB card, so a mirror is unavoidable and the arms differ in how much of
one there is:
wait copy(the phase waiting for the staging DMAs)autowith a live free figure--expert-cache 800036% more mirrored bytes and 36% more experts streamed moved the prompt by 1.3%.
STRATA_VERIFY_PROFILE'sown line reads
0.00 distinct experts per layer read over PCIe. On the bandwidth side: arm B moves about7,874 x 1.7 MiB = 13.4 GiB over PCIe inside a 32.2 s prefill, which is 0.42 GB/s against the 8.3 GB/s
this card's own PCIe probe measures - the bus is at 5% of what it can do, and there is room for several
times more mirror before it would show up.
The same arms with the phases broken out, since that is where the time does go:
What this says about the report's premise. The 72x was not the mirror's PCIe traffic. The measured
cliff on this card sat at a 28.82 GiB expert cache against a 31.16 GiB card and disappeared when the free
figure the sizing reads became live - with the mirror size unchanged. In the arms above the mirror is
16.62 GiB and the prompt reads at 64.5 tok/s; in the pre-fix cliff run the mirror was smaller, 11.15
GiB, and the prompt read at 1.06 tok/s. A smaller mirror was 60x slower, which is the whole argument.
That matches what you already concluded from the Level Zero V2 figures: 570-758 tok/s with 8.7-23 GiB
mirrored says it is not the mirror itself.
One thing I should flag about the comparison rather than bury: this is engine 0.1.41, so the PLE table
is the pre-#1425/#1629 one you point at. On this card the
plephase is 67 ms of 31,695 (0.2%) for thewhole 2,049-token prompt, so whatever those changes did to the n-gram reads on the prompt path, there
does not appear to be much there to reclaim here - but that is this card's number, not a general one.
So the OpenCL half of this report is a sizing problem, not a mirror problem, and the fix for it is in
#1390:
device_free_bytes()on this backend answered fromSTRATA_DEVICE_FREE_MIB, a setup-timeconstant, so
autosized a cache against the whole card and then allocated 6.8 GiB on top of it. With alive figure from DXGI,
autois told 23.84 GiB rather than 31.00 and the same 2,048-token prompt readsat 113 tok/s for the Coder with 56.3 tok/s of decode against 73.8 and 13.0 before.
Happy to run anything else you want on this card - the remaining open question here is what the GPU is
doing with the last 2 GiB when the card is over-committed, which is a different measurement from this
one and I have not done it.
@Niko1221 commented on GitHub (Oct 13, 2026):
Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.
If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.