Add single-node DDP support, distributed utils, samplers, and gradient accumulation#7
Draft
agporto wants to merge 1 commit intocode-reviewfrom
Draft
Add single-node DDP support, distributed utils, samplers, and gradient accumulation#7agporto wants to merge 1 commit intocode-reviewfrom
agporto wants to merge 1 commit intocode-reviewfrom
Conversation
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.
Motivation
DistributedSamplersupport and cross-rank gather/aggregation.Description
bioencoder/core/utils.pyincludingis_distributed,get_rank,get_world_size,is_main_process,init_distributed, andteardown_distributed, plus a safe_all_gather_catfor gathering variable-length tensors.build_loadersto acceptdistributed,rank, andworld_sizeand createDistributedSamplerinstances when enabled, and updated dataset loaders to accept provided samplers.deviceparameter and to perform distributed gathering/aggregation (compute_embeddings,validation_constructive,validation_ce) as well as mixed-precision and gradient accumulation logic intrain_epoch_constructiveandtrain_epoch_ce.map_location, and changedbuild_model/script callers (lr_finder.py,swa.py,train.py) to construct and use adeviceobject instead of calling.cuda()directly.train.pywithtorch.nn.parallel.DistributedDataParallelwrapping, optionalSyncBatchNormconversion, sampler epoch setting per-epoch, rank-aware seeding (set_seednow acceptsrank_offset), main-process-only logging/tensorboard/writes, and proper distributed teardown.distributedconfiguration block tobioencoder_configs/train_stage1.ymlandtrain_stage2.ymland documented single-node multi-GPU usage inhelp/03-training.md.Testing
bioencoder.scripts.trainin--dry-runmode on a single GPU; the dry-run completed successfully.lr_finderandswascripts in a single-GPU environment against a small dataset as an automated smoke check; both ran and returned expected outputs.torchrun/DDP CI job was run here, but distributed code paths were covered by the smoke tests whendistributed.enabledwas set toFalseand by unit-like checks for device/map_location handling; those checks passed.Codex Task