mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#4025
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/2398
Author: @i-Vladimir-i
Created: 10/14/2026
Status: ❌ Closed
Base:
main← Head:hip-vmm-v2📝 Commits (2)
1823380HIP: virtual memory for --kv-grow and --vram-elastic (#533) through vmm.hpp60027b5HIP virtual memory only where the runtime shows it works: a check at its first use on a device📊 Changes
10 files changed (+546 additions, -234 deletions)
View changed files
📝
docs/DETAILS.md(+10 -3)📝
docs/VRAM_ELASTIC.md(+15 -5)📝
include/strata/core/expert_cache.hpp(+2 -2)📝
include/strata/core/vmm.hpp(+32 -6)📝
serve/test_vram.py(+1 -1)📝
src/core/expert_cache.cpp(+22 -142)📝
src/core/vmm.cpp(+417 -63)📝
src/program/generate.cpp(+11 -6)📝
tests/core/expert_cache_segmented_test.cpp(+3 -4)📝
tests/core/vmm_test.cpp(+33 -2)📄 Description
Title
HIP: virtual memory for
--kv-growand--vram-elastic, on only where a start-up check passes (resubmits #2189)Issue: follows up #2189 (closed: "a check at start that turns HIP's virtual memory on only where it works"); #533;
#1475's setup now skips for the right reason.
Summary
#2189 rebased on v0.1.44, plus a check at the first use on each GPU. HIP's virtual memory stays on only where the
runtime shows that it works. Everywhere else,
--kv-growand--vram-elasticstay off, the log says why, and theengine runs on with the cache in one allocation. With setup's ROCm 7.10.0a20251120 wheels on an R9700 the check fails
(granularity 4 KiB). With ROCm 7.14.1 it passes.
The check also fixes a bug #2189 had on every ROCm: on Linux, ROCm keeps one open file per physical allocation. A 24 GiB
--kv-growarena of 2 MiB chunks needs ~12,500 open files, so under the usual soft limit of 1,024 the cache could notbe mapped at any size.
#2399 (
--vram-elasticwith--kv-grow, the resubmitted #2201) is opened at the same time and builds on this one.What changed
Commit 1: #2189 rebased, unchanged.
src/core/vmm.cppis the one place that talks to the driver's virtual memory, for both backends (CUDA's driver API,HIP's
hipMem*).expert_cache.cpp's segments go through it.STRATA_GPU_METALguard: Metal now sits next to gfx906 (no backend).Commit 2: the check.
src/core/vmm.cpp: a per-device verdict, decided once, at the first use. On HIP it requires:hipMemGetInfo's free memory down by about that much, and back up oncethey are unmapped and released (the addresses stay reserved). One retry, in case another program moves the counter
at the same moment;
and the log says so. The engine uses no
select(), the one thing a higher limit could break.CUDA decides as before (entry points and the device attribute), without the measurement.
include/strata/core/vmm.hpp:vmm_off_reason(), which says what the check saw and names the HIP runtime.vmm_available()/vmm_device_supported()answer with the verdict.src/program/generate.cpp: the reason goes into--kv-grow is off (...; no GPU virtual memory: <reason>)and--vram-elastic is off: <reason>.src/core/expert_cache.cpp: the segmented cache's open error carries the reason.Before,
--vram-elasticon a driver without virtual memory failed the start. Now it falls back like the other cases,on CUDA too.
tests/core/vmm_test.cpp:docs/VRAM_ELASTIC.md,docs/DETAILS.md: the check, the open files, and what the two ROCm versions do.What it leaves alone:
--kv-grow/--vram-elastic, nothing calls the new code (both callers short-circuit onthe switch).
vmm.cpp,expert_cache.cppandgenerate.cpp. From this change it compiles only thetwo headers:
vmm.hppgains declarations that nothing insycl/calls, andexpert_cache.hppchanges only acomment.
Extra Notes
How it was checked. Radeon AI PRO R9700 32 GB (gfx1201), Linux 6.8, amdgpu 6.19.14. Both ROCm versions ran on the
same machine with the same build flags (
-DCMAKE_HIP_ARCHITECTURES=gfx1201 -DSTRATA_PREFILL_MMQ=ON -DSTRATA_BUILD_TESTS=ON). Setup's wheels were installed from the gfx120X-all index into a venv and built with setup's--rocm-path/--rocm-device-lib-pathflags. Live runs used Unsloth UD-IQ4_XS, every expert in RAM, a 262K context,--kv-growand"vram_elastic": truethroughserve.server, started from a shell with the default open-file limit(soft 1,024).
ROCm 7.10.0a20251120 (HIP runtime 7.2.53210):
vmm_test:no GPU virtual memory here (the recommended allocation granularity is 4 KiB, not 2 MiB or more (HIP runtime 7.2.53210)) - skipped.expert_cache_segmented_testskips (77) with the same reason. Before, both failed.This is #1475's setup.
ple_parity(it needs the Q2_0 fixture, as on 7.14.1). In one of two runs,hip_prefill_native_batchalso segfaulted once; it links only the kernels, notvmm.cpp, and it passed in the otherrun.
--kv-grow is off (...; no GPU virtual memory: the recommended allocation granularity is 4 KiB, not 2 MiB or more (HIP runtime 7.2.53210))and--vram-elastic is off: <the same>. The cache was 9,578 slots (21.58 GiB) in oneallocation. Answers were normal, and
POST /v1/vramgot the usual 400.measured here.
ROCm 7.14.1 (HIP runtime 7.14.60850):
ple_parity, as above).vmm_testandexpert_cache_segmented_testpass.--kv-growis off next to--vram-elastichere, as on v0.1.44):VRAM 4000left3,662 MiB free. A 30.6K-token prompt with a needle was answered right while the cache was shrunk.
VRAM 0broughtback all 9,578 slots.
open-file limit 1024 -> 17336. Without that raise, a fresh process mapped 1,017chunks and then
hipMemCreatefailed; the free VRAM came back whole after each failed attempt. Underulimit -Hn 4096(with PR B's build, the same check):--vram-elastic is off: ROCm keeps an open file per 2 MiB chunk: 17336 needed, and the open-file limit is 4096 (hard 4096; ...), and the engine served with one allocation.the free VRAM fell by 32 MiB for 32 MiB mapped and rose by 0 MiB after its release, and both tests skip.--kv-grow, no--vram-elastic), greedy, 256 tokens, two prompts, in the order v0.1.44, this, v0.1.44, this. Theanswers were byte-identical: one output hash per prompt across all four runs, with decode 60.1 / 60.1 / 60.1 / 59.9
and 70.8 / 70.7 / 70.8 / 70.7 tok/s. No line about virtual memory or open files appeared.
Other backends:
CMAKE_CUDA_ARCHITECTURES=120, 0 errors, and no warnings in the changedfiles. Not run on an NVIDIA GPU (there is none here).
sycl/project (engine and parity tests, 217 targets) builds with oneAPI DPC++ 2026.1 on bothbranches, 0 errors, and no warnings from the two headers. Not run: there is no Intel GPU here.
serve.test_vramandserve.test_vision_elasticpass (14 tests).Not tested: NVIDIA at run time; Windows (HIP keeps
--vram-elasticoff there, and--kv-growgoes through the samecheck, without the open-file part); the gfx906 build; other RDNA cards; ROCm versions between 7.10 and 7.14.1.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.