Models tab in one view with the family switch, one result card for every tune outcome, the tuned values in Expert mode, glow instead of a spinning ring
- Models: the family switch (Qwen3.8-Flash-Next, Qwen3.6-35B-A3B) is back in the navbar without the word Model; version, context and computer use, the tuning line and Load/Tune sit in one card beside This computer, so the tab fits the first view; image generation moves into Expert mode - Tune: one result card for faster, already the fastest, couldn't measure (busy PC, with plain copy and Try again), failed and stopped, driven by the host's code, reason_code and values; the same Tune dialog frame for all of them - Tune running: the step icon glows and a small dot beeps instead of a ring spinning around a square tile; reduced motion respected - Expert mode: Context memory and Low-RAM mode show the active tuning's values, the engine settings list what the tuning sets, and loading does not re-prepare the model because of them - the tuning line (Using your tuning / Switch off) is a calm line with an icon - strings in 8 languages; tests in tune-outcome.test.mjs
This commit is contained in:
1 parent
99cc9829a0
commit
35c72bcd10
10 files changed
+300
-49
No files matched your search
@@ -0,0 +1,12 @@
|
||||
import { tr } from '../lib/i18n';
|
||||
import type { CatalogModel } from '../lib/native-catalog';
|
||||
|
||||
/** The model families of the catalog as a switch in the navbar (Qwen3.8-Flash-Next, Qwen3.6-35B-A3B). A single family is just its name. */
|
||||
export function FamilySwitch({ families, selected, onPick }: { families: CatalogModel[]; selected?: string; onPick: (family: CatalogModel) => void }) {
|
||||
const shown = families.filter(f => f.sizes.length);
|
||||
if (shown.length < 2) return shown[0] ? <span className="family-switch family-switch--single">{tr(shown[0].title)}</span> : null;
|
||||
return <div className="family-switch" role="tablist" aria-label={tr("Model family")}>
|
||||
{shown.map(f => <button key={f.family} type="button" role="tab" aria-selected={f.family === selected} tabIndex={f.family === selected ? 0 : -1} onClick={() => onPick(f)}
|
||||
onKeyDown={e => { if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') { e.preventDefault(); const at = shown.findIndex(x => x.family === selected); onPick(shown[(at + (e.key === 'ArrowRight' ? 1 : shown.length - 1)) % shown.length]); } }}>{tr(f.title)}</button>)}
|
||||
</div>;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { tr } from '../lib/i18n';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Screen } from './layout';
|
||||
import { VersionPicker } from './VersionPicker';
|
||||
import { FamilySwitch } from './FamilySwitch';
|
||||
import { PcFitCard } from './PcFitCard';
|
||||
import { fitOn } from '../lib/native-fit';
|
||||
import { Btn, Dialog, ErrorNotice, Icon, Select } from './ui';
|
||||
@@ -12,6 +13,8 @@ import { plainFailureText } from '../lib/plain-errors';
|
||||
import { api } from '../lib/client';
|
||||
import { go, setSettingsSection, selectRemoteModel, pushToast } from '../lib/store';
|
||||
import { nativeAction, useNative, type NativeJob } from '../lib/native';
|
||||
import { tuneEffective } from '../lib/native-tune';
|
||||
import { tunedFields } from '../lib/tune-values';
|
||||
import { NativeSettings } from './NativeSettings';
|
||||
import { RunImageModel } from './RunImageModel';
|
||||
import { useStore } from '../lib/store';
|
||||
@@ -57,6 +60,15 @@ export function NativeModels({ onOtherModels, onReady, onImport, onConnectEngine
|
||||
// What the running model was really started with is what the page shows: after Load the highlight must still be the profile that was applied.
|
||||
useEffect(() => { if (loadedSelected?.resourceProfile)
|
||||
setResourceProfile(loadedSelected.resourceProfile); }, [loadedSelected?.id, loadedSelected?.resourceProfile]);
|
||||
// After a tuning, Expert mode shows the values the tuning set (the active preset's), not the ones the model was prepared with.
|
||||
const [tunedNow, setTunedNow] = useState<{ name: string; fields: ReturnType<typeof tunedFields> } | null>(null);
|
||||
useEffect(() => {
|
||||
if (!selectedSize || !installed?.ready) { setTunedNow(null); return; }
|
||||
let alive = true;
|
||||
tuneEffective(selectedSize.id, resourceProfile, selectedSize.images ? vision : 'no').then(t => { if (alive) setTunedNow(t.applied && t.preset ? { name: t.preset.name, fields: tunedFields(t.changed) } : null); }).catch(() => { if (alive) setTunedNow(null); });
|
||||
return () => { alive = false; };
|
||||
}, [selectedSize?.id, installed?.ready, resourceProfile, vision, native?.jobs.filter(j => j.state === 'done').length]);
|
||||
useEffect(() => { if (tunedNow?.fields.kv) setKv(tunedNow.fields.kv as typeof kv); if (tunedNow?.fields.lowRam) setLowRam(tunedNow.fields.lowRam as typeof lowRam); }, [tunedNow]);
|
||||
const active = native?.jobs.find(j => j.state === 'running');
|
||||
const job = native?.jobs.find(j => j.id === jobId) ?? (!jobId ? native?.jobs.filter(j => ['load', 'install'].includes(j.kind)).at(-1) : undefined);
|
||||
const noFit = selectedSize?.on_this_pc === 'does not fit';
|
||||
@@ -94,38 +106,42 @@ export function NativeModels({ onOtherModels, onReady, onImport, onConnectEngine
|
||||
setPending(false);
|
||||
} }
|
||||
async function load() { if (!selectedSize)
|
||||
return; await perform(async () => { if (installed?.ready && context === installed.context && (!selectedSize?.images || installed.images && installed.images !== 'off') && (!installed.kv || kv === installed.kv) && lowRam === (installed.lowRamMode ?? 'auto')) {
|
||||
return; await perform(async () => { if (installed?.ready && context === installed.context && (!selectedSize?.images || installed.images && installed.images !== 'off') && (!installed.kv || kv === installed.kv || kv === tunedNow?.fields.kv) && (lowRam === (installed.lowRamMode ?? 'auto') || lowRam === tunedNow?.fields.lowRam)) {
|
||||
const result = await nativeAction<NativeJob>('operations', { kind: 'load', args: { model: selectedSize.id, resourceProfile, vision: selectedSize?.images ? vision : 'no', multiple: expert && multiple, ...(expert && gpus.length ? { gpus, layerSplit: split } : {}), values: {} } });
|
||||
setJobId(result.id);
|
||||
}
|
||||
else
|
||||
setPlan(await api.post('/api/native/plan', downloadValues)); }); }
|
||||
async function download() { await perform(async () => { const result = await nativeAction<NativeJob>('operations', { kind: 'install', args: downloadValues }); setJobId(result.id); setPlan(null); }); }
|
||||
return <Screen plainHeader title={tr("Model")} actions={<Btn icon="sliders" aria-pressed={expert} aria-expanded={expert} aria-controls="native-expert-settings" onClick={() => { setExpert(v => !v); setMultiple(false); setGpus([]); setDeviceChoice('auto'); }}>{tr(expert ? 'Close expert mode' : 'Expert mode')}</Btn>}>
|
||||
{tr(selectedFamily ? <div className="native-model-toolbar"><div className="native-toolbar-summary"><Icon name="models"/><strong>{tr(selectedFamily.title)}</strong><small>{tr(selectedSize ? catalogVersionLabel(selectedSize) : '')} · {tr(context / 1024)}{tr("K")}{tr(vision !== 'no' ? ' · Reads pictures' : '')}</small>{tr(native?.instances.some(i => i.model === selectedSize?.id && i.status === 'ready') ? <span className="native-ready">{tr("Ready")}</span> : null)}</div><NativePresets values={values} onApply={v => { const f = families.find(f => f.family === v.family || f.sizes.some(s => s.sourceFamily === v.family)); if (!f)
|
||||
return; presetPending.current = true; setFamily(f.family); setSize(f.sizes.find(s => s.model === v.model && (s.sourceFamily === v.family || f.family === v.family))?.id ?? ''); setContext(v.context ?? 32768); setVision(v.vision ?? 'no'); setKv(v.kv ?? 'int8'); setLowRam(v.low_ram ?? 'auto'); }}/><Btn icon="models" onClick={() => setManage(true)}>{tr("Manage models")}</Btn></div> : null)}
|
||||
<div className="native-model-layout">
|
||||
<div className="stack stack--lg">
|
||||
return <Screen plainHeader title={<span className="sr-only">{tr("Models")}</span>} titleDetail={<FamilySwitch families={families} selected={selectedFamily?.family} onPick={f => { setFamily(f.family); setSize((f.sizes.find(s => native?.installed?.models.some(m => m.model === s.id && m.ready)) ?? f.sizes[0])?.id ?? ''); setVision('no'); setError(''); }}/>} actions={<Btn icon="sliders" aria-pressed={expert} aria-expanded={expert} aria-controls="native-expert-settings" onClick={() => { setExpert(v => !v); setMultiple(false); setGpus([]); setDeviceChoice('auto'); }}>{tr(expert ? 'Close expert mode' : 'Expert mode')}</Btn>}>
|
||||
<div className="native-model-layout native-model-layout--fit">
|
||||
<div className="stack">
|
||||
{tr(native?.instances.length && expert ? <section className="st-card native-running"><h2 className="h4">{tr(native.instances.length === 1 ? 'Loaded model' : 'Loaded models')}</h2>{tr(native.instances.map(i => <div key={i.id}><span><strong>{tr(i.label)}</strong><small>{tr(i.gpus.length ? i.gpus.map(g => `GPU ${g + 1}`).join(' + ') : 'Automatic GPU')} · {tr(i.status === 'ready' ? i.phase : i.status)}{tr(native.defaultId === i.id ? ' · Chat default' : '')}</small>{tr(i.error ? <small className="inline-error">{tr(plainFailureText(i.error).message)}</small> : null)}</span>{tr(expert && multiple && native.defaultId !== i.id ? <Btn size="sm" variant="ghost" onClick={() => void perform(() => nativeAction(`instances/${i.id}/default`))}>{tr("Use in chat")}</Btn> : null)}<Btn size="sm" disabled={pending || !!active} onClick={() => void perform(() => nativeAction(`instances/${i.id}/unload`))}>{tr("Unload")}</Btn></div>))}</section> : null)}
|
||||
<section className="st-card native-choice">{tr(selectedFamily && !selectedSize ? <><h2 className="h3">{tr("This model needs a newer engine.")}</h2><p className="small muted">{tr("Update your engine or import a local GGUF for this model.")}</p><Btn onClick={() => { setSettingsSection('Engine'); go('settings'); }}>{tr("Update engine")}</Btn><Btn variant="ghost" onClick={onImport ?? onOtherModels}>{tr("Use a local GGUF\u2026")}</Btn></> : null)}{tr(!selectedFamily ? <><h2 className="h3">{tr("Set up Strata")}</h2><p className="small muted">{tr("Connect your local installation to choose an optimized model.")}</p><Btn variant="primary" onClick={onConnectEngine ?? (() => { setSettingsSection('Engine'); go('settings'); })}>{tr("Connect engine")}</Btn>{tr(native?.error ? <p className="small inline-error">{tr(native.error)}</p> : null)}<Btn variant="ghost" onClick={onOtherModels}>{tr("Other local models")}</Btn></> : null)}
|
||||
{tr(selectedSize ? <><div className="input-field"><span>{tr("Version")}</span><VersionPicker versions={allSizes} selectedId={selectedSize.id} hardware={fitHardware} onSelect={id => { const f = families.find(f => f.sizes.some(s => s.id === id)); if (f) { setFamily(f.family); setSize(id); setError(''); } }} onOwnGguf={() => (onImport ?? onOtherModels)()}/></div><p className="small muted">{tr(selectedSize.about)}</p>
|
||||
{tr(selectedSize ? <>
|
||||
<div className="native-choice__head"><span className="native-choice__label">{tr("Version")}</span><span className="native-choice__tools"><NativePresets values={values} onApply={v => { const f = families.find(f => f.family === v.family || f.sizes.some(s => s.sourceFamily === v.family)); if (!f)
|
||||
return; presetPending.current = true; setFamily(f.family); setSize(f.sizes.find(s => s.model === v.model && (s.sourceFamily === v.family || f.family === v.family))?.id ?? ''); setContext(v.context ?? 32768); setVision(v.vision ?? 'no'); setKv(v.kv ?? 'int8'); setLowRam(v.low_ram ?? 'auto'); }}/><Btn icon="models" onClick={() => setManage(true)}>{tr("Manage models")}</Btn></span></div>
|
||||
<div className="native-version"><VersionPicker versions={allSizes} selectedId={selectedSize.id} hardware={fitHardware} onSelect={id => { const f = families.find(f => f.sizes.some(s => s.id === id)); if (f) { setFamily(f.family); setSize(id); setError(''); } }} onOwnGguf={() => (onImport ?? onOtherModels)()}/></div>
|
||||
{tr(noFit ? <p className="small muted native-spill-note"><Icon name="disk" size={16}/>{tr("May run slower \u00B7 Model data can be read from SSD.")}</p> : null)}
|
||||
<div className="native-choice__row">
|
||||
<div className="native-choice__col"><span className="native-choice__label">{tr("Conversation context")}</span><Select ariaLabel={tr("Conversation context")} value={String(context)} options={(native?.catalog?.contexts ?? [8192, 32768, 65536, 131072, 262144]).map(n => ({ value: String(n), label: `${n / 1024}K` }))} onChange={n => setContext(Number(n))}/></div>
|
||||
<div className="native-choice__col"><span className="native-choice__label">{tr("Computer use")}</span><div className="native-resource-choice"><button aria-pressed={resourceProfile === 'work'} data-selected={resourceProfile === 'work'} onClick={() => setResourceProfile('work')}><Icon name="computer" size={20}/><span><strong>{tr("Leave 20% for my work")}</strong><small>{tr("Headroom for your other apps")}</small></span>{tr(resourceProfile === 'work' ? <Icon name="check" size={15}/> : null)}</button><button aria-pressed={resourceProfile === 'performance'} data-selected={resourceProfile === 'performance'} onClick={() => setResourceProfile('performance')}><Icon name="bolt" size={20}/><span><strong>{tr("Full performance")}</strong><small>{tr("Give Strata priority")}</small></span>{tr(resourceProfile === 'performance' ? <Icon name="check" size={15}/> : null)}</button></div></div>
|
||||
</div>
|
||||
{tr(selectedSize?.images ? <div className="native-image-reading"><label><input type="checkbox" checked={vision !== 'no'} disabled={!selectedSize?.images || !!active} onChange={e => setVision(e.target.checked ? 'yes' : 'no')}/><span><strong>{tr("Read pictures ")}<small>{tr("Optional")}</small></strong><small>{tr("Understand photos, screenshots and charts. Vision files download automatically. Enable them when loading this model.")}</small></span></label>{tr(expert && vision !== 'no' ? <Select ariaLabel={tr("Image encoder device")} value={vision === 'yes' ? 'yes' : vision} options={[{ value: 'yes', label: 'Automatic' }, { value: 'gpu', label: 'GPU' }, { value: 'cpu', label: 'CPU' }]} onChange={setVision}/> : null)}</div> : null)}
|
||||
</> : null)}
|
||||
{tr(active ? <NativeProgress job={active}/> : null)}
|
||||
{tr(job?.state === 'error' ? <ErrorNotice message={job.error ?? job.summary} action={tr("Retry")} onRetry={() => void load()}/> : null)}
|
||||
{tr(error ? <ErrorNotice message={error}/> : null)}
|
||||
{selectedSize && installed?.ready ? <NativeTuneBadge model={selectedSize.id} resourceProfile={resourceProfile} vision={selectedSize.images ? vision : 'no'}/> : null}
|
||||
<div className="native-model-actions">{tr(loadedSelected ? <><Btn disabled={pending || !!active} onClick={() => void perform(() => nativeAction(`instances/${loadedSelected.id}/unload`))}>{tr("Unload")}</Btn>{tr(onReady ? <Btn variant="primary" onClick={onReady}>{tr("Start chatting")}</Btn> : <span className="native-ready">{tr("Ready")}</span>)}</> : onReady && native?.instances.some(i => i.status === 'ready') ? <Btn variant="primary" onClick={onReady}>{tr("Start chatting")}</Btn> : <><Btn icon="gauge" disabled={!installed?.ready || !native?.available || !!active || !selectedSize} onClick={() => setTuneOpen(true)}>{tr("Tune model")}</Btn><Btn variant="primary" icon="models" disabled={pending || !native?.available || !!active || !selectedSize || expert && deviceChoice === 'split' && gpus.length < 2} onClick={() => void load()}>{tr(pending ? 'Checking…' : installed?.ready ? 'Load model' : 'Download & load')}</Btn></>)}</div>
|
||||
</section>
|
||||
{tr(selectedFamily ? <section className="st-card"><div className="section-toolbar"><h2 className="h4">{tr("Conversation context")}</h2><span className="small muted">{tr(context / 1024)}{tr("K tokens")}</span></div><p className="small muted">{tr("How much your model can keep in mind.")}</p><Select ariaLabel={tr("Conversation context")} value={String(context)} options={(native?.catalog?.contexts ?? [8192, 32768, 65536, 131072, 262144]).map(n => ({ value: String(n), label: `${n / 1024}K` }))} onChange={n => setContext(Number(n))}/></section> : null)}
|
||||
<section className="st-card native-computer-use"><h2 className="h4">{tr("Computer use")}</h2><div className="native-resource-choice"><button aria-pressed={resourceProfile === 'work'} data-selected={resourceProfile === 'work'} onClick={() => setResourceProfile('work')}><Icon name="computer" size={20}/><span><strong>{tr("Leave 20% for my work")}</strong><small>{tr("Headroom for your other apps")}</small></span>{tr(resourceProfile === 'work' ? <Icon name="check" size={15}/> : null)}</button><button aria-pressed={resourceProfile === 'performance'} data-selected={resourceProfile === 'performance'} onClick={() => setResourceProfile('performance')}><Icon name="bolt" size={20}/><span><strong>{tr("Full performance")}</strong><small>{tr("Give Strata priority")}</small></span>{tr(resourceProfile === 'performance' ? <Icon name="check" size={15}/> : null)}</button></div></section>
|
||||
<details className="native-generation"><summary>{tr("Image generation ")}<span className="muted">{tr("Optional")}</span></summary><RunImageModel library={imageLibrary} disabled={pending || !!active} onChange={() => { }}/></details>
|
||||
{tr(expert ? <section id="native-expert-settings" ref={expertSection} className="st-card native-execution"><h2 className="h4">{tr("Expert settings")}</h2><label className="native-toggle"><span><strong>{tr("Run multiple models")}</strong><small>{tr("Loading another model keeps the others loaded.")}</small></span><button className="st-toggle" role="switch" aria-label={tr("Run multiple models")} aria-checked={multiple} onClick={() => setMultiple(v => !v)}/></label><h3 className="small strong">{tr("Run on")}</h3><p className="small muted">{tr("Automatic uses the installation\u2019s GPU placement. Choose a GPU, or split this model across several GPUs.")}</p><Select ariaLabel={tr("Run on")} value={deviceChoice} options={[{ value: 'auto', label: 'Automatic' }, ...(native?.hardware?.gpus ?? []).map(g => ({ value: String(g.index), label: `GPU ${g.index + 1} · ${g.name}` })), ...((native?.hardware?.gpus.length ?? 0) > 1 ? [{ value: 'split', label: 'Split across GPUs…' }] : [])]} onChange={value => { setDeviceChoice(value); setGpus(value === 'auto' ? [] : value === 'split' ? (native?.hardware?.gpus ?? []).map(g => g.index) : [Number(value)]); }}/>{tr(deviceChoice === 'split' ? <div className="native-gpu-options">{tr(native?.hardware?.gpus.map(g => <label key={g.index}><input type="checkbox" checked={gpus.includes(g.index)} onChange={e => setGpus(old => e.target.checked ? [...old, g.index] : old.filter(i => i !== g.index))}/><span>{tr("GPU ")}{tr(g.index + 1)} · {tr(g.name)}<small>{tr(g.vram_gb)}{tr(" GB VRAM")}</small></span></label>))}</div> : null)}{tr(gpus.length > 1 ? <label className="input-field"><span>{tr("Layer split")}</span><input className="st-input" value={split} placeholder={tr("auto or 16,32")} onChange={e => setSplit(e.target.value)}/></label> : null)}<div className="native-field-grid"><label className="input-field"><span>{tr("Context memory")}</span><Select ariaLabel={tr("Native KV format")} value={kv} options={[{ value: 'int8', label: 'INT8' }, { value: 'q4_0', label: 'Q4' }, { value: 'k8v4', label: 'K8 / V4' }]} onChange={setKv}/></label><label className="input-field"><span>{tr("Low-RAM mode")}</span><Select ariaLabel={tr("Native low RAM mode")} value={lowRam} options={['auto', 'resident', 'mmap'].map(v => ({ value: v, label: v === 'auto' ? 'Automatic' : v === 'resident' ? 'Keep experts in RAM' : 'Read experts from disk' }))} onChange={setLowRam}/></label></div>{tr(installed ? <NativeSettings model={installed.model}/> : <p className="small muted">{tr("More engine parameters become available after preparing this version.")}</p>)}</section> : null)}
|
||||
{tr(active ? <NativeProgress job={active}/> : null)}
|
||||
{tr(job?.state === 'error' ? <ErrorNotice message={job.error ?? job.summary} action={tr("Retry")} onRetry={() => void load()}/> : null)}
|
||||
{tr(error ? <ErrorNotice message={error}/> : null)}
|
||||
{selectedSize && installed?.ready ? <NativeTuneBadge model={selectedSize.id} resourceProfile={resourceProfile} vision={selectedSize.images ? vision : 'no'}/> : null}
|
||||
<div className="native-model-actions">{tr(loadedSelected ? <><Btn disabled={pending || !!active} onClick={() => void perform(() => nativeAction(`instances/${loadedSelected.id}/unload`))}>{tr("Unload")}</Btn>{tr(onReady ? <Btn variant="primary" onClick={onReady}>{tr("Start chatting")}</Btn> : <span className="native-ready">{tr("Ready")}</span>)}</> : onReady && native?.instances.some(i => i.status === 'ready') ? <Btn variant="primary" onClick={onReady}>{tr("Start chatting")}</Btn> : <><Btn icon="gauge" disabled={!installed?.ready || !native?.available || !!active || !selectedSize} onClick={() => setTuneOpen(true)}>{tr("Tune model")}</Btn><Btn variant="primary" icon="models" disabled={pending || !native?.available || !!active || !selectedSize || expert && deviceChoice === 'split' && gpus.length < 2} onClick={() => void load()}>{tr(pending ? 'Checking…' : installed?.ready ? 'Load model' : 'Download & load')}</Btn></>)}</div>
|
||||
{tr(expert ? <><details className="native-generation"><summary>{tr("Image generation ")}<span className="muted">{tr("Optional")}</span></summary><RunImageModel library={imageLibrary} disabled={pending || !!active} onChange={() => { }}/></details></> : null)}
|
||||
{tr(expert ? <section id="native-expert-settings" ref={expertSection} className="st-card native-execution"><h2 className="h4">{tr("Expert settings")}</h2>{tr(tunedNow ? <p className="small muted native-tuned-note">{tr("Showing the values of your tuning '{0}'.", [tunedNow.name])}</p> : null)}<label className="native-toggle"><span><strong>{tr("Run multiple models")}</strong><small>{tr("Loading another model keeps the others loaded.")}</small></span><button className="st-toggle" role="switch" aria-label={tr("Run multiple models")} aria-checked={multiple} onClick={() => setMultiple(v => !v)}/></label><h3 className="small strong">{tr("Run on")}</h3><p className="small muted">{tr("Automatic uses the installation\u2019s GPU placement. Choose a GPU, or split this model across several GPUs.")}</p><Select ariaLabel={tr("Run on")} value={deviceChoice} options={[{ value: 'auto', label: 'Automatic' }, ...(native?.hardware?.gpus ?? []).map(g => ({ value: String(g.index), label: `GPU ${g.index + 1} · ${g.name}` })), ...((native?.hardware?.gpus.length ?? 0) > 1 ? [{ value: 'split', label: 'Split across GPUs…' }] : [])]} onChange={value => { setDeviceChoice(value); setGpus(value === 'auto' ? [] : value === 'split' ? (native?.hardware?.gpus ?? []).map(g => g.index) : [Number(value)]); }}/>{tr(deviceChoice === 'split' ? <div className="native-gpu-options">{tr(native?.hardware?.gpus.map(g => <label key={g.index}><input type="checkbox" checked={gpus.includes(g.index)} onChange={e => setGpus(old => e.target.checked ? [...old, g.index] : old.filter(i => i !== g.index))}/><span>{tr("GPU ")}{tr(g.index + 1)} · {tr(g.name)}<small>{tr(g.vram_gb)}{tr(" GB VRAM")}</small></span></label>))}</div> : null)}{tr(gpus.length > 1 ? <label className="input-field"><span>{tr("Layer split")}</span><input className="st-input" value={split} placeholder={tr("auto or 16,32")} onChange={e => setSplit(e.target.value)}/></label> : null)}<div className="native-field-grid"><label className="input-field"><span>{tr("Context memory")}</span><Select ariaLabel={tr("Native KV format")} value={kv} options={[{ value: 'int8', label: 'INT8' }, { value: 'q4_0', label: 'Q4' }, { value: 'k8v4', label: 'K8 / V4' }]} onChange={setKv}/></label><label className="input-field"><span>{tr("Low-RAM mode")}</span><Select ariaLabel={tr("Native low RAM mode")} value={lowRam} options={['auto', 'resident', 'mmap'].map(v => ({ value: v, label: v === 'auto' ? 'Automatic' : v === 'resident' ? 'Keep experts in RAM' : 'Read experts from disk' }))} onChange={setLowRam}/></label></div>{tr(installed ? <NativeSettings model={installed.model}/> : <p className="small muted">{tr("More engine parameters become available after preparing this version.")}</p>)}</section> : null)}
|
||||
</div>
|
||||
<aside className="stack stack--lg"><PcFitCard gpuName={pcGpu?.name} ramGb={pcRam} vramGb={pcVram} fit={selectedSize ? fitOn(selectedSize, fitHardware) : null}/><section className="st-card"><h2 className="h4">{tr("Model files")}</h2><p className="small muted">{tr("Strata prepares all shards, the draft layer and shared files. Completed downloads are reused.")}</p><code className="native-path">{installed?.dataFolder ?? native?.downloadDirectory ?? native?.installed?.data_folder ?? 'Choose an installation'}</code><Btn size="sm" variant="ghost" onClick={() => { setSettingsSection('Storage'); go('settings'); }}>{tr("Storage settings")}</Btn></section><Btn size="sm" variant="ghost" onClick={onOtherModels}>{tr("Other local models\u2026")}</Btn></aside>
|
||||
</div>
|
||||
<Dialog open={!!plan} title={tr(installed?.ready ? "Apply settings and load" : "Download and prepare")} compact onClose={() => !pending && setPlan(null)} actions={<><Btn disabled={pending} onClick={() => setPlan(null)}>{tr("Cancel")}</Btn><Btn variant="primary" disabled={pending || !!plan?.plan?.disk_short} onClick={() => void download()}>{tr(installed?.ready ? "Apply & load" : "Download & load")}</Btn></>}><p><strong>{tr(plan?.plan?.title ?? selectedFamily?.title)}</strong>{tr(installed?.ready ? null : <>{tr(" \u00B7 approximately ")}{tr(plan?.plan?.download_gb ?? selectedSize?.download_gb)}{tr(" GB")}</>)}</p>{tr(installed?.ready ? <p className="small muted">{tr("The model files are already on this computer. Nothing will be downloaded; only the settings you chose are applied.")}</p> : null)}{tr(plan?.plan?.disk_short ? <ErrorNotice message={plan.plan.disk_short}/> : null)}{tr(installed?.ready ? <p className="small muted">{tr("Any currently loaded native models will be unloaded first.")}</p> : <><p className="small muted">{tr("Existing files are checked and reused. Any currently loaded native models will be unloaded before preparing files.")}</p><p className="small muted">{tr("Your computer may feel slower while weights load. You can stop the download and resume later.")}</p></>)}{tr(selectedSize?.images ? <p className="small muted">{tr("Vision encoder files are included. Picture reading loads only when enabled.")}</p> : null)}</Dialog>
|
||||
|
||||
<Dialog open={!!plan} title={tr(installed?.ready ? "Apply settings and load" : "Download and prepare")} compact onClose={() => !pending && setPlan(null)} actions={<><Btn disabled={pending} onClick={() => setPlan(null)}>{tr("Cancel")}</Btn><Btn variant="primary" disabled={pending || !!plan?.plan?.disk_short} onClick={() => void download()}>{tr(installed?.ready ? "Apply & load" : "Download & load")}</Btn></>}><p><strong>{tr(plan?.plan?.title ?? selectedFamily?.title)}</strong>{tr(installed?.ready ? null : <>{tr(" \u00B7 approximately ")}{tr(plan?.plan?.download_gb ?? selectedSize?.download_gb)}{tr(" GB")}</>)}</p>{tr(installed?.ready ? <p className="small muted">{tr("The model files are already on this computer. Nothing will be downloaded; only the settings you chose are applied.")}</p> : null)}{tr(plan?.plan?.disk_short ? <ErrorNotice message={plan.plan.disk_short}/> : null)}{tr(installed?.ready ? <p className="small muted">{tr("Any currently loaded native models will be unloaded first.")}</p> : <><p className="small muted">{tr("Existing files are checked and reused. Any currently loaded native models will be unloaded before preparing files.")}</p><p className="small muted">{tr("Your computer may feel slower while weights load. You can stop the download and resume later.")}</p></>)}{tr(selectedSize?.images ? <p className="small muted">{tr("Vision encoder files are included. Picture reading loads only when enabled.")}</p> : null)}</Dialog>
|
||||
<NativeDeleteDialog id={deleting} onClose={() => setDeleting(null)}/>
|
||||
<Dialog open={manage} title={tr("Manage models")} onClose={() => setManage(false)} actions={<Btn onClick={() => setManage(false)}>{tr("Done")}</Btn>}><div className="native-manage">
|
||||
{tr(downloaded.length ? <div className="native-manage-list" role="list">{tr(downloaded.map(m => { const v = allSizes.find(x => x.id === m.model), loaded = native?.instances.some(i => i.model === m.model && i.status === 'ready'); return <div className="native-manage-row" role="listitem" key={m.model} data-selected={selectedSize?.id === m.model || undefined}>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { tr } from '../lib/i18n';
|
||||
import {nativeSettingsResponse,nativeSettingsValues} from '../lib/native-settings-response';
|
||||
import { describeChange, type TunedChange } from '../lib/tune-values';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { api } from '../lib/client';
|
||||
import { refreshNative, useNative, type NativeField } from '../lib/native';
|
||||
@@ -10,6 +11,7 @@ export function NativeSettings({ model }: {
|
||||
}) {
|
||||
const native = useNative();
|
||||
const [revision,setRevision]=useState(0);
|
||||
const [tuned, setTuned] = useState<{ preset: { name: string } | null; changed: TunedChange[] } | null>(null);
|
||||
const [values, setValues] = useState<Record<string, any>>({}), [mcp, setMcp] = useState('{}'), [original, setOriginal] = useState(''), [text, setText] = useState(''), [tab, setTab] = useState('fields'), [pending, setPending] = useState(false), [error, setError] = useState(''), [notice, setNotice] = useState(''), [query, setQuery] = useState('');
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
@@ -22,9 +24,11 @@ export function NativeSettings({ model }: {
|
||||
void api.get<{
|
||||
values: Record<string, any>;
|
||||
mcp: Record<string, any>;
|
||||
tuned?: { preset: { name: string } | null; changed: TunedChange[] } | null;
|
||||
}>(`/api/native/models/${model}/settings`).then(input => {
|
||||
if (!active)
|
||||
return;
|
||||
setTuned(input.tuned ?? null);
|
||||
const value = nativeSettingsResponse(input);
|
||||
setValues(value.values);
|
||||
setText(JSON.stringify(value.values, null, 2));
|
||||
@@ -87,7 +91,7 @@ export function NativeSettings({ model }: {
|
||||
{error ? <><ErrorNotice message={tr('Couldn’t load model settings.')} next={tr('Check that the engine is connected and this model is installed, then try again.')} onRetry={() => setRevision(value => value + 1)}/><details className="native-settings-diagnostic"><summary className="small">{tr('Details')}</summary><p className="small muted">{error}</p></details></> : <p className="small muted" role="status">{tr('Reading saved settings…')}</p>}
|
||||
</details>;
|
||||
const rows = (native?.fields ?? []).filter(f => `${tr(f.label)} ${f.id} ${tr(f.group)}`.toLowerCase().includes(query.toLowerCase()));
|
||||
return <details className="native-settings"><summary>{tr("Native engine settings")}</summary><p className="small muted">{tr(!original ? 'Reading saved settings… ' : '')}{tr("Settings for this model. Blank values use Strata\u2019s defaults.")}</p><div className="editor-tabs" role="tablist" aria-label={tr("Native settings editor")}>{tr(['fields', 'json', 'tools'].map(t => <button key={t} role="tab" aria-selected={tab === t} onClick={() => chooseTab(t)}>{tr(t === 'fields' ? 'Parameters' : t === 'json' ? 'JSON' : 'MCP tools')}</button>))}</div>
|
||||
return <details className="native-settings"><summary>{tr("Native engine settings")}</summary>{tr(tuned?.changed?.length ? <div className="native-tuned"><p className="small"><strong>{tr("Your tuning '{0}' sets", [tuned.preset?.name ?? ''])}</strong></p><ul>{tuned.changed.map(c => { const d = describeChange(c); return <li key={c.flag}><span>{d.name}</span><b>{d.now || tr('off')}</b>{d.was !== null ? <small className="muted">{tr("was {0}", [d.was])}</small> : null}</li>; })}</ul></div> : null)}<p className="small muted">{tr(!original ? 'Reading saved settings… ' : '')}{tr("Settings for this model. Blank values use Strata\u2019s defaults.")}</p><div className="editor-tabs" role="tablist" aria-label={tr("Native settings editor")}>{tr(['fields', 'json', 'tools'].map(t => <button key={t} role="tab" aria-selected={tab === t} onClick={() => chooseTab(t)}>{tr(t === 'fields' ? 'Parameters' : t === 'json' ? 'JSON' : 'MCP tools')}</button>))}</div>
|
||||
{tr(tab === 'fields' ? <><input className="st-input" type="search" aria-label={tr("Search native parameters")} placeholder={tr("Search parameters…")} value={query} onChange={e => setQuery(e.target.value)}/>{tr(['Responses', 'GPU & memory', 'Serving', 'Image reading', 'Tools', 'Recovery'].map(group => rows.some(f => f.group === group) ? <section className="native-settings-group" key={group}><h3 className="h4">{tr(group)}</h3>{tr(rows.filter(f => f.group === group).map(f => <label className="native-setting-row" key={f.id}><span><strong>{tr(f.label)}</strong>{tr(f.supported === false ? <small>{tr("Requires a newer Strata installation.")}</small> : f.hint ? <small>{tr(f.hint)}</small> : null)}</span><NativeFieldInput field={f} value={values[f.id]} onChange={v => change(f.id, v)}/></label>))}</section> : null))}<section className="native-settings-group"><h3 className="h4">{tr("Sampling")}</h3>{tr([['temperature', 'Temperature'], ['top_p', 'Top-p'], ['top_k', 'Top-k'], ['min_p', 'Min-p'], ['repetition_penalty', 'Repetition penalty'], ['presence_penalty', 'Presence penalty'], ['frequency_penalty', 'Frequency penalty'], ['penalty_last_n', 'Penalty window'], ['seed', 'Seed']].map(([id, label]) => <label className="native-setting-row" key={id}><span><strong>{tr(label)}</strong></span><input className="st-input" aria-label={tr("Native {0}", [label])} inputMode="decimal" value={values.sampling?.[id] ?? ''} onChange={e => {
|
||||
const sampling = { ...values.sampling };
|
||||
if (e.target.value === '')
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { tr } from '../lib/i18n';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { Btn, Dialog, Icon, Select } from './ui';
|
||||
import { TuneRunView, TuneResultView } from './TuneRunView';
|
||||
import { Btn, Dialog, Select } from './ui';
|
||||
import { TuneRunView, TuneOutcomeCard } from './TuneRunView';
|
||||
import { readOutcome } from '../lib/tune-outcome';
|
||||
import { go } from '../lib/store';
|
||||
import { nativeAction, useNative, type NativeJob } from '../lib/native';
|
||||
import { answerNotice, tunePresetAction, tuneStatus, tuneUndo, type TuneProgress, type TunePreset, type TuneResult, type TuneStatus } from '../lib/native-tune';
|
||||
|
||||
@@ -53,7 +55,6 @@ export function NativeTune({ open, onClose, model, resourceProfile, vision }: {
|
||||
|
||||
const progress = job?.progress as TuneProgress | undefined;
|
||||
const result = job?.state === 'done' ? (job.result as TuneResult | null) : null;
|
||||
const stopped = job?.state === 'cancelled';
|
||||
const ratio = progress && progress.runsPlanned ? Math.min(0.96, progress.runsDone / progress.runsPlanned) : 0;
|
||||
const active = status?.active ?? null;
|
||||
|
||||
@@ -64,14 +65,15 @@ export function NativeTune({ open, onClose, model, resourceProfile, vision }: {
|
||||
body = <TuneRunView progress={progress} ratio={ratio} saving={false}/>;
|
||||
actions = <><Btn onClick={() => void act(() => nativeAction(`operations/${job!.id}/cancel`))} disabled={busy}>{tr("Stop")}</Btn></>;
|
||||
} else if (phase === 'result') {
|
||||
const improved = result?.outcome === 'improved' || result?.verdict === 'keep';
|
||||
const text = stopped ? tr("Stopped. Your settings were not changed.") : job?.state === 'error' ? tr("The tune did not finish. Your settings were not changed.") : result?.verdict ? (result.verdict === 'keep' ? tr("Still as fast as when it was saved.") : result.verdict === 'retune' ? tr("It is slower than before. You can tune again.") : tr("Could not tell right now. Your tuning was kept.")) : result?.outcome === 'improved' ? tr("+{0}% faster answers, saved as '{1}'", [Math.max(0, Math.round(result.gain_pct ?? 0)), result.preset?.name ?? '']) : result?.code === 'busy_pc' ? tr("Your PC was busy, so the measurements were not reliable. Nothing was changed. Try again when it is quiet.") : result?.outcome === 'default_confirmed' ? tr("Your current settings are already the fastest we found.") : (result?.message ?? tr("Nothing was changed."));
|
||||
const good = improved || result?.outcome === 'default_confirmed';
|
||||
body = result?.outcome === 'improved' ? <div className="stack"><TuneResultView result={result} saved={result.preset?.name ?? null}/>{notice(result.answers?.class, result.answers?.default_repeatable)}</div> : <div className="tune-progress"><div className="tune-orbit" data-complete={good}><svg viewBox="0 0 120 120" aria-hidden="true"><circle cx="60" cy="60" r="50"/><circle cx="60" cy="60" r="50" pathLength="100" strokeDasharray={`${good ? 100 : 4} 100`}/></svg><Icon name={good ? 'check' : 'gauge'} size={42}/></div><h3 role="status">{text}</h3>
|
||||
{result?.outcome === 'default_confirmed' && result.preset ? <p className="small muted">{tr("Saved as '{0}', so it is not tuned again when you reopen the app.", [result.preset.name])}</p> : null}
|
||||
|
||||
{job?.state === 'error' ? <p className="small inline-error" role="alert">{job.error}</p> : null}</div>;
|
||||
actions = <>{status?.can_undo && result?.outcome === 'improved' ? <Btn disabled={busy} onClick={() => void act(async () => { await tuneUndo(model, resourceProfile, vision); setJobId(''); })}>{tr("Undo")}</Btn> : null}<Btn variant="primary" onClick={close}>{tr("Close")}</Btn></>;
|
||||
const outcome = readOutcome(result, job?.state);
|
||||
const ok = outcome.tone === 'ok';
|
||||
body = <div className="stack"><TuneOutcomeCard outcome={outcome} details={job?.state === 'error' ? (job.details || job.error) : null}/>{outcome.code === 'faster' ? notice(result?.answers?.class, result?.answers?.default_repeatable) : null}</div>;
|
||||
const again = <Btn variant={ok ? undefined : 'primary'} disabled={busy || !!other} onClick={() => void start('autotune')}>{tr(outcome.code === 'faster' || outcome.code === 'already_fastest' || outcome.code === 'still_fast' ? 'Tune again' : 'Try again')}</Btn>;
|
||||
actions = <>
|
||||
{status?.can_undo && outcome.code === 'faster' ? <Btn disabled={busy} onClick={() => void act(async () => { await tuneUndo(model, resourceProfile, vision); setJobId(''); })}>{tr("Undo")}</Btn> : null}
|
||||
<span className="tune-actions-gap"/>
|
||||
{ok ? <>{again}<Btn variant="primary" onClick={() => { close(); go('chat'); }}>{tr(outcome.code === 'faster' ? 'Start chatting' : 'Close')}</Btn></> : <><Btn onClick={close}>{tr("Close")}</Btn>{again}</>}
|
||||
</>;
|
||||
} else {
|
||||
const stale = active && status?.state && status.state !== 'fresh';
|
||||
body = <div className="stack">
|
||||
@@ -100,5 +102,5 @@ export function NativeTune({ open, onClose, model, resourceProfile, vision }: {
|
||||
{active && status?.state === 'soft' ? <Btn disabled={busy || !!other} onClick={() => void start('recheck')}>{tr("Check again")}</Btn> : null}
|
||||
<Btn variant="primary" icon="gauge" disabled={busy || !!other || !status} onClick={() => void start('autotune')}>{tr(active ? "Tune again" : "Start tuning")}</Btn></>;
|
||||
}
|
||||
return <Dialog open={open} wide={phase !== 'idle'} title={phase === 'result' && result?.outcome === 'improved' ? tr("Tuned and saved") : tr("Tune this model")} onClose={close} actions={actions}>{body}</Dialog>;
|
||||
return <Dialog open={open} wide={phase !== 'idle'} title={phase === 'result' && readOutcome(result, job?.state).code === 'faster' ? tr("Tuned and saved") : tr("Tune this model")} onClose={close} actions={actions}>{body}</Dialog>;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { tr } from '../lib/i18n';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { Btn } from './ui';
|
||||
import { Btn, Icon } from './ui';
|
||||
import { answerNotice, tunePresetAction, tuneOff, tuneStatus, type TuneStatus } from '../lib/native-tune';
|
||||
import { useNative } from '../lib/native';
|
||||
|
||||
@@ -26,12 +26,12 @@ export function NativeTuneBadge({ model, resourceProfile, vision }: { model: str
|
||||
}
|
||||
if (!status || (!status.active && !status.last_active)) return null;
|
||||
const active = status.active;
|
||||
return <p className="small muted" data-tuning-active={!!active} role="status">
|
||||
return <p className="native-tune-line" data-tuning-active={!!active} role="status"><Icon name="gauge" size={15}/><span>
|
||||
{active ? <>{tr("Using your tuning '{0}'", [active.name])}{status.state === 'hard' ? <> {'·'} {tr("This PC changed since it was tuned, so these settings are not used until you tune again.")}</> : null}
|
||||
{active.answers && active.answers.class !== 'exact' ? <> {'·'} {tr(answerNotice(active.answers.class, active.answers.default_repeatable))}</> : null}{' '}
|
||||
<Btn size="sm" variant="ghost" disabled={busy} onClick={() => void flip(() => tuneOff(model, resourceProfile, vision))}>{tr("Switch off")}</Btn></>
|
||||
: <>{tr("Your tuning is off. The standard settings are used.")}{' '}
|
||||
<Btn size="sm" variant="ghost" disabled={busy} onClick={() => void flip(() => tunePresetAction(status.last_active!.id, 'apply'))}>{tr("Switch on")}</Btn></>}
|
||||
{error ? <span className="inline-error" role="alert"> {error}</span> : null}
|
||||
</p>;
|
||||
</span></p>;
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import { tr } from '../lib/i18n';
|
||||
import { Icon, type IconName } from './ui';
|
||||
import type { TuneProgress, TuneResult } from '../lib/native-tune';
|
||||
import type { TuneProgress } from '../lib/native-tune';
|
||||
import type { Outcome } from '../lib/tune-outcome';
|
||||
import { tokS } from '../lib/tune-outcome';
|
||||
import { tunePhase, tuneSpeeds } from '../lib/tune-phase';
|
||||
|
||||
const STEPS: { icon: IconName; title: string; running: string }[] = [
|
||||
@@ -56,18 +58,39 @@ export function TuneRunView({ progress, ratio, saving }: { progress: TuneProgres
|
||||
</div>;
|
||||
}
|
||||
|
||||
/** The result: the gain large, before and after, and what it was saved as. */
|
||||
export function TuneResultView({ result, saved }: { result: TuneResult; saved: string | null }) {
|
||||
const before = result.base?.decode_tok_s ?? 0, after = result.chosen?.decode_tok_s ?? 0;
|
||||
const gain = result.gain_pct ?? (before ? ((after / before) - 1) * 100 : 0);
|
||||
const top = Math.max(before, after, 1);
|
||||
return <div className="tune-result">
|
||||
<div className="tune-hero"><span className="label">{tr("Faster answers")}</span><div className="tune-hero__big">+{Math.round(gain)}%</div>
|
||||
<p className="small muted">{tr("{0} to {1} tokens per second", [fmt(before), fmt(after)])}</p></div>
|
||||
<div className="tune-compare">
|
||||
<div><span className="small muted">{tr("Before")}</span><div className="tune-compare__bar"><i style={{ width: `${(before / top) * 100}%` }}/></div><b>{fmt(before)}</b></div>
|
||||
<div data-new="true"><span className="small">{tr("After")}</span><div className="tune-compare__bar"><i style={{ width: `${(after / top) * 100}%` }}/></div><b>{fmt(after)}</b></div>
|
||||
{saved ? <p className="small muted">{tr("Saved as {0}. It is used every time you load this model.", [saved])}</p> : null}
|
||||
/**
|
||||
* The result of a tune, in one layout whatever happened: a round tile (green, amber, red or quiet), a headline, one sentence, up to three facts.
|
||||
* The buttons are the dialog's footer.
|
||||
*/
|
||||
export function TuneOutcomeCard({ outcome, details }: { outcome: Outcome; details?: string | null }) {
|
||||
const o = outcome;
|
||||
const headline = ({
|
||||
faster: o.gainPct != null ? tr('{0}% faster', [Math.round(o.gainPct)]) : tr('Faster answers'),
|
||||
already_fastest: tr('Already the fastest'), still_fast: tr('Still as fast as before'), slower: tr('Slower than before'),
|
||||
busy_pc: tr("Couldn't measure reliably"), unsure: tr("Couldn't tell right now"), failed: tr("Tuning didn't finish"), stopped: tr('Stopped'),
|
||||
} as Record<string, string>)[o.code];
|
||||
const lead = ({
|
||||
faster: tr('Your answers now arrive sooner. Quality is the same.'),
|
||||
already_fastest: tr('Nothing we tried beat your current settings, so nothing was changed.'),
|
||||
still_fast: tr('Your saved tuning is still working as well as when it was saved.'),
|
||||
slower: tr('It is slower than before. You can tune again.'),
|
||||
unsure: tr('Your tuning was kept. Try the check again later.'),
|
||||
busy_pc: o.reason === 'not_tried' ? tr('Your PC was too busy to try other settings, so nothing was changed. Try again when other programs are closed.') : tr("Your PC was busy during the test, so we couldn't measure reliably. Nothing was changed. Try again when other programs are closed."),
|
||||
failed: o.reason === 'no_memory' ? tr("There wasn't enough free memory to test. Nothing was changed. Close other programs and try again.") : o.reason === 'start_failed' ? tr('The engine could not start with these settings. Nothing was changed.') : tr('The engine stopped while we were measuring. Nothing was changed.'),
|
||||
stopped: tr('Nothing was changed.'),
|
||||
} as Record<string, string>)[o.code];
|
||||
const facts: [string, string][] = [];
|
||||
if (o.code === 'faster') { facts.push([tr('Before'), `${tokS(o.baseTokS)} ${tr('tok/s')}`], [tr('After'), `${tokS(o.tunedTokS)} ${tr('tok/s')}`]); if (o.presetName) facts.push([tr('Saved as'), o.presetName]); }
|
||||
else if (o.code === 'already_fastest' || o.code === 'still_fast') { facts.push([tr('Speed'), `${tokS(o.baseTokS)} ${tr('tok/s')}`]); if (o.minutes != null) facts.push([tr('Took'), tr('{0} min', [Math.max(1, Math.round(o.minutes))])]); if (o.presetName) facts.push([tr('Saved as'), o.presetName]); }
|
||||
else if (o.code === 'busy_pc') { facts.push([tr('Speed'), o.baseTokS != null ? `${tokS(o.baseTokS)} ${tr('tok/s')}` : '—']); if (o.noisePct != null) facts.push([tr('Variation'), `${Math.round(o.noisePct)}%`]); facts.push([tr('Changed'), tr('Nothing')]); }
|
||||
else if (o.code === 'failed' || o.code === 'stopped' || o.code === 'unsure' || o.code === 'slower') facts.push([tr('Changed'), tr('Nothing')]);
|
||||
return <div className="tune-outcome" data-tone={o.tone} data-code={o.code}>
|
||||
<div className="tune-outcome__tile" aria-hidden="true"><Icon name={o.icon} size={34}/></div>
|
||||
<div className="tune-outcome__body" role="status">
|
||||
<h3>{headline}</h3>
|
||||
<p>{lead}</p>
|
||||
{facts.length ? <dl className="tune-outcome__facts">{facts.map(([k, v]) => <div key={k}><dt>{k}</dt><dd>{v}</dd></div>)}</dl> : null}
|
||||
{details ? <details className="tune-outcome__details"><summary>{tr('Details')}</summary><pre>{details}</pre></details> : null}
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import type { TuneResult } from './native-tune';
|
||||
|
||||
/**
|
||||
* One layout for every way a tune can end: a tone (the round tile's colour and icon), a headline, one plain sentence, up to three facts, and
|
||||
* the buttons that make sense. The host says which outcome it was (`code`, `reason_code`, `values`, see strata_control/autotune.py); older
|
||||
* answers without a code are read from `outcome` and `verdict`. All words go through the catalog in the component, not here.
|
||||
*/
|
||||
export type OutcomeCode = 'faster' | 'already_fastest' | 'busy_pc' | 'failed' | 'stopped' | 'still_fast' | 'slower' | 'unsure';
|
||||
export type Tone = 'ok' | 'warn' | 'bad' | 'neutral';
|
||||
|
||||
export interface Outcome {
|
||||
code: OutcomeCode;
|
||||
tone: Tone;
|
||||
icon: 'check' | 'clock' | 'x' | 'stop';
|
||||
/** the reason within the outcome (busy_pc: noisy | drift | not_tried; failed: start_failed | no_memory | other) */
|
||||
reason: string;
|
||||
gainPct: number | null;
|
||||
baseTokS: number | null;
|
||||
tunedTokS: number | null;
|
||||
noisePct: number | null;
|
||||
minutes: number | null;
|
||||
presetName: string | null;
|
||||
/** the person can try again straight away (nothing is running) */
|
||||
retry: boolean;
|
||||
}
|
||||
|
||||
const num = (v: unknown): number | null => (typeof v === 'number' && Number.isFinite(v) ? v : null);
|
||||
|
||||
export function readOutcome(result: TuneResult | null | undefined, jobState: 'done' | 'error' | 'cancelled' | 'running' | undefined): Outcome {
|
||||
const v = result?.values ?? {};
|
||||
const facts = {
|
||||
gainPct: num(v.gain_pct) ?? num(result?.gain_pct),
|
||||
baseTokS: num(v.base_tok_s) ?? num(result?.base?.decode_tok_s),
|
||||
tunedTokS: num(v.tuned_tok_s) ?? num(result?.chosen?.decode_tok_s),
|
||||
noisePct: num(v.noise_pct), minutes: num(v.minutes),
|
||||
presetName: v.preset_name ?? result?.preset?.name ?? null,
|
||||
};
|
||||
const make = (code: OutcomeCode, tone: Tone, icon: Outcome['icon'], reason = '', retry = true): Outcome => ({ code, tone, icon, reason, retry, ...facts });
|
||||
if (jobState === 'cancelled') return make('stopped', 'neutral', 'stop');
|
||||
if (jobState === 'error' && !result) return make('failed', 'bad', 'x', 'other');
|
||||
const code = result?.code;
|
||||
if (code === 'faster') return make('faster', 'ok', 'check');
|
||||
if (code === 'already_fastest') return make('already_fastest', 'ok', 'check');
|
||||
if (code === 'busy_pc') return make('busy_pc', 'warn', 'clock', result?.reason_code ?? 'noisy');
|
||||
if (code === 'failed') return make('failed', 'bad', 'x', result?.reason_code ?? 'other');
|
||||
if (code === 'stopped') return make('stopped', 'neutral', 'stop');
|
||||
// answers from a check of a saved tuning
|
||||
if (result?.verdict === 'keep') return make('still_fast', 'ok', 'check');
|
||||
if (result?.verdict === 'retune') return make('slower', 'warn', 'clock');
|
||||
if (result?.verdict === 'inconclusive') return make('unsure', 'warn', 'clock');
|
||||
// answers without a code (an older Control)
|
||||
switch (result?.outcome) {
|
||||
case 'improved': return make('faster', 'ok', 'check');
|
||||
case 'default_confirmed': return make('already_fastest', 'ok', 'check');
|
||||
case 'inconclusive': return make('busy_pc', 'warn', 'clock', 'noisy');
|
||||
case 'cancelled': return make('stopped', 'neutral', 'stop');
|
||||
case 'base_failed': return make('failed', 'bad', 'x', 'other');
|
||||
default: return make(jobState === 'error' ? 'failed' : 'unsure', jobState === 'error' ? 'bad' : 'warn', jobState === 'error' ? 'x' : 'clock', jobState === 'error' ? 'other' : '');
|
||||
}
|
||||
}
|
||||
|
||||
export const tokS = (n: number | null): string => (n == null ? '—' : `${(Math.round(n * 10) / 10).toFixed(1)}`);
|
||||
@@ -0,0 +1,19 @@
|
||||
/** What a saved tuning changes in the engine's start-up flags (GET /api/native/models/<id>/settings -> tuned.changed), as the Expert mode fields show it. */
|
||||
export interface TunedChange { flag: string; was: string | null; now: string | null }
|
||||
export interface TunedFields { kv?: string; lowRam?: 'auto' | 'resident' | 'mmap'; vramReserveMib?: number }
|
||||
|
||||
export function tunedFields(changed: TunedChange[] | undefined | null): TunedFields {
|
||||
const out: TunedFields = {};
|
||||
for (const c of changed ?? []) {
|
||||
if (c.flag === '--kv' && c.now) out.kv = c.now;
|
||||
else if (c.flag === '--resident-experts') out.lowRam = c.now !== null ? 'resident' : c.was !== null ? 'auto' : out.lowRam;
|
||||
else if (c.flag === '--mmap-experts') out.lowRam = c.now !== null ? 'mmap' : c.was !== null ? 'auto' : out.lowRam;
|
||||
else if (c.flag === '--vram-reserve-mib' && c.now !== null && Number.isFinite(Number(c.now))) out.vramReserveMib = Number(c.now);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** "--spec 6 (was 4)" for the list of what the tuning changed. */
|
||||
export function describeChange(c: TunedChange): { name: string; now: string; was: string | null } {
|
||||
return { name: c.flag.replace(/^--/, '').replace(/-/g, ' '), now: c.now ?? '', was: c.was };
|
||||
}
|
||||
@@ -7086,7 +7086,8 @@ textarea {
|
||||
.tune-step[data-s="done"]:not(:last-child)::after { background: var(--st-accent); }
|
||||
.tune-step__badge { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--st-surface-2); border: 1px solid var(--st-line); color: var(--st-ink-muted); position: relative; }
|
||||
.tune-step[data-s="run"] .tune-step__badge { background: var(--st-accent-tint); color: var(--st-accent-text); border-color: var(--st-accent); }
|
||||
.tune-step[data-s="run"] .tune-step__badge::before { content: ""; position: absolute; inset: -5px; border-radius: 18px; border: 2px solid transparent; border-top-color: var(--st-accent); animation: tune-spin 1.1s linear infinite; }
|
||||
.tune-step[data-s="run"] .tune-step__badge { animation: tune-glow 1.8s ease-out infinite; }
|
||||
.tune-step[data-s="run"] .tune-step__state::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; animation: tune-beep 1.1s ease-in-out infinite; }
|
||||
.tune-step[data-s="done"] .tune-step__badge { background: var(--st-accent); color: var(--st-accent-ink); border-color: transparent; animation: tune-pop 260ms var(--st-ease); }
|
||||
.tune-step__text { display: flex; flex-direction: column; min-width: 0; }
|
||||
.tune-step__text small { color: var(--st-ink-muted); font-size: var(--st-fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
@@ -7123,14 +7124,15 @@ textarea {
|
||||
.tune-compare__bar i { display: block; height: 100%; border-radius: 9px; background: var(--st-ink-muted); transition: width 700ms var(--st-ease); }
|
||||
.tune-compare > div[data-new] .tune-compare__bar i { background: var(--st-accent); }
|
||||
.tune-compare p { margin: 4px 0 0; grid-column: 1 / -1; }
|
||||
@keyframes tune-spin { to { transform: rotate(360deg); } }
|
||||
@keyframes tune-glow { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--st-accent) 45%, transparent); } 70%, 100% { box-shadow: 0 0 0 11px transparent; } }
|
||||
@keyframes tune-beep { 0%, 100% { opacity: .25; transform: scale(.7); } 40% { opacity: 1; transform: scale(1); } }
|
||||
@keyframes tune-pop { 0% { transform: scale(.7); opacity: .4; } 100% { transform: scale(1); opacity: 1; } }
|
||||
@keyframes tune-sweep { from { transform: rotate(-16deg); } to { transform: rotate(16deg); } }
|
||||
@keyframes tune-slide { from { transform: translateX(-2px); } to { transform: translateX(2px); } }
|
||||
@keyframes tune-breathe { 50% { transform: scale(1.12); } }
|
||||
@media (max-width: 720px) { .tune-run, .tune-result { grid-template-columns: 1fr; } .tune-live { border-left: 0; border-top: 1px solid var(--st-line); border-radius: 0 0 var(--st-r-md) var(--st-r-md); margin-top: 8px; } }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.tune-step[data-s="run"] .tune-step__badge::before, .tune-step[data-s="run"] .tune-step__badge svg, .tune-step[data-s="done"] .tune-step__badge, .tune-hero__big { animation: none !important; }
|
||||
.tune-step[data-s="run"] .tune-step__badge, .tune-step[data-s="run"] .tune-step__state::before, .tune-step[data-s="run"] .tune-step__badge svg, .tune-step[data-s="done"] .tune-step__badge, .tune-hero__big { animation: none !important; }
|
||||
.tune-live__bar i, .tune-compare__bar i { transition: none; }
|
||||
}
|
||||
|
||||
@@ -7273,3 +7275,51 @@ textarea {
|
||||
.task-answer ul, .task-answer ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
|
||||
.task-answer pre { max-height: 260px; overflow: auto; }
|
||||
.task-answer table { font-size: var(--st-fs-sm); }
|
||||
|
||||
/* ---- Tune model: one result card for every outcome ---- */
|
||||
.tune-outcome { display: grid; grid-template-columns: 92px 1fr; gap: 22px; align-items: start; padding: 4px 4px 8px; }
|
||||
.tune-outcome__tile { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: var(--st-accent-tint); color: var(--st-accent-text); position: relative; animation: tune-pop 360ms var(--st-ease); }
|
||||
.tune-outcome__tile::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--st-accent); opacity: .25; }
|
||||
.tune-outcome[data-tone="warn"] .tune-outcome__tile { background: var(--st-warn-tint); color: var(--st-warn-text); } .tune-outcome[data-tone="warn"] .tune-outcome__tile::before { border-color: var(--st-warn); }
|
||||
.tune-outcome[data-tone="bad"] .tune-outcome__tile { background: var(--st-danger-tint); color: var(--st-danger-text); } .tune-outcome[data-tone="bad"] .tune-outcome__tile::before { border-color: var(--st-danger); }
|
||||
.tune-outcome[data-tone="neutral"] .tune-outcome__tile { background: var(--st-surface-2); color: var(--st-ink-muted); } .tune-outcome[data-tone="neutral"] .tune-outcome__tile::before { border-color: var(--st-line); }
|
||||
.tune-outcome__body h3 { margin: 4px 0 4px; font-size: var(--st-fs-xl); letter-spacing: -.02em; }
|
||||
.tune-outcome__body p { margin: 0 0 14px; color: var(--st-ink-soft); }
|
||||
.tune-outcome__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin: 0; border: 1px solid var(--st-line); border-radius: var(--st-r-md); overflow: hidden; }
|
||||
.tune-outcome__facts > div { padding: 10px 14px; border-left: 1px solid var(--st-line-soft); min-width: 0; }
|
||||
.tune-outcome__facts > div:first-child { border-left: 0; }
|
||||
.tune-outcome__facts dt { font-size: var(--st-fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--st-ink-muted); }
|
||||
.tune-outcome__facts dd { margin: 2px 0 0; font-weight: 700; font-size: var(--st-fs-md); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.tune-outcome[data-code="faster"] .tune-outcome__facts > div:nth-child(2) dd { color: var(--st-accent-text); }
|
||||
.tune-outcome__details { margin-top: 10px; font-size: var(--st-fs-sm); color: var(--st-ink-muted); }
|
||||
.tune-outcome__details summary { cursor: pointer; }
|
||||
.tune-outcome__details pre { max-height: 120px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; font-size: 12px; }
|
||||
.tune-actions-gap { flex: 1; }
|
||||
@media (max-width: 560px) { .tune-outcome { grid-template-columns: 1fr; } }
|
||||
@media (prefers-reduced-motion: reduce) { .tune-outcome__tile { animation: none; } }
|
||||
|
||||
/* ---- Models: the family switch, one-view layout, the tuning line ---- */
|
||||
.family-switch { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--st-line); border-radius: var(--st-r-md); background: var(--st-surface-2); }
|
||||
.family-switch button { border: 0; background: transparent; padding: 7px 14px; border-radius: 11px; font: 600 var(--st-fs-sm)/1 var(--st-font); color: var(--st-ink-muted); cursor: pointer; white-space: nowrap; }
|
||||
.family-switch button[aria-selected="true"] { background: var(--st-surface); color: var(--st-ink); box-shadow: var(--st-sh-card); }
|
||||
.family-switch--single { padding: 7px 14px; font-weight: 700; border-color: transparent; background: transparent; }
|
||||
.native-model-layout--fit { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
|
||||
.native-model-layout--fit > .stack, .native-model-layout--fit > aside { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
|
||||
.native-choice__head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
|
||||
.native-choice__label { font-size: var(--st-fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--st-ink-muted); }
|
||||
.native-choice__tools { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
|
||||
.native-choice__row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 14px; margin-top: 14px; align-items: start; }
|
||||
.native-choice__col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
|
||||
.native-choice__col .native-resource-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
|
||||
.native-choice__col .native-resource-choice button { min-height: 42px; padding: 6px 10px; }
|
||||
.native-choice__col .native-resource-choice small { display: none; }
|
||||
.native-version { margin-bottom: 4px; }
|
||||
.native-about { margin: 8px 0 0; }
|
||||
.native-tune-line { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; font-size: var(--st-fs-sm); color: var(--st-ink-muted); }
|
||||
.native-tune-line > svg { flex: none; color: var(--st-icon); }
|
||||
.native-tune-line .st-btn { height: auto; padding: 0 4px; color: var(--st-accent-text); background: transparent; font-weight: 700; }
|
||||
.native-tuned { margin: 8px 0 10px; padding: 10px 12px; border: 1px solid var(--st-line); border-radius: var(--st-r-md); background: var(--st-surface-2); }
|
||||
.native-tuned ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; font-size: var(--st-fs-sm); }
|
||||
.native-tuned li { display: flex; gap: 8px; align-items: baseline; }
|
||||
.native-tuned li span { color: var(--st-ink-muted); }
|
||||
@media (max-width: 980px) { .native-model-layout--fit { grid-template-columns: 1fr; } }
|
||||
@@ -0,0 +1,63 @@
|
||||
/** Items 11, 13 and 15: one result layout for every outcome, and the tuned values in Expert mode. */
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { build } from 'esbuild';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const src = f => fileURLToPath(new URL(`../src/${f}`, import.meta.url));
|
||||
async function load(file) {
|
||||
const result = await build({ entryPoints: [src(`lib/${file}`)], bundle: true, format: 'esm', platform: 'node', write: false, alias: { react: fileURLToPath(new URL('./helpers/react-stub.mjs', import.meta.url)) }, logLevel: 'silent', loader: { '.json': 'json' } });
|
||||
return import(`data:text/javascript;base64,${Buffer.from(result.outputFiles[0].text).toString('base64')}`);
|
||||
}
|
||||
globalThis.window ??= globalThis; globalThis.localStorage ??= { getItem: () => null, setItem: () => {} };
|
||||
globalThis.navigator ??= { language: 'en' };
|
||||
const { readOutcome, tokS } = await load('tune-outcome.ts');
|
||||
const { tunedFields, describeChange } = await load('tune-values.ts');
|
||||
|
||||
test('every outcome the host reports lands on one card with a tone, an icon and its reason', () => {
|
||||
const o = (result, state = 'done') => readOutcome(result, state);
|
||||
const faster = o({ code: 'faster', values: { gain_pct: 18.4, base_tok_s: 41.2, tuned_tok_s: 48.6, preset_name: 'Fast · 64K' } });
|
||||
assert.deepEqual([faster.code, faster.tone, faster.icon, faster.gainPct, faster.baseTokS, faster.tunedTokS, faster.presetName], ['faster', 'ok', 'check', 18.4, 41.2, 48.6, 'Fast · 64K']);
|
||||
assert.deepEqual([o({ code: 'already_fastest', values: { base_tok_s: 41.2, minutes: 12 } }).tone, o({ code: 'already_fastest' }).icon], ['ok', 'check']);
|
||||
const busy = o({ code: 'busy_pc', reason_code: 'noisy', values: { noise_pct: 14 } });
|
||||
assert.deepEqual([busy.code, busy.tone, busy.icon, busy.reason, busy.noisePct], ['busy_pc', 'warn', 'clock', 'noisy', 14]);
|
||||
assert.equal(o({ code: 'busy_pc', reason_code: 'not_tried' }).reason, 'not_tried');
|
||||
const failed = o({ code: 'failed', reason_code: 'no_memory' });
|
||||
assert.deepEqual([failed.code, failed.tone, failed.icon, failed.reason], ['failed', 'bad', 'x', 'no_memory']);
|
||||
assert.equal(o({ code: 'stopped' }).tone, 'neutral');
|
||||
assert.equal(o(null, 'cancelled').code, 'stopped');
|
||||
assert.equal(o(null, 'error').code, 'failed', 'a job that ended in an error is a failed tune');
|
||||
});
|
||||
|
||||
test('answers from a check of a saved tuning and from an older Control still get a card', () => {
|
||||
const o = (r, s = 'done') => readOutcome(r, s);
|
||||
assert.equal(o({ verdict: 'keep' }).code, 'still_fast'); assert.equal(o({ verdict: 'retune' }).code, 'slower'); assert.equal(o({ verdict: 'inconclusive' }).code, 'unsure');
|
||||
assert.equal(o({ outcome: 'improved', gain_pct: 12, base: { decode_tok_s: 40 }, chosen: { decode_tok_s: 45 } }).tunedTokS, 45);
|
||||
assert.equal(o({ outcome: 'default_confirmed' }).code, 'already_fastest'); assert.equal(o({ outcome: 'inconclusive' }).code, 'busy_pc'); assert.equal(o({ outcome: 'base_failed' }).code, 'failed');
|
||||
assert.equal(tokS(41.234), '41.2'); assert.equal(tokS(null), '—');
|
||||
});
|
||||
|
||||
test('the busy-PC card says it in plain words, in the same card as every other result, with Try again', async () => {
|
||||
const card = await readFile(src('components/TuneRunView.tsx'), 'utf8');
|
||||
assert.match(card, /Your PC was busy during the test, so we couldn't measure reliably\. Nothing was changed\. Try again when other programs are closed\./);
|
||||
const dialog = await readFile(src('components/NativeTune.tsx'), 'utf8');
|
||||
assert.match(dialog, /<TuneOutcomeCard outcome=\{outcome\}/); assert.match(dialog, /'Try again'/);
|
||||
assert.ok(!/tune-orbit/.test(dialog), 'no second, different-looking result screen');
|
||||
});
|
||||
|
||||
test('item 14: the running step glows and beeps instead of spinning a ring around a square icon', async () => {
|
||||
const css = await readFile(src('styles/app.css'), 'utf8');
|
||||
const run = css.slice(css.indexOf('.tune-step[data-s="run"] .tune-step__badge { animation: tune-glow'), css.indexOf('.tune-live {'));
|
||||
assert.match(run, /tune-glow/); assert.match(run, /tune-beep/);
|
||||
assert.ok(!/\.tune-step\[data-s="run"\] \.tune-step__badge::before/.test(css), 'the spinning ring is gone');
|
||||
assert.match(css, /prefers-reduced-motion: reduce\) \{[\s\S]*tune-step__state::before/, 'reduced motion switches the pulse off too');
|
||||
});
|
||||
|
||||
test('item 11: Expert mode shows the values the tuning set', () => {
|
||||
const f = tunedFields([{ flag: '--kv', was: 'int8', now: 'k8v4' }, { flag: '--resident-experts', was: null, now: '' }, { flag: '--vram-reserve-mib', was: '1536', now: '2048' }, { flag: '--spec', was: '4', now: '6' }]);
|
||||
assert.deepEqual(f, { kv: 'k8v4', lowRam: 'resident', vramReserveMib: 2048 });
|
||||
assert.deepEqual(tunedFields([{ flag: '--mmap-experts', was: '', now: null }]), { lowRam: 'auto' });
|
||||
assert.deepEqual(tunedFields(undefined), {});
|
||||
assert.deepEqual(describeChange({ flag: '--pool-workers', was: '6', now: '8' }), { name: 'pool workers', now: '8', was: '6' });
|
||||
});
|
||||
Reference in new issue
Block a user