A schematic of memory-mapped file access across sharded model weights.

Building a Safetensors Schema Validator and mmap-Backed Tensor Reader for Sharded Model Weights

This project demonstrates how to validate safetensors schemas and read sharded model weights using memory-mapped files, showing practical systems expertise.

September 10, 2026 · 8 min · 1701 words · martinuke0

Memory-Mapped Files (mmap): A Practical Guide to Faster I/O and Shared Memory

Introduction Memory-mapped files (mmap) let you treat file contents (or anonymous memory) as a region of your process’s virtual memory. Instead of calling read/write in loops, you map a file, then access it as if it were an in-memory buffer. The kernel transparently brings pages into RAM on demand and writes them back when needed. This can reduce system calls, enable zero-copy I/O, and open up powerful patterns like inter-process shared memory. ...

December 6, 2025 · 12 min · 2402 words · martinuke0
Feedback