Linux integrated GPU: the auto expert cache counts the RAM once (cache <= RAM available - desktop reserve); the APU warning uses the same reserve
A Strix Halo's free VRAM is the GPU pool (carve-out + GTT, nearly all RAM with ttm.pages_limit raised) while the cache copies experts into that same RAM on top of the arena, so a cache sized from the pool alone could ask for more than the OS had left (OOM killer). The auto size is now min(GPU free, MemAvailable - max(8 GiB, 8% of RAM)); --expert-cache N is kept as asked, STRATA_UMA_RESERVE_GIB=N sets the reserve (0 = old sizing).
This commit is contained in:
1 parent
ab61f892d8
commit
f801953992
4 files changed
+97
-1
No files matched your search
@@ -33,6 +33,7 @@
|
||||
#include "strata/core/foresight_swap.hpp"
|
||||
#include "strata/core/pinned.hpp"
|
||||
#include "strata/core/pin_budget.hpp"
|
||||
#include "strata/core/uma_cache.hpp"
|
||||
#include "strata/core/remote_experts.hpp"
|
||||
#include "strata/core/on_device.hpp"
|
||||
#include "strata/core/peer_experts.hpp"
|
||||
@@ -5931,6 +5932,32 @@ int main(int argc, char** argv) {
|
||||
(void) cudaGetLastError();
|
||||
free_b = strata::core::device_free_bytes();
|
||||
}
|
||||
#if defined(STRATA_USE_HIP) && !defined(_WIN32)
|
||||
{ // An integrated GPU's "free VRAM" is system RAM (the BIOS carve-out plus the GTT pool, nearly all of the RAM when the kernel was told
|
||||
// ttm.pages_limit), and the cache copies experts into that same RAM on top of the arena: sized from the pool alone it can ask for
|
||||
// more than the OS has left, and the OOM killer takes the engine or the desktop. So the AUTO size counts that RAM once: the
|
||||
// cache gets at most what the OS reports available less a reserve for the desktop (include/strata/core/uma_cache.hpp).
|
||||
// A recommendation: --expert-cache N is kept as asked, STRATA_UMA_RESERVE_GIB=0 gives the old sizing.
|
||||
cudaDeviceProp up{};
|
||||
int ud = 0;
|
||||
strata::core::detail::HostMemory uh{};
|
||||
if (cudaGetDevice(&ud) == cudaSuccess && cudaGetDeviceProperties(&up, ud) == cudaSuccess && up.integrated &&
|
||||
strata::core::detail::host_available_memory(uh)) {
|
||||
const uint64_t reserve = strata::core::uma_desktop_reserve_bytes(strata::platform::total_physical_memory());
|
||||
const uint64_t room = strata::core::uma_cache_room_bytes((uint64_t) uh.available, reserve);
|
||||
if (reserve > 0 && room < (uint64_t) free_b) {
|
||||
std::fprintf(stderr, "strata generate: expert cache auto: this GPU shares system RAM: %.2f GiB free on the GPU, but the OS has "
|
||||
"%.2f GiB available; %.2f GiB stay for the desktop, so the cache is sized from %.2f GiB "
|
||||
"(STRATA_UMA_RESERVE_GIB changes the reserve, --expert-cache N sets the cache)\n",
|
||||
(double) free_b / 1073741824.0, (double) uh.available / 1073741824.0,
|
||||
(double) reserve / 1073741824.0, (double) room / 1073741824.0);
|
||||
free_b = (size_t) room;
|
||||
}
|
||||
} else {
|
||||
(void) cudaGetLastError();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Plan v0.3 P5: the batched prompt path's chunk buffers are allocated later, so they are reserved here -
|
||||
// under WDDM an over-subscribed allocation does not fail, it pages to system memory and crawls.
|
||||
// (with borrowing - the default with a profile - the prompt path lends cache slots instead; `pf_borrow` is
|
||||
@@ -5985,7 +6012,7 @@ int main(int argc, char** argv) {
|
||||
strata::core::detail::HostMemory hm{};
|
||||
if (cudaGetDevice(&apu_dev) == cudaSuccess && cudaGetDeviceProperties(&apu_prop, apu_dev) == cudaSuccess &&
|
||||
apu_prop.integrated && strata::core::detail::host_available_memory(hm)) {
|
||||
const int64_t host_headroom = 4ll << 30; // the OS and request-time CPU work
|
||||
const int64_t host_headroom = (int64_t) strata::core::uma_desktop_reserve_bytes(strata::platform::total_physical_memory()); // the OS, the desktop and request-time CPU work
|
||||
const int64_t cache_b = (int64_t) o.expert_cache * blob;
|
||||
if (cache_b > (int64_t) hm.available - host_headroom)
|
||||
std::fprintf(stderr, "strata generate: WARNING: this GPU shares system RAM, and the cache above (%.2f GiB) is "
|
||||
|
||||
Reference in new issue
Block a user