Module caches

Module caches 

Source
Expand description

2026-10-02: The caches a circuit declares (StateKind::is_cache), sized: how many units each kind holds is a plan input (CacheInputs) the engine decides; the bytes of one unit are the declaration’s elements times its element size. A cache whose input is absent holds nothing; nothing here guesses a count.

Owner: metrale-circuit (memory). Invariants:

  • One unit rule per kind (units_of); every byte count but the prompt-lookup index is units x elements x element size.
  • The prompt-lookup index is a host hash table per sequence: its bytes follow the table’s growth law (hash_table_bytes), evaluated at the sequence’s history length.
  • A keyed format must be given (crate::state::StateInputs::formats); a missing key is an error, as in crate::state::StatePlan.

Structs§

CacheInputs
2026-10-02: How many units each cache kind holds; None or 0 for a cache the serve does not keep.
CacheTerm
2026-10-02: One sized cache declaration.
LookupInputs
2026-10-02: The prompt-lookup index of the sequences in flight.

Functions§

cache_terms
2026-10-02: Size every cache declaration of states under inputs; formats resolves keyed formats.
hash_table_bytes
2026-10-02: Bytes of a Rust HashMap (hashbrown) holding entries entries of entry_bytes each (a multiple of 16), as it grows by inserting them: buckets are the next power of two of entries * 8 / 7 (4 or 8 below 8 entries; hashbrown capacity_to_buckets), each bucket one entry plus one control byte, plus one 16-byte control group. 0 entries hold no allocation.
units_of
2026-10-02: The units inputs give a cache of kind; None for a non-cache kind, for the prompt-lookup index (not linear in its units) and on overflow.