mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-06 00:08:52 +00:00
Merge f-strix-c4 00807c9b3 into f-p4-int (with two or more requests at once on Windows integrated AMD, the pinned RAM copy of experts is capped so every slot fits)
With --batch 2 or more on Windows, HIP, integrated AMD (the gfx1151 block that sets the own-path prompt chunk) and a RAM budget in the start arguments, every session (the main one and each slot) pins its streamed K/V for the whole context, and the RAM copy of experts is pinned on top of that; at 4 slots and 131,072 tokens the engine stopped inside the prompt path's allocation, and with a smaller budget the OS ran out of page-locked memory. The RAM copy is now cut to what keeps it plus the sessions' pinned K/V at 22.75 GiB (include/strata/core/uma_cache.hpp, two plain inline functions, unit tested in src/core/uma_cache_test.cpp), the level of the largest 4-slot start that worked (15 GiB of experts, 7.75 GiB of K/V). The experts left out are read from the SSD when needed. Context, slot count and the 16,384-token chunk are untouched; --batch 1, starts without --batch, every other OS and backend, and 2 and 3 slots on a 64 GB box (their RAM copy is under the cap) are unchanged. The cap has no floor: for any number of requests the engine keeps as little in RAM as needed and starts. With so many slots that their pinned K/V alone is over 22.75 GiB the RAM copy is empty (budget 1 byte; 0 would mean no limit) and every expert outside the GPU cache is read from the SSD; the start goes on. The engine says so once after the pin, only when the cap cut: "N requests at once: X GiB of experts are kept in RAM so that everything fits in this PC's memory; the rest are read from the SSD when needed (STRATA_UMA_PIN_CAP=0 keeps the RAM budget as set)", or at cap 0 the same without the figure. After a start that really failed with 2 or more slots the engine says "N requests at once do not fit in this PC's memory: start with --batch N-1", and the Terminal's step for that failure reads "This PC's memory cannot hold that many requests at once. Lower Concurrent requests in the app (or `--parallel` in the Terminal) by one and start again." (strata_cli/launch/runner.py, tests/terminal/test_batch_memory_words.py). STRATA_UMA_PIN_CAP=0 keeps the RAM budget as set (settings register status rollback; one sentence in docs/BATCHING.md). Measured on a Strix Halo with 64 GB (UD-Q4_K_XL, 131,072 context, 4 prompts of 68 to 2,067 tokens): 2 slots and 3 slots print no line and keep their cache slots; 4 slots print the line with 15.0 GiB, start and serve every slot; the one-slot run gives the same 36 ids as before. Both branches changed data/settings-register.json and src/program/generate.cpp. generate.cpp merged without a conflict. The register conflicted in three hunks, all generated fields (the line numbers of the STRATA_PF_FUSED reads and defaults, and one read entry); it was resolved by running tools/settings_register.py on the merged tree, so every generated field is the tool's output for this tree, and the hand-kept fields (status, owner, note) of both branches are carried unchanged (checked against git's own merge of the file: no hand-kept field differs). docs/SETTINGS.md is regenerated after the gate round, not here.
This commit is contained in:
commit
47d46ccce9
7 files changed
+1751
-1514
No files matched your search
@@ -10689,10 +10689,43 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
src.set_extra_drop_files(std::move(drop));
|
||||
}
|
||||
#if defined(STRATA_USE_HIP) && defined(_WIN32)
|
||||
// BATCH SLOTS ON THE STRIX HALO: every session (the main one and each slot) pins its streamed K/V for the whole context, and with the RAM copy of experts
|
||||
// that is the page-locked memory of the start. 4 slots at 131,072 tokens with the usual 38 GiB budget (20.33 GiB of complement) stopped inside the prompt
|
||||
// path, and with 18 GiB the OS ran out of page-locked memory; 15 GiB started and served. So here the RAM copy is cut to what leaves complement + pinned K/V
|
||||
// at the level of the largest start that worked (include/strata/core/uma_cache.hpp, with the job ids); the experts left out are read from the SSD. Context,
|
||||
// slot count and prompt chunk are untouched. Only with --batch 2 or more, so a single request is as before. STRATA_UMA_PIN_CAP=0: the RAM budget stays as set (the way back).
|
||||
// The line below is printed after the pin, and only when the cap really left experts out (the RAM copy filled up to it): with 2 slots (12.47 GiB of complement) and
|
||||
// 3 slots (16.40 GiB) the whole complement is under the cap, nothing is cut and the start is as before (strix-20261112-1952-001f printed the line there).
|
||||
// The cap has no floor that turns into a refusal (owner, 11-12: "we should allow people to start, even if its read by ssd"): with so many slots that their K/V alone is over
|
||||
// the level the cap is 0 and the RAM copy is empty (budget 1 byte: 0 would mean "no limit"); every expert the GPU cache does not hold is read from the SSD, and the start goes on.
|
||||
bool uma_cap_applied = false;
|
||||
uint64_t uma_cap = 0;
|
||||
const char* const uma_pin_cap = std::getenv("STRATA_UMA_PIN_CAP");
|
||||
if (o.batch >= 2 && o.prefill_own_keep_chunk && o.resident_budget > 0 && !(uma_pin_cap != nullptr && uma_pin_cap[0] == '0')) {
|
||||
const uint64_t kv = strata::core::qsa_kv_host_bytes();
|
||||
uma_cap = strata::core::uma_pinned_complement_cap_bytes(kv);
|
||||
const uint64_t budget = strata::core::uma_pinned_complement_budget_bytes(kv);
|
||||
if (o.resident_budget > budget) {
|
||||
uma_cap_applied = true;
|
||||
o.resident_budget = budget;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
const std::vector<std::pair<int32_t, int32_t>>& rank_all = profile_all.empty() ? profile : profile_all;
|
||||
src.budget_is_automatic(ram_fallback_resident); // its clamp line then names no flag
|
||||
bool resident_ok = src.pin_cache_complement(xcache, err, o.resident_pin, stage_pairs, lend_from,
|
||||
o.resident_headroom, o.resident_budget, &rank_all);
|
||||
#if defined(STRATA_USE_HIP) && defined(_WIN32)
|
||||
// cut = the RAM copy reached the cap (within 16 MiB: the ranked experts are taken while they fit, the last gap is under one expert's blob, about 4 MiB)
|
||||
if (uma_cap_applied && resident_ok && src.resident_bytes() + (16ull << 20) >= uma_cap) {
|
||||
if (uma_cap == 0)
|
||||
std::fprintf(stderr, "strata: %d requests at once: the experts are read from the SSD when needed so that everything fits in this PC's memory (STRATA_UMA_PIN_CAP=0 keeps the RAM budget as set)\n", o.batch);
|
||||
else
|
||||
std::fprintf(stderr, "strata: %d requests at once: %.1f GiB of experts are kept in RAM so that everything fits in this PC's memory; the rest are read from the SSD when needed (STRATA_UMA_PIN_CAP=0 keeps the RAM budget as set)\n",
|
||||
o.batch, (double) uma_cap / 1073741824.0);
|
||||
}
|
||||
#endif
|
||||
std::string whole_err;
|
||||
if (!resident_ok && o.resident_soft) {
|
||||
// #467: the whole complement does not fit - keep what does, the hottest by the profile, through the #403
|
||||
@@ -11597,10 +11630,13 @@ int main(int argc, char** argv) {
|
||||
continue;
|
||||
}
|
||||
std::fprintf(stderr, "strata serve: %s\n", err.c_str());
|
||||
if (err.find("fit") != std::string::npos) // #85: say what frees VRAM
|
||||
const bool batch_memory = o.batch >= 2 && o.prefill_own_keep_chunk && (err.find("fit") != std::string::npos || err.find("copy stream") != std::string::npos);
|
||||
if (err.find("fit") != std::string::npos && !batch_memory) // #85: say what frees VRAM
|
||||
std::fprintf(stderr, "strata serve: the GPU has too little free VRAM for the prompt path: turn images "
|
||||
"off (setup: --vision no), close other programs using the GPU, use a shorter "
|
||||
"context, or read prompts in smaller chunks (--prefill 512)\n");
|
||||
if (batch_memory) // (the chunk list has been tried by now, and a failed attempt leaves the pool full: no retry can follow)
|
||||
std::fprintf(stderr, "strata: %d requests at once do not fit in this PC's memory: start with --batch %d\n", o.batch, o.batch - 1);
|
||||
return 1;
|
||||
}
|
||||
uma_refuse_chunk_if_full(o.prefill_chunk, borrow != nullptr, xcache.gib());
|
||||
|
||||
Reference in new issue
Block a user