Files
Strata/include/strata/prefill/timer_marks.hpp
T
a5b820a415 Request accounting and prompt timing marks: yielded prompt legs summed once, admission time without a double count, unknown stays unknown (P0.4)
Reporting only (class E): no engine speedup, no change to what the engine computes.

serve/server.py
- A prompt read that gives way (BYIELD) and resumes keeps the request's external prefix boundary, and the prompt
  time and tokens of every leg are summed exactly once (prefill_leg_stats; PR #5318).
- The admission's DONE times one token and BDONE counts that token but times only the slot: the slot time now
  includes the admission time, and the output token is not counted twice. A figure the engine never reported
  (a close at the admission token, in the slot, a carry back to the solo path) stays unknown (None) instead of
  turning into 0 or into the API's output count (PR #5307).
- The two patches overlap in the request finalization; ended_on_yield is taken before the unknown-figures step so
  the identity check still sees the yield's own record.

PfTimer::mark(): a mark in the phase already running is not recorded (PR #4006). The totals are the same, a
fraction of the event records; under WDDM every record is a submission of its own and the launch gaps they made
were charged to "dequant". The rule is a pure function in prefill/timer_marks.hpp with a host test.

Tests: serve/test_yield_accounting.py (new: two yields, solo and admission yields, cancel after one and two
yields), serve/test_parallel.py BatchLegAccounting (EOS and length finishes, zero slot time, close at the
admission token and in the slot, slot to solo carry), serve/test_request_accounting.py (unknown stays unknown,
explicit zero), tests/prefill/timer_marks_test.cpp (same totals with 18 of 23 records skipped).

Co-authored-by: YusenZhang0601 <280892689+YusenZhang0601@users.noreply.github.com>
Co-authored-by: shoucandanghehe <51957264+shoucandanghehe@users.noreply.github.com>
Co-authored-by: Vop3p <69450118+Vop3p@users.noreply.github.com>
2026-11-05 23:31:14 +01:00

21 lines
1.1 KiB
C++

// include/strata/prefill/timer_marks.hpp - which STRATA_PREFILL_TIMING marks are recorded (PR #4006, @Vop3p).
//
// PfTimer charges the gap between two consecutive marks to the phase of the earlier one. Two marks in a row in the same
// phase therefore add nothing to the totals: the gap between them is charged to that phase either way. Skipping the
// second one leaves the totals as they were with a fraction of the event records. That matters under WDDM, where every
// cudaEventRecord is a submission of its own (~80 us on an RX 6900 XT, Windows 11): compute() marks "dequant" once per
// expert, which put ~16 records per MMQ group on the stream and charged the launch gaps they made to "dequant".
// Pure functions, so a host test can check the rule and the totals without a GPU.
#pragma once
#include <cstddef>
namespace strata::prefill {
/// A mark for `phase` is redundant when the newest recorded mark (ph[used - 1]) is already in that phase.
inline bool timer_mark_repeats(const int* ph, size_t used, int phase) {
return used > 0 && ph[used - 1] == phase;
}
} // namespace strata::prefill