On first load, AirLLM decomposes the original model into per-layer shards on disk; subsequent runs stream directly from those shards. Sufficient disk space is required in the HuggingFace cache directory.[1] The air_llm/airllm/persist/ package exports only ModelPersister via its __init__.py, making it the sole public symbol of the persist subpackage.[2]
SafetensorModelPersister.persist_model in air_llm/airllm/persist/safetensor_model_persister.py writes the weight data first, then touches a .safetensors.done marker file to signal that the shard is complete and safe to load.[3] SafetensorModelPersister.model_persist_exist requires BOTH a .safetensors file and a .safetensors.done marker to exist before treating a layer shard as complete — a write-then-marker pattern that guards against partial writes.[3] MlxModelPersister.model_persist_exist in air_llm/airllm/persist/mlx_model_persister.py mirrors this contract: it checks for both a .mlx.npz weight file and a .mlx.done marker before treating the shard as complete.[4] MlxModelPersister.persist_model casts all tensors to float16 before saving them as NumPy .npz files — weights are not preserved in their original dtype on macOS.[4]
link_or_copy_file in air_llm/airllm/utils.py always resolves the source to its real path via os.path.realpath before linking, because HuggingFace cache files are stored as symlinks into a blob directory.[5] When creating a shard reference, link_or_copy_file tries a hard link first, then a symlink, then a full copy — hard links are preferred because they keep the data alive even if the original checkpoint file is later deleted, and cost no extra disk space.[5] This linking strategy has practical significance at scale: for Kimi K3's 1.56 TB checkpoint, a naive split would require 3.12 TB, but because K3's shards are pure single-module files, split layers are hard-linked to the originals instead of copied — see Kimi K3 for further detail.[6]
Sources