[GH-ISSUE #4514] [Engine] HIP/Linux: split serving on 2× MI50 does not start; two engines on one shared arena run out of the amdgpu memory budget #2029

Closed
opened 2026-11-04 01:56:05 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @MarcoTool on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4514

Area

[Engine] (speed, kernels, models, the server and API)

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

What happened

Note

Two problems found so far, both on 2× MI50 (gfx906) under Linux:

  1. Two HIP engines on one shared arena: the amdgpu driver counts the arena once per engine. This is a count of registered pages, not extra RAM. This does not look specific to gfx906, but I have no other AMD cards to check it on.
  2. The gfx906 build only: experts copied from the part of the arena that is not registered are charged again on each copy. A fix is in my fork: MarcoTool/Strata@d39fb2cb.

If you run two HIP engines on one arena on another AMD card, the output of journalctl -k | grep "SVM mapping failed" would help.

In short: split serving from #4000 does not start on two AMD cards when the PC has less than about twice the experts' size in RAM. The second engine runs out of a memory budget that the AMD driver keeps for the whole machine. A larger STRATA_PIN_RESERVE_MIB works around it; the workaround is at the end.

What I saw. I ran split serving on its supported case: two MI50s, the prompt read on card 0, the answer made on card 1, one shared expert arena in /dev/shm. The prefill engine starts. The decode engine does not become ready, and the kernel log fills with amdgpu: SVM mapping failed, exceeds resident system memory limit.

Setting Decode engine
defaults fills its GPU cache very slowly and misses the 900 s start limit
"engine_ready_s": 3600 fills its cache, then exits after prefill: copy stream with no error line
STRATA_PIN_RESERVE_MIB=4096 exits on verify: copy stream create failed (verify.cpp:1130)
STRATA_PIN_RESERVE_MIB=12288 starts and serves

What I think is happening. Host memory registered for an AMD GPU is charged to one counter for the whole machine (amdgpu_amdkfd_gpuvm.c:56-63), limited to RAM × 63/64 − 1.5 GiB (:126-130), 91.3 GiB here. The count follows the process that registers the memory, not the pages, so the arena that is one copy in RAM is counted once per engine. Registering does not take more RAM: it reserves the pages for the GPU and adds them to the driver's count. RAM holds one copy of the arena; the count holds two, and it is the count that reaches the limit. I logged each engine's driver calls with a small LD_PRELOAD shim:

One copy in RAM, charged once per engine

Two things in the engine turn this into a failure:

  1. The second engine registers until the driver refuses. When the whole arena is refused, pinned.cu:463-469 registers it slice by slice until a slice fails, which leaves no room for any HIP process. Whichever engine allocates next fails. With problem 2 fixed and no reserve, the decode engine started, and the prefill engine failed on the first request with an error that points elsewhere: verify router: bf16_gemv_fp32_mmvf_multi launch: invalid device function. Windows has a limit for this case (#243, pinned.cu:361-390); Linux does not.

  2. The gfx906 build is charged again for every expert it copies from the part it did not register. The HIP build copies through a small staging buffer to avoid this (expert_cache.cpp:801-811), but only under STRATA_USE_HIP, which the gfx906 build does not define (expert_cache.cpp:5-6). The copies then register arena pages that stay charged: 4.51 GiB in 4,308 copies here. Adding || defined(STRATA_HIP_GFX906) to the six guards of that buffer (expert_cache.hpp:247; expert_cache.cpp 538, 632, 670, 688, 801) took those charges to 0.

Why NVIDIA is not affected. The budget belongs to the amdgpu driver, so only memory registered for AMD cards counts against it; the NVIDIA driver on Linux has no such budget (pin_budget.hpp:16-18). The same PC shows this: with the prefill engine on an RTX 3070 and the decode engine on the two MI50s, both engines registered the whole arena, 94 GiB in all and above the 91.3 GiB limit, and both started, because only the decode engine's 47 GiB was counted.

Measured charges per engine (stock 0.2.7)

From the driver calls (ALLOC_MEMORY_OF_GPU, FREE_MEMORY_OF_GPU, SVM), overlapping ranges merged. The shim does not see every release by munmap, so sums are upper bounds.

One engine alone Split, prefill Split, decode (reserve 4096)
Expert arena registered by Strata 46.84 GiB 46.84 GiB 36.11 GiB
Arena pages registered by copies 0 0 4.51 GiB (4,308 × 2.1 MiB)
Other SVM ranges 2.58 GiB 2.58 GiB 2.54 GiB
GTT and userptr allocations 0.86 GiB 0.27 GiB 1.27 GiB
Total 50.3 GiB 49.7 GiB 44.4 GiB

Call stack of one copy's registration (Strata frames resolved with addr2line):

libkfdtrace.so  ioctl  (AMDKFD_IOC_SVM, set_attr, 2,179,072 bytes, inside the arena mapping)
libhsa-runtime64.so.1  (+0x1cea4d, +0x1cbaee, +0x1cb6eb, +0xa0a90, +0xd9698, +0xebb67)
libamdhip64.so.7  ... hipMemcpy
strata  strata::core::ExpertCache::fill_slot_blocking(int, unsigned char const*, std::string&, long)
strata  main

Smallest steps or command that reproduce it

  1. Linux, two AMD cards, RAM below about twice the experts' size plus a few GiB (here 2× MI50 and 94 GiB RAM with Flash-Next IQ3_S, experts 46.8 GiB).
  2. Run config with "split_serve": {"prefill_gpu": 0, "decode_gpu": 1} and --shared-expert-arena /dev/shm/<file>.
  3. python serve/server.py --config <it>: the decode engine does not become ready, and journalctl -k shows SVM mapping failed, exceeds resident system memory limit.

Reproduction status

Reproduced locally

Strata version

Strata 0.2.7 · engine 0.1.52, built from source at v0.2.7 (5e8a4cca) with the one-line gfx906 build fix of #3986 (0.2.7 does not compile for gfx906 without it)

Graphics card, memory and system

2× AMD Instinct MI50 32 GB (gfx906) · 94 GiB RAM (Threadripper 1920X) · Ubuntu 22.04, kernel 6.8.0-138, amdgpu DKMS 6.10.5, ROCm 7.14

Model, size and settings

Qwen3.8-Flash-Next IQ3_S · 256K context, --kv int8, --kv-resident 262144 · MTP on · pictures off · split serving, shared arena in /dev/shm

Logs

Decode engine, stock build, STRATA_PIN_RESERVE_MIB=4096
strata: pinned-memory headroom: holding 5120 MiB for the buffers allocated after the expert arena (released after it: 4096 MiB; kept until needed: 1024 MiB; STRATA_PIN_RESERVE_MIB changes it)
strata: pinned-memory headroom: 4096 MiB handed back after the expert arena
strata generate: expert arena: mlock failed (raise ulimit -l); cudaHostRegister of the whole arena FAILED (invalid argument); 38 slices pinned (36 GiB); MAP_SHARED file /dev/shm/fn-iq3s.arena (pack hash checked)
strata generate: session is up (engine 0.1.52)
strata serve: prompt chunk auto: 8192 tokens, a 96-slot ring
strata serve: the prompt path borrows 1795 CUDA0 cache slots (3.41 GiB)
strata hc: CUDA0: the check of split/staged could not run (setting up the check failed)
strata serve: verify: copy stream create failed

Workaround

Set a headroom reserve for both engines, in the run config's env or the environment: STRATA_PIN_RESERVE_MIB=12288 on stock 0.2.7, or 4096 with the staging guards above. These are values that worked here, not tuned ones.

If you need a gfx906 build of 0.2.7 with the staging fix, it is in my fork: PDHyperMix-Strata-MI50 v0.2.7-pdhm-fix-v0.0, with the Strata branch, build steps and the measuring tools.

This is not optimized. It only gets split serving to run on gfx906.

Runs that work, 16K prompt with no cache and 256 answer tokens, one run each:

Stock, reserve 12288 Staging guards, reserve 4096
Decode engine ready 291 s 292 s
Arena registered by the decode engine 26 GiB 36 GiB
Prefill on card 0 352 tok/s 347 tok/s
Hand-over, 465 MiB session (save + restore) 1.4 s 2.0 s
Decode on card 1 35.7 tok/s 34.4 tok/s

Direction

The two problems are fixed separately.

Problem 1: two HIP engines on one arena. Leave room when registering: on Linux/HIP, stop registering the arena some way below the point where the driver refuses, as Windows already does (#243). The next allocation of either engine then still fits.

Problem 2: the gfx906 build counts copies. Compile the staging buffer into the gfx906 build, the commit in my fork above. It changes only the build guards.

I will follow up to check that the cause of each is what I describe above, and report back here.

Originally created by @MarcoTool on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4514 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Source (START-HERE.bat, setup.sh or a build) ### What happened > [!NOTE] > Two problems found so far, both on 2× MI50 (gfx906) under Linux: > > 1. Two HIP engines on one shared arena: the amdgpu driver counts the arena once per engine. This is a count of registered pages, not extra RAM. This does not look specific to gfx906, but I have no other AMD cards to check it on. > 2. The gfx906 build only: experts copied from the part of the arena that is not registered are charged again on each copy. A fix is in my fork: [MarcoTool/Strata@d39fb2cb](https://github.com/MarcoTool/Strata/commit/d39fb2cb). > > If you run two HIP engines on one arena on another AMD card, the output of `journalctl -k | grep "SVM mapping failed"` would help. **In short:** split serving from #4000 does not start on two AMD cards when the PC has less than about twice the experts' size in RAM. The second engine runs out of a memory budget that the AMD driver keeps for the whole machine. A larger `STRATA_PIN_RESERVE_MIB` works around it; the workaround is at the end. **What I saw.** I ran split serving on its supported case: two MI50s, the prompt read on card 0, the answer made on card 1, one shared expert arena in `/dev/shm`. The prefill engine starts. The decode engine does not become ready, and the kernel log fills with `amdgpu: SVM mapping failed, exceeds resident system memory limit`. | Setting | Decode engine | |---|---| | defaults | fills its GPU cache very slowly and misses the 900 s start limit | | `"engine_ready_s": 3600` | fills its cache, then exits after `prefill: copy stream` with no error line | | `STRATA_PIN_RESERVE_MIB=4096` | exits on `verify: copy stream create failed` ([`verify.cpp:1130`](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/core/verify.cpp#L1124-L1131)) | | `STRATA_PIN_RESERVE_MIB=12288` | starts and serves | **What I think is happening.** Host memory registered for an AMD GPU is charged to one counter for the whole machine ([`amdgpu_amdkfd_gpuvm.c:56-63`](https://github.com/torvalds/linux/blob/v6.8/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c#L56-L63)), limited to RAM × 63/64 − 1.5 GiB ([`:126-130`](https://github.com/torvalds/linux/blob/v6.8/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c#L126-L130)), 91.3 GiB here. The count follows the process that registers the memory, not the pages, so the arena that is one copy in RAM is counted once per engine. Registering does not take more RAM: it reserves the pages for the GPU and adds them to the driver's count. RAM holds one copy of the arena; the count holds two, and it is the count that reaches the limit. I logged each engine's driver calls with a small `LD_PRELOAD` shim: ![One copy in RAM, charged once per engine](https://gist.githubusercontent.com/MarcoTool/7a0d06ce2a4761fc34d3231f3bfec377/raw/kfd-concept.png) Two things in the engine turn this into a failure: 1. **The second engine registers until the driver refuses.** When the whole arena is refused, [`pinned.cu:463-469`](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/core/pinned.cu#L463-L469) registers it slice by slice until a slice fails, which leaves no room for any HIP process. Whichever engine allocates next fails. With problem 2 fixed and no reserve, the decode engine started, and the prefill engine failed on the first request with an error that points elsewhere: `verify router: bf16_gemv_fp32_mmvf_multi launch: invalid device function`. Windows has a limit for this case (#243, [`pinned.cu:361-390`](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/core/pinned.cu#L361-L390)); Linux does not. 2. **The gfx906 build is charged again for every expert it copies from the part it did not register.** The HIP build copies through a small staging buffer to avoid this ([`expert_cache.cpp:801-811`](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/core/expert_cache.cpp#L801-L811)), but only under `STRATA_USE_HIP`, which the gfx906 build does not define ([`expert_cache.cpp:5-6`](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/core/expert_cache.cpp#L5-L6)). The copies then register arena pages that stay charged: 4.51 GiB in 4,308 copies here. Adding `|| defined(STRATA_HIP_GFX906)` to the six guards of that buffer ([`expert_cache.hpp:247`](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/include/strata/core/expert_cache.hpp#L247); `expert_cache.cpp` [538](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/core/expert_cache.cpp#L538), [632](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/core/expert_cache.cpp#L632), [670](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/core/expert_cache.cpp#L670), [688](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/core/expert_cache.cpp#L688), [801](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/src/core/expert_cache.cpp#L801)) took those charges to 0. **Why NVIDIA is not affected.** The budget belongs to the amdgpu driver, so only memory registered for AMD cards counts against it; the NVIDIA driver on Linux has no such budget ([`pin_budget.hpp:16-18`](https://github.com/Niko1221/Strata/blob/5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d/include/strata/core/pin_budget.hpp#L16-L18)). The same PC shows this: with the prefill engine on an RTX 3070 and the decode engine on the two MI50s, both engines registered the whole arena, 94 GiB in all and above the 91.3 GiB limit, and both started, because only the decode engine's 47 GiB was counted. <details><summary>Measured charges per engine (stock 0.2.7)</summary> From the driver calls (`ALLOC_MEMORY_OF_GPU`, `FREE_MEMORY_OF_GPU`, `SVM`), overlapping ranges merged. The shim does not see every release by `munmap`, so sums are upper bounds. | | One engine alone | Split, prefill | Split, decode (reserve 4096) | |---|---|---|---| | Expert arena registered by Strata | 46.84 GiB | 46.84 GiB | 36.11 GiB | | Arena pages registered by copies | 0 | 0 | 4.51 GiB (4,308 × 2.1 MiB) | | Other SVM ranges | 2.58 GiB | 2.58 GiB | 2.54 GiB | | GTT and userptr allocations | 0.86 GiB | 0.27 GiB | 1.27 GiB | | Total | 50.3 GiB | 49.7 GiB | 44.4 GiB | Call stack of one copy's registration (Strata frames resolved with `addr2line`): ``` libkfdtrace.so ioctl (AMDKFD_IOC_SVM, set_attr, 2,179,072 bytes, inside the arena mapping) libhsa-runtime64.so.1 (+0x1cea4d, +0x1cbaee, +0x1cb6eb, +0xa0a90, +0xd9698, +0xebb67) libamdhip64.so.7 ... hipMemcpy strata strata::core::ExpertCache::fill_slot_blocking(int, unsigned char const*, std::string&, long) strata main ``` </details> ### Smallest steps or command that reproduce it 1. Linux, two AMD cards, RAM below about twice the experts' size plus a few GiB (here 2× MI50 and 94 GiB RAM with Flash-Next IQ3_S, experts 46.8 GiB). 2. Run config with `"split_serve": {"prefill_gpu": 0, "decode_gpu": 1}` and `--shared-expert-arena /dev/shm/<file>`. 3. `python serve/server.py --config <it>`: the decode engine does not become ready, and `journalctl -k` shows `SVM mapping failed, exceeds resident system memory limit`. ### Reproduction status Reproduced locally ### Strata version Strata 0.2.7 · engine 0.1.52, built from source at v0.2.7 (5e8a4cca) with the one-line gfx906 build fix of #3986 (0.2.7 does not compile for gfx906 without it) ### Graphics card, memory and system 2× AMD Instinct MI50 32 GB (gfx906) · 94 GiB RAM (Threadripper 1920X) · Ubuntu 22.04, kernel 6.8.0-138, amdgpu DKMS 6.10.5, ROCm 7.14 ### Model, size and settings Qwen3.8-Flash-Next IQ3_S · 256K context, `--kv int8`, `--kv-resident 262144` · MTP on · pictures off · split serving, shared arena in `/dev/shm` ### Logs <details><summary>Decode engine, stock build, STRATA_PIN_RESERVE_MIB=4096</summary> ``` strata: pinned-memory headroom: holding 5120 MiB for the buffers allocated after the expert arena (released after it: 4096 MiB; kept until needed: 1024 MiB; STRATA_PIN_RESERVE_MIB changes it) strata: pinned-memory headroom: 4096 MiB handed back after the expert arena strata generate: expert arena: mlock failed (raise ulimit -l); cudaHostRegister of the whole arena FAILED (invalid argument); 38 slices pinned (36 GiB); MAP_SHARED file /dev/shm/fn-iq3s.arena (pack hash checked) strata generate: session is up (engine 0.1.52) strata serve: prompt chunk auto: 8192 tokens, a 96-slot ring strata serve: the prompt path borrows 1795 CUDA0 cache slots (3.41 GiB) strata hc: CUDA0: the check of split/staged could not run (setting up the check failed) strata serve: verify: copy stream create failed ``` </details> ## Workaround Set a headroom reserve for both engines, in the run config's `env` or the environment: `STRATA_PIN_RESERVE_MIB=12288` on stock 0.2.7, or `4096` with the staging guards above. These are values that worked here, not tuned ones. If you need a gfx906 build of 0.2.7 with the staging fix, it is in my fork: [PDHyperMix-Strata-MI50 `v0.2.7-pdhm-fix-v0.0`](https://github.com/MarcoTool/PDHyperMix-Strata-MI50/tree/v0.2.7-pdhm-fix-v0.0), with the Strata branch, build steps and the measuring tools. > This is not optimized. It only gets split serving to run on gfx906. Runs that work, 16K prompt with no cache and 256 answer tokens, one run each: | | Stock, reserve 12288 | Staging guards, reserve 4096 | |---|---|---| | Decode engine ready | 291 s | 292 s | | Arena registered by the decode engine | 26 GiB | 36 GiB | | Prefill on card 0 | 352 tok/s | 347 tok/s | | Hand-over, 465 MiB session (save + restore) | 1.4 s | 2.0 s | | Decode on card 1 | 35.7 tok/s | 34.4 tok/s | ## Direction The two problems are fixed separately. **Problem 1: two HIP engines on one arena.** Leave room when registering: on Linux/HIP, stop registering the arena some way below the point where the driver refuses, as Windows already does (#243). The next allocation of either engine then still fits. **Problem 2: the gfx906 build counts copies.** Compile the staging buffer into the gfx906 build, the commit in my fork above. It changes only the build guards. I will follow up to check that the cause of each is what I describe above, and report back here.
Author
Owner

@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:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6660579705 --> @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: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2029
No description provided.