Archived
sched_test: the burst simulation starts with sequences decoding, and takes auto:SHARE
Cause: the device measurements of --prefill-interleave were taken with sessions already decoding when the long prompts arrive (8 decoders beside 64K prompts); the simulation only had the burst's own prompts, which decode after their first token, and could not set auto's share. Change: SIM_DECODERS sequences of 64-token prompts (SIM_DEC_OUT tokens each, default 4096) decode for 16 steps before the burst arrives and count as decoders while it prefills; the run ends with the burst's last prompt. SIM_SHARE is auto's share (SIM_IL=-1 SIM_SHARE=1 is auto:1). The summary adds the decoders, the steps that carried a chunk per checkpoint interval prefilled, and prints the interleave as given (N or auto:SHARE). Evidence: RAD_SCHED_SIM=1 SIM_N=1 SIM_LEN=65536 SIM_DECODERS=8 SIM_SEQS=16, SIM_IL 0 / auto / auto:1 / auto:2: TTFT 17 / 20 / 33 / 51 s, decode while the prompt waits 9.7 / 17.0 / 37.0 / 47.1 tokens/s a sequence, against the device's 17.3 / 20 / 35.5 / 56 s and 12.3 / 23 / 40.9 / 50 (Qwen3.8-Flash-Next fp8, TP2, MTP 3). SIM_N=4: TTFT max 56 / 67 / 109 s at 0 / auto / auto:1, decode 6.7 / 15.6 / 34.5, against the device's 64 / 74 / 137 s and 5.4 / 14.8 / 33.
This commit is contained in:
1 parent
c00b882b96
commit
6e134fc15f
1 file changed
+61
-22
+61
-22
@@ -7752,16 +7752,22 @@ TEST(a_recycled_slot_does_not_carry_the_previous_request_s_admission) {
|
||||
* Not a check: a measurement harness for scheduling policy, run on request only:
|
||||
*
|
||||
* RAD_SCHED_SIM=1 [SIM_N=32 SIM_LEN=131072 SIM_OUT=512 SIM_MAXTOK=2048 SIM_INTERVAL=2048
|
||||
* SIM_BUSY=-1 SIM_IL=0 SIM_SEQS=32 SIM_TRACE=1] sched_test sim_burst
|
||||
* SIM_BUSY=-1 SIM_IL=0 SIM_SHARE=0.25 SIM_SEQS=32 SIM_DECODERS=0
|
||||
* SIM_TRACE=1] sched_test sim_burst
|
||||
*
|
||||
* SIM_DECODERS sequences of 64-token prompts are decoding (SIM_DEC_OUT tokens each, default
|
||||
* 4096) before the burst arrives. The summary counts the steps that carried a chunk per
|
||||
* checkpoint interval prefilled.
|
||||
*
|
||||
* SIM_N prompts of SIM_LEN tokens arrive at once, each then decodes SIM_OUT tokens with three
|
||||
* drafts a step (a uniform 0..3 accepted), the stager arming at 1025 rows, under
|
||||
* --prefix-resume exact. SIM_BUSY and SIM_IL are --busy-prefill-chunk and --prefill-interleave
|
||||
* (-1 for auto). Each step's time is a cost model in seconds: SIM_DEC0 + SIM_DECR per decode row
|
||||
* when it has one, plus SIM_PF0 + SIM_PFB per row when it carries a chunk. The defaults are fitted
|
||||
* to Qwen3.8-Flash-Next at TP2 (a lone prefill at ~5.4K tokens/s on 2048-token chunks; one
|
||||
* sequence decoding ~145 tokens/s, sixteen ~650 with MTP), not measured per step shape: the
|
||||
* schedule is the scheduler's own, the times are an estimate. Prints the aggregate prefill rate,
|
||||
* (-1 for auto, at SIM_SHARE of a chunk step's time: SIM_IL=-1 SIM_SHARE=1 is auto:1). Each step's
|
||||
* time is a cost model in seconds: SIM_DEC0 + SIM_DECR per decode row when it has one, plus
|
||||
* SIM_PF0 + SIM_PFB per row when it carries a chunk. The defaults are fitted to Qwen3.8-Flash-Next
|
||||
* at TP2 (a lone prefill at ~5.4K tokens/s on 2048-token chunks; one sequence decoding ~145
|
||||
* tokens/s, sixteen ~650 with MTP), not measured per step shape: the schedule is the scheduler's
|
||||
* own, the times are an estimate. Prints the aggregate prefill rate,
|
||||
* the time-to-first-token spread and the decode rate of sequences decoding while some prompt still
|
||||
* waits for its first token. */
|
||||
static double sim_env(const char* k, double d) {
|
||||
@@ -7783,11 +7789,31 @@ TEST(sim_burst_of_long_prompts) {
|
||||
f.cfg.checkpoint_interval = (int64_t)sim_env("SIM_INTERVAL", 2048);
|
||||
f.cfg.busy_prefill_chunk = (int64_t)sim_env("SIM_BUSY", -1);
|
||||
f.cfg.prefill_interleave = (int64_t)sim_env("SIM_IL", 0);
|
||||
f.cfg.prefill_interleave_share = sim_env("SIM_SHARE", 0.25);
|
||||
f.cfg.max_seqs = (int64_t)sim_env("SIM_SEQS", 32);
|
||||
f.cfg.prefix_exact = true;
|
||||
f.cfg.n_spec = 3;
|
||||
CHECK_OK(f.start());
|
||||
f.sch.set_stage_rows(1025);
|
||||
uint32_t rng = 12345;
|
||||
int32_t draft[3] = { 7, 7, 7 };
|
||||
/* The decoders, decoding before the burst arrives. */
|
||||
std::vector<uint64_t> decs;
|
||||
const int ND = (int)sim_env("SIM_DECODERS", 0);
|
||||
const int DOUT = (int)sim_env("SIM_DEC_OUT", 4096);
|
||||
for (int i = 0; i < ND; ++i) decs.push_back(f.submit(64, DOUT, 0, /*ignore_eos=*/true));
|
||||
auto draft_all = [&](const std::vector<uint64_t>& v) {
|
||||
for (uint64_t id : v) {
|
||||
const Request* r = f.sch.find(id);
|
||||
if (r && r->state == ReqState::Running && r->n_computed >= (int64_t)r->prompt.size())
|
||||
(void)f.sch.set_draft(id, draft, 3);
|
||||
}
|
||||
};
|
||||
for (int k = 0; k < 16 && ND > 0; ++k) {
|
||||
draft_all(decs);
|
||||
if (!f.sch.step()) break;
|
||||
CHECK_OK(f.commit(7, 0, [&](const StepEntry& e) { return random_accept(rng, e); }));
|
||||
}
|
||||
std::vector<uint64_t> ids;
|
||||
for (int i = 0; i < N; ++i) {
|
||||
auto r = f.request((int)L, OUT);
|
||||
@@ -7798,16 +7824,11 @@ TEST(sim_burst_of_long_prompts) {
|
||||
}
|
||||
std::vector<double> ttft(ids.size(), -1), done(ids.size(), -1);
|
||||
double t = 0, t_pf = 0, dec_s = 0;
|
||||
int64_t pf_tok = 0, steps = 0, mixed = 0, small = 0, dec_tok = 0;
|
||||
uint32_t rng = 12345;
|
||||
int32_t draft[3] = { 7, 7, 7 };
|
||||
int64_t pf_tok = 0, steps = 0, mixed = 0, small = 0, dec_tok = 0, chunk_steps = 0;
|
||||
auto idx = [&](uint64_t id) { return (size_t)(id - ids[0]); };
|
||||
while (steps < 200000) {
|
||||
for (uint64_t id : ids) {
|
||||
const Request* r = f.sch.find(id);
|
||||
if (r && r->state == ReqState::Running && r->n_computed >= (int64_t)r->prompt.size())
|
||||
(void)f.sch.set_draft(id, draft, 3);
|
||||
}
|
||||
draft_all(ids);
|
||||
draft_all(decs);
|
||||
if (!f.sch.step()) break;
|
||||
const StepPlan& p = f.sch.plan();
|
||||
int64_t P = 0, D = 0, nd = 0;
|
||||
@@ -7825,6 +7846,7 @@ TEST(sim_burst_of_long_prompts) {
|
||||
std::printf("\n");
|
||||
}
|
||||
++steps;
|
||||
chunk_steps += P > 0;
|
||||
mixed += P && nd;
|
||||
small += P && P < 1025;
|
||||
pf_tok += P;
|
||||
@@ -7835,6 +7857,7 @@ TEST(sim_burst_of_long_prompts) {
|
||||
if (done[k] >= 0) continue;
|
||||
if (ttft[k] >= 0) ++decoders; else waiting = true;
|
||||
}
|
||||
for (uint64_t id : decs) decoders += f.sch.find(id) != nullptr;
|
||||
std::vector<std::pair<uint64_t, size_t>> before;
|
||||
for (const StepEntry& e : p.e) before.push_back({ e.seq, e.req->output.size() });
|
||||
CHECK_OK(f.commit(7, 0, [&](const StepEntry& e) { return random_accept(rng, e); }));
|
||||
@@ -7844,26 +7867,42 @@ TEST(sim_burst_of_long_prompts) {
|
||||
for (const auto& b : before) {
|
||||
const Request* r = f.sch.find(b.first);
|
||||
if (!r) continue;
|
||||
const size_t k = idx(b.first);
|
||||
if (b.second == 0 && !r->output.empty() && ttft[k] < 0) ttft[k] = t;
|
||||
const bool burst = b.first >= ids[0];
|
||||
if (burst && b.second == 0 && !r->output.empty() && ttft[idx(b.first)] < 0)
|
||||
ttft[idx(b.first)] = t;
|
||||
else if (waiting && b.second > 0) dec_tok += (int64_t)(r->output.size() - b.second);
|
||||
}
|
||||
std::vector<uint64_t> c;
|
||||
f.sch.take_completed(&c);
|
||||
for (uint64_t id : c) { done[idx(id)] = t; (void)f.sch.reap(id); }
|
||||
for (uint64_t id : c) {
|
||||
if (id >= ids[0]) done[idx(id)] = t;
|
||||
(void)f.sch.reap(id);
|
||||
}
|
||||
/* The decoders outlive the burst; the run ends with its last prompt. */
|
||||
bool left = false;
|
||||
for (double d : done) left = left || d < 0;
|
||||
if (!left) break;
|
||||
}
|
||||
std::vector<double> tt;
|
||||
for (double x : ttft) if (x >= 0) tt.push_back(x);
|
||||
std::sort(tt.begin(), tt.end());
|
||||
if (tt.empty()) return;
|
||||
auto pct = [&](double q) { return tt[std::min(tt.size() - 1, (size_t)(q * (double)tt.size()))]; };
|
||||
std::printf("sim: %d x %lld tokens, max_tok %lld, busy %lld, interleave %lld: %lld steps (%lld "
|
||||
"mixed, %lld with a chunk under 1025); prefill %.0f tokens/s over the steps with a "
|
||||
const double intervals = (double)pf_tok / (double)std::max<int64_t>(f.cfg.checkpoint_interval, 1);
|
||||
char il[32];
|
||||
if (f.cfg.prefill_interleave < 0)
|
||||
std::snprintf(il, sizeof il, "auto:%g", f.cfg.prefill_interleave_share);
|
||||
else
|
||||
std::snprintf(il, sizeof il, "%lld", (long long)f.cfg.prefill_interleave);
|
||||
std::printf("sim: %d x %lld tokens beside %d decoders, max_tok %lld, busy %lld, "
|
||||
"interleave %s: %lld steps (%lld mixed, %lld with a chunk under 1025, %.2f with a "
|
||||
"chunk per interval); prefill %.0f tokens/s over the steps with a "
|
||||
"chunk, %.0f to the last first token; TTFT p50 %.0f p95 %.0f max %.0f s; decode "
|
||||
"while prompts wait %.1f tokens/s a sequence; all done at %.0f s\n",
|
||||
N, (long long)L, (long long)MT, (long long)f.cfg.busy_prefill_chunk,
|
||||
(long long)f.cfg.prefill_interleave, (long long)steps, (long long)mixed,
|
||||
(long long)small, (double)pf_tok / std::max(t_pf, 1e-9),
|
||||
N, (long long)L, ND, (long long)MT, (long long)f.cfg.busy_prefill_chunk,
|
||||
il, (long long)steps, (long long)mixed,
|
||||
(long long)small, (double)chunk_steps / std::max(intervals, 1e-9),
|
||||
(double)pf_tok / std::max(t_pf, 1e-9),
|
||||
(double)N * (double)L / tt.back(), pct(0.5), pct(0.95), tt.back(),
|
||||
dec_s > 0 ? (double)dec_tok / dec_s : 0.0, t);
|
||||
}
|
||||
Reference in new issue
Block a user