mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #2850] [Bug]: HIP/Linux, 2x RX 7900 XTX: the page-locked RAM complement takes 2-6 min on many starts (median 300 s in an interleaved A/B: ROCr's KFD userptr allocation returns EAGAIN thousands of times); with THP disabled for the process, 34 s #1149
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#1149
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 @kylebakerio on GitHub (Oct 17, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2850
What happened
With
--resident-budget-gib 40on two RX 7900 XTX (layer split), the engine page-locks a 28.47 GiB cache complementwith one
cudaHostAlloc(Mapped | Portable)(FileExpertSource::pin_cache_complement). On this machine that stepoften takes 2-6 minutes, at other times 25-35 s, with the same config. Strata's own copy into the complement is 14-17 s every
time. The rest of the time goes to one call into the driver that fails and is retried thousands of times.
With transparent huge pages (THP) disabled for the server process (
prctl(PR_SET_THP_DISABLE), inherited by theengine), the same start took 33-35 s in 4 of 4 starts, against 294-322 s for the default in 4 of 4 starts,
interleaved, same config, same hour. Decode and prompt speed did not change measurably.
Interleaved A/B, real engine (2026-10-16, 15:39-16:27)
Same config each time (below), back-to-back fresh starts, nothing else on the GPUs; the bench after each start is one
short prompt and one 32K prompt, 512 tokens generated at the server's default sampling (temperature 1.0), so the
tok/s columns are single requests. "alloc" = the complement total minus its copy: the allocation plus a few seconds of
bookkeeping.
Two more default starts were run under strace (
strace -f --seccomp-bpf -T -tt -e trace=ioctl): 91 s (its copy took73 s that time, the allocation 8.5 s with 93 retries) and 223 s (below). Before the test, in normal use the same config
started 8 times on 2026-10-16 with a complement time of 174 (that one took the paced #1250 path), 33, 132, 376, 347, 316, 38 and 386 s. Over 76 starts in
our logs since 2026-10-12 (0.1.43.1 and 0.1.44.1) the median is 27 s and the slow ones are 75-497 s: many
calibration starts in a row were fast; in normal use (a coding benchmark between starts) most are slow.
Where the time goes
ROCr implements this
hipHostMallocas an anonymousmmapof the whole size,madvise(MADV_HUGEPAGE)on it, then oneAMDKFD_IOC_ALLOC_MEMORY_OF_GPU(a KFD userptr:/proc/<pid>/statusshowsVmLckandVmPin0 after it). From thestandalone test's trace:
In the real engine's 223 s start, the complement's allocation call was made about 3,770 times from 16:20:09.8 to
16:23:28.4 (198.6 s), every attempt but the last returning EAGAIN; the last succeeded (0.34 s) and the GPU mapping after it took
0.29 s. In a slow start in normal use (sampled from
/proc, no strace), one engine threadwas at 100% CPU for 5 minutes, all of it system time (
wchan0), while the process's resident memory grew by about95 MB/s; the 28 GiB landed in the last ~20 s.
Standalone reproduction (no model, no kernels)
pintest.cpp(below) makes the same call (hipHostMalloc(28.47 GiB, Mapped | Portable)) and times it, with/proc/vmstatdeltas over the allocation:pgfault+31.2M for 7.46M pages;thp_fault_alloc+14,698;compact_stall+1,567;pswpin+257,614pgfault= pages, compaction ~0compact_stall+2,538PR_SET_THP_DISABLE), idle / cache full / cache dropped / after a 28 GiB pinned process exitsmalloc+memset(0)+hipHostRegister(Mapped | Portable)hipHostRegisterHIP_VISIBLE_DEVICES=0)Only the first row hit the slow state. I could not bring it on with a standalone recipe (a full page cache, a dropped
cache, a large pinned process that just exited). Today's back-to-back real starts with the default were slow 5 of 6
times (the A/B's 4, the 223 s traced one; the other traced one was 91 s), but in a calibration run the night before,
many back-to-back starts of the same config were fast; I do not know what differs. So the
standalone rows other than the first show only the cost of each variant in the fast state. THP off is the only
variant measured in the slow state (the A/B above).
What I think happens (not confirmed: no root tracing on this machine)
The userptr allocation walks the range with HMM (
hmm_range_fault) and returns-EAGAINwhen the range isinvalidated during the walk; ROCr then retries the whole 28.47 GiB. With THP
enabled=madvise,defrag=madvise, the2 MB faults in this
MADV_HUGEPAGEregion can do direct compaction and reclaim, which migrate movable pages, possiblypages of this same range faulted in a moment earlier, and every move invalidates the walk. That fits the slow
standalone run (each page faulted ~4 times; huge pages were allocated for the whole range, yet with 22 GiB of it
resident only ~5 GiB of the machine's anonymous memory was in huge pages; compaction stalls) and the fast THP-off runs (one fault per page, no compaction), but I have not traced the
invalidations. It may be the same family as the reclaim / migration + KFD userptr stalls in
docs/AMD_HIP.md(#750, #1705, #2413). We also saw one
verify: timed out at layer 32 (#267)on 0.1.44.1 the same day, butI have not tested whether THP off changes those.
Workaround that works here
Start the server with THP disabled for it; the engine inherits it:
nothp python serve/server.py --engine strata --config <config.json>. No root needed. Cost: about 5 s more for theallocation in the fast state (8.2 s against 3 s); no measurable change in decode or prompt speed in the A/B above
(4 starts per arm, single requests, so only large differences would show).
Possible changes in Strata (suggestions; only the first is measured, and only as the process-wide workaround)
prctl(PR_SET_THP_DISABLE, 1)before thecudaHostAlloc,restore the previous value after it. The faults happen inside that call. (Other threads' faults in that window
lose THP too.)
state, where a piece that is invalidated would retry only its own 2 GiB.
complement readyline, so a slow start can be toldapart from a slow read.
Not tested
System-wide
transparent_hugepage/defrag=defer+madviseornever, orenabled=never(root); a kernel trace ofthe invalidations (root); other ROCm or kernel versions; one GPU with the real engine;
HSA_USERPTR_FOR_PAGED_MEM=0(as far as I can tell it applies to paged allocations, not this one); what makes back-to-back starts slow on one day and fast
on another (our workload between starts is the obvious suspect).
pintest.cpp (standalone timing)
Build:
hipcc -O2 -std=c++17 --offload-arch=gfx1100 -o pintest pintest.cpp. Run:pintest alloc-mp 28.47 0 1(Strata's call),
pintest alloc-mp 28.47 2 1(2 GiB pieces),pintest register 28.47 0 1,nothp pintest alloc-mp 28.47 0 1.Strata version, GPU, OS
CPU's lanes split between the two slots), measured at 14.1 GB/s host to device
/opt/rocm-7.2.4)enabled[madvise],defrag[madvise],khugepaged/defrag1;vm.compaction_proactiveness20,vm.swappiness10,vm.watermark_scale_factor125; GTT 31.4 GiB per cardstrata --serve --pack .../packs/ud-iq4_xs --native .../Qwen3.8-Flash-Next-UD-IQ4_XS-00001-of-00003.gguf --resident-budget-gib 40 --expert-profile .../data/expert-profile.bin --expert-cache auto --prefill auto --spec 3 --spec-min-p 0.7 --mtp .../mtp/rt --max-context 262144 --kv int8 --pipeline-windows 2 --layer-split autoenv:STRATA_HIPBLASLT_TUNING(gfx1100 table),STRATA_MTP_PREFILL_SYNC=1,STRATA_STAGE_TRIM=1,STRATA_HIP_ADAPT_KERNEL_COPY=1Engine log
Slow start (d4, default THP):
The next start (n4, THP off for the process), same config:
(Full engine log of the 10 test starts and both strace files available on request.)
@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for taking the time to report this.
We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. 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.