Load the native head and the logits before the expert arena; name the free VRAM when they fail (#620)
The native head's cudaMalloc ran after the expert arena had registered ~45 GiB of host pages. WDDM then refused it
on a 16 GB card with the desktop on the iGPU ("native head upload: out of memory" with GiBs free) - the drafter is
loaded before the arena for the same reason. Now the head and the logits buffer load right after the drafter, still
before the expert cache is sized, so the slots are the same. The head's, the drafter's and a split stage's head
failures print "(N MiB of M MiB VRAM free on this GPU)".
setup: a context of 64K or more whose KV streaming does not fit the RAM test now says so (it was silent, and a
regenerated config lost --kv-resident without a word).
This commit is contained in:
1 parent
d161e25ff6
commit
502c7296c9
2 files changed
+48
-25
No files matched your search
+44
-25
@@ -113,6 +113,20 @@ bool under_wddm() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// #620 #486: " (N MiB of M MiB VRAM free on this GPU)" for an allocation's failure message (clears the error first)
|
||||
std::string vram_free_note() {
|
||||
(void) cudaGetLastError();
|
||||
size_t free_b = 0, total_b = 0;
|
||||
if (cudaMemGetInfo(&free_b, &total_b) != cudaSuccess) {
|
||||
(void) cudaGetLastError();
|
||||
return {};
|
||||
}
|
||||
char buf[96];
|
||||
std::snprintf(buf, sizeof buf, " (%llu MiB of %llu MiB VRAM free on this GPU)", (unsigned long long) (free_b >> 20),
|
||||
(unsigned long long) (total_b >> 20));
|
||||
return buf;
|
||||
}
|
||||
|
||||
// perf-review D-4: the lent slots are refilled with queued copies and one wait; STRATA_REFILL_BLOCKING=1 waits on each
|
||||
bool refill_blocking() {
|
||||
static const bool v = std::getenv("STRATA_REFILL_BLOCKING") != nullptr;
|
||||
@@ -2637,8 +2651,9 @@ int main(int argc, char** argv) {
|
||||
const strata::core::WeightRef* wo_s = st.wt.find("output.weight");
|
||||
if (wo_s == nullptr ||
|
||||
(last && !o.native_head_gguf.empty() && !st.head.load(o.native_head_shards, g.n_embd, wo_s->ne1, err))) {
|
||||
std::fprintf(stderr, "strata generate: layer split, CUDA%d head: %s\n", st.dev,
|
||||
wo_s == nullptr ? "output.weight is missing" : err.c_str());
|
||||
std::fprintf(stderr, "strata generate: layer split, CUDA%d head: %s%s\n", st.dev,
|
||||
wo_s == nullptr ? "output.weight is missing" : err.c_str(),
|
||||
wo_s == nullptr ? "" : vram_free_note().c_str());
|
||||
return 1;
|
||||
}
|
||||
size_t fb = 0, tb = 0;
|
||||
@@ -2662,7 +2677,32 @@ int main(int argc, char** argv) {
|
||||
static const strata::core::ModelGeometry draft_geometry{};
|
||||
// with a layer split across GPUs the drafter reads the last stage's residual: it lives on that device
|
||||
const strata::core::OnDevice on_mtp(last_st ? last_st->dev : -1);
|
||||
if (!o.mtp.empty() && !mtp.load(o.mtp, draft_geometry, last_st ? last_st->ss : ss, o.spec, err, o.mtp_window)) { std::fprintf(stderr, "strata generate: %s\n", err.c_str()); return 1; }
|
||||
if (!o.mtp.empty() && !mtp.load(o.mtp, draft_geometry, last_st ? last_st->ss : ss, o.spec, err, o.mtp_window)) { std::fprintf(stderr, "strata generate: %s%s\n", err.c_str(), vram_free_note().c_str()); return 1; }
|
||||
}
|
||||
// THE HEAD BEFORE THE CACHE, AND BEFORE THE ARENA. The expert cache takes what is free minus the reserve, so
|
||||
// everything allocated after it comes out of the reserve. The native head (~0.5 GB with IQ3_S) was loaded after
|
||||
// it and ate most of the 700 MiB: 128K IQ3_S ended with 30 MiB free, the driver paged, and a request stalled for
|
||||
// good at its first verify window. Loaded first, the cache is sized around it. #620: and before the expert
|
||||
// arena registers tens of GiB of host pages, like the drafter above - WDDM then refused the head's cudaMalloc on
|
||||
// a 16 GB card with the desktop on the iGPU ("native head upload: out of memory" with GiBs free).
|
||||
const strata::core::WeightRef* wo = wt.find("output.weight");
|
||||
if (wo == nullptr) { std::fprintf(stderr, "strata generate: output.weight is missing\n"); return 1; }
|
||||
const int64_t n_vocab = wo->ne1;
|
||||
strata::core::NativeHead native_head;
|
||||
if (!o.native_head_gguf.empty() && !multi_gpu) { // a layer split's head is on its last stage
|
||||
if (!native_head.load(o.native_head_shards, g.n_embd, n_vocab, err)) {
|
||||
std::fprintf(stderr, "strata generate: %s%s\n", err.c_str(), vram_free_note().c_str());
|
||||
return 1;
|
||||
}
|
||||
std::fprintf(stderr, "strata generate: experimental native Q5_K head, %llu bytes\n",
|
||||
(unsigned long long) native_head.weight_bytes());
|
||||
}
|
||||
std::vector<float> logits((size_t) n_vocab);
|
||||
float* d_logits = nullptr;
|
||||
if (cudaMalloc(&d_logits, (size_t) n_vocab * 4) != cudaSuccess) {
|
||||
(void) cudaGetLastError();
|
||||
std::fprintf(stderr, "strata generate: the logits buffer failed%s\n", vram_free_note().c_str());
|
||||
return 1;
|
||||
}
|
||||
// Create the additional contexts after MTP has secured CUDA0 memory, but
|
||||
// before the host arena maps its expert pages into their address spaces.
|
||||
@@ -2819,28 +2859,7 @@ int main(int argc, char** argv) {
|
||||
// numbers if the slots do not fit, instead of handing back a cache smaller than it was asked for.
|
||||
mem_mark("the weights, the session and the drafter");
|
||||
strata::core::ExpertCache xcache;
|
||||
// THE HEAD BEFORE THE CACHE. The expert cache takes what is free minus the reserve, so everything allocated
|
||||
// after it comes out of the reserve. The native head (~0.5 GB with IQ3_S) was loaded after it and ate most of
|
||||
// the 700 MiB: 128K IQ3_S ended with 30 MiB free, the driver paged, and a request stalled for good at its first
|
||||
// verify window. Loaded first, the cache is sized around it.
|
||||
const strata::core::WeightRef* wo = wt.find("output.weight");
|
||||
if (wo == nullptr) { std::fprintf(stderr, "strata generate: output.weight is missing\n"); return 1; }
|
||||
const int64_t n_vocab = wo->ne1;
|
||||
strata::core::NativeHead native_head;
|
||||
if (!o.native_head_gguf.empty() && !multi_gpu) { // a layer split's head is on its last stage
|
||||
if (!native_head.load(o.native_head_shards, g.n_embd, n_vocab, err)) {
|
||||
std::fprintf(stderr, "strata generate: %s\n", err.c_str());
|
||||
return 1;
|
||||
}
|
||||
std::fprintf(stderr, "strata generate: experimental native Q5_K head, %llu bytes\n",
|
||||
(unsigned long long) native_head.weight_bytes());
|
||||
}
|
||||
std::vector<float> logits((size_t) n_vocab);
|
||||
float* d_logits = nullptr;
|
||||
if (cudaMalloc(&d_logits, (size_t) n_vocab * 4) != cudaSuccess) {
|
||||
std::fprintf(stderr, "strata generate: the logits buffer failed\n");
|
||||
return 1;
|
||||
}
|
||||
// THE HEAD BEFORE THE CACHE: the native head and the logits are allocated above, before the expert arena (#620)
|
||||
const bool auto_cache = o.expert_cache < 0;
|
||||
bool reserve_adapted = false; // #496: the auto sizing lowered the reserve so a small card's cache fits
|
||||
if (o.expert_cache < 0) {
|
||||
|
||||
Reference in new issue
Block a user