Commit e2acfcc
perf(restored): ADR 0015 item #1 - memory-efficient restoration prefill
Unblock long-context multi-tenant for the restored-S5 path:
- forward() gains logits_to_keep (default 0 = unchanged; spec-decode still
gets all-position logits). Bench passes 1 (only last logits needed).
- capture_verifier_own_kv skips the [B,T,vocab] logits entirely (logits_to_keep=1;
it only needs K/V via hooks).
- restored K/V cast to verifier compute dtype right after f_theta (was held
full-length in fp32; cast-at-use was already bf16, so numerically identical).
- bench --attn-impl (default eager for exact repro; sdpa for long context routes
the patched forward to SDPA, killing the O(T^2) eager score materialisation).
41 v04 unit tests still pass (logits_to_keep default preserves behavior).
Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>1 parent f030a74 commit e2acfcc
2 files changed
Lines changed: 35 additions & 6 deletions
File tree
- inference_engine/v04
- scripts/research
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| 313 | + | |
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
316 | 323 | | |
317 | 324 | | |
318 | 325 | | |
| |||
335 | 342 | | |
336 | 343 | | |
337 | 344 | | |
338 | | - | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
339 | 349 | | |
340 | 350 | | |
341 | 351 | | |
342 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
343 | 362 | | |
344 | 363 | | |
345 | 364 | | |
| |||
375 | 394 | | |
376 | 395 | | |
377 | 396 | | |
378 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
379 | 401 | | |
380 | 402 | | |
381 | 403 | | |
| |||
548 | 570 | | |
549 | 571 | | |
550 | 572 | | |
551 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
552 | 576 | | |
553 | 577 | | |
554 | 578 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
114 | 118 | | |
115 | 119 | | |
116 | 120 | | |
| |||
134 | 138 | | |
135 | 139 | | |
136 | 140 | | |
137 | | - | |
| 141 | + | |
138 | 142 | | |
139 | 143 | | |
140 | 144 | | |
| |||
233 | 237 | | |
234 | 238 | | |
235 | 239 | | |
| 240 | + | |
236 | 241 | | |
237 | 242 | | |
238 | 243 | | |
| |||
0 commit comments