generate, mtp: near the context's end the spec window and its drafts stay inside it

The admission checks prompt + max_new <= max_context, but the spec loop
opened every window at S_mtp rows, so a request that fits ended with
"ran out of context" (rc 2) once p + S passed the end, and printed
nothing. The window now takes only the rows the context still holds.
MtpDrafter::draft wrote draft j at cell p + a + j for every step, past
max_cells near the end, where the page table has no entry; it now drafts
only the cells that exist. Far from the end nothing changes.
This commit is contained in:
midagedev authored and Niko1221 committed 2026-10-09 15:17:33 +02:00
1 parent 730700126b
commit e85567b617
2 files changed
+10 -3

No files matched your search

+7 -2
View File
@@ -12237,13 +12237,18 @@ int main(int argc, char** argv) {
if (pk.lookup) { T = pk.t; from_sfx = true; }
}
}
// The window's rows sit at p .. p + T - 1, and past the context there is no cell to verify them in: near
// its end the window takes only the rows that fit (the admission checked the prompt and max_new, which a
// full window can overrun)
const int room = (int) std::min<int64_t>(o.spec, o.max_context - p);
T = std::min(T, room);
// --lookup-chain: what followed an earlier occurrence of the context + the MTP's drafts, after them
int chain_n = 0, cm = 0;
if (o.lookup_chain > 0 && use_mtp && !first_window && !from_sfx && T < o.spec) {
if (o.lookup_chain > 0 && use_mtp && !first_window && !from_sfx && T < room) {
int csrc = -1;
const int nt = chain_tail(sfx, drafts.data(), T - 1, ctail);
chain_n = strata::spec::propose_from_sources(lookup_src, ctail.data(), nt, T - 1,
std::min(o.lookup_chain, o.spec - T), o.lookup_chain_min,
std::min(o.lookup_chain, room - T), o.lookup_chain_min,
cbuf.data(), &cm, &csrc);
if (chain_n > 0 && std::getenv("STRATA_LOOKUP_CHAIN_FIXED") == nullptr) {
double p_mtp = 1.0;