Commit 14e58c4
FixBot
Fix slot selection logic in get_available_slot
The bug was likely introduced in PR ikawrakow#973 when the similarity calculation
was changed from LCP to token-level similarity, but sim_best was still
initialized to 0 instead of -1.0f.
When slot_prompt_similarity threshold was set high (e.g., 0.8) and no slot
met the threshold, sim_best stayed at 0, causing ret to remain nullptr.
This led to the system getting stuck without selecting any slot.
This fix:
- Changed sim_best initialization from 0 to -1.0f
- Added best_slot variable to track the best slot found during similarity search
- Only set ret = best_slot after the loop completes
- Removed redundant ret == nullptr check
This ensures that even when no slot meets the slot_prompt_similarity threshold,
the system still identifies the best available slot and falls back to LRU correctly.
Related: PR ikawrakow#973 (Server: Handle context shift better), PR ikawrakow#1285 (Fix slot prompt updating)1 parent 62a7dca commit 14e58c4
1 file changed
Lines changed: 8 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
690 | 690 | | |
691 | 691 | | |
692 | 692 | | |
693 | | - | |
| 693 | + | |
694 | 694 | | |
695 | | - | |
| 695 | + | |
| 696 | + | |
696 | 697 | | |
697 | 698 | | |
698 | 699 | | |
| |||
720 | 721 | | |
721 | 722 | | |
722 | 723 | | |
723 | | - | |
| 724 | + | |
724 | 725 | | |
725 | 726 | | |
726 | | - | |
| 727 | + | |
727 | 728 | | |
728 | 729 | | |
729 | | - | |
| 730 | + | |
| 731 | + | |
730 | 732 | | |
731 | 733 | | |
732 | 734 | | |
| |||
749 | 751 | | |
750 | 752 | | |
751 | 753 | | |
752 | | - | |
753 | 754 | | |
754 | 755 | | |
755 | 756 | | |
| |||
766 | 767 | | |
767 | 768 | | |
768 | 769 | | |
769 | | - | |
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
| |||
799 | 799 | | |
800 | 800 | | |
801 | 801 | | |
802 | | - | |
803 | 802 | | |
804 | 803 | | |
805 | 804 | | |
806 | 805 | | |
807 | 806 | | |
808 | 807 | | |
809 | 808 | | |
810 | | - | |
811 | 809 | | |
812 | 810 | | |
813 | 811 | | |
| |||
821 | 819 | | |
822 | 820 | | |
823 | 821 | | |
| 822 | + | |
824 | 823 | | |
825 | 824 | | |
826 | 825 | | |
| |||
0 commit comments