The UI source from the 14 October handoff (src/, public/, index.html, vite and tsconfig, tests, audit-fixes, design docs) and the App Host (server/*.mjs): model import and monitor routes, API-provider catalog and streaming (OpenAI chat, OpenAI Responses, the Messages API), serving, tunnel, tasks, plus the host routes for Time-skip (server/timeskip.mjs) and the tuning plan/reports. src/lib/time-skip.ts renders a real job's own record. The UI design is unchanged. The rebuild routed #/tuning to a new TunePanel; that is reverted: src/screens/ModelRun.tsx and src/main.tsx are the handoff's again (#/tuning goes where the handoff sends it), and src/components/TunePanel.tsx and src/styles/tuning.css, which only that route used, are not carried over. Left out of git on purpose: dist/ (build output), node_modules, and docs/evidence + docs/checkpoints (170 MB of screenshots, kept in StrataSplit\evidence-archive). From the owner's rebuild branch strata/rebuild-2026-10.
54 lines
3.0 KiB
TypeScript
54 lines
3.0 KiB
TypeScript
import type { Experience } from './experience';
|
|
import type { Hardware } from './types';
|
|
import type { ComputerUse } from './run-profiles';
|
|
|
|
export interface RunMemory {
|
|
total: number;
|
|
weights: number;
|
|
context: number;
|
|
runtime: number;
|
|
ram: number;
|
|
gpu: number;
|
|
ssd: number;
|
|
budget: number;
|
|
reserve: number;
|
|
unified: boolean;
|
|
cacheFits: boolean;
|
|
devices: { name: string; budget: number }[];
|
|
}
|
|
|
|
/** A capacity planning preview. Actual placement must be verified by the engine. */
|
|
export function planMemory(experience: Experience, hardware: Hardware | null, use: ComputerUse, parallel = 1, allowSpill = true): RunMemory | null {
|
|
if (!experience.memory || !hardware) return null;
|
|
const m = experience.memory;
|
|
const unified = hardware.accelerator.unified;
|
|
const cpuOnly = hardware.accelerator.backend === 'cpu' || experience.config.placement === 'CPU only';
|
|
const reserve = Math.min(hardware.memory.totalGb, use === 'shared' ? Math.max(4, hardware.memory.totalGb * .25) : Math.max(2, hardware.memory.totalGb * .125));
|
|
const ramBudget = Math.max(0, hardware.memory.totalGb - reserve);
|
|
const devices = unified || cpuOnly ? [] : hardware.gpus.filter(g => !g.unified && g.backend !== 'cpu').map(g => ({
|
|
name: g.name,
|
|
budget: Math.max(0, g.vramGb - (use === 'shared' ? Math.max(1, g.vramGb * .1) : Math.max(.5, g.vramGb * .05))),
|
|
}));
|
|
const gpuBudget = devices.reduce((sum, g) => sum + g.budget, 0);
|
|
// Explicit partial offload needs layer sizes, which this catalog does not expose.
|
|
if (!unified && !cpuOnly && !['Automatic', 'All layers'].includes(experience.config.placement)) return null;
|
|
const budget = ramBudget + gpuBudget;
|
|
const context = m.cache * Math.max(1, parallel);
|
|
const total = m.weights + context + m.runtime;
|
|
const fixed = context + m.runtime;
|
|
const cacheFits = fixed <= (unified || cpuOnly ? ramBudget : gpuBudget || ramBudget);
|
|
const ssd = cacheFits && allowSpill ? Math.min(m.weights, Math.max(0, total - budget)) : 0;
|
|
const gpu = Math.min(gpuBudget, total - ssd);
|
|
const ram = Math.min(ramBudget, Math.max(0, total - ssd - gpu));
|
|
return { total, weights: m.weights, context, runtime: m.runtime, ram, gpu, ssd, budget, reserve, unified, cacheFits, devices };
|
|
}
|
|
|
|
/** Illustrative preview curves stay separate from measured/estimated evidence. */
|
|
export function demoRunExperience(experience: Experience, memory: RunMemory | null, use: ComputerUse): Experience {
|
|
if (experience.source !== 'demo' || !memory || !experience.reading || !experience.answer) return experience;
|
|
const spillFraction = memory.ssd / Math.max(1, memory.weights);
|
|
const factor = (use === 'full' ? 1.08 : 1) / (1 + spillFraction * 3);
|
|
const scale = (range: NonNullable<Experience['reading']>) => ({ low: Math.max(1, Math.round(range.low * factor)), high: Math.max(2, Math.round(range.high * factor)) });
|
|
return { ...experience, reading: scale(experience.reading), answer: scale(experience.answer), provenance: 'Illustrative design preview including context, computer use and SSD spill. Not a benchmark.' };
|
|
}
|