Expand description
Best-effort host physical-memory queries for proactive load pre-flight.
cera’s weight and KV-cache allocations are infallible (Vec::with_capacity
/ owned-buffer reads), so loading a model larger than available RAM aborts
the process rather than returning an error. A benchmark harness that runs
many models on constrained devices (e.g. Pipette on Android) uses these
helpers to estimate the fit and skip an over-large model before
loading, instead of crashing.
Best-effort by design: available_memory_bytes returns None on
platforms where it can’t query (currently everything except Linux/Android),
and the caller decides whether to proceed. Converting the abort itself into
a recoverable Err at the allocation site is deliberately out of scope —
that needs fallible allocation (try_reserve) threaded through the load path.
Functions§
- available_
memory_ bytes - Currently-available physical memory in bytes, or
Nonewhen it can’t be determined on this platform. - fits_
in_ available_ memory - Whether
required_bytesfits in currently-available physical memory leaving at leastheadroom_bytesfree.Nonewhen available memory can’t be queried (seeavailable_memory_bytes) — the caller then decides whether to proceed.