Commit e9a538f
Ralf Waldukat
fix: critical fixes for recurrent/hybrid model support
After external code review (GPT-5.2), fixed 4 critical issues:
1. CRITICAL: Fixed tokens[:-1] bug in prefix matching
- Was silently breaking prefix matching for ALL models
- Caused false rewind detection and cache inefficiency
- Impact: Transformers AND recurrent models
2. CRITICAL: Implement proper reset() for recurrent models
- Now actually clears llama_memory backend state
- Root cause fix for 'sequence positions not consecutive' crash
- Without this, reset was a no-op for recurrent models
3. CRITICAL: Enforce strict append policy for recurrent models
- Prevents KV cache rewinding that's impossible without state snapshots
- Forces full reset on history edits instead of crashing
4. Performance: Cache _is_recurrent to avoid repeated FFI calls
5. Documentation: Simplified comments and updated docstring
6. Testing: All existing tests pass + Mistral-Small-3.2-24B validated
Resolves multi-turn crashes for Nemotron-A3B, Mamba, RWKV, Jamba models.
Reviewed-by: GPT-5.2 (OpenAI)
Tested-by: pytest + Mistral-Small-3.2-24B
Fixes: abetlen#2108 (recurrent model crashes)
Compatible-with: abetlen#2109 (Granite-Docling/SmolVLM special tokens)1 parent 02d6bee commit e9a538f
1 file changed
+40
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
| |||
553 | 558 | | |
554 | 559 | | |
555 | 560 | | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
556 | 566 | | |
557 | 567 | | |
558 | 568 | | |
| |||
580 | 590 | | |
581 | 591 | | |
582 | 592 | | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
583 | 606 | | |
584 | 607 | | |
585 | 608 | | |
| |||
638 | 661 | | |
639 | 662 | | |
640 | 663 | | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
641 | 669 | | |
642 | 670 | | |
643 | 671 | | |
| |||
888 | 916 | | |
889 | 917 | | |
890 | 918 | | |
891 | | - | |
| 919 | + | |
892 | 920 | | |
893 | 921 | | |
894 | 922 | | |
895 | 923 | | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
896 | 935 | | |
897 | 936 | | |
898 | 937 | | |
| |||
0 commit comments