Repository navigation
fix(studio): explain why quantized KV enlarges Inkling's compute buffer - #18849
Open
InfoSage05 wants to merge 9 commits into
Open
InfoSage05 wants to merge 9 commits into
InfoSage05 wants to merge 9 commits into
Conversation
…etuning example with WER/CER metrics Adds explicit model routing for PaddlePaddle/PaddleOCR-VL-1.6 in the unsloth registry (org=PaddlePaddle, base_name=PaddleOCR, multimodal), disables compile optimization for this trust_remote_code model in loader.py, and provides a comprehensive finetuning example with WER/CER OCR benchmark evaluation via jiwer.
Add PaddleOCR-VL-1.6 registry entry, loader routing, and finetuning example with WER/CER evaluation
For Inkling, a quantized KV cache turns off llama.cpp's banded attention and falls back to a dense relative-bias scratch buffer, so q8_0/q4_0 show a larger total than f16/bf16 even though the KV cache itself shrinks. The numbers are correct, but the UI never said why, and the KV Cache Dtype hint claimed quantizing saves VRAM. Expose compute_dense_fallback on the estimate-memory response, show it as a note on the Compute buffers line, and add an Inkling exception to the KV Cache Dtype hint. No estimate values change. Fixes unslothai#18833 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In Studio's memory estimate for Inkling, a quantized KV cache (q8_0/q4_0) shows a larger total than f16/bf16, even though the KV cache itself is smaller. The numbers are correct: quantized KV disables llama.cpp's banded relative-bias attention path, so the dense fallback needs a much larger compute scratch buffer. But the UI never said so, and the KV Cache Dtype hint claimed lower precision saves VRAM. This PR surfaces the reason; no estimate values change.
Classification: Bug (misleading UX), no behaviour change in the math.
Root Cause
The root cause is the dense relative-bias branch in
LlamaCppBackend._compute_buffer_ctx_bytes(studio/backend/core/inference/llama_cpp.py, Inkling and Inkling 2 branches) taken for any quantized KV cache, whose scratch (e.g. ~402 KiB/token on Inkling, ~99 KiB/token on Inkling 2 at ub=512) outweighs the KV savings, while the UI shows only the whole-model total with no explanation.Estimates for an Inkling 2 Mini-like config (MiB; KV / compute / total), 128k ctx, ub=512: f16 4336 / 1176 / 5512; q8_0 2304 / 12672 / 14976; q4_0 1220 / 12672 / 13892. This matches the measured llama.cpp buffers recorded in
tests/test_compute_buffer.py.Changes
studio/backend/core/inference/llama_cpp.py: new_quantized_kv_dense_bias_fallback()helper; Inkling v1 branch reuses it (behaviour-identical).studio/backend/routes/inference.py,core/inference/memory_contract.py,models/inference.py: carry a newcompute_dense_fallbackbool through the estimate-memory response (default False, so older clients and other architectures are unaffected).studio/frontend/.../memory-estimate.ts,memory-estimate-row.tsx: map the flag and show a note on the "Compute buffers" line.studio/frontend/.../model-config-page.tsx: the KV Cache Dtype hint now notes the Inkling exception.TestQuantizedKvDenseBiasFallbackintests/test_compute_buffer.py; flag present/absent/non-boolean cases intests/memory-estimate-skew.test.ts.Reproduction
Load an Inkling / Inkling 2 GGUF in Studio, open the memory estimate panel and switch KV Cache Dtype between f16 and q8_0: the Total/GPU figure rises sharply for q8_0.
Testing
Backend: 718 passed, 134 skipped. Two unrelated Windows symlink-privilege tests in
test_compute_buffer.pyfail identically without this change. Frontend skew test passes;memory-estimate-narrow-panel.test.tsfails on a missing dev dependency (@typescript/typescript6) with or without this change.ruffandtscwere not available locally and the.tsxnote was not rendered.Known limitation: for Inkling 2 the flag keys on cache type only; f16 can also go dense without flash attention or at tiny ubatch, which is not flagged.
Checklist
ruff check .) not run locallyFixes #18833