Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tools/server/server-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,11 +970,17 @@ struct server_context_impl {
std::string stage;
std::vector<std::string> stages;
int64_t t_last_load_progress_ms = 0;
llama_progress_callback orig_cb = nullptr;
void * orig_ud = nullptr;
load_progress_data(server_context_impl * ctx, const std::string & stage) : ctx(ctx), stage(stage) {}
};
static bool load_progress_callback(float progress, void * user_data) {
auto * d = static_cast<load_progress_data *>(user_data);
GGML_ASSERT(d);
// chain the caller-provided callback unthrottled
if (d->orig_cb && !d->orig_cb(progress, d->orig_ud)) {
return false;
}
// always emit the first and final sample; throttle the rest to one per 200ms
{
auto & t_last = d->t_last_load_progress_ms;
Expand Down Expand Up @@ -1009,6 +1015,13 @@ struct server_context_impl {
params_base = params;
params_base.n_outputs_max = server_n_outputs_max(params_base);

load_progress_text.orig_cb = params.load_progress_callback;
load_progress_text.orig_ud = params.load_progress_callback_user_data;
load_progress_mmproj.orig_cb = params.load_progress_callback;
load_progress_mmproj.orig_ud = params.load_progress_callback_user_data;
load_progress_spec.orig_cb = params.load_progress_callback;
load_progress_spec.orig_ud = params.load_progress_callback_user_data;

const bool has_mmproj = !params.mmproj.path.empty();
const bool has_draft = params.speculative.has_dft();
const bool spec_mtp = std::find(params_base.speculative.types.begin(),
Expand Down
Loading