@troed/oc-ls-stats 1.1.0 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +11 -6
  2. package/package.json +1 -1
  3. package/tui.tsx +12 -7
package/README.md CHANGED
@@ -55,15 +55,20 @@ Every 500ms, the plugin polls `GET /slots?model=<model>` on each discovered serv
55
55
 
56
56
  ### State Classification
57
57
 
58
- Each slot is classified as prefill or generation based on the `n_decoded` counter in `next_token[0]`. The plugin tracks a per-slot baseline value:
58
+ Each processing slot is classified as prefill (PP) or generation (TG) by comparing `n_decoded` and `n_prompt_tokens` against per-slot/per-task baselines. The plugin tracks two baseline maps keyed by slot ID:
59
59
 
60
- 1. When a slot first appears as processing, the current `n_decoded` is recorded as the baseline with `hasIncreased = false`.
61
- 2. If `n_decoded <= baseline` and `hasIncreased` is false, the slot is classified as prefilling.
62
- 3. If `n_decoded > baseline`, `hasIncreased` is set to true and the slot is classified as generating.
60
+ - `prevNdBySlot[slotId]` — stores `{ prevNd, idTask, classification }`
61
+ - `prevPromptTokensBySlot[slotId]` — stores `{ tokens, idTask }`
63
62
 
64
- This approach handles the case where `n_decoded` drops when a new request starts on a reused slot, and prevents generation stalls (where `n_decoded` plateaus) from being misclassified as prefill.
63
+ The `idTask` field ensures baselines are invalidated when a slot starts a new task (task reuse).
65
64
 
66
- When no slots are processing, all tracked state for those slots is cleared.
65
+ Classification logic:
66
+
67
+ 1. **First time or after task change/reset**: If we have no baseline for this slot+task, or `n_decoded` or `n_prompt_tokens` dropped below baseline (indicating a new request), use a heuristic: `n_decoded > 0` → TG, otherwise → PP.
68
+ 2. **Compare against baseline**: If `n_decoded > baselineNd` → TG. If `n_prompt_tokens > baselineNt` → PP.
69
+ 3. **Neither increased**: Persist the previous classification. This handles frequent polling where neither field increases on every poll cycle.
70
+
71
+ When a slot stops being processed, all tracked state for that slot is cleared.
67
72
 
68
73
  ### Prefill Rate (PP)
69
74
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@troed/oc-ls-stats",
4
- "version": "1.1.0",
4
+ "version": "1.1.5",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  "./tui": {
package/tui.tsx CHANGED
@@ -143,16 +143,23 @@ function SessionPromptRight(props: {
143
143
  })
144
144
 
145
145
  const text = createMemo(() => {
146
+ props.clock()
146
147
  if (props.tracker.failure) return props.tracker.failure
147
148
  const pp = prefillRate()
148
149
  const tps = liveTps()
149
150
  if (props.tracker.isPrefilling && pp) {
150
- return `${formatPps(pp)} tps (PP)`
151
+ const result = `${formatPps(pp)} tps (PP)`
152
+ debug(`UI_TEXT="${result}" isPrefilling=${props.tracker.isPrefilling} isGenerating=${props.tracker.isGenerating} failure=${props.tracker.failure} pp=${pp} tps=${tps}`)
153
+ return result
151
154
  }
152
155
  if (props.tracker.isGenerating && tps) {
153
- return `${formatTps(tps)} tps (TG)`
156
+ const result = `${formatTps(tps)} tps (TG)`
157
+ debug(`UI_TEXT="${result}" isPrefilling=${props.tracker.isPrefilling} isGenerating=${props.tracker.isGenerating} failure=${props.tracker.failure} pp=${pp} tps=${tps}`)
158
+ return result
154
159
  }
155
- return `- tps (TG)`
160
+ const result = `- tps (TG)`
161
+ debug(`UI_TEXT="${result}" isPrefilling=${props.tracker.isPrefilling} isGenerating=${props.tracker.isGenerating} failure=${props.tracker.failure} pp=${pp} tps=${tps}`)
162
+ return result
156
163
  })
157
164
 
158
165
  return <>{text() ? <text fg={props.api.theme.current.textMuted}>{text()}</text> : null}</>
@@ -256,6 +263,7 @@ const tui: TuiPlugin = async (api) => {
256
263
  bump()
257
264
 
258
265
  const result = processPoll(slotList, tracker)
266
+ bump()
259
267
 
260
268
  if (result.isPrefilling) {
261
269
  debug(`PP rate=${Math.round(result.lastPrefillRate)} tps`)
@@ -270,10 +278,6 @@ const tui: TuiPlugin = async (api) => {
270
278
  debug(`TG ended rate=${Math.round(result.lastGeneratedTps)} tps`)
271
279
  }
272
280
  }
273
-
274
- if (tracker.lastPrefillRate > 0 || tracker.lastGeneratedTps > 0) {
275
- bump()
276
- }
277
281
  }
278
282
 
279
283
  const onDelta = api.event.on("message.part.delta", (evt) => {
@@ -360,6 +364,7 @@ const tui: TuiPlugin = async (api) => {
360
364
  api.slots.register({
361
365
  slots: {
362
366
  session_prompt_right(_ctx, value) {
367
+ debug(`slot_callback: session=${value.session_id}`)
363
368
  return <SessionPromptRight api={api} sessionID={value.session_id} tracker={tracker} version={version} clock={clock} />
364
369
  },
365
370
  },