generate: warn when the profile caps an explicit --expert-cache; retry a split stage's cache at 90% (#831 #841)
- #831: an explicit --expert-cache above the profile's length was cut to it with no word on the native-pack path; a warning now says so (the allocation is unchanged). - #841: a layer-split stage whose expert cache fails to open (out of memory with the VRAM free) is retried with 90% of the slots, up to 3 times, each try logged. Nothing changes when the first open works.
This commit is contained in:
1 parent
bb19becc24
commit
74d566bd1c
1 file changed
+24
-3
@@ -3610,6 +3610,13 @@ int main(int argc, char** argv) {
|
||||
used += b;
|
||||
sized_slots.push_back((int64_t) lay.blob_bytes(pr.first));
|
||||
}
|
||||
// #831: the sized-slots loop walks the profile's pairs, so the profile's length is the ceiling; an explicit
|
||||
// --expert-cache above it used to be cut with no word. A warning only (what is allocated does not change).
|
||||
if (!auto_cache && o.expert_cache > 0 && sized_slots.size() == profile.size() && (size_t) o.expert_cache > profile.size())
|
||||
std::fprintf(stderr, "strata generate: WARNING: --expert-cache %d is more than the %zu pairs of the profile %s: "
|
||||
"%zu slots (the profile is the ceiling on a native pack; a profile that ranks every "
|
||||
"(layer, expert) pair lifts it - tools/make_profile.py)\n", o.expert_cache,
|
||||
profile.size(), o.expert_profile.c_str(), profile.size());
|
||||
o.expert_cache = (int) sized_slots.size();
|
||||
}
|
||||
// #533: --vram-elastic: the cache in physical segments (the VRAM command resizes it between requests). One GPU,
|
||||
@@ -3832,9 +3839,23 @@ int main(int argc, char** argv) {
|
||||
used += b;
|
||||
sized.push_back((int64_t) lay.blob_bytes(pr.first));
|
||||
}
|
||||
if (sized.empty() ||
|
||||
!(native_pack ? st.cache.open_sized(sized, g.n_layers, g.n_expert, err)
|
||||
: st.cache.open((int64_t) sized.size(), g.n_layers, g.n_expert, (int64_t) lay.max_blob, err))) {
|
||||
// #841: a stage's cache can fail to open with the VRAM free (the card's allocation is also charged to the
|
||||
// Windows commit, or the free figure ran high): it is tried again with 90% of the slots, up to 3 times, each
|
||||
// try said. Nothing changes when the first open works.
|
||||
bool stage_open = false;
|
||||
for (int attempt = 0; !sized.empty(); ++attempt) {
|
||||
stage_open = native_pack ? st.cache.open_sized(sized, g.n_layers, g.n_expert, err)
|
||||
: st.cache.open((int64_t) sized.size(), g.n_layers, g.n_expert, (int64_t) lay.max_blob, err);
|
||||
if (stage_open || attempt >= 3) break;
|
||||
(void) cudaGetLastError();
|
||||
const size_t keep = sized.size() * 9 / 10;
|
||||
std::fprintf(stderr, "strata generate: layer split, CUDA%d expert cache: %s; trying %zu of %zu slots "
|
||||
"(try %d of 3)\n", st.dev, err.c_str(), keep, sized.size(), attempt + 1);
|
||||
if (keep == 0) break;
|
||||
st.cache.close();
|
||||
sized.resize(keep);
|
||||
}
|
||||
if (!stage_open) {
|
||||
std::fprintf(stderr, "strata generate: layer split, CUDA%d expert cache: %s\n", st.dev,
|
||||
sized.empty() ? "no room" : err.c_str());
|
||||
return 1;
|
||||
|
||||
Reference in new issue
Block a user