Fix hardcoded grain_worker_count in HF data processing pipelines to prevent OOM while running Multimodal SFT via pathway#4552
Open
chiajunglien wants to merge 1 commit into
Conversation
chiajunglien
requested review from
SurbhiJainUSC,
aireenmei,
darisoy,
igorts-git,
richjames0 and
shralex
as code owners
July 21, 2026 07:16
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
aireenmei
reviewed
Jul 22, 2026
aireenmei
left a comment
Collaborator
There was a problem hiding this comment.
Could you add a guard in types.py, so it errors out when user set grain_worker_count > 1 for dataset_type=hf?
SurbhiJainUSC
approved these changes
Jul 23, 2026
chiajunglien
requested review from
A9isha,
NuojCheng,
RissyRan,
abhinavclemson,
bvandermoon,
dipannita08,
gagika,
gobbleturk,
hengtaoguo,
huytransformer,
jiangjy1982,
khatwanimohit,
suexu1025,
vipannalla and
xibinliu
as code owners
July 23, 2026 01:29
chiajunglien
force-pushed
the
emma/fix-multimodalsft
branch
from
July 23, 2026 01:30
38bff2d to
2a2f009
Compare
chiajunglien
force-pushed
the
emma/fix-multimodalsft
branch
from
July 23, 2026 01:55
5926098 to
b83daf9
Compare
chiajunglien
force-pushed
the
emma/fix-multimodalsft
branch
from
July 23, 2026 04:03
80bbb53 to
fa28b05
Compare
Contributor
Author
Added. Thank you! |
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.
Description
This PR addresses an issue in
hf_data_processing.pywhere the Grain DataLoader's worker count was strictly hardcoded or omitted during instantiation, ignoring the user-providedconfig.grain_worker_count.Problem
vision_sft_preprocessing_pipeline),worker_countwas hardcoded to1. Because text/image batches can be extremely large, forcing data loading into a multiprocessing background worker quickly exhausted the container's default/dev/shm(Shared Memory), causing aSIGBUS(exit code -7) crash.make_hf_train_iteratorandmake_hf_eval_iteratorfailed to passconfig.grain_worker_countdown topreprocessing_pipeline,silently falling back to the default
1regardless of user configuration.Solution
config.grain_worker_countdirectly into thegrain.DataLoaderinsidevision_sft_preprocessing_pipeline.grain_worker_count=config.grain_worker_counttopreprocessing_pipelineinside both train and eval iterators.This enables users to properly disable multiprocessing on multimodal/heavy data workflows by passing
--grain_worker_count=0in their XPK commands, completely avoiding the/dev/shmlimit.Tests
train_sft_nativeon ChartQA dataset correctly respectsgrain_worker_count=0without crashing.Command:
Log: https://paste.googleplex.com/5331889429807104
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.