Color cookbook context fit notes

This commit is contained in:
pewdiepie-archdaemon
2026-06-27 21:02:10 +00:00
parent da7c6a667b
commit 7af3f15288
2 changed files with 33 additions and 3 deletions
+18 -3
View File
@@ -513,8 +513,10 @@ function _estimateLlamaContextFit(model, fields, modelCtxMax, modelWeightsGb = 0
} }
const raw = Math.floor(freeForKv / kvGbPerToken); const raw = Math.floor(freeForKv / kvGbPerToken);
const rounded = Math.max(1024, Math.floor(raw / 1024) * 1024); const rounded = Math.max(1024, Math.floor(raw / 1024) * 1024);
let ctx = Math.min(modelMax, rounded); const gpuEstimateCtx = Math.min(modelMax, rounded);
let ctx = gpuEstimateCtx;
let reasonSuffix = ''; let reasonSuffix = '';
let unifiedSpill = false;
if (isUnifiedMode) { if (isUnifiedMode) {
// Unified memory is not just "GPU math with a slightly bigger VRAM number". // Unified memory is not just "GPU math with a slightly bigger VRAM number".
// llama.cpp can spill into system RAM, so a conservative pure-VRAM KV // llama.cpp can spill into system RAM, so a conservative pure-VRAM KV
@@ -527,6 +529,7 @@ function _estimateLlamaContextFit(model, fields, modelCtxMax, modelWeightsGb = 0
const unifiedCtx = Math.min(modelMax, unifiedCap); const unifiedCtx = Math.min(modelMax, unifiedCap);
if (unifiedCtx > ctx) { if (unifiedCtx > ctx) {
ctx = unifiedCtx; ctx = unifiedCtx;
unifiedSpill = true;
reasonSuffix = '; unified can spill into system RAM, slower than pure GPU'; reasonSuffix = '; unified can spill into system RAM, slower than pure GPU';
} }
const gpuUsableGb = Math.max(1, totalVramGb - Math.max(1.0, selectedCount * 0.6)); const gpuUsableGb = Math.max(1, totalVramGb - Math.max(1.0, selectedCount * 0.6));
@@ -545,6 +548,8 @@ function _estimateLlamaContextFit(model, fields, modelCtxMax, modelWeightsGb = 0
ctx, ctx,
modelGb, modelGb,
kvGbPerToken, kvGbPerToken,
gpuEstimateCtx,
unifiedSpill,
reason: `~${ctx.toLocaleString()} tokens fits llama.cpp KV (${freeForKv.toFixed(1)}G free ${isUnifiedMode ? 'unified' : 'VRAM'}${reasonSuffix})`, reason: `~${ctx.toLocaleString()} tokens fits llama.cpp KV (${freeForKv.toFixed(1)}G free ${isUnifiedMode ? 'unified' : 'VRAM'}${reasonSuffix})`,
}; };
} }
@@ -1655,22 +1660,31 @@ function _rerenderCachedModels() {
const ggufGb = _selectedGgufSizeGb(m, f.gguf_file); const ggufGb = _selectedGgufSizeGb(m, f.gguf_file);
fit = _estimateLlamaContextFit(m, f, panel._modelCtxMax, ggufGb || panel._modelWeightsGb, panel._fitSystem, panel._contextProfileData); fit = _estimateLlamaContextFit(m, f, panel._modelCtxMax, ggufGb || panel._modelWeightsGb, panel._fitSystem, panel._contextProfileData);
} else { } else {
if (_ctxAutoNote) _ctxAutoNote.textContent = ''; if (_ctxAutoNote) {
_ctxAutoNote.textContent = '';
_ctxAutoNote.classList.remove('gpu-fit', 'unified-spill');
}
return; return;
} }
if (!fit) { if (!fit) {
if (_ctxAutoNote) _ctxAutoNote.textContent = ''; if (_ctxAutoNote) {
_ctxAutoNote.textContent = '';
_ctxAutoNote.classList.remove('gpu-fit', 'unified-spill');
}
return; return;
} }
if ((fit.needsHardwareScan || fit.needsModelSize) && !fit.ctx) { if ((fit.needsHardwareScan || fit.needsModelSize) && !fit.ctx) {
if (_ctxAutoNote) { if (_ctxAutoNote) {
_ctxAutoNote.textContent = fit.reason; _ctxAutoNote.textContent = fit.reason;
_ctxAutoNote.title = fit.reason; _ctxAutoNote.title = fit.reason;
_ctxAutoNote.classList.remove('gpu-fit', 'unified-spill');
} }
return; return;
} }
if (_ctxAutoNote) { if (_ctxAutoNote) {
_ctxAutoNote.textContent = `Auto ${fit.ctx.toLocaleString()} · ${fit.reason}`; _ctxAutoNote.textContent = `Auto ${fit.ctx.toLocaleString()} · ${fit.reason}`;
_ctxAutoNote.classList.toggle('gpu-fit', !!fit.ctx && !fit.unifiedSpill);
_ctxAutoNote.classList.toggle('unified-spill', !!fit.unifiedSpill);
const _llamaMemoryLabel = String(f.llama_mode || '').toLowerCase() === 'unified' || f.unified_mem const _llamaMemoryLabel = String(f.llama_mode || '').toLowerCase() === 'unified' || f.unified_mem
? 'unified system memory' ? 'unified system memory'
: 'selected GPU memory'; : 'selected GPU memory';
@@ -1713,6 +1727,7 @@ function _rerenderCachedModels() {
if (_ctxAutoNote && data?.model_probe_error && (!ctxMax || !weightsGb)) { if (_ctxAutoNote && data?.model_probe_error && (!ctxMax || !weightsGb)) {
_ctxAutoNote.textContent = data.model_probe_error; _ctxAutoNote.textContent = data.model_probe_error;
_ctxAutoNote.title = data.model_probe_error; _ctxAutoNote.title = data.model_probe_error;
_ctxAutoNote.classList.remove('gpu-fit', 'unified-spill');
} }
return { ctxMax, weightsGb, data }; return { ctxMax, weightsGb, data };
} }
+15
View File
@@ -20203,6 +20203,14 @@ body.gallery-selecting .gallery-dl-btn,
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.hwfit-auto-ctx-note.gpu-fit {
color: var(--green, var(--color-success, #50fa7b));
opacity: 0.82;
}
.hwfit-auto-ctx-note.unified-spill {
color: var(--yellow, var(--color-warning, #f0ad4e));
opacity: 0.9;
}
.hwfit-serve-row label select, .hwfit-serve-row label select,
.hwfit-serve-row label input { .hwfit-serve-row label input {
display: block; display: block;
@@ -24032,6 +24040,13 @@ details.hwfit-serve-advanced > .hwfit-serve-row {
gap: 4px; gap: 4px;
row-gap: 4px; row-gap: 4px;
} }
details.hwfit-serve-advanced > .hwfit-serve-row.hwfit-backend-llamacpp,
details.hwfit-serve-advanced > .hwfit-serve-checks.hwfit-backend-llamacpp {
margin-top: -4px;
}
details.hwfit-serve-advanced > .hwfit-serve-row.hwfit-vram-monitor {
gap: 4px !important;
}
details.hwfit-serve-advanced > .hwfit-serve-row label select, details.hwfit-serve-advanced > .hwfit-serve-row label select,
details.hwfit-serve-advanced > .hwfit-serve-row label input { details.hwfit-serve-advanced > .hwfit-serve-row label input {
margin-top: 1px; margin-top: 1px;