Page-size check prevents mmap for blob-aligned checkpoints
- Lingua principale
- C++
- Stelle
- 7k
- Fork
- 660
- Merge medio
- 20h 43m
- PR unite (30g)
- 33
Descrizione
## Problem
`ChooseMode` disables mmap when the checkpoint size is not divisible by the system page size, even if the file is padded to the blob format's 256-byte alignment.
For example, the 4B checkpoint is 5,401,208,832 bytes: divisible by 256, but with a 2,048-byte remainder on a 4,096-byte page system. It therefore falls back to copying the weights into allocated memory instead of using file-backed mappings.
## Proposed fix
Relax the file-length alignment requirement from the base page size to `kBlobAlign` (256 bytes).
The OS accepts partial-page mappings, but inference kernels can read multiple vectors ahead. Retain the blob-alignment guard and fall back to ordinary reads for lengths that do not meet it. Arbitrary-length mmap support would require separate handling of those reads.
Covered by #1032.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da ChooseMode ed esamina il controllo della lunghezza del checkpoint che la confronta con la dimensione della pagina di sistema, quindi segui i percorsi di fallback mmap e di lettura ordinaria. Il lavoro è completato quando le lunghezze allineate ai blob, come il checkpoint da 4B, possono usare mapping supportati da file, mentre le lunghezze non divisibili per kBlobAlign continuano a usare letture ordinarie.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp
- Ambito
- machine-learning, performance
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Attiva
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 75/100