mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4866] [Engine] HIP/Linux: kernel NUMA balancing evicts the GPU queues (watchdog stops on two-socket hosts) #2234
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#2234
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 @vivienfanghuagood on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4866
Area
[Engine] (speed, kernels, models, the server and API)
Desktop app, Terminal or source?
Source checkout (setup.sh --backend hip --build)
What happened
On a two-socket Linux host with
kernel.numa_balancing=1, the HIP engine stops making progress at random points of arequest: in the prompt read (layer 0, layer 31, ...) and in decode. The #29 watchdog ends it with
no progress for 60 s during a request (reading the prompt (batched): ...), and the server restarts the engine. Withsetup's own config, 7 of 20 fresh 1K-token requests stopped like that. Some stalls end by themselves after 43 s or
80 s, so this is not a deadlock: the GPU is paused for an unbounded time.
What a stuck engine looks like (rocgdb attached during a stall):
Prefill::run_impl, waiting inside the HIP runtime;strata-issueyielding, waiting for a ring slot.The driver's own counter
/sys/class/kfd/kfd/proc/<pid>/stats_<gpu_id>/evicted_ms(how long it kept the process'squeues evicted) reaches 77 to 236 s per engine start. On the same host the kernel log shows
INFO: task kworker/...: blocked for more than 122 secondsinWorkqueue: events_freezable amdgpu_amdkfd_restore_userptr_workerwhile the engine runs (9 times in 3 hours, one of 245 s).Cause, as far as we can show it: the expert arena and the other ranges the GPU reads are registered with
hipHostRegister, so amdgpu keeps them as KFD userptr ranges. The NUMA-balancing scanner periodically marks the PTEs ofmigratable ranges
PROT_NONEto sample NUMA access. Each change is an MMU-notifier invalidation, and on a GPU withoutXNACK, KFD evicts all of the process's queues until the range is validated again. This is the mechanism of #649 and
#3913, with a different trigger: it happens with plenty of free RAM, no swap and no reclaim.
Ruled out, each over the same 20 requests, counting watchdog stops:
HIP_HOST_COHERENT=1STRATA_VERIFY_COHERENT=1STRATA_PREFILL_ISSUER=0HSA_ENABLE_SDMA=0HSA_USERPTR_FOR_PAGED_MEM=0What stops it is an explicit memory policy for the engine process (no
MPOL_F_NUMA_BALANCING). Then the scannerskips its memory (
vma_policy_mof()is false):numactl --interleave=0,1: 0 stops, 0 ms evicted.numactl --localalloc: 0 stops.set_mempolicy(MPOL_LOCAL)at the top ofmain(): 0 stops, under 1 s evicted.Decode is unchanged (62 tok/s median).
A standalone reproducer without Strata (below) shows the same: a 1-page GPU read every millisecond against a 16 GiB
hipHostRegistered buffer that 32 CPU threads read.The policy is per thread, and the scanner judges memory by the policy of the thread it interrupts, so it has to be
set before threads are created.
A PR with the
MPOL_LOCALchange (default on whennuma_balancingis on,STRATA_NUMA_BALANCING=keepto opt out)follows as a draft. Since it changes a default, scope agreement is welcome: it can be made opt-in instead if you
prefer. Operators can also set
kernel.numa_balancing=0on the host or start the engine undernumactl --localalloc.Smallest steps or command that reproduce it
cat /proc/sys/kernel/numa_balancing= 1../setup.sh --backend hip --family qwen --model IQ3_S --build --yes --no-start, then serve with the generated config.evicted_msunder/sys/class/kfd/kfd/proc/*/stats_<gpu_id>/grows by tens of seconds.Standalone reproducer (
hipcc -O2 --offload-arch=gfx1100 evict_probe.hip -o evict_probe -lpthread, then./evict_probe 16 120and./evict_probe 16 120 local-first):evict_probe.hip
Reproduction status
Reproduced locally
Strata version
0.2.9 (engine 0.1.55), source at
c62d5e3a1Graphics card, memory and system
Radeon PRO W7900D 48 GB (gfx1100), one card used, two-socket host with NUMA balancing on, Ubuntu 24.04, kernel 6.8, ROCm 7.2.1
Model, size and settings
Qwen3.8-Flash-Next GSQ-RCO IQ3_S, setup's config:
--expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5 --mtp ... --kv int8 --ple-io ramLogs
@vivienfanghuagood commented on GitHub (Nov 1, 2026):
Related, for anyone who finds this thread: ROCm/rocm-systems#12528 reports the same mechanism from another trigger. There, memory reclaim invalidates the pinned (userptr) ranges while clr page-locks pageable memory, and KFD keeps the process's queues evicted for most of the run. Here the trigger is the NUMA balancing scan. In both cases an MMU notifier invalidation of a userptr range makes KFD evict all of the process's queues until the range is validated again.
@aurelbalteaux commented on GitHub (Nov 2, 2026):
Same mechanism here on a single-socket desktop with NUMA balancing off. On this box the trigger is ordinary
page reclaim and compaction, as in ROCm/rocm-systems#12528. Below is an ftrace of the KFD eviction path under a Strata
workload (it shows the SVM path is hit as well, not only userptr), plus A/B runs of the settings people usually try.
System
0.1.52-linux-x86_64-hip-rx9070, Fedora 44, kernel 7.2.13kernel.numa_balancing=0was reset and the baseline re-run; same result, see the table)
TQ1_0(58.5 GB GGUF, pack 26 GB / 24 GiB experts), 256K context,--kv int8, MTP,--kv-resident 262144 --vram-reserve-mib 1536, resident RAM mode (~21 GiB of experts in RAM)leaving ~3.5–4 GB for the desktop
Symptoms
Fresh 16K–40K-token prompts fail ~7 % of the time (7 of 104 across three soak runs) with all three known messages:
no progress for 60 s … reading the prompt (batched),verify: timed out at layer N … did not finish within 5 s (#267),and
waiting for the GPU (attention, router) at layer 32. A 30-turn conversation growing to 67K tokens with prefixreuse never failed. dmesg is empty around all 23 failed/slow requests: no amdgpu/MES/reset messages. Note this
Fedora kernel is built without
CONFIG_DETECT_HUNG_TASK, so a blockedrestore_userptr_workerwould not bereported either; the silence doesn't rule that out.
evicted_msgrows in single restores of 45, 105, 110, 144 and 248 s right when requests stall; healthy runs stillshow 3–8 evictions per minute of 0.5–2 s.
What triggers the evictions (ftrace)
Function tracer +
func_stack_traceonkgd2kfd_quiesce_mm,svm_range_evict,amdgpu_hmm_invalidate_hsa,amdkfd_fence_enable_signalingand the restore workers, during a 24-prompt soak (2 hangs). This run hadHSA_USERPTR_FOR_PAGED_MEM=0; all ranges showed up as SVM rather than userptr:All 779 queue quiesces came from
svm_range_evict←svm_range_cpu_invalidate_pagetables←__mmu_notifier_invalidate_range_start. No eviction-fence/TTM path, no userptr path.shrink_folio_list→try_to_unmap; kswapd 503, direct reclaim in strata/baloo/… )kcompactd→migrate_pages→try_to_migrate)Representative stack:
What I see during a stall:
sched_yield, one HSA thread sits inkfd_wait_on_events, and the GPU is either idle or at100 %. In other stalls the engine's watchdog thread is in D state at
lock_mm_and_find_vma, and reading/proc/<pid>/cmdlineblocks for minutes. That looks like the restore holdingmmap_lockwhile it faults therange back in.
restore slower still.
ttm_bo_delayed_deletekworkers sit indma_resv_wait_timeout.The trigger on this box: during a prompt read the engine's RSS rises ~5 GB above idle, which on 32 GB forces reclaim.
Reclaim then hits the engine's GPU-registered pages.
What I tried (fresh-prompt soaks, 16K–40K)
HSA_USERPTR_FOR_PAGED_MEM=0)STRATA_RESIDENT_PIN=1--vram-reserve-mib 3072(~2 GB VRAM free)HSA_USERPTR_FOR_PAGED_MEM=1=1+STRATA_RESIDENT_HEADROOM_GIB=8Samples are small, so treat the hang rates as rough.
STRATA_RESIDENT_PIN=1does not mlock anything. With 20.95 GiB reported "page-locked", the engine showsVmLck: 0 kBandVmPin: 0 kB, and system-wideMlockedis 116 kB. That holds even withRLIMIT_MEMLOCK=unlimitedinherited from the server. So the "pinned" tier stays reclaimable and migratable, andvm.compact_unevictable_allowed=0cannot help it.Suggestions
#267verify timeout (5 s) and the 60 s watchdog fire on KFD eviction pauses. A growingevicted_mscould bereported as "GPU queues evicted by the kernel" instead of a hang. Waiting or retrying there would avoid restarts
for the shorter pauses.
mlockthe registered resident tier when the memlock limit allows it, or say clearly that "page-locked"only means driver-registered. With a real mlock, reclaim stops and
compact_unevictable_allowed=0would stopcompaction too, which together cover ~99 % of the quiesces above.
I can rerun with a build or env switch, or share the trace, stall reports and 1 Hz samples (meminfo/PSI, engine
RSS/VmSwap, GPU busy,
evicted_ms).@vivienfanghuagood commented on GitHub (Nov 2, 2026):
Thank you, this is a very useful report. The ftrace answers what we could not see on our machine.
What #4867 covers. It removes one trigger: the NUMA balancing scanner, on multi-socket machines with
kernel.numa_balancing=1. It does nothing for reclaim, compaction or THP splits. Your trace shows the general case: on aGPU without XNACK, any MMU-notifier invalidation of host memory registered with the GPU (a userptr or an SVM range)
evicts all of the process's queues until the range is valid again.
What we measured. We extended our probe to compare the ways the memory can be set up against several triggers.
Setup: Radeon PRO W7900D (gfx1100), 2x EPYC 9334, ROCm 7.2.1, kernel 6.8, no swap. An 8 GiB region, 32 CPU threads reading
it, and a small GPU kernel reading it every millisecond, for 60 s. The table gives the seconds of queue eviction that
KFD itself reports (
evicted_ms), which match the GPU stalls:hipHostRegister(as the resident tier is registered today)mlock+hipHostRegisterhipHostMallocMigration here is
move_pages()on the region itself, the samemigrate_pagespath compaction takes. Without a triggerthe longest launch was 0.3 ms.
mlockdoes not stop NUMA balancing or migration.hipHostMallocavoids NUMA balancing, because its pages carry anode policy, but its pages are migrated like any other on ROCm 7.2.1.
That looks like your 45-248 s single restores, and like ROCm/rocm-systems#12528.
reclaimed, by the kernel's design.
move_pages()also ignoresvm.compact_unevictable_allowed, so we could not showthe effect of that setting on compaction either.
So we agree with your suggestions 1 and 2. A real
mlockof the registered resident tier stops reclaim, and withvm.compact_unevictable_allowed=0on the host, compaction leaves those pages alone too. By your counts that covers about99% of the quiesces. Reading
expert_source.cpp(we have not confirmed this on your setup), when RAM is short theresident complement is registered in steps from ordinary memory:
malloc, thencudaHostRegister. That path never callsmlock, yet the log says "page-locked", which would explainVmLck: 0 kBon your machine.What we would propose, as separate changes from #4867 once the maintainers agree on the scope:
RLIMIT_MEMLOCKallows it, say so plainly in the log when it does not, anddocument
vm.compact_unevictable_allowed=0as the matching host setting.#267verify timeout and the 60 s watchdog check whether the process'sevicted_msis growing, and treatthat as an eviction pause rather than a hang.
If you can run a build with (1) on your 32 GB machine, that is the test we cannot do here. The probe behind the table is
the reproducer in the issue description (
evict_probe.hip),extended with the three memory setups and the migration and reclaim triggers. We can post that version if it helps.
@alexanderi96 commented on GitHub (Nov 2, 2026):
@vivienfanghuagood @aurelbalteaux your suggestion 1 (mlock the GPU-registered host memory when
RLIMIT_MEMLOCKallows it) is in #3913 as
STRATA_HIP_MLOCK=1. It covers everycudaHostRegister/cudaHostAlloc/cudaMallocHostof the HIP build, including the complement registered in steps that @aurelbalteaux found atVmLck: 0. Withvm.compact_unevictable_allowed=0the watchdog stops ended here (about 80 starts, 0 stops, against12 before). It does nothing for NUMA balancing; the PR's docs now point here for that.
mlock still left short evictions, 10-600 ms. A kprobe trace on
amdgpu_hmm_invalidate_hsa/svm_range_cpu_invalidate_pagetablesover one 30K prompt put every hit on 82 shared/dev/zeromappings (233 MiB,Locked: 0). These are host allocations ROCr makes for itself (fmm_allocate_host_gpu:MAP_SHARED|MAP_ANONYMOUSHSA_USERPTR_FOR_PAGED_MEMis on), so the engine never sees them. 78% of the hits came from kswapdand 10% from kcompactd.
With
HSA_USERPTR_FOR_PAGED_MEM=0they become GTT, driver-pinned with no notifier, and the evictions go to 0. Theknown catch, a much slower prompt read, comes from the complement being fine-grained GTT. #3913 now has an opt-in
coarse-grained complement (
STRATA_HIP_ARENA_NONCOHERENT=1). Withttm.pages_limitraised so GTT holds it: samespeed as userptr + mlock,
kfd_evicted_ms0 through ten 30K prompts and 6 GB of pressure (table in the PR).@aurelbalteaux on your 32 GB box with zram, the run worth doing is the fresh-prompt soak with
with
kfd_evicted_msfrom/healthbefore and after. On two sockets, NUMA balancing should not touch GTT pageseither (they are not on the LRU), but I cannot test that here.
@aurelbalteaux commented on GitHub (Nov 2, 2026):
@vivienfanghuagood @alexanderi96 Thanks both. Replies to each of you below, plus what I found since my first comment.
One correction to the
expert_source.cppreading, from currentmain(I run 0.1.52, but it matches what I see): theresident tier does call
mlock, throughplatform::lock_resident, but only fromlock_offon. On the paced path,lock_off = partial_pin. The registered prefix is skipped on purpose ("the registered prefix is page-locked by the driveralready - locking it twice made the next device allocation fail"; that comment refers to an RTX 5070 / WDDM). Here the whole
20.95 GiB got registered, so
lock_off == bytesand nothing is locked, henceVmLck: 0 kB. #3913 (STRATA_HIP_MLOCK=1)now covers exactly that.
What triggers the reclaim on this box
It depends on how large a resident tier the engine picks at start-up. The
prefill plan inputs: … GiB RAM copy (N lend slots kept)line tells. With all 3391 lend slots kept, prompts read no expertsfrom the GGUF, and nothing fails. With fewer, every prompt streams the missing experts from the mmapped model: 16–97 GB of
file-tier expert reads per soak, up to 5 M major faults, the page cache growing to 23 GB. That growth pushes the box into
reclaim, which hits the engine's GPU-registered pages, and the minute-long evictions follow.
To test this directly, I held a balloon only while the engine started and released it before the soak. Every engine then
came up with 20.5–20.8 GiB and 2240–2596 slots:
Each failure restarted the engine. With the RAM free again it came back with all 3391 slots, and the rest of that soak
(74 requests) ran clean. The difference between the two modes is only ~0.65–1 GiB of free RAM at start-up, so on a 32 GB host
whether the engine works or stalls comes down to what else happens to be open when it starts.
Two mitigations tested under that trigger
Every engine started with the same start-up balloon, 24 prompts per soak, in the order baseline, A, B, B, A, baseline:
STRATA_RESIDENT_HEADROOM_GIB=2memory.swap.max=0margin doesn't shrink either: MemAvailable stays ~4 GB minimum, same as the baseline. It's now in my preset, and a
follow-up check (16K–64K fresh prompts and a conversation grown to 66K with prefix reuse) shows the same prefill and decode
speed as before.
pressure but doesn't fix it. With the tier reduced, something still invalidates GPU-registered ranges under the
streaming load, and evictions still last a minute or more. That could be compaction migrating them, or reclaim of
file-backed or shared ranges, such as the ROCr
/dev/zerobuffers @alexanderi96 found. I didn't trace this run, so Ican't say which.
So on a 32 GB host a full tier matters more than locking it, and two cheap changes would help next to (1) and (2):
3. The start-up warning is already there ("N of 3391 lendable slots … will read their experts from the pack during a
long prompt; expect a slower prompt read on 50K+ token prompts"), but it presents this as a speed cost. On a 32 GB
host it also means reclaim and queue-eviction stalls on 16K–40K prompts. Saying so, and pointing at
STRATA_RESIDENT_HEADROOM_GIBas the lever (AMD_HIP.md already does), would save people a lot of searching.4. Grow the tier later, when the RAM becomes available (a watchdog restart already does this as a side effect), or give
a switch to wait for or require the full tier instead of starting reduced.
@vivienfanghuagood: on (2), eviction-aware timeouts
Useful, but
evicted_mswon't work as the live signal. KFD adds an eviction's time only when the queues are restored, orwhen the process is torn down. In 7 of my 10 failures in the runs above, the evicted time (62–104 s) only showed up when the
watchdog killed the engine. While the stall was going on,
evicted_msstayed flat, so a watchdog checking it would stillhave fired. The per-process sysfs has no live queue state either (
queues/*holds onlygpuid,size,type). The KFDSMI event interface should report queue eviction and restore as they happen (I haven't tried it), so that, or "GPU idle and
no progress" as a heuristic, would be the better trigger. Waiting would turn some failures into slow requests, not all:
earlier runs had stalls that recovered on their own after 73–83 s, but also a single 248 s eviction.
Please post the extended probe. This box has 8 GB zram swap and gets real anonymous reclaim, so it can fill the reclaim
column you couldn't test (gfx1201,
hipHostRegistervsmlock+hipHostRegistervshipHostMalloc).@alexanderi96: #3913
That's the piece I was missing. The
/dev/zeromappings also change how I read my own trace. In my first comment, ~15 % ofthe quiesces came through the file rmap path, and I had attributed them to the mapped GGUF. Shared anonymous memory is
shmem and goes through that same path, so part of that share may be ROCr's own
fmm_allocate_host_gpubuffers instead.Given the above, the useful case for your PR on 32 GB is the reduced tier: does GTT keep the queues running while the box
is under streaming pressure? I'm happy to run it. Before I do:
STRATA_HIP_MLOCKnorSTRATA_HIP_ARENA_NONCOHERENT, so I'd build #3913 myself.Is
packaging/build_hip_linux.shagainst the TheRock 7.2 wheels the right way, with gfx1201 only?ttm.pages_limithere is 4052118 pages (15.5 GiB,mem_info_gtt_total16.6 GB). Resident budget + ~6 GiB would be~28 GiB, close to all of the 31 GiB, and none of it reclaimable. On this box that may just move the pressure onto the
desktop, or end in an OOM kill. Does the arena have to sit in GTT whole, or does a smaller resident budget (a larger
headroom) work with
STRATA_HIP_ARENA_NONCOHERENT=1, so I can keep GTT around 20–22 GiB?/sys/module/ttm/parameters/pages_limitat runtime enough, or does it have to be on the kernel command line?Planned runs, each reporting
evicted_ms, failures, decode/prefill speed, and MemAvailable/PSI for the rest of thesystem: the same 24-prompt soak, both with the full tier and with a reduced start (balloon held only while the engine
starts). Baseline
=1vs your=0+STRATA_HIP_ARENA_NONCOHERENT=1, interleaved, two runs each.@vivienfanghuagood commented on GitHub (Nov 2, 2026):
Thanks, both. Two corrections to our last comment first.
expert_source.cpp, and our reading was wrong. The paced path does callplatform::lock_resident, but only fromlock_off = partial_pin, so when the whole tier gets registered nothing islocked. Thank you for checking it.
evicted_mscannot be the live signal for (2). KFD adds the time only when the queues comeback. Our own runs show the same: the ones that never recovered within 90 s reported
evicted_ms0 while they werestuck.
@alexanderi96, thanks for #3913. It covers our (1), so we drop it as a separate proposal.
We ran #3913's two options through the same probe and machine as before (Radeon PRO W7900D, gfx1100, 2x EPYC 9334, ROCm
7.2.1, kernel 6.8, no swap; 8 GiB, 60 s). The table gives the seconds of queue eviction KFD reports:
hipHostRegister, thenmlock(whatSTRATA_HIP_MLOCK=1does)hipHostMalloc,HSA_USERPTR_FOR_PAGED_MEM=0hipHostMallocwithhipHostMallocNonCoherent,HSA_USERPTR_FOR_PAGED_MEM=0(asSTRATA_HIP_ARENA_NONCOHERENT=1)HSA_USERPTR_FOR_PAGED_MEM=0,move_pages()moved none of thehipHostMallocpages, and NUMA balancing caused noeviction. So on this two-socket machine, NUMA balancing does not touch the GTT allocation, which was the open question
in #3913.
mlock, before or after the registration, stops neither NUMA balancing nor migration.STRATA_HIP_MLOCK=1addressesreclaim, and on multi-socket hosts with NUMA balancing on, the memory policy fix in #4867 is still needed.
reads one page per launch, so this says nothing about prompt speed.
@aurelbalteaux, here is the extended probe for the reclaim column.
GIB SECONDS ALLOC TRIGGER; ALLOC is one ofregister,mlock(before the registration),register-mlock-after,hostmalloc,hostmalloc-nc,file,file-mlock(withEVICT_FILE=<path>). TRIGGER is one ofnone,numa,migrate(EVICT_MIGRATE_MS, default 50),reclaim. Every trigger exceptnumasetsMPOL_LOCALfirst. SetHSA_USERPTR_FOR_PAGED_MEMin the environment for the GTTarms.
migrateneeds two NUMA nodes, so on your boxreclaimandnoneare the useful ones. Under real pressure, theregister/register-mlock-after/hostmalloc(with=0) comparison withTRIGGER=noneis the column we aremissing.
evict_probe2.hip
@alexanderi96 commented on GitHub (Nov 3, 2026):
@aurelbalteaux thanks, the start-up tier result is a good find. On a 64 GB host I see the same mechanism, but without the stalls: here only 976 of 5199 lend slots are covered at a 32K chunk, but the experts read for the uncovered ones come from the page cache (about 25 GB of expert reads per 63K-token prompt, 0.1-0.4 GB of it from the disk). On 32 GB the page cache cannot hold them, which fits what you measured.
1. Build. No packaging is needed for this test. Check out the PR branch (
gh pr checkout 3913, branchalexanderi96:pr-hip-mlock, two commits on v0.2.9) and build it as any source checkout:./setup.sh --backend hipbuilds for the detected card (gfx1201 takes thegfx120X-allwheels), or the cmake build in AMD_HIP.md, Build with-DCMAKE_HIP_ARCHITECTURES=gfx1201.packaging/build_hip_linux.shalso works, but it builds a whole engine package.2. Does the arena have to sit in GTT whole? No. With
HSA_USERPTR_FOR_PAGED_MEM=0, GTT has to hold the complement (the resident experts in RAM, whichSTRATA_HIP_ARENA_NONCOHERENT=1allocates), the KV copies, and ROCr's own buffers. A smaller--resident-budget-gib, or a largerSTRATA_RESIDENT_HEADROOM_GIB, lowers it by the same amount. The start log shows which path the complement took:mapped pinned cache complement ready: ... page-locked and mapped: the GTT allocation went through.mem_info_gtt_usedgrows by about the budget.page-locking refused (...); trying pageable memory: it did not fit under the GTT limit.page-locking the complement in steps: free RAM at start was below the complement plus a reserve, and the engine took the paced path. That path never makes the GTT allocation; it registers the memory in steps. With your start-up balloon this is the likely case on 32 GB.I have not measured the last two with
=0, so I cannot tell you how they behave there;kfd_evicted_msand those log lines will show it. Note that GTT pages cannot be reclaimed either: on 32 GB whatever goes into GTT is taken away from the desktop, the same as with mlock.3.
ttm.pages_limitat runtime? It has to be set at boot. In the 6.18 source, amdgpu sizes its GTT once at init fromttm_tt_pages_limit()(amdgpu_ttm.c), and the KFD limit for these allocations is read once too (max_ttm_mem_limitinamdgpu_amdkfd_gpuvm.c). A later write to/sys/module/ttm/parameters/pages_limitchanges neither. The default is half the RAM, which is your 15.5 GiB. The KFD limit is also one for the whole system (all GPUs, all processes), and an allocation over it fails with-ENOMEM. Use the kernel command line (ttm.pages_limit=<4 KiB pages>), oroptions ttm pages_limit=...in modprobe.d as long as it is in the initramfs before amdgpu loads, then check/sys/class/drm/card*/device/mem_info_gtt_total. My host is NixOS (boot.kernelParams), so the exact steps on Ubuntu (GRUB,update-initramfs) may differ.@aurelbalteaux commented on GitHub (Nov 3, 2026):
@vivienfanghuagood Thanks for the probe. Here's the reclaim column from this box.
Setup: RX 9070 (gfx1201), Ryzen 7 7800X3D (one NUMA node,
numa_balancing0), 32 GB RAM, 8 GB zram swap, kernel 7.2.The probe was built with
--offload-arch=gfx1201and run against Strata 0.1.52's bundled runtime (ROCm 7.2.0, viaLD_LIBRARY_PATH), 8 GiB, 90 s per run. For "pressure" I filled RAM with an incompressible balloon down to 2.5 GBavailable once the probe had registered its memory, and streamed the 58 GB Gyro-S GGUF through the page cache in a loop,
roughly what a reduced-tier soak does. I didn't run the
mlockarms: the hardRLIMIT_MEMLOCKhere is 8 MiB.HSA_USERPTR_FOR_PAGED_MEMregisternone, no pressureregisternone, pressureregisternone, pressurehostmallocnone, pressurehostmalloc-ncnone, pressureregisterreclaimhostmallocreclaimVmSwapof the probe stayed 0 throughout (the readers keep its pages hot), yet the=1registrationlost 17 s of queue time. So something other than swap-out of the registered pages invalidates the range, likely
compaction or THP migration; I didn't trace it. That fits what I saw with the engine in a
memory.swap.max=0cgroup.=0takes the SVM path forhipHostRegisterand was evicted far less here (0.75 s), but not never.hostmalloc, either variant) was never evicted. Underreclaim,madvise(MADV_PAGEOUT)failed on every callfor those pages, so that row is 0 by construction.
fullpeaked around 1 in the pressure runs: short on RAM, not thrashing.One more result from the engine itself, on @hartmark's suggestion in ROCm/rocm-systems#12528: with the reduced start-up
tier,
GPU_PINNED_MIN_XFER_SIZE=100000(clr stages pageable copies instead of pinning them) took the soak from 1 failureand a 91–104 s eviction per run to 0 failures and no eviction over 1.1 s, two runs each. With plenty of RAM it cost no
measurable speed. So on this box most of the long evictions seem to come from clr pinning the source of pageable copies,
not from the arena registration. If the streamed experts go through a pageable
hipMemcpy, staging them through a pinnedbuffer of the engine's own (or setting that variable) may be a cheap fix on the Strata side.
@alexanderi96 Thanks for the answers. The probe supports the GTT direction of #3913 for the resident tier. For the
reduced-start case, which takes the paced path and never makes the GTT allocation as you said, the staging result above
matters more on this box. I haven't built #3913 yet.
@alexanderi96 commented on GitHub (Nov 3, 2026):
@aurelbalteaux thanks, the reclaim column and the
GPU_PINNED_MIN_XFER_SIZEresult are both useful. A follow-up on the two start-up paths I said I had not measured withHSA_USERPTR_FOR_PAGED_MEM=0. I ran them on my host (64 GB, RX 7900 XTX; it says nothing about your box, only about what the PR does), same build, budget 32 GiB, GTT limit 44 GiB, two fresh 24K-token prompts, then 14 GiB taken by another process with the engine idle and again during a prompt:kfd_evicted_msafter load / at the endpage-locked and mappedpage-locked after taking the pages in steps, forced withSTRATA_PIN_GUARD=2)Both arms already had
GPU_PINNED_MIN_XFER_SIZE=1048576set (my production config carries it), so clr was staging the pageable copies in both. The paced arm still lost minutes of queue time: here, on the paced path, the evictions come from the complement's own registration (it is a userptr whateverHSA_USERPTR_FOR_PAGED_MEMsays), not from copy pinning. That fits your probe (registerevicted,hostmallocwith=0never). Your staging result and this one look complementary: the variable removes the copy-pinning evictions, the GTT route removes the registration ones, and only the first start-up path gets the second.For your runs, if the start log shows the paced line, the engine started with less free RAM than the complement plus a reserve, and that start is not a test of the GTT route. A smaller budget or a larger
STRATA_RESIDENT_HEADROOM_GIBthat keeps it on the first path is.One more thing to watch for: the rest of the engine's host allocations also go to GTT, about 5.7 GiB on top of the complement here (256K context, int8 KV). With a 40 GiB budget under the 44 GiB limit the complement fitted, the start log then said "--adapt-async 1 is off (the exchange buffers could not be page-locked)", and the engine crashed during start-up. So keep the GTT limit a few GiB above the budget.
I am adding both to the PR's docs and description.
@vivienfanghuagood commented on GitHub (Nov 3, 2026):
@aurelbalteaux thank you, this fills the column we could not run. How we read it:
register,=1, pressure only: 17.4 s withVmSwap0. The registered pages were not swapped out, so theinvalidations came from something else. Compaction or THP migration of those pages is the likely candidate. That
matches our migration rows:
move_pages()on registered memory evicted for 21-34 s per minute, and GTT was never touched(our runs, including #3913's two options).
We have not attributed it, though. It could also be reclaim of other pages in the same ranges, or a THP split.
register,=0: 0.75 s. With=0,hipHostRegistertakes the SVM path, which is still a notifier range, so itis not immune. Why it recovered so much faster than the userptr range under the same pressure, we do not know.
reclaim. Together with our NUMA balancing and migration rows, GTT isthe only setup that held under every trigger either of us has tried.
GPU_PINNED_MIN_XFER_SIZE. In clr a value you set is in MiB, and the default threshold is 64 KiB. So 100000 (andthe 1048576 documented in #920) means pageable copies are staged and never page-locked. Our reading of your result: in
the reduced tier, the streamed copies' sources are page-locked for each copy, those short-lived ranges get invalidated
under reclaim, and each one evicts the queues. That is the same mechanism as ROCm/rocm-systems#12528. @alexanderi96's
paced-path run then shows the other half, evictions from the complement's own registration. We measured this
variable earlier on our W7900D for another reason (it also stops the
init_user_pageskernel-log lines from theread-only model mapping): the profile fill took 3.5 s either way, and TTFT and TPOT were unchanged within 0.1 s /
0.0 ms.
What we will check next, with no date: how many page-locked copies Strata's expert streaming makes during a long prompt
in a reduced tier, with and without the variable. We will count
hsa_amd_memory_lock*calls with anLD_PRELOADtracer, on our host. That would confirm which copy path your stalls go through.
One set of numbers from you would settle the 17.4 s. For the
register=1"pressure" run and thehostmalloc=0"pressure" run, the change in these
/proc/vmstatcounters over the run:compact_migrate_scanned,compact_success,pgmigrate_success,thp_split_page,thp_migration_success,pgsteal_kswapd,pgsteal_direct. If compaction or THPmigration moved the registered pages, the first arm should show it and the GTT arm should not. A
cat /proc/vmstat > before; <run>; cat /proc/vmstat > afteraround each run is enough. No ftrace is needed.@aurelbalteaux commented on GitHub (Nov 3, 2026):
@vivienfanghuagood Here are the counters, plus a trace that attributes the invalidations, since the counters alone can't.
Same setup as before (RX 9070, one NUMA node,
numa_balancing0, bundled ROCm 7.2.0, 8 GiB, 90 s, balloon to 2.5 GBavailable + the GGUF streamed through the page cache).
/proc/vmstatdeltas from the moment the probe had registered itsmemory to the end of the run. These are machine-wide, not per process:
register=1, no pressureregister=1, pressurehostmalloc=0, pressurecompact_migrate_scannedcompact_successpgmigrate_successthp_split_pagethp_migration_successpgsteal_kswapdpgsteal_directBoth pressure arms compact and reclaim heavily, and the GTT arm even more so. So the counters can't separate the arms:
GTT pages just aren't candidates, so no amount of compaction touches them. The one clear result is that THP is out
(no splits, no THP migrations).
To attribute it, I reran the
register=1pressure arm with function tracing and kernel stacks on the KFD eviction entrypoints (
amdgpu_hmm_invalidate_hsa,amdgpu_amdkfd_evict_userptr,kgd2kfd_quiesce_mm, the restore workers). The Strataengine was stopped, so the probe was the only KFD process. This run lost 13.8 s (18 launches > 100 ms, longest 2.6 s).
amdgpu_hmm_invalidate_hsa)shrink_folio_list→try_to_unmap: 669 direct, 300 kswapd), 318 compaction (compact_zone→migrate_pages→try_to_migrate, allkcompactd), 6 exitkgd2kfd_quiesce_mm) from the userptr pathsvm_range_evict__alloc_pages_direct_compact, fromdd's readahead), 3 kswapdamdgpu_amdkfd_restore_userptr_workerHow I read it:
compact_zone. Reclaim starts almost none.try_to_unmapfrom reclaim. Most of them arrive while the process is already evicted (only 9 of 1,293 stop the queues), so they
probably keep the userptr restore retrying rather than start new evictions. I didn't trace resume, so I can't split the
13.8 s between the two causes.
VmSwappeaked at 0.9 MB and 10 MB inthis round's two
registerruns (it was 0 last time). So "not swap-out" was too strong. It's mostly compaction plusreclaim, not THP.
svm_range_evict, even with=1, and the firstuserptr restore only came 53 s after the first queue stop. Besides the registered buffer,
evict_probe2allocatesonly
hipMalloc(VRAM), so these SVM ranges must belong to the runtime (ROCr/clr 7.2.0's own host allocations?), andcompaction hits them too. I haven't identified them. Do you see
svm_range_evictstops on your side with=1?@vivienfanghuagood commented on GitHub (Nov 3, 2026):
@aurelbalteaux thanks. That rules out THP and shows compaction starting the stops.
On
svm_range_evictstops with=1: we have not traced on our side. The ROCm 7.2.0 source points to an answer, though,and it assigns the two paths the other way round from your table:
hipHostRegisterreaches libhsakmt'shsakmt_fmm_register_memory()(throughhsa_amd_memory_lock). Inrocm-7.2.0(
projects/rocr-runtime/libhsakmt/src/fmm.c, around line 3910), that function registers new host memory through theSVM API whenever KFD reports
SVMAPISupported. It falls back to a userptr BO only if that fails.HSA_USERPTR_FOR_PAGED_MEMis not consulted there. So the probe's registered buffer would be an SVM range with=1as well, and its invalidations would show up as
svm_range_evict.HSA_USERPTR_FOR_PAGED_MEM(read around line 2813) applies to the runtime's own paged host allocations(
fmm_allocate_host_gpu). With it non-zero, those become userptr BOs: the shared/dev/zeromappings @alexanderi96traced. Those would be your
amdgpu_hmm_invalidate_hsacalls and therestore_userptr_workerruns.That fits what you saw. Most queue stops are SVM, the 1,293 userptr notifier calls mostly land while the queues are
already stopped, and the first userptr restore comes late. It would also explain your earlier
register=0run losingonly 0.75 s: with
=0the runtime's own allocations become GTT, and only the SVM range is left to invalidate. This isfrom reading the source, not from a trace. Logging the probe's region address and comparing it with the range in an
svm_range_evictstack would confirm or refute it.It also corrects our own wording earlier in this thread. We called the registered arena a userptr, which is only true
where the SVM API is not available. On ROCm 7.2 with SVM support it is an SVM range. The eviction mechanism is the same.
@vivienfanghuagood commented on GitHub (Nov 3, 2026):
We counted the page-locked copies, as promised in our last comment. Setup: Radeon PRO W7900D (gfx1100), ROCm 7.2.1,
Qwen3.8-Flash-Next IQ3_S native pack, engine at
c62d5e3, one 32K-token prompt per engine start. AnLD_PRELOADshim logsevery
hsa_amd_memory_lock*/hipHostRegistercall with the mapping it lands in. We split the log into what happensat start-up and what happens during the prompt read:
GPU_PINNED_MIN_XFER_SIZE--resident-budget-gib 8[heap]+ the same 12--resident-budget-gib 8With a RAM budget, almost every expert the prompt streams from the file tier goes through a heap buffer, and clr
page-locks that buffer for the copy. Those are the short-lived registered ranges that reclaim and compaction can
invalidate, so we read this as the source of @aurelbalteaux's long evictions in the reduced tier, and of why
GPU_PINNED_MIN_XFER_SIZE=100000removed them. With the variable set, nothing is page-locked during the prompt. Without abudget, as here, the start-up attempts all fail on the read-only mapping. Each failure is the
init_user_pages: Failed to get user pagesline in the kernel log, about 2,400 per start. They are harmless, but thevariable removes them as well.
Speed: TTFT 23.20 s against 23.22 s without a budget, and 33.3 s against 34.5 s with the 8 GiB budget. These are single
runs in separate processes, within the spread we see between engine starts on this card, so they do not measure a
cost. An earlier two-round alternating A/B on the default config showed TTFT within 0.1 s and the same TPOT.
A question for @Niko1221 before anyone opens a PR: would you take
GPU_PINNED_MIN_XFER_SIZEas an engine default onHIP, set before the first HIP call when the user has not set it? It would keep any value the user sets and have an
opt-out. #920 already documents the variable for the gfx1030 stalls; the question is whether it should be on without
the user knowing about it. Things to decide:
budget is in use;
We have a local change that does this. We will open it as a PR only if you want the default.
@alexanderi96 commented on GitHub (Nov 4, 2026):
Follow-up from #3913, two things this thread asked about.
STRATA_HIP_ARENA_NONCOHERENT=1the start decides on the RAM available instead of the RAM free, and when that covers the budget plus the reserve the complement goes to GTT in one go. amdgpu's GTT allocation reclaims the file cache itself (__GFP_RETRY_MAYFAIL), and a refused allocation still paces. On a 32 GB host it depends on how much is reclaimable at start: the start log saysGTT mode: ... one GTT allocationwhen it worked. Here, with the cache of other files filling 64 GB, it went from 59,960 ms of queue eviction to 0.hipHostMallocgoes to SVM unlessHSA_SVM_FOR_PAGED_MEM=0is set next toHSA_USERPTR_FOR_PAGED_MEM=0. And TTM's page pool keeps a stopped engine's GTT pages outsideMemAvailable(ttm.page_pool_sizebounds it). Details in the PR.