estimateLlmPeakRam

fun estimateLlmPeakRam(header: GgufModelHeader, options: LlmRamEstimateOptions = LlmRamEstimateOptions()): PeakRamEstimate(source)

Estimates the peak RAM needed to run the LLM described by header with llama.cpp.

  • weights: GgufModelHeader.tensorDataBytes;

  • KV cache: n_layer * n_ctx * n_head_kv * (key_length + value_length) * kvCacheElementBytes;

  • compute: logits (n_vocab * n_batch * 4), activations (n_embd * n_batch * 4 * 8), and without flash attention the attention scores (n_head * n_batch * n_ctx * 4, with n_batch capped at n_ctx);

  • overhead: 64 MiB.

Missing hyper-parameters (non-LLM GGUF files such as CLIP projectors or diffusion models) count as zero, so the estimate degrades to the weights plus overhead.

Throws

if a hyper-parameter is negative or the estimate overflows a Long (a corrupt header).