Repository navigation
perf(trainer): read the checkpoint into the page cache before loading it - #380
Merged
hodaaaaaaaaaa merged 1 commit intoOct 29, 2026
Conversation
training.prefetch reads a checkpoint's safetensors into the page cache with 8 threads and 16 MiB reads before the trainer loads it, for the LoRA trainer's base model and the FFT trainer's base model or saved state. It follows vLLM's loader prefetch: only on nfs, nfs4 and lustre, and skipped when the files would not fit in 90% of available memory. Files are split into 256 MiB chunks so a single-file checkpoint is read by all threads. A failed prefetch is logged and the load goes ahead.
hodaaaaaaaaaa
force-pushed
the
perf/trainer-checkpoint-prefetch
branch
from
October 29, 2026 21:44
77c4808 to
7a3d7e3
Compare
hodaaaaaaaaaa
requested review from
ShubyM and
droot
and removed request for
ShubyM
October 29, 2026 21:44
hodaaaaaaaaaa
marked this pull request as ready for review
October 29, 2026 21:44
droot
approved these changes
Oct 29, 2026
ShubyM
approved these changes
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The trainers load the base model with
from_pretrained, which memory-maps the safetensors files and reads them a page at a time. On a network filesystem such as Filestore each read waits on the server, so a large checkpoint takes many minutes to load. vLLM avoids this by streaming the files into the page cache with several threads first.Change
training.prefetchreads a checkpoint's safetensors into the page cache with 8 threads and 16 MiB reads before the trainer loads it, for the LoRA trainer's base model and the FFT trainer's base model or saved state. It follows vLLM's loader prefetch: it runs only on nfs, nfs4 and lustre, and skips files that would not fit in 90% of available memory. Unlike vLLM, it splits files into 256 MiB chunks, so a single-file checkpoint such as gemma-4-E2B (9.5 GiB) is read by all threads. A failed prefetch is logged and the load goes ahead.Based on droot's prototype in #343.