Skip to content

perf(trainer): read the checkpoint into the page cache before loading it - #380

Merged
hodaaaaaaaaaa merged 1 commit into
openrl-dev:mainfrom
hodaaaaaaaaaa:perf/trainer-checkpoint-prefetch
Oct 29, 2026
Merged

hodaaaaaaaaaa merged 1 commit into
openrl-dev:mainfrom
hodaaaaaaaaaa:perf/trainer-checkpoint-prefetch

Conversation

@hodaaaaaaaaaa

@hodaaaaaaaaaa hodaaaaaaaaaa commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

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.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: 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.

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
hodaaaaaaaaaa force-pushed the perf/trainer-checkpoint-prefetch branch from 77c4808 to 7a3d7e3 Compare October 29, 2026 21:44
@hodaaaaaaaaaa
hodaaaaaaaaaa requested review from ShubyM and droot and removed request for ShubyM October 29, 2026 21:44
@hodaaaaaaaaaa
hodaaaaaaaaaa marked this pull request as ready for review October 29, 2026 21:44
@hodaaaaaaaaaa
hodaaaaaaaaaa merged commit 163533d into openrl-dev:main Oct 29, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants