CoolDip00 commited on
Commit
015487f
·
verified ·
1 Parent(s): 9cc801f

tiny-llm 5eac619: Status history: bucket requests by wall-clock minute

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. src/tinyllm/obs.py +7 -2
Dockerfile CHANGED
@@ -31,7 +31,7 @@ WORKDIR /app
31
  COPY --chown=user src/tinyllm ./src/tinyllm
32
  COPY --chown=user tokenizer ./tokenizer
33
 
34
- ARG GIT_COMMIT=a2fd365
35
  # REVISION pins the Hub commit of the model upload (scripts/upload_model.py), so a rebuild serves the same weights.
36
  ENV TINYLLM_GIT_COMMIT=$GIT_COMMIT \
37
  MODEL=CoolDip00/tiny-llm-tinystories-30m REVISION=b11100b189f9d5085ce8c0fd775ca71a6eaf287c \
 
31
  COPY --chown=user src/tinyllm ./src/tinyllm
32
  COPY --chown=user tokenizer ./tokenizer
33
 
34
+ ARG GIT_COMMIT=5eac619
35
  # REVISION pins the Hub commit of the model upload (scripts/upload_model.py), so a rebuild serves the same weights.
36
  ENV TINYLLM_GIT_COMMIT=$GIT_COMMIT \
37
  MODEL=CoolDip00/tiny-llm-tinystories-30m REVISION=b11100b189f9d5085ce8c0fd775ca71a6eaf287c \
src/tinyllm/obs.py CHANGED
@@ -224,9 +224,13 @@ class Metrics:
224
  buckets = [b for h, b in self._slo if h > hour_now - SLO_WINDOW_S / 3600]
225
  uptime = now - self.started
226
 
 
 
 
227
  by_min: list[list[RequestRecord]] = [[] for _ in range(HISTORY_MINUTES)]
 
228
  for t, r in recs:
229
- ago = int((now - t) // 60)
230
  if 0 <= ago < HISTORY_MINUTES:
231
  by_min[ago].append(r)
232
  minutes = []
@@ -236,7 +240,8 @@ class Metrics:
236
  ttft = [r.ttft_s for r in ok if r.ttft_s is not None]
237
  lat = [r.latency_s for r in ok if r.latency_s is not None]
238
  minutes.append({
239
- "minutes_ago": ago, "covered": uptime >= ago * 60, # the server was up for this minute
 
240
  "requests": len(rs), "ok": len(ok),
241
  "failed": sum(r.status >= 500 for r in rs), "shed": sum(r.status == 429 for r in rs),
242
  "completion_tokens": sum(r.completion_tokens for r in rs),
 
224
  buckets = [b for h, b in self._slo if h > hour_now - SLO_WINDOW_S / 3600]
225
  uptime = now - self.started
226
 
227
+ # Wall-clock minutes (12:03:00-12:03:59), not minutes counted back from this call, so a
228
+ # request keeps its bucket across refreshes; minutes_ago 0 is the minute in progress and
229
+ # the oldest one can be partial (the hour window is pruned by age).
230
  by_min: list[list[RequestRecord]] = [[] for _ in range(HISTORY_MINUTES)]
231
+ cur_min, into_min = wall // 60, wall % 60
232
  for t, r in recs:
233
+ ago = int(cur_min - (wall - (now - t)) // 60)
234
  if 0 <= ago < HISTORY_MINUTES:
235
  by_min[ago].append(r)
236
  minutes = []
 
240
  ttft = [r.ttft_s for r in ok if r.ttft_s is not None]
241
  lat = [r.latency_s for r in ok if r.latency_s is not None]
242
  minutes.append({
243
+ # covered: the server started before this minute ended
244
+ "minutes_ago": ago, "covered": uptime > into_min + (ago - 1) * 60,
245
  "requests": len(rs), "ok": len(ok),
246
  "failed": sum(r.status >= 500 for r in rs), "shed": sum(r.status == 429 for r in rs),
247
  "completion_tokens": sum(r.completion_tokens for r in rs),