dsh-qwen-scope: Inspecting the Prefill Rate of a Local Inference Engine

Introduction

When using DeepSeek Harness (DSH) for local model inference, the built-in page statistics only show overall token counts or historical usage — there’s no real-time rate for the current tick’s prefill. This leaves a gap in troubleshooting and performance tuning: after selecting a model, you can’t immediately see how fast it’s actually computing, whether it’s queued, or whether it’s operating normally.

dsh-qwen-scope is a DSH plugin that adds a new cell to the statistics bar below the composer, displaying the current prefill rate of the local model service selected in this session. It follows the composer’s model selector — switch to a different local model and the next tick’s reading will come from that engine’s metrics.

Plugin Overview

  • Name: dsh-qwen-scope
  • Repository: https://github.com/coffee405/dsh-qwen-scope
  • Maintainer: coffee405
  • Category: Model Inference
  • License: MIT

Core Features

Position and Model Following

This cell belongs to the model currently running in the session. It reads the session’s own modelSelection projection rather than a page-level value: switching models in the composer will redirect the next polling cycle to the corresponding engine. On each poll, the page passes the model name to the host (GET /plugins/dsh-qwen-scope/state?model=...), and the host looks up the serving engine in the following order:

  1. The model ID declared in the model provider
  2. The model_name label in engine metrics
  3. The ID returned by the engine’s /v1/models

If none of these resolve to a local engine (e.g., an officially hosted model), the response is notLocal and the cell is not rendered.

Data Source and Polling

The host polls GET <address>/metrics (Prometheus text format) every two seconds from the machine running dsh (not the browser) for each reachable engine on localhost/LAN. Both name value and name{labels}= value line formats are supported. GET <address>/v1/models is polled every 30 seconds to supplement model IDs, though metric labels typically already include them.

When an engine is online but has no active compute tasks, it displays 0 — this is a real reading. Only when the engine is unresponsive or doesn’t provide the relevant counter does it display —.

An empty session (new window, no rounds or usage yet) does not render this cell, consistent with DSH’s built-in statistics cells.

Rate Calculation Methodology

The rate is defined as token count ÷ the actual time those tokens took:

  • If the engine publishes its own real-time rate (e.g., Radiance’s radiance:prefill_tokens_per_second), that value is used directly
  • Otherwise, the engine’s own timing histogram is used: prompt token count ÷ time to first token (time_to_first_token_seconds)
  • As a last resort, the difference between two consecutive samples is used, but only for engines that accumulate counters during inference; for engines that settle counters at request completion (e.g., TensorFold), the delta is not used to avoid dividing an entire long-context prompt by two seconds and producing a spurious reading in the hundreds of thousands

All readings are capped at 20,000 tok/s — anything above that is almost certainly a sampling window or floating-point artifact, and is displayed as empty rather than an erroneous speed.

Supported Engines and Metrics

Engines are identified by their metric prefix, and all metrics are then read using that engine’s own metric names — so engines that don’t mirror vLLM’s naming conventions are still readable. Metrics that an engine doesn’t expose display as —.

“Prefill” refers to prompt tokens actually computed by the engine. For engines with prefix caching (e.g., Radiance), cache hits are not counted, so its own counter is used rather than the mirrored vLLM name it also exposes. TensorFold settles prompt tokens at request completion, so its timing histogram is used to derive a rate (this cell reads 0 during inference and jumps to the real rate at request end — a consequence of the engine’s counting method).

Cell vLLM SGLang Radiance TensorFold
prefill vllm:prompt_tokens_total sglang:prompt_tokens_total (plus sglang:num_prefill_prompt_tokens_queued) radiance:prefill_tokens_total tensorfold:prompt_tokens_total
decode vllm:generation_tokens_total sglang:generation_tokens_total radiance:decode_tokens_total tensorfold:generation_tokens_total
running / waiting vllm:num_requests_{running,waiting} sglang:num_requests_{running,waiting} mirrored under vllm: tensorfold:num_requests_{running,waiting}
KV cache vllm:kv_cache_usage_perc sglang:token_usage mirrored under vllm: tensorfold:kv_cache_usage_perc
prefix cache vllm:gpu_prefix_cache_hit_rate sglang:cache_hit_rate mirrored under vllm: not tracked, displays —
TTFT / TPOT p95 vllm:time_to_first_token_seconds / …time_per_output_token_seconds sglang:time_to_first_token_seconds / sglang:inter_token_latency_seconds mirrored under vllm: tensorfold:time_to_first_token_seconds / …request_time_per_output_token_seconds

Installation and Enablement

The plugin is installed as a bundle. Select this directory under Plugins → Add Plugin, or declare it manually in the profile:

"dependencies": { "dsh-qwen-scope": "link:/path/to/dsh-qwen-scope" },
"dsh": { "profile": { "bundles": ["…", "dsh-qwen-scope"] } }

Then add a configuration entry to the profile’s cordis.patch.yml and restart dsh:

- id: qwen-scope
  name: dsh-qwen-scope
  config:
    active: local-model
    servers:
      - id: local-model
        name: local-model
        url: http://127.0.0.1:8000
        apiKeyEnv: LOCAL_API_KEY
      - id: second-model
        name: second-model
        url: http://127.0.0.1:8001
        apiKeyEnv: SECOND_API_KEY

Configuration Reference

Field Default Description
servers [] Manually registered servers; if empty, servers are auto-discovered from model provider configuration.
servers[].id — Stable identifier for the entry; active uses this to select which server to report.
servers[].name same as id Display name in the cell and settings page; keep it short.
servers[].url — Model service address (http / https, including any reverse-proxy path prefix).
servers[].apiKeyEnv LOCAL_API_KEY Environment variable name for the engine’s credential, resolved in order: credential file → launch environment → process environment.
active first entry Which server to report by default in the status bar when the session isn’t on one of the listed local models.
discover true Whether to auto-discover servers from model provider configuration.

Both servers and active are volatile configurations — adding/removing servers or switching the reporting target takes effect on the next polling tick without a restart.

API keys entered in settings are written only to the profile’s credential file, never into this plugin’s configuration, and never sent to the page. The plugin resolves them in the same order as the model provider: profile-stored credentials → launch environment (.env layer) → process environment.

Development and Debugging

Requires Node.js 24. The plugin’s scripts import '@deepseek-ai/schemastery'; the repo includes a development placeholder package at dev/schemastery. After cloning, place it in the expected location:

mkdir -p node_modules/@deepseek-ai
cp -r dev/schemastery node_modules/@deepseek-ai/schemastery

The dsh runtime provides the real package; the placeholder is only used for local scripts.

Command Purpose
npm run check Syntax check + offline self-tests: Prometheus parsing, rate calculation, address handling, and page-side parsing of host responses.
npm run probe Reads a real engine the same way the plugin does and prints what would appear in the cell: --url, --api-key-env, --seconds.
npm run e2e Runs the host-side half (poller + routing) against a mock dsh context, including two servers and switching the reporting target; also covers failure paths such as empty address, invalid address, unreachable host, and missing credentials. QWEN_SCOPE_URL specifies the engine address.
node scripts/fake-engine.mjs A stand-in engine with continuously incrementing counters, allowing e2e to run without hardware.

probe’s credential resolution follows the same order as the plugin: environment variable → profile credential file. Do not commit any key values.

Use Cases and Notes

Suitable for scenarios requiring real-time monitoring of a local inference engine’s prefill rate, such as diagnosing queuing, tuning parameters, or confirming that a model switch has taken effect. The plugin runs with the current dsh process’s permissions; review the source code and license before installing.

Summary

dsh-qwen-scope provides a real-time prefill rate reading for DSH’s local model inference workflow, reading directly from Prometheus metrics without depending on any intermediate topology layer. It follows the composer’s model selector, supports multi-engine auto-discovery and manual configuration, and is well-suited for developers who need an at-a-glance view of how fast the current model is prefilling during debugging and troubleshooting.

  • Directory page: https://www.skillhub.cn/plugins/coffee405/dsh-qwen-scope
  • GitHub: https://github.com/coffee405/dsh-qwen-scope
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye