Repository navigation
Set glibc malloc thresholds in the training launch scripts - #794
Open
timothyngo wants to merge 1 commit into
Open
timothyngo wants to merge 1 commit into
timothyngo wants to merge 1 commit into
Conversation
Loader workers that preprocess large images (3x3 tiling at 512 px makes ~28 MB float32 temporaries per image) grow their heap without bound once glibc's dynamic mmap threshold rises to 32 MB: the frees fragment the heap and are never returned. MALLOC_MMAP_THRESHOLD_=1048576 and MALLOC_TRIM_THRESHOLD_=4194304 keep such blocks on mmap and trim the heap, so worker memory stays flat. glibc reads them at process start, so they belong in the launch environment; forked workers inherit them.
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
amazloumi
self-requested a review
December 6, 2026 11:38
This branch has not been deployed
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.
Summary
The training launch scripts under
scripts/slurm/(multinode.sh,singlenode.sh,7b_requeue.sh,13b_validation.sh,interactive.sh,_run_training.sh) now export two glibc malloc settings next to their NCCL/Gloo env:so DataLoader workers stop accumulating host memory.
docs/reference/environment-variables.mdgets a short section on them, and the image-understanding README says to keep them in the stage-1/2 launch environment.Why
In the image-understanding stage-2 run (3 × 3 tiling at 512 px),
tile_imageconverts the whole 1536² canvas to float32 before cropping (kempnerforge/data/vlm_dataset.py,pil_to_tensor), so each image makes ~28 MB temporaries. glibc's dynamic mmap threshold rises to 32 MB after the first large free, so those blocks come from the worker heap, fragment, and are never returned: each DataLoader worker grew ~7.5 MB per document without bound (48 workers × ~30 GB per node), and the node ran out of host memory after ~10 h on a 1400 GB node.A 50-minute CPU probe of the real stage-2 loader (12 workers, prefetch 16):
Throughput was within noise. Disabling THP or setting
NUMPY_MADVISE_HUGEPAGE=0made no difference.glibc reads these variables at process start, so they have to be in the launch environment (workers are forked and inherit them); setting them from Python would be too late. No change to numerics or data order.
Tests
test_training_launchers_export_the_malloc_thresholdsintests/unit/test_slurm_scripts.pychecks each training launcher exports both.bash -non every script inscripts/slurm/,ruff check/ruff format --check,tests/unit/test_slurm_scripts.py, andsphinx-build -Won the docs.The benchmark launchers under
benchmarks/are left as they are.