prefill: owned buffers take the ring in one allocation, exact owned pricing (STRATA_OWNED_PRICE=exact), OOM diagnostics (#796 part A)
- carve: with owned buffers the streamed ring is one cudaMalloc instead of up to 1,024 pieces each rounded to 2 MiB (~0.5 GiB). A borrowed region keeps its per-slot layout and price, so the loans' slot counts do not move. - Prefill::bytes_needed_owned prices the real allocation (2 MiB pages, the ring in one piece). The cache sizing uses it only with STRATA_OWNED_PRICE=exact; the default is still 0.1.39's 160 + chunk * 680 / 1024 rule. - the "device buffers do not fit" error names the free VRAM, the bytes taken and the buffer that failed. No refusal was added: parts B (borrow_residency) and C (the advisory planner) stay out. Co-authored-by: Jakub Luwierski <j.luwierski@gmail.com>
This commit is contained in:
1 parent
aaf99d3074
commit
4a9b9041c2
3 files changed
+77
-13
No files matched your search
@@ -3751,6 +3751,19 @@ int main(int argc, char** argv) {
|
||||
std::fprintf(stderr, "strata generate: --pipeline-windows %d: %lld MiB of CUDA0 kept out of the expert cache "
|
||||
"(the second verifier%s)\n", o.pipeline_windows, (long long) (pipe_first >> 20),
|
||||
o.pipeline_windows >= 2 ? ", the GDN snapshots" : "");
|
||||
// The MiB the prompt path's OWN buffers (no loan) take, which the cache sizing leaves out. 0.1.39's rule is
|
||||
// 160 + chunk * 680 / 1024 (~16 GiB at 24576 against ~2.4 GiB really allocated); STRATA_OWNED_PRICE=exact prices the
|
||||
// real allocation instead (Prefill::bytes_needed_owned: 2 MiB pages, the ring in one piece, as PR #796 measured)
|
||||
// and gives that cache the difference. A recommendation to try, so it is not the default.
|
||||
auto owned_prefill_mib = [&]() -> int64_t {
|
||||
if (!(o.prefill_chunk > 0 && !pf_borrow)) return 0;
|
||||
static const bool exact = [] { const char* v = std::getenv("STRATA_OWNED_PRICE"); return v != nullptr && std::string(v) == "exact"; }();
|
||||
if (!exact) return 160 + (o.prefill_chunk * 680) / 1024;
|
||||
const int64_t mib = ((int64_t) strata::prefill::Prefill::bytes_needed_owned(g, ss, o.prefill_chunk) + (1 << 20) - 1) >> 20;
|
||||
std::fprintf(stderr, "strata generate: STRATA_OWNED_PRICE=exact: the prompt path's own buffers for a %lld-token chunk: %lld MiB (the 0.1.39 rule: %lld MiB)\n",
|
||||
(long long) o.prefill_chunk, (long long) mib, (long long) (160 + (o.prefill_chunk * 680) / 1024));
|
||||
return mib + 64; // a margin for the allocator
|
||||
};
|
||||
if (o.expert_cache < 0) {
|
||||
size_t free_b = 0, total_b = 0;
|
||||
free_b = strata::core::device_free_bytes(); (void) total_b;
|
||||
@@ -3758,7 +3771,7 @@ int main(int argc, char** argv) {
|
||||
// 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
|
||||
// the predicate a local `borrow` was here, hoisted above so both cache-size branches read the same one)
|
||||
const int64_t prefill_mib = (o.prefill_chunk > 0 && !pf_borrow) ? 160 + (o.prefill_chunk * 680) / 1024 : 0;
|
||||
const int64_t prefill_mib = owned_prefill_mib();
|
||||
// the draft layer's head and logits are allocated when it binds, after this: 0.1.27's CJK subset made them
|
||||
// ~110-180 MiB larger, and out of the reserve they left 16 GB cards below the stall line (#199)
|
||||
int64_t mtp_bind = (!o.mtp.empty() && native_head.loaded())
|
||||
@@ -3829,7 +3842,7 @@ int main(int argc, char** argv) {
|
||||
// slots instead and `prefill_mib` is 0, so only the reserve is checked)
|
||||
size_t free_b = 0, total_b = 0;
|
||||
free_b = strata::core::device_free_bytes(); (void) total_b;
|
||||
const int64_t prefill_mib = (o.prefill_chunk > 0 && !pf_borrow) ? 160 + (o.prefill_chunk * 680) / 1024 : 0;
|
||||
const int64_t prefill_mib = owned_prefill_mib();
|
||||
const int64_t reserve = (((int64_t) o.vram_reserve_mib + prefill_mib) << 20) + pipe_first;
|
||||
const int64_t fit = std::max<int64_t>(((int64_t) free_b - reserve) / (int64_t) strata::kernels::cpu::expert_layout().max_blob, 0);
|
||||
if (o.expert_cache > fit) {
|
||||
|
||||
Reference in new issue
Block a user