Module adapter

Module adapter 

Source
Expand description

Split a tensor name into (everything but its last numeric path segment, that segment as a number) so names sort NUMERICALLY on the index. embedders.2 must precede embedders.10; a plain lexicographic sort puts 10 first and silently mis-maps every table after the ninth. PEFT adapter loader: adapter_model.safetensorsWeightStore.

Not SafetensorsLoader because (a) that loader only probes model.safetensors* names (weights/loader.rs) and (b) WeightDtype::from_safetensors rejects F16 (weights.rs), the PEFT default save dtype. F16 is converted to BF16 on the host here so no F16 ever reaches a kernel or the WeightDtype whitelist.

NOTE: the device copies made here become garbage once the adapter is packed into the fixed-address LoRA pool and are never freed (no weight dealloc anywhere in Atlas). Accepted leak at adapter scale (~MBs).

Functions§

load_adapter_safetensors
Load a PEFT adapter’s adapter_model.safetensors from adapter_dir onto the GPU. Mirrors the single-file path of SafetensorsLoader (mmap → per-tensor alloc + copy_h2d → page-cache evict) with a host-side F16→BF16 conversion branch added.