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#3911
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/2189
Author: @i-Vladimir-i
Created: 10/12/2026
Status: ❌ Closed
Base:
main← Head:hip-vmm📝 Commits (1)
31d54fdHIP: virtual memory for --kv-grow and --vram-elastic (#533) through vmm.hpp📊 Changes
10 files changed (+341 additions, -224 deletions)
View changed files
📝
docs/DETAILS.md(+7 -2)📝
docs/VRAM_ELASTIC.md(+6 -5)📝
include/strata/core/expert_cache.hpp(+2 -2)📝
include/strata/core/vmm.hpp(+25 -5)📝
serve/test_vram.py(+1 -1)📝
src/core/expert_cache.cpp(+20 -139)📝
src/core/vmm.cpp(+268 -62)📝
src/program/generate.cpp(+4 -4)📝
tests/core/expert_cache_segmented_test.cpp(+3 -4)📝
tests/core/vmm_test.cpp(+5 -0)📄 Description
HIP: virtual memory for
--kv-growand--vram-elastic(#533) throughvmm.hppBoth switches were NVIDIA-only:
vmm.cpphad a stub for HIP, andexpert_cache.cppcarried a second copy of the CUDAdriver table for #533's segments and refused at open on HIP. ROCm has the same functions (
hipMemAddressReserve,hipMemCreate,hipMemMap,hipMemSetAccess,hipMemUnmap,hipMemRelease), so this ports them.What it changes
src/core/vmm.cppis the one place that talks to the driver's virtual memory, for both backends: a small set ofdriver operations per backend (CUDA: the driver API through the runtime's entry points, as before; HIP: the
runtime's
hipMem*), and the chunks,VmmRangeand #533's segments written once on top of it.hipMemGetInfocounts each 4 KiB chunk as 2 MiB, so the elastic K/V would have needed 512 times as many chunks.CUDA keeps its minimum (2 MiB).
expert_cache.cpp's segmented arena callsvmm_segment_*/vmm_reserve/vmm_address_freeinstead of its owndriver table. On CUDA these are the same driver calls with the same sizes in the same order (
cuMemCreate,cuMemMap,cuMemSetAccess,cuMemUnmap,cuMemRelease,cuMemAddressFree, the recommended granularity for thesegments as before).
generate.cpp:--vram-elasticis no longer refused on HIP; it stays off on HIP on Windows (AMD's virtualmemory was measured on Linux only). The help line and the
VRAMrefusal no longer say NVIDIA. Docs follow.vmm_testchecks the HIP chunk size;expert_cache_segmented_testruns on HIP instead of skipping.What it leaves alone: the default path (without
--kv-grow/--vram-elasticnothing calls the new code exceptvmm_available(), which only queries); the CUDA behaviour of both switches; the gfx906 compat build (no virtualmemory, as before: never measured there); every setup and server path.
Measured before writing it (a standalone probe on gfx1201, ROCm 7.14.1, amdgpu 6.19, Linux), because vLLM's ROCm
sleep mode needed workarounds (vllm-project/vllm#37533, #43022, #60367):
(
mem_info_vram_used) while its address range stays reserved, andhipMemGetInfoshows it at once. So theVA free-and-re-reserve cycle vLLM needed on MI300 / ROCm 7.2 is not needed here, and
VRAM's free-memory check readsthe right number.
hipMemAddressFreeof its tail: an error that also breaks the later fullfree), and one
hipMemSetAccessorhipMemcpycannot span two reservations (a kernel can). So, as on CUDA, onereservation per range.
is mapped (vLLM #60367 needed it on MI300 / ROCm 7.2).
user maps a chunk twice at once (the K/V maps a chunk the cache has unmapped), and
vmm_testmoves chunks that way.How it was checked
ple_parity(needs the Q2_0 fixture, as on thebase commit); one skip fewer than the base (
expert_cache_segmented_testnow passes).vmm_testandexpert_cache_segmented_testpass on both cards of the box.vmm_test), a segment unmapped but not released(
expert_cache_segmented_test: "VRAM not given back"), no access set (vmm_testfails, the segmented test hangs).CMAKE_CUDA_ARCHITECTURES=120, 0 errors and no warnings inthe changed files. Not run on an NVIDIA GPU (there is none here).
serve.test_vram: 7 tests OK.--serve:--vram-elastic: reserves of 4000 / 8000 / 16000 MiB took 35 / 44 / 80 ms and gave the driver 3.2 / 7.2 /14.7 GiB; decode 120.7 -> 119 / 114 / 98 tok/s (256-token greedy answers);
{"reserve_mib": null}grew it back in0.56 s,
{"reserve_mib": 0}to the full 10736 slots. With--adapt-every 0 STRATA_ROUTE_RESIDENT=0the answerafter growing back was token for token the one before the shrink (with the adaptive tier or route-resident on, two
identical requests already differ without any shrink, so that is the only clean comparison).
--kv-growagainst the K/V window (--kv-resident 32768), 320-token answers, two runs each: decode at 36Ktokens 115/115 vs 93/100 tok/s, at 78K 94/94 vs 94/94, at 156K 96/94 vs 81/88; prompt the same except one window
run at 156K (1600 vs 2400 tok/s, the earlier window run there read at 2393); every needle found.
Not tested: NVIDIA at run time, Windows (HIP stays off there for
--vram-elastic), the gfx906 build, other RDNAcards,
--kv-growtogether with batch slots (it refuses them, unchanged).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.