mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 23:38:47 +00:00
The first default-on build set --mtp-window 2048 once per process whenever KVA was on, so short prompts (where KVA never applies) lost draft context and decode speed. Now the draft layer keeps its window (32768 by default) and MtpDrafter::set_cell_floor() names the first draft cell built from a real row: a KVA read raises it to the end of its approximated chunks (they are neither built nor read), the draft attention starts at max(floor, pos - window) (window_ids_floor, window_start.hpp), and KvaFloorRegistry gives every state a request continues from (live, checkpoint, parked) the floor of its own tokens. A session KVA did not approximate has floor 0 and attends exactly as with STRATA_KVA=0; with STRATA_KVA=0 or a process KVA is ruled out for the draft layer's code is 0.2.6's. The tail is 2048 whatever the window. Unit tests: window_start with floor 0 equals the plain window, the registry, wants_cell_floor.
27 lines
1.1 KiB
C++
27 lines
1.1 KiB
C++
// include/strata/kernels/window_start.hpp - the first cell the draft layer's attention reads.
|
|
//
|
|
// The draft layer attends to the last `window` cells. KVA (docs/KVA.md) can leave cells in the draft layer's K/V
|
|
// that were built from approximated rows; `floor` is the first cell that holds a real one, so the attention starts
|
|
// there when it is higher. floor = 0 (every session KVA did not approximate) gives exactly the plain window.
|
|
// One function for the device kernel and for the host test.
|
|
#pragma once
|
|
|
|
#if defined(__CUDACC__) || defined(__HIPCC__)
|
|
#define STRATA_WINDOW_START_HD __host__ __device__
|
|
#else
|
|
#define STRATA_WINDOW_START_HD
|
|
#endif
|
|
|
|
namespace strata::kernels {
|
|
|
|
/// The first cell of the attention for a sequence of `n_kv` cells. The width n_kv - start is at least 1 whenever
|
|
/// n_kv is (a floor at or past the end must not leave the attention with nothing to read).
|
|
STRATA_WINDOW_START_HD inline int window_start(int n_kv, int window, int floor) {
|
|
int start = n_kv > window ? n_kv - window : 0;
|
|
if (floor > start) start = floor;
|
|
if (start > n_kv - 1) start = n_kv > 0 ? n_kv - 1 : 0;
|
|
return start;
|
|
}
|
|
|
|
} // namespace strata::kernels
|