Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions cmd/server/api/frontends/bui/src/components/VRAMCalculator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ export default function VRAMCalculator() {

const canResolve = provider.trim().length > 0 && family.trim().length > 0;

const handleClear = useCallback(() => {
setRepoFiles(null);
setError(null);
setResult(null);
setCalculatedModelLabel('');
setCalculatedModelId('');
setCalculatedModelUrl('');
cachedKeyRef.current = '';
}, []);

// runCalculate handles all of:
//
// - Model blank → browse files (show picker)
Expand All @@ -79,10 +89,7 @@ export default function VRAMCalculator() {
return;
}

setError(null);
setResult(null);
setRepoFiles(null);
cachedKeyRef.current = '';
handleClear();

// Model blank → browse the repo so the user can pick a file.
if (!m) {
Expand Down Expand Up @@ -165,7 +172,7 @@ export default function VRAMCalculator() {
}

await calculateOne(`${m}.gguf`);
}, [isResolving, loading, provider, family, model, controlsProps]);
}, [isResolving, loading, provider, family, model, controlsProps, handleClear]);

// calculateOne resolves a specific filename to the HF URL the
// calculateVRAM endpoint understands and stores the result. Split
Expand Down Expand Up @@ -197,8 +204,8 @@ export default function VRAMCalculator() {
return;
}

handleClear();
setLoading(true);
setError(null);

try {
const response = await api.calculateVRAM(
Expand All @@ -221,7 +228,7 @@ export default function VRAMCalculator() {
} finally {
setLoading(false);
}
}, [provider, family, controlsProps, result]);
}, [provider, family, controlsProps, result, handleClear]);

const handlePickFile = (filename: string) => {
setModel(modelIDFromFilename(filename));
Expand All @@ -247,16 +254,6 @@ export default function VRAMCalculator() {
}
};

const handleClear = () => {
setRepoFiles(null);
setError(null);
setResult(null);
setCalculatedModelLabel('');
setCalculatedModelId('');
setCalculatedModelUrl('');
cachedKeyRef.current = '';
};

const handleCalculateClick = () => {
void runCalculate();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,11 @@ export default function VRAMControls({
id={`vram-${variant}-moe-cache`}
type="number"
min="0"
step="0.25"
step="0.5"
value={(moeCacheSize ?? 0) / (1024 ** 3)}
onChange={(e) => onMoECacheSizeChange?.(Math.round(Math.max(0, Number(e.target.value)) * (1024 ** 3)))}
className={variant === 'compact' ? 'form-input' : 'playground-sweep-param-values'}
/>
<div style={{ fontSize: '11px', color: 'var(--color-gray-500)', marginTop: 2 }}>
0 = off. Additional memory; host expert weights remain.
</div>
</div>
);

Expand Down
15 changes: 12 additions & 3 deletions cmd/server/api/frontends/bui/src/components/vram/useVRAMState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,13 @@ export default function useVRAMState(opts: UseVRAMStateOptions = {}) {
const [autoFitError, setAutoFitError] = useState<string | null>(null);

useEffect(() => {
if (serverResponse) setLiveResponse(serverResponse);
setLiveResponse(serverResponse ?? null);
++latestRequestIdRef.current;
setRecomputing(false);
setAutoFitting(false);
setAutoFitError(null);
initialSeededRef.current = false;
if (!serverResponse) prevResponseRef.current = null;
}, [serverResponse]);

// Track the most recent request payload so we can ignore stale responses
Expand Down Expand Up @@ -337,7 +343,10 @@ export default function useVRAMState(opts: UseVRAMStateOptions = {}) {
}
}, RECOMPUTE_DEBOUNCE_MS);

return () => clearTimeout(handle);
return () => {
clearTimeout(handle);
++latestRequestIdRef.current;
};
// We intentionally do not depend on serverResponse here; that is handled
// by the seed effect.
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -413,7 +422,7 @@ export default function useVRAMState(opts: UseVRAMStateOptions = {}) {
]);

// ── Derived view ────────────────────────────────────────────────────────
const activeResponse = liveResponse ?? serverResponse ?? null;
const activeResponse = serverResponse === null ? null : liveResponse ?? serverResponse ?? null;
const vramInput = activeResponse?.input;
const hasSWA = (vramInput?.sliding_window ?? 0) > 0 && (vramInput?.sliding_window_layers ?? 0) > 0;
const isMoE = activeResponse?.moe?.is_moe === true && activeResponse?.weights != null;
Expand Down
Loading