mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4867] [Engine] HIP/Linux: keep the kernel's NUMA balancing off the engine's memory (GPU queue evictions) #5224
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#5224
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4867
Author: @vivienfanghuagood
Created: 11/1/2026
Status: 🔄 Open
Base:
main← Head:fix/numa-balancing-kfd-evictions📝 Commits (1)
718259a[Engine] HIP/Linux: keep the kernel's NUMA balancing off the engine's memory (GPU queue evictions)📊 Changes
5 files changed (+140 additions, -0 deletions)
View changed files
📝
CMakeLists.txt(+5 -0)➕
include/strata/platform/numa_balancing.hpp(+97 -0)📝
src/dsv41/ds4_main.cpp(+4 -0)📝
src/program/generate.cpp(+5 -0)➕
tests/platform/numa_balancing_test.cpp(+29 -0)📄 Description
Problem and result
On a Linux host with
kernel.numa_balancing=1(the default on most two-socket machines), the HIP engine stops atrandom points of a request, in the prompt read and in decode, until the #29 watchdog ends it:
no progress for 60 s during a request (...).The cause is the NUMA-balancing scanner. Its PTE updates (
PROT_NONEsampling) are MMU-notifier invalidations of thehipHostRegistered, KFD userptr ranges the GPU reads. On a GPU without XNACK, amdgpu answers each invalidation byevicting all of the process's GPU queues until the range is validated again. Details, the ruled-out alternatives and a
standalone reproducer are in https://github.com/Niko1221/Strata/issues/4866.
This change sets
MPOL_LOCALfirst thing inmain()when balancing is on and nobody chose a policy. MPOL_LOCAL is anexplicit policy with the same placement as the default, and the scanner skips memory under an explicit policy.
Radeon PRO W7900D (gfx1100), two-socket host, Ubuntu 24.04 / kernel 6.8, ROCm 7.2.1,
c62d5e3a1. Qwen3.8-Flash-NextIQ3_S with setup's config. Each row is 20 fresh 1K-token prompts with 64 output tokens:
evicted_msper engine startThe host's kernel log tells the same story:
Workqueue: events_freezable amdgpu_amdkfd_restore_userptr_worker, blocked 122 to 245 s.numactlpolicy.Related discussion
https://github.com/Niko1221/Strata/issues/4866. Since this changes a default (on Linux when
numa_balancingis on), it can be made opt-in if you prefer.Same mechanism as #649 and #3913 (non-XNACK queue eviction on userptr invalidation), different trigger: no swap or
reclaim here, plenty of free RAM. #3913 locks the registered ranges against reclaim; we did not test whether
mlockalso keeps the NUMA scanner away. Possibly related: #4363, #3443, #1705 (untested here).Approach
The new
include/strata/platform/numa_balancing.hppis called at the top ofmain()instrata(the server's--serveengine) andstrata-dsv41. On Linux, when/proc/sys/kernel/numa_balancingis non-zero andget_mempolicyreports the default policy, it callsset_mempolicy(MPOL_LOCAL)and logs one line.task_numa_work()passes over a VMA whenvma_policy_mof()is false,which is the case for an explicit policy without
MPOL_F_NUMA_BALANCING. Placement is the same as the default's, sothe NUMA pool's first-touch placement is unchanged, and so are the output tokens.
set_mempolicyis per thread, and the scanner judges a VMA by the policyof the thread it interrupts. The helper counts
/proc/self/taskand warns when other threads already exist. Onthis build
main()starts with one. In the standalone reproducer, setting the policy after the CPU threads startedleft stalls of 44 to 46 s; setting it before left none over 100 ms in one round.
numactl --membind,--interleave, ...), and the DeepSeek path'sper-slice
mbind.STRATA_NUMA_BALANCING=keep.hipHostRegistercall site (arena, KV host copy, file tier, DeepSeek) andfuture ones. It also avoids splitting the arena into many VMAs (the
vm.max_map_countconcern inexpert_source.cpp).An alternative needs no code change: operators can set
kernel.numa_balancing=0on the host, or start the engineunder
numactl --localalloc.Validation
Passed:
numa_balancing_test(new, header-only): the decision table, built with g++ 13 and with the HIP build.STRATA_PREFILL_MMQ,STRATA_Q6K_EXPERTS,STRATA_MMQ_KQUANTS) atc62d5e3a1.strata --versionon a balancing host prints the new line and no thread warning.serve/server.py, card used alone: 20 / 20 fresh 1K requests, no watchdog stop, the engine logshows the new line,
evicted_msup to 907 for the whole run (table above). The same 20 requests on the unpatchedbuild in the same session: 7 stops.
MPOL_LOCAL(up to 3,223 ms evicted),MPOL_INTERLEAVE0,1 (0 ms).requests): 25 engine starts, 260 requests served, 0 watchdog stops, and no hung task in the kernel log.
Failed:
Not run:
__linux__and needs no GPU API, but it touchesgenerate.cppandds4_main.cpp, which those builds compile, so this stays a draft until they are built.strata-dsv41at runtime: it is built, not run with this change.numa_balancingis usually 0 and the change does nothing; not tried.Limits
compaction. They are far below the watchdog.
STRATA_NUMA_BALANCING=keep(or a user policy that keepsMPOL_F_NUMA_BALANCING), the stalls come back.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.