prefill: take expert blobs from a helper's VRAM cache when it holds them
A helper GPU's expert cache already holds a copy of the blobs the prompt path streams, and the helpers compute nothing while a prompt is read on a serial request path. Add RemotePrefillSource, an ExpertSource that wraps the file source and asks the helpers first: a blob a helper holds is copied cache-to-host on that helper's own stream, misses are merged into one call to the fallback's existing batched reads, and every other decision is forwarded unchanged. Opt-in through STRATA_PREFILL_HELPER_SOURCE; it applies only where the serve path is serial (one GPU, no layer split, no batch slots) and the prompt path streams every expert the main card does not hold. Same-day A/B on an 11-request fixture: 91.5 s -> 65.7 s of prefill (-28.3%) and 92.1 GB (64.8%) fewer bytes read from the files.
This commit is contained in:
1 parent
66aaed2119
commit
268647d2ec
3 files changed
+222
-1
No files matched your search
@@ -6621,6 +6621,23 @@ int main(int argc, char** argv) {
|
||||
// neither fires, plain one-token-per-round decoding - slower, never wrong: the verify window still
|
||||
// confirms every emitted token against the real model regardless of where the draft came from.
|
||||
const bool use_mtp = !o.mtp.empty();
|
||||
// STRATA_PREFILL_HELPER_SOURCE (opt-in): the prompt path may take a blob a helper's VRAM cache already
|
||||
// holds from that cache instead of reading the files again. The helpers are idle while a prompt is read
|
||||
// (the serve path is serial: no batch slots), so the copy needs no ordering against their kernel streams.
|
||||
// Everything else - the fallback's batched unbuffered reads, its pinned RAM copy, the prompt path's own
|
||||
// decisions - is forwarded unchanged. Default off: the prompt path's source is srcp, exactly as before.
|
||||
std::vector<strata::core::RemoteExperts*> prefill_helpers;
|
||||
for (int r = 0; r < drive.d.remote_count; ++r) prefill_helpers.push_back(drive.d.remote[r]);
|
||||
std::unique_ptr<strata::core::RemotePrefillSource> prefill_helper_src;
|
||||
strata::core::ExpertSource* prefill_src = srcp;
|
||||
uint64_t helper_blobs_before = 0, helper_bytes_before = 0;
|
||||
if (const char* hv = std::getenv("STRATA_PREFILL_HELPER_SOURCE"); hv != nullptr && std::atoi(hv) != 0 &&
|
||||
srcp != nullptr && !multi_gpu && stages.empty() && o.batch <= 0 && !prefill_helpers.empty()) {
|
||||
prefill_helper_src = std::make_unique<strata::core::RemotePrefillSource>(*srcp, prefill_helpers);
|
||||
prefill_src = prefill_helper_src.get();
|
||||
std::fprintf(stderr, "strata serve: the prompt path reads the experts a helper cache holds from that "
|
||||
"cache (STRATA_PREFILL_HELPER_SOURCE)\n");
|
||||
}
|
||||
strata::prefill::Prefill sp;
|
||||
// the pool is idle while a prompt is read unless batch slots decode between its parts; with
|
||||
// STRATA_PREFILL_CPU_SHARE the staged-chunk limit before the chunk below sizes the loans (bytes_needed reads it)
|
||||
@@ -6949,7 +6966,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
if (multi_gpu) sp.set_stage(0, split_at[0], &stages[0]->sp);
|
||||
if (share_pool) sp.set_cpu_pool(&pool);
|
||||
if (!sp.init(wt, g, ss, srcp, &xcache, host_res.data(), o.prefill_chunk, main_cs, err, borrow, borrow_bytes))
|
||||
if (!sp.init(wt, g, ss, prefill_src, &xcache, host_res.data(), o.prefill_chunk, main_cs, err, borrow, borrow_bytes))
|
||||
return err.find("do not fit") != std::string::npos ? 2 : 1;
|
||||
return 0;
|
||||
};
|
||||
@@ -11687,6 +11704,14 @@ int main(int argc, char** argv) {
|
||||
(double) (remote_experts[(size_t) r].full_row_bytes() - full_before[(size_t) r]) / 1048576.0,
|
||||
remote_experts[(size_t) r].ms_begin() - begin_before[(size_t) r],
|
||||
remote_experts[(size_t) r].ms_wait() - wait_before[(size_t) r]);
|
||||
if (prefill_helper_src) {
|
||||
const uint64_t blobs = prefill_helper_src->helper_blobs(), bytes = prefill_helper_src->helper_bytes();
|
||||
std::fprintf(stderr, "strata serve: prefill helper source: %lld blobs / %.1f MiB taken from a helper's "
|
||||
"cache in this request\n",
|
||||
(long long) (blobs - helper_blobs_before), (double) (bytes - helper_bytes_before) / 1048576.0);
|
||||
helper_blobs_before = blobs;
|
||||
helper_bytes_before = bytes;
|
||||
}
|
||||
}
|
||||
save_profile("exit"); // #477: QUIT, or the server closed stdin
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user