double t_prompt_processing; // ms
double t_token_generation; // ms
- std::function<void(int /* slot_id */)> callback_on_release;
+ std::function<void(int /* id_slot */)> callback_on_release;
// Speculative decoding stats
int32_t n_draft_total = 0; // Total draft tokens generated
SLT_INF(slot, "new slot, n_ctx = %d\n", slot.n_ctx);
- slot.callback_on_release = [this](int slot_id) {
- queue_tasks.pop_deferred_task(slot_id);
+ slot.callback_on_release = [this](int id_slot) {
+ queue_tasks.pop_deferred_task(id_slot);
};
slot.reset();
}
server_slot * get_slot_by_id(int id_slot) {
+ // note: allow id_slot to be out of bounds (wrap around)
+ id_slot = id_slot % slots.size();
+
for (server_slot & slot : slots) {
if (slot.id == id_slot) {
return &slot;
break;
}
- int id_slot = task.slot_action.slot_id;
+ const int id_slot = task.slot_action.id_slot;
server_slot * slot = get_slot_by_id(id_slot);
if (slot == nullptr) {
send_error(task, "Invalid slot ID", ERROR_TYPE_INVALID_REQUEST);
case SERVER_TASK_TYPE_SLOT_RESTORE:
{
if (!check_no_mtmd(task.id)) break;
- int id_slot = task.slot_action.slot_id;
+ const int id_slot = task.slot_action.id_slot;
server_slot * slot = get_slot_by_id(id_slot);
if (slot == nullptr) {
send_error(task, "Invalid slot ID", ERROR_TYPE_INVALID_REQUEST);
if (!check_no_mtmd(task.id)) {
break;
}
- int id_slot = task.slot_action.slot_id;
+ const int id_slot = task.slot_action.id_slot;
server_slot * slot = get_slot_by_id(id_slot);
if (slot == nullptr) {
send_error(task, "Invalid slot ID", ERROR_TYPE_INVALID_REQUEST);
}
// TODO: get rid of this dynamic_cast
- auto res_task = dynamic_cast<server_task_result_metrics*>(result.get());
+ auto * res_task = dynamic_cast<server_task_result_metrics*>(result.get());
GGML_ASSERT(res_task != nullptr);
// optionally return "fail_on_no_slot" error
}
std::string id_slot_str = req.get_param("id_slot");
- int id_slot;
+ int id_slot;
try {
id_slot = std::stoi(id_slot_str);
} catch (const std::exception &) {
if (action == "save") {
return handle_slots_save(req, id_slot);
- } else if (action == "restore") {
+ }
+ if (action == "restore") {
return handle_slots_restore(req, id_slot);
- } else if (action == "erase") {
+ }
+ if (action == "erase") {
return handle_slots_erase(req, id_slot);
- } else {
- res->error(format_error_response("Invalid action", ERROR_TYPE_INVALID_REQUEST));
- return res;
}
+
+ res->error(format_error_response("Invalid action", ERROR_TYPE_INVALID_REQUEST));
+ return res;
};
this->get_props = [this](const server_http_req &) {
{
server_task task(SERVER_TASK_TYPE_SLOT_SAVE);
task.id = rd.get_new_id();
- task.slot_action.slot_id = id_slot;
+ task.slot_action.id_slot = id_slot;
task.slot_action.filename = filename;
task.slot_action.filepath = filepath;
rd.post_task(std::move(task));
{
server_task task(SERVER_TASK_TYPE_SLOT_RESTORE);
task.id = rd.get_new_id();
- task.slot_action.slot_id = id_slot;
+ task.slot_action.id_slot = id_slot;
task.slot_action.filename = filename;
task.slot_action.filepath = filepath;
rd.post_task(std::move(task));
{
server_task task(SERVER_TASK_TYPE_SLOT_ERASE);
task.id = rd.get_new_id();
- task.slot_action.slot_id = id_slot;
+ task.slot_action.id_slot = id_slot;
rd.post_task(std::move(task));
}