|
39 | 39 |
|
40 | 40 | constexpr int HTTP_POLLING_SECONDS = 1; |
41 | 41 |
|
| 42 | +// KVFIX-114: a slot action (save, restore, erase) runs on the task loop |
| 43 | +// without launching its slot, so no release follows it and |
| 44 | +// slot.callback_on_release never pops the next deferred task. A completion |
| 45 | +// deferred alongside the action was then left in queue_tasks_deferred until |
| 46 | +// some other request released the slot: forever, on an idle server |
| 47 | +// (pilotlight item 114, spike 99 UPSTREAM.md). Constructed once the action |
| 48 | +// is committed to run (after the is_processing() deferral check), it pops |
| 49 | +// one deferred task on every exit, success or error. pop_deferred_task |
| 50 | +// still prefers a task naming this slot, so a chain of waiting slot actions |
| 51 | +// drains one after another and then one generation task starts. |
| 52 | +struct slot_action_drain { |
| 53 | + server_queue & queue; |
| 54 | + const int id_slot; |
| 55 | + |
| 56 | + ~slot_action_drain() { |
| 57 | + queue.pop_deferred_task(id_slot); |
| 58 | + } |
| 59 | +}; |
| 60 | + |
42 | 61 | static common_speculative_output_limits server_output_limits(const common_params & params) { |
43 | 62 | if (params.embedding || |
44 | 63 | (params.pooling_type != LLAMA_POOLING_TYPE_UNSPECIFIED && params.pooling_type != LLAMA_POOLING_TYPE_NONE)) { |
@@ -2905,6 +2924,9 @@ struct server_context_impl { |
2905 | 2924 | break; |
2906 | 2925 | } |
2907 | 2926 |
|
| 2927 | + // KVFIX-114: drain one deferred task when this action ends |
| 2928 | + const slot_action_drain drain_on_exit{queue_tasks, id_slot}; |
| 2929 | + |
2908 | 2930 | const int64_t t_start = ggml_time_us(); |
2909 | 2931 |
|
2910 | 2932 | std::string filename = task.slot_action.filename; |
@@ -2972,6 +2994,9 @@ struct server_context_impl { |
2972 | 2994 | break; |
2973 | 2995 | } |
2974 | 2996 |
|
| 2997 | + // KVFIX-114: drain one deferred task when this action ends |
| 2998 | + const slot_action_drain drain_on_exit{queue_tasks, id_slot}; |
| 2999 | + |
2975 | 3000 | const int64_t t_start = ggml_time_us(); |
2976 | 3001 |
|
2977 | 3002 | std::string filename = task.slot_action.filename; |
@@ -3055,6 +3080,9 @@ struct server_context_impl { |
3055 | 3080 | break; |
3056 | 3081 | } |
3057 | 3082 |
|
| 3083 | + // KVFIX-114: drain one deferred task when this action ends |
| 3084 | + const slot_action_drain drain_on_exit{queue_tasks, id_slot}; |
| 3085 | + |
3058 | 3086 | // Erase token cache |
3059 | 3087 | const size_t n_erased = slot->prompt.tokens.size(); |
3060 | 3088 |
|
|
0 commit comments