Commit ca0c575
feat(server): reuse restored KV/recurrent state instead of reprocessing
On hybrid recurrent models, slot restore followed by prompt reuse always
forced a full reprocess: only the current recurrent plane was persisted,
rs_idx was reset on read, and the reuse gate reset n_past whenever the
aggregate pos_min came from recurrent memory. This made cross-process KV
restore useless for skipping prompt processing.
- llama-memory-recurrent: persist all 1+n_rs_seq rollback planes (offset
k*size) and rs_idx in state_write_data/state_read_data, so the running
state can roll back to the reuse boundary after a restore.
- server-context: in the reuse gate, when the memory supports bounded
recurrent rollback and (pos_min - n_past + 1) <= n_rs_seq, keep n_past
and reuse; otherwise fall back to full reprocess (no abort). Add a .dft
sidecar to save/restore the speculative draft context so seq_rm on the
draft does not abort under --spec-type.
- common: add KVARN_N_RS_SEQ env override for the recurrent rollback budget
(native comes from speculative need_n_rs_seq(); 0 without speculation).
Result: restored state is reused instead of reprocessed (prompt_n 4843->19
in tests), correct recall, works cross-GPU, with safe reprocess fallback.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RErC5TKNN678KpqAQwFatc1 parent f16b973 commit ca0c575
3 files changed
Lines changed: 75 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1697 | 1697 | | |
1698 | 1698 | | |
1699 | 1699 | | |
| 1700 | + | |
1700 | 1701 | | |
1701 | 1702 | | |
1702 | 1703 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
810 | | - | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
811 | 820 | | |
812 | 821 | | |
813 | 822 | | |
| |||
820 | 829 | | |
821 | 830 | | |
822 | 831 | | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
823 | 835 | | |
824 | 836 | | |
825 | 837 | | |
| |||
839 | 851 | | |
840 | 852 | | |
841 | 853 | | |
842 | | - | |
| 854 | + | |
843 | 855 | | |
844 | 856 | | |
845 | 857 | | |
| |||
886 | 898 | | |
887 | 899 | | |
888 | 900 | | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
893 | 907 | | |
894 | 908 | | |
895 | 909 | | |
| |||
908 | 922 | | |
909 | 923 | | |
910 | 924 | | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
915 | 931 | | |
916 | 932 | | |
917 | 933 | | |
| |||
1086 | 1102 | | |
1087 | 1103 | | |
1088 | 1104 | | |
1089 | | - | |
1090 | | - | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1091 | 1108 | | |
1092 | 1109 | | |
1093 | 1110 | | |
| |||
1116 | 1133 | | |
1117 | 1134 | | |
1118 | 1135 | | |
1119 | | - | |
1120 | | - | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
1121 | 1139 | | |
1122 | 1140 | | |
1123 | 1141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2476 | 2476 | | |
2477 | 2477 | | |
2478 | 2478 | | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
2479 | 2490 | | |
2480 | 2491 | | |
2481 | 2492 | | |
| |||
2535 | 2546 | | |
2536 | 2547 | | |
2537 | 2548 | | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
2538 | 2564 | | |
2539 | 2565 | | |
2540 | 2566 | | |
| |||
3270 | 3296 | | |
3271 | 3297 | | |
3272 | 3298 | | |
3273 | | - | |
3274 | | - | |
3275 | | - | |
3276 | | - | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
3277 | 3315 | | |
3278 | 3316 | | |
3279 | 3317 | | |
| |||
0 commit comments