pub struct SpillCtx {
pub file_maps: Vec<Arc<Mmap>>,
pub files: Vec<Arc<File>>,
pub pinned_remaining: usize,
pub n_pinned: usize,
pub n_mmap: usize,
pub mmap_bytes: usize,
}Expand description
Shared load-time spill context (SPILLING-PLAN §2 step 4). Built ONCE per model load when the
disk tier is on, then handed by &mut to each HostExps::load so all layers/projections share
ONE file mmap PER SHARD and draw down a single running pinned-RAM budget. Greedy in load order:
pin until pinned_remaining is exhausted, then spill every later expert to Mmap.
Fields§
§file_maps: Vec<Arc<Mmap>>One MAP_SHARED mmap per physical GGUF shard, shared (Arc) across every spilled expert
block that lives in that shard. Index = TensorInfo::shard. Single-file models have len 1.
PER-SHARD, not one map: a split model’s tensor_file_range offsets are relative to the
OWNING shard’s file, so pairing them with shard 0’s mmap would read the wrong bytes (and
would index out of bounds for any shard larger than shard 0).
files: Vec<Arc<File>>The opened inodes backing file_maps, same indexing, retained for positioned expert reads.
pinned_remaining: usizePinned-RAM budget still available (bytes); decremented as experts are pinned.
n_pinned: usizeDiagnostics: how many experts landed pinned vs. mmap’d, and total disk-tier bytes.
n_mmap: usize§mmap_bytes: usizeImplementations§
Source§impl SpillCtx
impl SpillCtx
Sourcepub fn open(g: &GgufFile, budget: &MemBudget) -> Result<Self, Box<dyn Error>>
pub fn open(g: &GgufFile, budget: &MemBudget) -> Result<Self, Box<dyn Error>>
Clone each parsed shard’s opened inode, create a MAP_SHARED mmap per shard, and seed the
pinned budget from a live MemBudget probe.
The whole-map expert advice defaults to random (the historical behavior); setting
MEMRA_MOE_MMAP_ADVICE=normal restores ordinary Linux readahead. SPILLING-PLAN §1.