Skip to main content

compute_auto_cache_ram_mb

Function compute_auto_cache_ram_mb 

Source
pub const fn compute_auto_cache_ram_mb(
    total_ram_bytes: u64,
    model_bytes: u64,
    kv_bytes: u64,
) -> u64
Expand description

Compute the auto --cache-ram budget, in MiB.

budget = total_ram − model_weights − kv_bytes − HEADROOM
result = if budget < FLOOR { 0 } else { budget }

Claims all RAM safely available after weights, KV, and headroom — no fractional cap. Saturating throughout: a model larger than RAM yields 0 (cache disabled) rather than wrapping into a huge budget.

§Arguments

  • total_ram_bytes — total physical system RAM.
  • model_bytes — on-disk size of the model weights (all shards).
  • kv_bytes — estimated KV cache at the launch context size; pass CACHE_RAM_UNKNOWN_KV_ALLOWANCE_BYTES when unknown.