mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #3681] [Engine] SYCL --stream-experts: mirror PCIe bandwidth depends on host memory fragmentation at engine start (Arc Pro B70: 27 vs 42 tok/s, same boot, same link) #1524
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#1524
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 @phg1024 on GitHub (Oct 22, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3681
Area
[Engine]
Desktop app, Terminal or source?
Source (a build)
What happened
On a single Arc Pro B70, the
--stream-expertsmirror's PCIe bandwidth depends on how fragmented host RAM is when the engine starts. Decode speed follows it. With the same binary, config, link and boot, decode ranges from 27 to 43 tok/s, depending only on host memory state at startup.The mirror is about 27 GiB, and about 55% of experts on this pack are read from it over PCIe. It is pinned once at start (
GgufExpertSource::mirror,sycl::malloc_hostin 2 GiB chunks), so whatever pages the driver hands out then stay for the life of the process. The effects:Measurements. Same boot, same PCIe 4.0 x16 link with 0 AER errors throughout, same binary and config. Host memory before the "compacted" rows was reset with
sync; echo 3 > /proc/sys/vm/drop_caches; echo 1 > /proc/sys/vm/compact_memory, then the engine was restarted.memcpy, best of 10)malloc_hostmemoryMemFree≈ 0, 5,341compact_stalls since boot), 4 engine startsdrop_caches+compact_memory, engine restartedthrottle/reasons = none.Suspected mechanism (not yet verified).
DMA-FQ, the Ubuntu default, with noiommu=on the command line.malloc_hostare mostly order-0. The GPU's reads of the mirror then hit IOMMU translation (IOTLB misses) on scattered 4 KiB pages. With mostly high-order pages, the same reads run at full link speed.DMA-FQcosting pinned copy bandwidth on a Gen3 box (7.7–9.2 against 12.3 GB/s withiommu=pt). That covers the translation part. The dependence on fragmentation at start is the new part.iommu=pt. I have not run it yet and will add it here.Why this is a Strata issue and not only host tuning.
mirror()allocation is the one large pinned allocation whose page backing Strata does not control.MAP_HUGETLB, thenMADV_HUGEPAGE(core/pinned.dp.cpp), but the mirror goes straight tosycl::malloc_host.Workaround that works today: run
drop_caches+compact_memoryas root right before the engine starts, for example inExecStartPre. That gave 42.4 / 42.7 tok/s.Smallest steps or command that reproduce it
--stream-expertson a pack where a large share of experts is mirrored, and run the same short benchmark (2K and 32K prompts, 512 tokens, temperature 0). Note the decode speed.MemFreeis near 0 and/proc/buddyinfoshows few high-order blocks. Restart the engine and benchmark again. Decode drops.sync; echo 3 > /proc/sys/vm/drop_caches; echo 1 > /proc/sys/vm/compact_memory. Restart the engine and benchmark again. Decode recovers.The microbenchmark below shows the same split without the engine: the zero-copy row is the access pattern the decode path uses on the mirror.
bw.cpp (SYCL,
icpx -fsycl -O2 bw.cpp -o bw)Reproduction status
Reproduced locally
Strata version
Engine 0.1.45.3 (commit
e88ee39). The mirror code is unchanged onmain@011c9e6(v0.2.2).Graphics card, memory and system
Intel Arc Pro B70 32 GB (BMG-G31) in the CPU x16 slot, ReBAR on. i7-12700K, 64 GB DDR4 (61 GiB visible), ASUS Z690. Ubuntu 26.04, kernel 7.0.0-38,
xe, GuC 70.58, compute-runtime 26.31.39395.16, IGC 2.40.16, Level Zero loader 1.32.0, oneAPI 2026.1. IOMMUDMA-FQ, THPmadvise.Model, size and settings
Qwen3.8-Flash-Next IQ3_S native pack, text only.
--stream-experts --expert-cache auto --vram-reserve-mib 2048 --kv int8 --kv-resident 32768 --max-context 262144 --spec 4 --spec-min-p 0.5 --mtp ... --prefill 8192,STRATA_VERIFY_DEVICE_PLAN=1 STRATA_VERIFY_NO_HOST=1. In the runs above, 13,446 of 25,746 experts were mirrored (25.71 GiB).Logs
Both starts are in the same boot, with the same config and binary. The mirror has the same size both times; only the host memory state differs.
Happy to test a patch on this box: hugepage-backed mirror chunks, an opt-in pre-compaction step, or a start-log line reporting the mirror's backing.
@phg1024 commented on GitHub (Oct 22, 2026):
Follow-up: refined cause, a root-free reproduction, and an opt-in fix measured in the engine
Short version. "Fragmentation" in the original report was too broad. What matters is whether the mirror's pinned chunks are allocated from free memory or under reclaim.
GgufExpertSource::mirror()runs. So on a 64 GB host, MemFree at that point is often below 1 GiB, against 25.7 GiB needed for the mirror.posix_fadvise, with the patch below.Unless noted otherwise, everything below was measured on the same box as in the report, now at PCIe 4.0 x16 with 0 AER errors throughout. Engine:
main@011c9e6(v0.2.2) plus the patch.1. Where the pages come from (Level Zero is not the variable)
With
NEOReadDebugKeys=1 PrintBOCreateDestroyResult=1 LogAllocationMemoryPool=1 PrintBOChunkingLogs=1, a 2 GiBsycl::malloc_hostis a single system-memory BO:The UMD passes no page-size hint, so the physical backing is decided by xe/TTM in the kernel.
2. GPU vs CPU reads of the same chunks
This is a standalone SYCL microbenchmark: 13 × 2 GiB
malloc_hostchunks, the mirror's shape. For each chunk it measures a GPU copy-engine H2D, a GPU kernel zero-copy read, and a CPU read with 8 threads. Values are GB/s, listed per chunk in allocation order.posix_fadviseon the model files)In the slow state, the first ~6 GiB came from free memory at full speed. Every chunk that needed reclaim is slow for the GPU only, never for the CPU. I have not yet separated whether the cost is IOMMU translation or the GPU's own PTE granularity on small pages.
iommu=ptis the next test, and it needs a reboot.3. Reproduction without root
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED)on each GGUF. Then start the engine and benchmark it: fast.cat other.gguf > /dev/null), start it again and benchmark: slow.It reproduced on every pair below.
4. In the engine:
STRATA_MIRROR_DROP_CACHEA/B over 24 startsoff, before, both, both, before, off. Hereoffis a build mode that only reports MemFree and drops nothing.Decode is in tok/s as 2K / 32K, with one value per block. MemFree is read in the engine right before the chunks are allocated.
beforebefore: the mirror fill reads from NVMe instead of the cache, 13.0 s → 14.4 s per start.after, my first attempt) made restarts 2–4 slower than off: 27.6–30.3 against 35.5–38.9 tok/s, again as two ABBA blocks.bothdrifts down over restarts. I do not have a clean explanation for either, so the patch below does onlybefore.5. Five-hour soak with
beforeon the live service6. Patch (opt-in; the default path is unchanged)
The binary I measured is a measurement build with extra modes (
log,after,both). Itsbeforepath is exactly the lines below. This trimmed diff itself has not been rebuilt and re-run; I will do that before opening a PR.sycl/src/core/gguf_expert_source.cpp (against
011c9e6)Limits:
xe, one Arc Pro B70 box. CUDA and HIP were not tested.beforecannot help; root-side compaction oriommu=pt(still untested) would be the next step.What I would propose next: a PR with this opt-in plus one start-log line reporting MemFree before and after the drop. I can also run the same A/B on another backend if someone wants to compare, and add the
iommu=ptresult here once I have it.@Niko1221 commented on GitHub (Nov 5, 2026):
Thanks for taking the time to report this.
Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.