Skip to content

fix(umbp): keep the standalone server serving when its GPU-registered DRAM pool is migrated - #756

Merged
isytwu merged 3 commits into
ROCm:mainfrom
isytwu:fix/umbp-sa-stall
Oct 13, 2026
Merged

isytwu merged 3 commits into
ROCm:mainfrom
isytwu:fix/umbp-sa-stall

Conversation

@isytwu

@isytwu isytwu commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

On MI355X nodes with fragmented host memory, the UMBP standalone process stalled sglang for up to ~15 minutes at the start of a benchmark (no request returned; BatchExists took 900+ s on every rank), and GPU IPC registration took 90-150 s per buffer.

Root cause

  • The standalone process registers its whole DRAM pool (~1.1 TiB of 4 KiB pages) with hipHostRegister. KFD does not pin userptr registrations; it mirrors them (HMM).
  • Kernel compaction (proactive compaction, vm.compaction_proactiveness=20) migrates pages of the pool. Every migration fires amdgpu_amdkfd_evict_userptr, which quiesces all of the process's queues on every GPU; the restore worker then re-validates the entire registration (130-150 s per attempt on the affected node), and a migration during the attempt reschedules it.
  • While evicted, the GPU copies in BatchPutRanges never finish; the write holds client_mu_ exclusively, so every rank's BatchExists blocks, and the sglang scheduler waits on it. KFD ioctls, IPC import included, also wait for the restore.
  • Evidence (kprobes and KFD SMI events): 94% of evict_userptr calls came from kcompactd -> proactive_compact_node -> ... -> try_to_migrate_one; the eviction windows of the standalone process line up with the stalls, and IPC registrations completed only when a restore attempt ended.

Changes

  1. Lock scope (standalone_server.cpp). For a distributed backend on a non-SSD medium, which already synchronizes itself, writes take client_mu_ shared and lookups take no lock. Registration, deregistration, Clear, Flush and shutdown stay exclusive; other backends are unchanged. A stalled write no longer blocks lookups.
  2. Chunked GPU registration (HostTierRegistration, HbmCopyEngine::Plan). Gather regions are registered in UMBP_DRAM_HOST_REGISTER_CHUNK_MB pieces (default 1024; 0 keeps whole-region registration), so a migration re-validates one piece; the planner splits host-side ranges at piece boundaries. This is the fallback for pools that are not on hugetlbfs pages.
  3. Hugetlb fallback logging. When UMBP_DRAM_USE_HUGEPAGES=1 cannot get enough hugetlbfs pages, the fallback to 4 KiB pages is logged as an error with the page count and its consequence, instead of a one-line warning.

Not included on purpose: transparent hugepages for the pool (tried in #679, reverted in #687; coverage varied from 4% to 100% across our runs).

Recommended deployment

  • Reserve enough 2 MiB hugetlbfs pages and set UMBP_DRAM_USE_HUGEPAGES=1. Compaction never moves hugetlb pages, and GPU registration of the pool takes ~5 s instead of minutes.
  • Optionally set HSA_USERPTR_FOR_PAGED_MEM=0 for the standalone process only, so HIP/ROCr's own small host allocations are GTT BOs rather than userptr; with it the standalone process saw no queue eviction at all.

Testing

CI on this PR passed: builds (MI355X_AINIC, MI300X_MLX), mori umbp unit test (MI355X_AINIC), pre-commit, intranode/internode tests. mori umbp single-node hicache smoke test was skipped while the PR is a draft.

Hardware validation of these three commits (applied to 066fd10e; the six files they touch are identical on main), MI355X x8, Kimi-K3, sglang DCP8 conc=48, UMBP standalone process with a 1160 GiB DRAM pool:

Run GPU registration of the pool Result
Hugetlb shortfall: standalone process started with UMBP_DRAM_USE_HUGEPAGES=1 and no pages reserved - the new error-level log with the page count (593920) and its consequence; the standalone process continues on 4 KiB pages
DCP8, pool on 4 KiB pages (the fallback path) 174 s, 1161 pieces no stall; warmup 2384 s (HiCache x1.3 = 2547 s); BatchExists <= 0.03 s throughout; 71.8k input tok/s, 94.8% prefix hit, 0 errors. The standalone process still had its GPU queues evicted (up to 60 s at a time during the benchmark), and writes slowed to tens of seconds in the first minute of the benchmark: degraded, but sglang keeps serving
DCP8, pool on 2 MiB hugetlbfs pages + HSA_USERPTR_FOR_PAGED_MEM=0 on the standalone process (recommended) 4.8 s, 1161 pieces no queue eviction in the standalone process; warmup 2461 s; BatchExists <= 0.04 s; 70.5k input tok/s, 94.5% prefix hit, 0 errors

Unit tests in a container on the same node, with memlock unlimited, the docker default, and 2 MiB pieces (UMBP_DRAM_HOST_REGISTER_CHUNK_MB=2): test_hbm_backend 12/12 including the new NeverPlansASegmentAcrossAHostRegistrationPiece, test_standalone_shm_ipc 11 passed and 1 skipped, test_page_backend and test_umbp_host_mem_allocator passed; the pool_client_ranges / batch_put failures are the pre-existing remote-path ones (no RDMA in the container), identical to stock.

Reference, stock mori on the same line: zero-return phase 931 s, BatchExists max 919.7 s, standalone process queues evicted for up to 931 s at a time. Earlier images carrying the same lock and chunking code, on hugetlb: 5/5 DCP8 rounds warmed up in 2140-2304 s, and the DCP8 3600 s regression passed all six checks (73.3k input tok/s, 95.2% prefix hit; stock 72.4k-74.0k, 95.0-95.2%).

Related, not addressed here

On AINIC (ionic), ibv_reg_mr of host memory is limited to ~2 GiB per MR and ~3 GiB per device with 4 KiB pages, and to ~1 TiB per MR with 2 MiB pages. mori-io registers a whole buffer as one MR on the first cross-node session and aborts if that fails, so a 1.1 TiB pool would abort; multi-node deployments need hugetlb plus chunked MR registration (or 1 GiB pages, or smaller buffers).

Every write handler took client_mu_ exclusively and held it through the
backend call, GPU copies included. A write that stalled -- for instance
while the KFD driver re-validated the GPU-registered host pool after kernel
compaction migrated one of its pages -- therefore blocked BatchExists for
every rank, and sglang's scheduler waits on that lookup.

A distributed backend on a non-SSD medium already synchronizes puts, gets
and lookups itself (DistributedClient's op_mutex_, PageBackend's own lock),
since an embedded client drives it from several threads. For it client_mu_
only has to be the lifetime barrier for resolved client mappings: writes
now take it shared, and lookups, which dereference no client memory, do not
take it at all. Registration, deregistration, Clear, Flush and shutdown
still take it exclusively, and every other backend keeps its old locking.
The KFD driver does not pin memory registered with hipHostRegister. When
the kernel migrates any page of a registration -- compaction does this
continuously on a host with fragmented free memory -- the driver stops the
process's queues on every GPU and re-validates the whole registration. For
a terabyte DRAM pool on 4 KiB pages one attempt takes minutes, and a
migration during the attempt restarts it, so the standalone server can get
no GPU work done for a quarter of an hour.

Register gather regions in UMBP_DRAM_HOST_REGISTER_CHUNK_MB pieces instead
(default 1024; 0 keeps whole-region registration), so a migration
re-validates one piece. Pieces are cut at absolute multiples of the piece
size and registered in address order on a background thread; a piece is
usable as soon as it is registered. HbmCopyEngine::Plan splits host-side
ranges at the same boundaries, because hipMemcpy rejects a range spanning
two registrations and a gather fragment can use only one piece's device
alias.

This is the fallback for pools that are not on hugetlbfs pages, which
compaction never migrates.
…costs

When UMBP_DRAM_USE_HUGEPAGES=1 cannot get enough hugetlbfs pages, the pool
falls back to anonymous 4 KiB pages with a one-line warning. For a
GPU-registered pool that quietly brings back what reserving hugepages was
for: kernel compaction migrates the pages, and every migration stops the
process's GPU queues until the driver re-validates the registration. Keep
the fallback, but log it as an error with the number of pages asked for and
how to avoid it.
@isytwu
isytwu marked this pull request as ready for review October 13, 2026 03:11
@isytwu
isytwu merged commit e96709b into ROCm:main Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant