113 static const std::pair<const char*, double> kScales[] = {
124 for (
const auto& entry : kScales) {
125 if (type == entry.first) {
126 scale = entry.second;
149 }
else if (gpu_layers == 0) {
184 est.
reason =
"partial offload: layer count is not knowable without "
185 "GGUF metadata, so the budget gate stays open";
193 const uint64_t kv =
static_cast<uint64_t
>(
196 est.
bytes = resident + kv
216 uint64_t available_bytes) {
220 if (!fixed.known || fixed.bytes >= available_bytes) {
224 const uint64_t kv_budget = available_bytes - fixed.bytes;
225 const uint64_t fits =
static_cast<uint64_t
>(
226 static_cast<double>(kv_budget) / per_token);
229 uint64_t chosen = fits < requested ? fits : requested;
230 chosen -= chosen % 512ull;
231 return static_cast<int>(chosen);
Activate model on GPU (WARM → ACTIVE).
FootprintEstimate estimate_vram_footprint(const FootprintInputs &in)
Estimate the VRAM a tier will occupy, or report that it cannot.
constexpr uint64_t kBaseKvPerTokenF16
KV bytes per token at f16, the rate the v2.2.4 estimate assumed.
constexpr int kAllLayersSentinel
gpu_layers at or above this means "every layer" (llama.cpp's 99).
double kv_scale_for_cache_type(const std::string &type)
Cost of a KV cache type relative to f16.
Offload classify_offload(int gpu_layers)
Classify a tier's offload request into a priceable placement.
double kv_bytes_per_token(const FootprintInputs &in)
Per-token KV cost in bytes for this tier's cache configuration.
int recommend_context_length(const FootprintInputs &in, uint64_t available_bytes)
Largest context length that fits, for the "won't fit" recommendation.
Offload
Where a tier's weights land, as far as the estimate can tell.
@ none
gpu_layers == 0: weights cost no VRAM.
@ partial_unknown
A layer count we cannot price without GGUF metadata.
@ full
-1 or >= 99: the whole file is resident.