perf(cuda,decode): zero-doorbell verify graph, sub-warp expert packing, shared-mem staging, and batched PLE/MTP

This commit is contained in:
Stuart Chapin authored and Niko1221 committed 2026-10-03 23:27:36 +02:00
1 parent 586367cb00
commit a36be1db29
21 files changed
+1197 -322

No files matched your search

+12 -5
View File
@@ -2493,7 +2493,7 @@ int main(int argc, char** argv) {
}
}
}
strata::core::Verifier::set_commit_async(!multi_gpu); // see Verifier::set_commit_async
strata::core::Verifier::set_commit_async(!split_same); // see Verifier::set_commit_async
// ---- layer split across GPUs: each later stage's own copy of the dense weights, its session and (the last) the
// head, made on its device before the host arena is mapped (as the drafter below, for the same WDDM reason)
std::vector<std::unique_ptr<GpuStage>> stages;
@@ -2668,7 +2668,7 @@ int main(int argc, char** argv) {
// those allocations are already made before a stage's cache is sized, so what has to be held back here is
// the windows and - only on the stage that carries them - the drafter and the head.
const int64_t kWindowMib = 96; // the verify windows; 75 MiB measured, rounded up
const int64_t kDrafterMib = 1000; // the MTP drafter (839 MiB) + the head, on the last stage only
const int64_t kDrafterMib = 1320; // the MTP drafter (839 MiB) + the native Q5_K head (466 MiB), on the last stage only
// #340: with the own prompt buffers chosen by the split's rule (not asked for with --no-prefill-borrow) the
// boundary is searched as the borrowing configuration would (no reserve): the reserve then only makes the caches
// smaller, which measured cost no decode (K=28 on 9070 XT + R9700: 58.4 tok/s own vs 58.5 borrowing), while a
@@ -2769,7 +2769,7 @@ int main(int argc, char** argv) {
for (int i = 0; i + 1 < ns; ++i) {
acc += 1.0 / layer_ms[(size_t) i];
at[(size_t) i] = std::clamp<int64_t>((int64_t) std::llround(acc / total * (double) L),
i == 0 ? 2 : at[(size_t) i - 1] + 1, L - (ns - 1 - i));
i == 0 ? 2 : at[(size_t) i - 1] + 1, L - (ns - 1 - i));
}
consider();
}
@@ -2883,6 +2883,7 @@ int main(int argc, char** argv) {
// 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%s\n", err.c_str(), vram_free_note().c_str()); return 1; }
mtp.set_ple_session(&ss);
}
// 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
@@ -4749,6 +4750,7 @@ int main(int argc, char** argv) {
strata::core::Verifier ver;
strata::core::VerifyHits vh;
vh.d_res = thits.d_res;
vh.h_res = host_res.empty() ? nullptr : host_res.data();
vh.cache_base = thits.cache_base;
vh.blob = thits.blob;
vh.slot_off = xcache.slot_offsets(); // E-6: the device plan's pointers
@@ -4795,6 +4797,7 @@ int main(int argc, char** argv) {
const strata::core::OnDevice on(gs.dev);
strata::core::VerifyHits vs;
vs.d_res = gs.d_res;
vs.h_res = host_res.empty() ? nullptr : host_res.data();
vs.cache_base = gs.cache.device_slot(0);
vs.blob = thits.blob;
vs.slot_off = gs.cache.slot_offsets();
@@ -5049,11 +5052,14 @@ int main(int argc, char** argv) {
}
drive.d.plan = ver.plan_sink();
drive.d.pcie_num = std::max(0, std::min(256, (int) (o.pcie_frac * 256.0 + 0.5)));
if (o.adapt_every > 0 && o.adapt_swaps > 0) drive.d.usage.assign((size_t) (g.n_layers * g.n_expert), 0.0f);
const bool all_experts_resident = !host_res.empty() &&
std::all_of(host_res.begin(), host_res.end(), [](int32_t r) { return r >= 0; });
if (o.adapt_every > 0 && o.adapt_swaps > 0 && !all_experts_resident)
drive.d.usage.assign((size_t) (g.n_layers * g.n_expert), 0.0f);
// #477 --expert-profile-save: what the adaptive tier learned, kept across restarts (opt-in; off: `heat` stays
// empty and nothing below runs). It needs the adaptive tier's counts and the residency table.
std::vector<double> heat;
if (!o.expert_profile_save.empty()) {
if (!o.expert_profile_save.empty() && !all_experts_resident) {
if (drive.d.usage.empty() || host_res.empty())
std::fprintf(stderr, "strata serve: --expert-profile-save needs the adaptive tier (--adapt-every and "
"--adapt-swaps above 0) and --expert-profile: nothing will be saved\n");
@@ -6860,6 +6866,7 @@ int main(int argc, char** argv) {
strata::core::Verifier ver;
strata::core::VerifyHits vh;
vh.d_res = thits.d_res;
vh.h_res = host_res.empty() ? nullptr : host_res.data();
vh.cache_base = thits.cache_base;
vh.blob = thits.blob;
vh.slot_off = xcache.slot_offsets(); // E-6: the device plan's pointers