diff --git a/c/glm.c b/c/glm.c index 68f9267..872057e 100644 --- a/c/glm.c +++ b/c/glm.c @@ -4874,6 +4874,7 @@ typedef struct { float temp, top_p; double started; uint64_t hits0, miss0; + ProfBase pb; /* PROF=1: window start (same convention as hits0) */ } ServeReq; static void mux_data(Tok *T, unsigned long long id, int token){ @@ -4894,6 +4895,10 @@ static void mux_done(Model *m, ServeCtx *sc, ServeReq *r){ r->emitted/dt,(dh+dm)>0?100.0*dh/(dh+dm):0.0,rss_gb(), r->prompt_tokens,r->length_limited); fflush(stdout); kv_bind(m,&sc->kv); kv_disk_append(m,sc->hist,sc->len); + /* PROF window = this request's lifetime; with KV_SLOTS>1 concurrent slots + * share the batched forwards, so the shares describe the engine, not the + * single request (same convention as the STAT hit%% above). */ + if(g_prof) prof_report(m,&r->pb,dt,r->emitted,stderr); r->active=0; } @@ -4956,6 +4961,7 @@ static int mux_submit(Model *m, Tok *T, ServeCtx *ctx, ServeReq *req, int nctx, ServeReq *r=&req[sub.slot]; memset(r,0,sizeof(*r)); r->id=sub.id; r->maximum=sub.max_tokens; r->temp=sub.temperature; r->top_p=sub.top_p; r->prompt_tokens=nt; r->started=now_s(); r->hits0=m->hits; r->miss0=m->miss; + if(g_prof) prof_base(m,&r->pb); int room=maxctx-sc->len-1; if(r->maximum>room){r->maximum=room; r->length_limited=1;} g_temp=r->temp; g_nuc=r->top_p; int next=pick_tok(logit,m->c.vocab,-1); free(logit); @@ -5032,8 +5038,10 @@ static void run_serve_mux(Model *m, const char *snap){ for(int i=0;in_fw++; + if(g_prof) prof_lat(now_s()-tf0); for(int s=0;slen++; g_temp=r->temp; g_nuc=r->top_p;