Archived
radiance 2.0.0
Radiance becomes a multi-model engine: one process serves several models behind one port, loads each when a request names it, parks it in host memory or restores it from its container, and shares the cards between them (docs/MULTIMODEL.md). The configuration is one YAML file; the command line flags are gone (`radiance --config FILE`, hot reload on SIGHUP). Formats. IQ8R (rotated int8) and IQR-V4 replace FP8 and MXFP4 as whole-model formats, with an int8 KV cache (`kv-cache-dtype: i8`) in place of the fp8 one. Containers whose weights are block FP8, MXFP4, M2XFP4, NVFP4 or ParoQuant are refused at startup by the name of the first such weight. Not served until they have int8 containers: GLM-5.3-Flash, Ornith-1.5, Sage-A1.5, Nemotron-3.5-Bolt-74B, Ling-3.0-flash, drama-3 and Anima's FP8 container; Nemotron-3.5-Bolt-E4B, the Gemma 4 31B DFlash containers and MiniCPM5-2B bf16 serve without their drafter. 1.17.0 serves all of them. Speed. Chained launches for Qwen3.8-27B, Gemma 4, Gemma 3 and the small bf16 models, a new Qwen3.8-Flash-Next container (IQR-V4 experts, int8 trunk) with its decode step and prefill reworked, and a reworked adaptive draft window. Deployment. deploy/compose has two fleet files, tp1.yaml and tp2.yaml, each with its configuration beside it, in place of the per-model files. `host-pool-mib` is a model's host pool in all, split among its ranks. The dashboard is rebuilt: an hour of history kept by the server, each accelerator's memory by model, model states over time. Merged since 1.17.0: Nemotron-3.5-Bolt-74B-A9B by keptn42 (#339); GLM-5.3-Flash on four cards by AnimusNull (#397); chained launches for Flash-Next's decode step (#396) and preempted requests keeping their prefix and place (#405) by mici81; --prefill-interleave auto by Code000 (#410); eight more libr3d kernels and the w4a4 reference by RikshaDriver (#403, #407, #408); libr3d large-BAR and E4M3 decode fixes by neuromanMD (#438, #439); int4/int5 decode tiles by Kezi (#426); attention for Nanbeige 4.3 33B by everplays (#417); expert_stats_report.py by baKon (#431). Fixed: #398, #402, #419, #437 (dschmitz's patch); added the metrics of #392, and multi-model serving as asked for in #367 and #109. Plugin ABI 39: out-of-tree plugins need to be rebuilt. Thanks to @keptn42, @AnimusNull, @mici81, @Code000, @RikshaDriver, @neuromanMD, @Kezi, @everplays, @baKon and @dschmitz.
This commit is contained in:
1 parent
b4c04b6042
commit
ddcb9c69bb
696 files changed
+120770
-56596
No files matched your search
@@ -0,0 +1,109 @@
|
||||
// What the page asks the engine for. Everything it draws every second comes from /history, which
|
||||
// the process answers from its sampler's last read: an open page reads nothing of a running model.
|
||||
// /sessions, /graph and /server_info are asked for once, when their view is opened.
|
||||
|
||||
export interface Columns { [name: string]: (number | null)[] }
|
||||
export interface FinishedRequest {
|
||||
id: string; prompt: number; out: number; ctx: number
|
||||
ttft: number | null; pf: number | null; tps: number | null; at: number
|
||||
}
|
||||
export interface HistoryBody<Live> {
|
||||
keep_s: number
|
||||
t: number[]
|
||||
c: Columns
|
||||
requests?: FinishedRequest[]
|
||||
live: Live | null
|
||||
}
|
||||
|
||||
export interface FleetModel {
|
||||
id: string; state: string; file?: string; aliases?: string[]
|
||||
priority?: number; pinned?: boolean; tp?: number; ttl_ms?: number
|
||||
parks?: number; restores?: number; loads?: number; unloads?: number
|
||||
in_flight?: number; waiting?: number
|
||||
cards?: number[]; vram_bytes_per_card?: number; parked_bytes_per_card?: number
|
||||
/** What the model holds on each accelerator now, in any state (loading and partly parked too). */
|
||||
vram_bytes_by_card?: Record<string, number>
|
||||
host_bytes?: number; host_pinned_bytes?: number; drive_bytes?: number; last_restore_s?: number; load_s?: number
|
||||
doing?: string; waiting_for?: string; error?: string; warm?: boolean; in_place?: boolean
|
||||
park?: { ram?: string; restore?: string; vram?: string }
|
||||
capabilities?: Record<string, unknown>
|
||||
[k: string]: unknown
|
||||
}
|
||||
export interface FleetCard { card: number; name?: string; vram_bytes?: number; free_bytes?: number; busy?: number; power_w?: number; temp_c?: number; queues?: number; queues_idle?: number; queue_bytes?: number }
|
||||
export interface Fleet {
|
||||
version: string; uptime_s: number
|
||||
models: FleetModel[]; cards: FleetCard[]
|
||||
groups: { name: string; kind: string; members: string[] }[]
|
||||
host: { budget_bytes?: number; copies_bytes?: number; held_bytes?: number; disk_tier?: string }
|
||||
warm_up: { queued?: number; loading?: string | null; drive_only_bytes?: number }
|
||||
}
|
||||
|
||||
// What the page reads of each route's object. Every field read is declared here (the compiler
|
||||
// refuses any other), and the engine's tests check that the routes emit each one
|
||||
// (tools/dashboard_embed.py copies these names into the compiled-in header).
|
||||
export interface RunningRequest {
|
||||
id: string | number; state: string; prompt: number; computed: number; cached: number; output: number
|
||||
max: number; age_s: number; tps: number
|
||||
}
|
||||
export interface DraftPosition { reached: number; rate: number }
|
||||
export interface ExpertTier { name: string; units: number; bytes: number }
|
||||
export interface Experts { n_units: number; tiers: ExpertTier[]; layer_units?: number[]; layer_resident?: number[] }
|
||||
export interface Stats {
|
||||
model: string; uptime_s: number
|
||||
in_flight: number; max_num_seqs?: number
|
||||
jobs: { running: number; done: number; failed: number; total_ms: number; last_ms: number }
|
||||
running?: number; waiting?: number
|
||||
kv_bytes_used?: number; kv_bytes_total?: number
|
||||
prefix_hit_rate?: number; prefill_tps?: number; decode_tps?: number
|
||||
total_requests?: number; preemptions?: number
|
||||
step_ns_decode_best?: number
|
||||
draft_positions?: DraftPosition[]
|
||||
requests?: RunningRequest[]
|
||||
experts?: Experts
|
||||
}
|
||||
export interface Session { id: number | string; label?: string; tokens: number; bytes: number; idle_s: number; on_device: number; on_host: number; moving: boolean; snapshots: number; resume_tokens: number }
|
||||
export interface Sessions {
|
||||
sessions: Session[]; enabled?: boolean
|
||||
pool?: { tokens_used: number; tokens_total: number; bytes_used: number; bytes_total: number }
|
||||
occupancy?: { host_bytes: number; host_cap_bytes: number }
|
||||
linear?: { checkpoints_written: number }
|
||||
prefix_hit_rate?: number
|
||||
}
|
||||
|
||||
let apiKey: string | null = null
|
||||
try { apiKey = localStorage.getItem("radiance.key") } catch { /* storage may be blocked */ }
|
||||
const listeners = new Set<() => void>()
|
||||
let needKey = false
|
||||
export const auth = {
|
||||
get needed() { return needKey },
|
||||
get key() { return apiKey },
|
||||
set(k: string) {
|
||||
apiKey = k || null
|
||||
try { if (k) localStorage.setItem("radiance.key", k); else localStorage.removeItem("radiance.key") } catch { /* as above */ }
|
||||
needKey = false
|
||||
listeners.forEach((f) => f())
|
||||
},
|
||||
subscribe(f: () => void) { listeners.add(f); return () => { listeners.delete(f) } },
|
||||
}
|
||||
|
||||
export class HttpError extends Error {
|
||||
status: number
|
||||
constructor(status: number, message: string) { super(message); this.status = status }
|
||||
}
|
||||
|
||||
export async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const headers: Record<string, string> = { ...(init?.headers as Record<string, string> | undefined) }
|
||||
if (apiKey) headers.Authorization = "Bearer " + apiKey
|
||||
const r = await fetch("/" + path, { cache: "no-store", ...init, headers })
|
||||
if (r.status === 401) {
|
||||
if (!needKey) { needKey = true; listeners.forEach((f) => f()) }
|
||||
throw new HttpError(401, "an API key is required")
|
||||
}
|
||||
if (!r.ok) {
|
||||
let msg = r.statusText
|
||||
try { const j = await r.json(); msg = j?.error?.message ?? msg } catch { /* not JSON */ }
|
||||
throw new HttpError(r.status, msg)
|
||||
}
|
||||
return (await r.json()) as T
|
||||
}
|
||||
export const withModel = (path: string, model: string) => path + (path.includes("?") ? "&" : "?") + "model=" + encodeURIComponent(model)
|
||||
@@ -0,0 +1,23 @@
|
||||
// A body asked for when a view opens, and again every `refreshMs` while the view stays open and
|
||||
// the tab is visible. Kept per path, so coming back to a view shows the last answer at once.
|
||||
import { useEffect, useState } from "react"
|
||||
import { api } from "./api"
|
||||
|
||||
const cache = new Map<string, unknown>()
|
||||
export function useFetched<T>(path: string | null, refreshMs = 0): { data: T | null; error: string | null } {
|
||||
const [, bump] = useState(0)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
useEffect(() => {
|
||||
if (!path) return
|
||||
let alive = true
|
||||
const load = () => {
|
||||
if (document.hidden) return
|
||||
api<T>(path).then((d) => { if (alive) { cache.set(path, d); setError(null); bump((n) => n + 1) } })
|
||||
.catch((e: unknown) => { if (alive) setError(e instanceof Error ? e.message : String(e)) })
|
||||
}
|
||||
load()
|
||||
const timer = refreshMs ? window.setInterval(load, refreshMs) : undefined
|
||||
return () => { alive = false; window.clearInterval(timer) }
|
||||
}, [path, refreshMs])
|
||||
return { data: path ? ((cache.get(path) as T | undefined) ?? null) : null, error }
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Number formats shared by every view. A value that is missing prints as a dash, never as zero.
|
||||
export const DASH = "–"
|
||||
export const fin = (v: unknown): v is number => typeof v === "number" && Number.isFinite(v)
|
||||
|
||||
export function fBytes(b: number | null | undefined): string {
|
||||
if (!fin(b)) return DASH
|
||||
const u = ["B", "KiB", "MiB", "GiB", "TiB"]
|
||||
let i = 0
|
||||
let v = Math.abs(b)
|
||||
while (v >= 1024 && i < u.length - 1) { v /= 1024; ++i }
|
||||
const s = v >= 100 || i === 0 ? v.toFixed(0) : v >= 10 ? v.toFixed(1) : v.toFixed(2)
|
||||
return (b < 0 ? "-" : "") + s + " " + u[i]
|
||||
}
|
||||
/** [value, unit] for a tile that sets the unit apart. */
|
||||
export function bytesParts(b: number | null | undefined): [string, string] {
|
||||
const s = fBytes(b)
|
||||
if (s === DASH) return [DASH, ""]
|
||||
const k = s.lastIndexOf(" ")
|
||||
return [s.slice(0, k), s.slice(k + 1)]
|
||||
}
|
||||
export const fRate = (b: number | null | undefined) => (fin(b) ? fBytes(b) + "/s" : DASH)
|
||||
export function fNum(v: number | null | undefined, digits = 0): string {
|
||||
if (!fin(v)) return DASH
|
||||
return v.toLocaleString("en-US", { minimumFractionDigits: digits, maximumFractionDigits: digits })
|
||||
}
|
||||
/** Three significant figures without trailing noise: 1,234 · 176 · 22.0 · 2.00 · 0.33 */
|
||||
export function fSig(v: number | null | undefined): string {
|
||||
if (!fin(v)) return DASH
|
||||
const a = Math.abs(v)
|
||||
if (a >= 100) return fNum(v, 0)
|
||||
if (a >= 10) return fNum(v, 1)
|
||||
return fNum(v, 2)
|
||||
}
|
||||
export const fPct = (v: number | null | undefined, digits = 1) => (fin(v) ? (v * 100).toFixed(digits) : DASH)
|
||||
export function fDur(s: number | null | undefined): string {
|
||||
if (!fin(s)) return DASH
|
||||
if (s < 1) return Math.round(s * 1000) + " ms"
|
||||
if (s < 60) return (s < 10 ? s.toFixed(1) : s.toFixed(0)) + " s"
|
||||
if (s < 3600) return Math.floor(s / 60) + " m " + String(Math.floor(s % 60)).padStart(2, "0") + " s"
|
||||
if (s < 86400) return Math.floor(s / 3600) + " h " + String(Math.floor((s % 3600) / 60)).padStart(2, "0") + " m"
|
||||
return Math.floor(s / 86400) + " d " + Math.floor((s % 86400) / 3600) + " h"
|
||||
}
|
||||
export function fClock(t: number, withSeconds = false): string {
|
||||
const d = new Date(t * 1000)
|
||||
const p = (n: number) => String(n).padStart(2, "0")
|
||||
return p(d.getHours()) + ":" + p(d.getMinutes()) + (withSeconds ? ":" + p(d.getSeconds()) : "")
|
||||
}
|
||||
export function fAgo(ms: number, now: number): string {
|
||||
return fDur(Math.max(0, (now - ms) / 1000)) + " ago"
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
// The page's copy of what the process remembers. One Scope per subject (the fleet, or a model):
|
||||
// it loads the server's hour once, then asks five times a second for what came after its last sample and
|
||||
// appends it. Views read a scope through useScope and redraw when its version moves.
|
||||
import { useSyncExternalStore } from "react"
|
||||
import { HttpError, api, withModel, type FinishedRequest, type Fleet, type HistoryBody, type Stats } from "./api"
|
||||
|
||||
const KEEP_S = 3600
|
||||
// The server samples five times a second while a page asks (once a second otherwise), so each
|
||||
// answer carries the rows since the last one and the live object.
|
||||
const POLL_MS = 200
|
||||
|
||||
export class Series {
|
||||
t: number[] = []
|
||||
c = new Map<string, (number | null)[]>()
|
||||
|
||||
append(t: number[], cols: Record<string, (number | null)[]>) {
|
||||
// Only what is later than everything held: a sample the server sent before is not kept twice.
|
||||
let from = 0
|
||||
while (from < t.length && t[from] <= this.end) ++from
|
||||
if (from === t.length) return
|
||||
const n0 = this.t.length
|
||||
for (let i = from; i < t.length; ++i) this.t.push(t[i])
|
||||
const n = this.t.length
|
||||
for (const [k, a] of Object.entries(cols)) {
|
||||
let col = this.c.get(k)
|
||||
if (!col) { col = new Array(n0).fill(null); this.c.set(k, col) }
|
||||
for (let i = from; i < a.length; ++i) col.push(a[i])
|
||||
}
|
||||
for (const col of this.c.values()) while (col.length < n) col.push(null)
|
||||
const cut = this.firstAfter(this.t[n - 1] - KEEP_S)
|
||||
if (cut > 64) { this.t.splice(0, cut); for (const col of this.c.values()) col.splice(0, cut) }
|
||||
}
|
||||
/** The first index whose time is later than `t`. */
|
||||
firstAfter(t: number): number {
|
||||
let lo = 0, hi = this.t.length
|
||||
while (lo < hi) { const m = (lo + hi) >> 1; if (this.t[m] <= t) lo = m + 1; else hi = m }
|
||||
return lo
|
||||
}
|
||||
col(k: string): (number | null)[] | undefined { return this.c.get(k) }
|
||||
has(k: string): boolean { const a = this.c.get(k); return !!a && a.some((v) => v !== null) }
|
||||
/** The latest value of a column among the last `within` samples (five minutes of them). */
|
||||
last(k: string, within = 300): number | null {
|
||||
const a = this.c.get(k)
|
||||
if (a) for (let i = a.length - 1; i >= 0 && i >= a.length - within; --i) if (a[i] !== null) return a[i]
|
||||
return null
|
||||
}
|
||||
get end(): number { return this.t.length ? this.t[this.t.length - 1] : 0 }
|
||||
}
|
||||
|
||||
type Listener = () => void
|
||||
|
||||
export class Scope<Live> {
|
||||
series = new Series()
|
||||
live: Live | null = null
|
||||
finished: FinishedRequest[] = []
|
||||
loaded = false
|
||||
error: string | null = null
|
||||
/** True once the server said this subject is not for this client (403): asking again is pointless. */
|
||||
refused = false
|
||||
version = 0
|
||||
private path: string
|
||||
private subs = new Set<Listener>()
|
||||
private timer: number | undefined
|
||||
private busy = false
|
||||
private users = 0
|
||||
|
||||
constructor(path: string) { this.path = path }
|
||||
|
||||
subscribe = (f: Listener) => {
|
||||
this.subs.add(f)
|
||||
if (++this.users === 1) this.start()
|
||||
return () => { this.subs.delete(f); if (--this.users === 0) this.stop() }
|
||||
}
|
||||
getVersion = () => this.version
|
||||
|
||||
private start() {
|
||||
void this.poll()
|
||||
this.timer = window.setInterval(() => { if (!document.hidden) void this.poll() }, POLL_MS)
|
||||
document.addEventListener("visibilitychange", this.onVisible)
|
||||
}
|
||||
private stop() {
|
||||
window.clearInterval(this.timer)
|
||||
document.removeEventListener("visibilitychange", this.onVisible)
|
||||
}
|
||||
private onVisible = () => { if (!document.hidden) void this.poll() }
|
||||
|
||||
private async poll() {
|
||||
if (this.busy || this.refused) return
|
||||
this.busy = true
|
||||
try {
|
||||
const since = this.series.end
|
||||
const sep = this.path.includes("?") ? "&" : "?"
|
||||
const b = await api<HistoryBody<Live>>(this.path + (since ? sep + "since=" + since : ""))
|
||||
this.series.append(b.t, b.c)
|
||||
if (b.requests?.length) {
|
||||
const have = new Set(this.finished.slice(-64).map((r) => r.id + ":" + r.at))
|
||||
for (const r of b.requests) if (!have.has(r.id + ":" + r.at)) this.finished.push(r)
|
||||
if (this.finished.length > 500) this.finished.splice(0, this.finished.length - 500)
|
||||
}
|
||||
this.live = b.live
|
||||
this.loaded = true
|
||||
this.error = null
|
||||
} catch (e) {
|
||||
this.error = e instanceof Error ? e.message : String(e)
|
||||
if (e instanceof HttpError && e.status === 403) this.refused = true
|
||||
} finally {
|
||||
this.busy = false
|
||||
++this.version
|
||||
this.subs.forEach((f) => f())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const fleet = new Scope<Fleet>("history")
|
||||
const models = new Map<string, Scope<Stats>>()
|
||||
export function modelScope(id: string): Scope<Stats> {
|
||||
let s = models.get(id)
|
||||
if (!s) { s = new Scope<Stats>(withModel("history", id)); models.set(id, s) }
|
||||
return s
|
||||
}
|
||||
|
||||
/** Subscribes the component to a scope; the scope polls while anything is subscribed. */
|
||||
export function useScope<L>(s: Scope<L>): Scope<L> {
|
||||
useSyncExternalStore(s.subscribe, s.getVersion)
|
||||
return s
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// What the viewer chose, kept across reloads where the browser lets the page keep anything: the
|
||||
// theme, the charts' time window, and the view named by the address's fragment.
|
||||
import { useSyncExternalStore } from "react"
|
||||
|
||||
function store<T>(initial: T) {
|
||||
let value = initial
|
||||
const subs = new Set<() => void>()
|
||||
return {
|
||||
get: () => value,
|
||||
set(v: T) { if (v !== value) { value = v; subs.forEach((f) => f()) } },
|
||||
subscribe(f: () => void) { subs.add(f); return () => { subs.delete(f) } },
|
||||
}
|
||||
}
|
||||
const read = (k: string): string | null => { try { return localStorage.getItem(k) } catch { return null } }
|
||||
const write = (k: string, v: string) => { try { localStorage.setItem(k, v) } catch { /* storage may be blocked */ } }
|
||||
|
||||
export type Theme = "dark" | "light"
|
||||
const theme = store<Theme>(document.documentElement.classList.contains("dark") ? "dark" : "light")
|
||||
export function setTheme(t: Theme) {
|
||||
document.documentElement.classList.toggle("dark", t === "dark")
|
||||
write("radiance.theme", t)
|
||||
theme.set(t)
|
||||
}
|
||||
export const useTheme = () => useSyncExternalStore(theme.subscribe, theme.get)
|
||||
|
||||
export const RANGES = [[60, "1m"], [300, "5m"], [900, "15m"], [3600, "1h"]] as const
|
||||
const stored = Number(read("radiance.range"))
|
||||
const range = store<number>(RANGES.some(([s]) => s === stored) ? stored : 300)
|
||||
export function setRange(s: number) { write("radiance.range", String(s)); range.set(s) }
|
||||
export const useRange = () => useSyncExternalStore(range.subscribe, range.get)
|
||||
|
||||
export type Tab = "performance" | "requests" | "sessions" | "details"
|
||||
export interface Route { model: string | null; tab: Tab }
|
||||
const TABS: Tab[] = ["performance", "requests", "sessions", "details"]
|
||||
function parse(): Route {
|
||||
const m = /^#\/m\/([^/]+)(?:\/([a-z]+))?/.exec(location.hash)
|
||||
if (!m) return { model: null, tab: "performance" }
|
||||
const tab = TABS.includes(m[2] as Tab) ? (m[2] as Tab) : "performance"
|
||||
return { model: decodeURIComponent(m[1]), tab }
|
||||
}
|
||||
let current = parse()
|
||||
const routeSubs = new Set<() => void>()
|
||||
window.addEventListener("hashchange", () => { current = parse(); routeSubs.forEach((f) => f()) })
|
||||
export const useRoute = () => useSyncExternalStore((f) => { routeSubs.add(f); return () => { routeSubs.delete(f) } }, () => current)
|
||||
export const hrefOf = (model: string | null, tab: Tab = "performance") => (model === null ? "#/" : "#/m/" + encodeURIComponent(model) + "/" + tab)
|
||||
@@ -0,0 +1 @@
|
||||
export { cn } from "cn"
|
||||
Reference in new issue
Block a user