Archived
core/sched: a prefix hit resumes on the cold run's chunk grid, so it recomputes the cold run's own chunks
A hit recomputes the tokens past where it resumes. Kernels may round a row differently at another chunk length (spec §17: the fp8 GEMM's split-K count is chosen from M), so a hit that recomputes its tail in other chunks than a cold prefill of the same prompt can flip a near-tie in greedy text. On the DeepSeek-V4.1 daily (TP4) a 24k-token prompt that hit a 16k one's tail snapshot resumed at 15856, ran a 528-token chunk to the next boundary and answered differently from its cold run. --prefix-resume exact, the default: - ChunkGeometry carries the grid an idle server's cold prefill chunks on: --max-num-batched-tokens rounded down to the quantum, or the checkpoint interval where chunks split at it and it is the smaller, times the span from the second interval on. - plan_chunk writes checkpoints only on that grid. A prompt's tail snapshot is taken where its last chunk starts (sliding-window snapshots keep their one-block margin) instead of at its last quantum boundary. The chunk already ends there, so a long cold prompt no longer runs a short extra step at its end. - A checkpoint interval past the chunk must be a multiple of it; otherwise it is rounded up, and startup says so. - admit_one steps a hit with no snapshot to resume from (full attention) back to the grid. A request's own checkpoint (Request::checkpoint_at, /v1/systemone's shared head) is honored where it falls. --prefix-resume nearest keeps the previous rule. The cost is re-prefill: an exact repeat runs the cold run's last chunk again, and an agent's next turn resumes where the previous prompt's last chunk started, about half a chunk more than nearest (2048 tokens at a 4096-token budget). The property holds on an idle server; a prefill that shares its steps with decode rows or other requests (--busy-prefill-chunk, --prefill-interleave) is cut differently, as batching already changes greedy text. Tests: sched_test covers the grid for six geometries (GDN hybrid, interval past the budget, span, periodic and tip-only window snapshots, full attention), the interval rounding, the tail snapshot at the last chunk start, admission stepping back to the grid, and a property over prompt lengths: every checkpoint is a chunk start of the cold run of its prompt and of any longer prompt it prefixes, and a hit from it cuts the cold run's chunks. config_test covers the flag.
This commit is contained in:
1 parent
f43929ccb8
commit
662b7720b5
9 files changed
+449
-4
No files matched your search
@@ -60,7 +60,29 @@ struct ChunkGeometry {
|
||||
* tip-only, which keeps the tail alone and so splits no chunk at the interval. */
|
||||
bool window_periodic = false;
|
||||
|
||||
/* --prefix-resume exact (Config::prefix_exact): a prefix hit resumes only where a cold prefill
|
||||
* of the same prompt starts a chunk, so the tokens a hit recomputes are cut into the chunks a
|
||||
* cold run cuts them into. A kernel may round a row differently at another chunk length (a
|
||||
* split-K count chosen from M, a small-M path); computed in the same chunks, the hit's output
|
||||
* is the cold run's, bit for bit, on an idle server. The grid is where an idle server's prefill
|
||||
* chunks start: 0, then grid_origin + k * grid. `grid` is the checkpoint interval where chunks
|
||||
* split at it and it fits the budget, times the span from the second interval on (origin = the
|
||||
* interval), and otherwise --max-num-batched-tokens rounded down to the quantum (the interval
|
||||
* is then rounded up to a multiple of it). Zero when not exact. */
|
||||
bool exact = false;
|
||||
int64_t grid = 0;
|
||||
int64_t grid_origin = 0;
|
||||
|
||||
bool checkpoints() const { return checkpoint_interval > 0; }
|
||||
|
||||
/* The deepest grid position at or below `pos`; `pos` itself when not exact. */
|
||||
int64_t grid_floor(int64_t pos) const {
|
||||
if (pos <= 0) return 0;
|
||||
if (!exact || grid <= 0) return pos;
|
||||
if (pos < grid_origin) return 0;
|
||||
return grid_origin + (pos - grid_origin) / grid * grid;
|
||||
}
|
||||
bool on_grid(int64_t pos) const { return grid_floor(pos) == pos; }
|
||||
};
|
||||
|
||||
/* The budget of a step a span does not take (ChunkGeometry::shared_tok), from the configuration
|
||||
|
||||
Reference in new issue
Block a user