Skip to main content

Live per-token distillation-loss (SDPO) heatmap server for any vLLM-served chat model

Project description

opd-viz

Live per-token distillation-loss (SDPO) heatmap server for any vLLM-served chat model.

opd-viz visualizes the gold-hint SDPO per-token distillation loss: for each rollout token it compares the student-policy prediction against the gold-procedure-reprompted teacher prediction as a top-k KL, and colors that divergence onto the realized tokens in a browser heatmap. It is model-agnostic (you pick the endpoint, model, and tokenizer at runtime from the browser) and brings-your-own-MCP (register any MCP server for the agentic generate loop).

Install / run

Zero-checkout, via uv:

uvx --from opd-viz opd-viz --port 8088

or into an environment:

pip install opd-viz
opd-viz --port 8088

Then open http://127.0.0.1:8088. The server binds loopback and is single-user; there is no auth on the opd-viz server itself.

Flags: --host (default 127.0.0.1), --port (default 8088). Everything else is set in the browser.

Requirements

  • A served, OpenAI-compatible vLLM endpoint. It must be started with --max-logprobs 100 so the teacher-forcing pass can return top-100 prompt_logprobs; opd-viz preflights this on Connect and reports a clear error if it is missing.

  • The tokenizer matching your model is pulled from the Hugging Face Hub by the model id at Connect time. For gated repos, set HF_TOKEN in the environment before launching:

    HF_TOKEN=<paste your hf_… token> uvx --from opd-viz opd-viz
    

    (Reference a secret manager rather than pasting tokens into shared shells.)

Use it (connect, generate, recompute)

  1. Connect. Fill in the vLLM endpoint (e.g. http://host:port/v1), optional API key, the model id (e.g. org/Model-Name), an optional system prompt, and sampling params (temperature plus any of top_p / top_k / min_p / presence_penalty / repetition_penalty; blank fields are not sent). Click Connect — this loads the matching tokenizer, runs the vLLM preflight, and runs a chat-template self-check, surfacing any warnings. Changing the model and clicking Connect again re-pulls the matching tokenizer and re-preflights; no restart needed.
  2. Generate. Type a question and click Generate rollout. Without tools this is a single assistant turn (the student = its own tokens, so gen == score holds). The generation logprobs are the student distribution.
  3. Recompute. Paste the gold hindsight (and optionally tweak the reprompt template), then click Recompute & visualize. The exact generated token ids are teacher-forced under the gold-hint prompt via vLLM prompt_logprobs, and the per-token KL (JSD / reverse / forward) is colored onto the realized tokens. Hover any token for the student/teacher top-k and the top-1 (dis)agreement.

A rollout is stamped with the config that produced it; if you reconnect with a different model/config and then score a stale rollout, the server refuses (regenerate instead of mis-coloring).

MCP tools (optional, agentic)

Register MCP servers in the Connect panel to make their tools available to an agentic generate loop:

  • remote: a URL (e.g. https://host/mcp) plus an optional auth header.
  • stdio: a command + args (+ optional KEY=val env), e.g. uvx some-mcp-server.

After connecting, the use tools toggle enables once at least one MCP tool is discovered. With it on, Generate runs the model through tool calls (executed live) until it answers without a tool call; scoring colors each assistant turn and greys the tool results.

opd-viz contacts only your vLLM endpoint, the MCP servers you register, and the HF Hub (for the tokenizer). Nothing else.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opd_viz-0.1.0.tar.gz (36.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opd_viz-0.1.0-py3-none-any.whl (40.6 kB view details)

Uploaded Python 3

File details

Details for the file opd_viz-0.1.0.tar.gz.

File metadata

  • Download URL: opd_viz-0.1.0.tar.gz
  • Upload date:
  • Size: 36.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for opd_viz-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f7ba440c743acf72dc1591d11955aeb53d3c96c4b62553f168c23e87beceef33
MD5 4ae61cc944c0e11b7f08a844fb206e25
BLAKE2b-256 1a0b7a729de0c253fe10b6f6e74e0eeb6791cc6c597fd92e247d978c9bef2cc6

See more details on using hashes here.

File details

Details for the file opd_viz-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: opd_viz-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 40.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for opd_viz-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c87f3bf22886a4d29e5a688b725b936db71cd81f832aa3d44920406432342964
MD5 9487c8274156e5f98b09aa67c87b0ebb
BLAKE2b-256 05173ca1440a905fee3d0ecd15bc948e6f3106e3ad1deaf99485f2f2abfa796a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page