Merge PR #109 (q8atnight): batch the verify window's per-token kernels
Resolved against 0.1.22: E-6's device-plan waits and copies kept (the row copy of the CPU share is used when the device plan is off - bit-identical, +0.0 on the GPU rows as the pool leaves them); the multi-GPU per-device shared-memory opt-in and stage pool callback kept. Left out: the session-wide --pcie-frac 0 skip of the PCIe path, because a request can ask for a PCIe share (pcie_frac=, used by --calibrate) and the window graph is captured once.
This commit is contained in:
commit
1977f5952b
16 files changed
+382
-11
No files matched your search
@@ -3966,6 +3966,20 @@ int main(int argc, char** argv) {
|
||||
for (int64_t i = 0; i < n - 1; ++i) consumed.push_back((int32_t) ids[(size_t) i]);
|
||||
const char* finish = "length";
|
||||
const Clock::time_point d0 = Clock::now();
|
||||
// STRATA_DECODE_TIMING=1: where a request's decode time goes (one line per request)
|
||||
static const bool dec_timing = std::getenv("STRATA_DECODE_TIMING") != nullptr;
|
||||
struct DecSnap {
|
||||
double wait, pool, host, plan, actq, jobs, run;
|
||||
int64_t misses, entries, hits, pcie;
|
||||
};
|
||||
auto dec_snap = [&]() {
|
||||
return DecSnap{ver.ms_wait, ver.ms_pool, ver.ms_host, drive.d.ms_plan, drive.d.ms_actq, drive.d.ms_jobs,
|
||||
drive.d.ms_run, drive.d.multi_misses, drive.d.multi_entries, drive.d.cache_hits,
|
||||
drive.d.pcie_experts};
|
||||
};
|
||||
const DecSnap ds0 = dec_snap();
|
||||
double dt_run = 0, dt_commit = 0, dt_draft = 0;
|
||||
int64_t dec_windows = 0, dec_T = 0;
|
||||
const int64_t decode_hits0 = drive.d.cache_hits;
|
||||
const int64_t decode_look0 = drive.d.cache_hits + drive.d.cache_admitted + drive.d.cache_refused;
|
||||
if (cancelled) finish = "cancel";
|
||||
@@ -4009,6 +4023,7 @@ int main(int argc, char** argv) {
|
||||
cudaMemcpyHostToDevice);
|
||||
}
|
||||
tr("window", p, T);
|
||||
const Clock::time_point tw0 = Clock::now();
|
||||
if (!ver.run(T, window.data(), p, win_pool_fn, win_pool_user, outv.data(), err) || drive.d.failed) {
|
||||
std::printf("ERR %s\n", drive.d.failed && drive.d.fail ? drive.d.fail : err.c_str());
|
||||
return 1;
|
||||
@@ -4016,6 +4031,7 @@ int main(int argc, char** argv) {
|
||||
int a = 0;
|
||||
while (a < T - 1 && window[(size_t) a + 1] == outv[(size_t) a]) ++a;
|
||||
if (from_sfx) { ++sfx_windows; sfx_drafts += T - 1; sfx_ok += a; }
|
||||
const Clock::time_point tw1 = Clock::now();
|
||||
std::thread adapt_thr; // the adaptive tier beside the commit and the draft (as in generate)
|
||||
bool adapt_ok = true;
|
||||
if (!drive.d.usage.empty() && ((rounds + 1) % o.adapt_every) == 0)
|
||||
@@ -4040,8 +4056,15 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
std::fflush(stdout);
|
||||
++rounds;
|
||||
const Clock::time_point tw2 = Clock::now();
|
||||
const bool drafted = eos || produced_n >= max_new ||
|
||||
mtp.draft(T, outv.data(), p, a, drafts.data(), err, dprob.data(), (float) req_spec_min_p);
|
||||
{
|
||||
const Clock::time_point tw3 = Clock::now();
|
||||
auto msd = [](Clock::time_point a0, Clock::time_point b0) { return std::chrono::duration<double, std::milli>(b0 - a0).count(); };
|
||||
dt_run += msd(tw0, tw1); dt_commit += msd(tw1, tw2); dt_draft += msd(tw2, tw3);
|
||||
++dec_windows; dec_T += T;
|
||||
}
|
||||
if (adapt_thr.joinable()) adapt_thr.join();
|
||||
if (!adapt_ok) {
|
||||
std::printf("ERR an adaptive refill failed\n");
|
||||
@@ -4060,6 +4083,21 @@ int main(int argc, char** argv) {
|
||||
p += a + 1;
|
||||
}
|
||||
const double decode_ms = std::chrono::duration<double, std::milli>(Clock::now() - d0).count();
|
||||
if (dec_timing && dec_windows > 0) {
|
||||
const DecSnap d1 = dec_snap();
|
||||
const double w = (double) dec_windows, L = (double) g.n_layers;
|
||||
std::fprintf(stderr, "strata decode timing: %lld windows, avg T %.2f, %.2f tokens/window, %.2f ms/window = "
|
||||
"verify %.2f (GPU-reach wait %.2f + per-layer host %.2f [plan %.2f actq %.2f jobs %.2f "
|
||||
"CPU %.2f] + stage %.2f) + commit/emit %.2f + draft %.2f; per layer-window: CPU experts "
|
||||
"%.2f (%.2f entries), VRAM hits %.2f, PCIe %.2f\n",
|
||||
(long long) dec_windows, dec_T / w, produced_n / w, decode_ms / w, dt_run / w,
|
||||
(d1.wait - ds0.wait) / w, (d1.pool - ds0.pool) / w, (d1.plan - ds0.plan) / w,
|
||||
(d1.actq - ds0.actq) / w, (d1.jobs - ds0.jobs) / w, (d1.run - ds0.run) / w,
|
||||
(d1.host - ds0.host) / w, dt_commit / w, dt_draft / w, (d1.misses - ds0.misses) / (w * L),
|
||||
(d1.entries - ds0.entries) / (w * L), (d1.hits - ds0.hits) / (w * L), (d1.pcie - ds0.pcie) / (w * L));
|
||||
const std::string pr = ver.profile_report();
|
||||
if (!pr.empty()) std::fprintf(stderr, "strata decode GPU stages (ms/window):%s\n", pr.c_str());
|
||||
}
|
||||
if (!cancelled) {
|
||||
// a prompt stopped halfway leaves the session somewhere between two chunks: nothing to continue from
|
||||
// (the checkpoints taken while reading it are still good)
|
||||
|
||||
Reference in new issue
Block a user