Streaming diloco with vmap finished#4287
Draft
Dr-Left wants to merge 1 commit into
Draft
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 implements Streaming DiLoCo with communication overlapping in MaxText.
In vanilla DiLoCo, the outer optimization step synchronizes all parameters at once every
diloco_sync_periodsteps, creating a massive network communication spike on the slow DCN interconnect and causing slices to idle while waiting for the collective communication to finish.Streaming DiLoCo solves this by partitioning the model parameters into$P$ fragments (one for non-scanned parameters, and $P-1$ for transformer layers) and staggering their synchronization schedule. Instead of a single large communication step, a different fragment is synchronized and updated at a staggered interval. This distributes the communication payload across steps, smoothing out peak bandwidth.
Furthermore, we support communication overlapping ($\tau$ steps of delay) by scheduling a fragment's $s$ but only applying the updated weights at step $s + \tau$ . During these $\tau$ steps, the local slices continue training, allowing XLA to overlap the DCN communication with computation. [TODO: hasn't been tested yet]
reduce_meancollective communication at stepImplementation Details:
FragmentedTreeManipulator: A helper class that slices parameters along the layer axis for scanned layer parameters and groups non-scanned parameters into fragment 0. It supportshas_replica_dim=Trueto handle parameters that are vectorized (vmap'ed) over thedilocoreplica dimension (which is the case for the innertrain_stateunderdrjax.map_fn).enable_streaming_diloco(defaultfalse): Enable/disable streaming DiLoCo.num_diloco_fragments(default16): Number of fragments to split transformer layers into.use_sequential_layers(defaultfalse): Whether to partition layers sequentially or interleaved.num_communication_overlapping_steps(default0): Communication delay (communication_overlapping_alpha(default0.0): Interpolation factor to blend local parameters with globally synchronized parameters.scripts/diloco/run_diloco.shto easily launch DiLoCo pre-training workloads on XPK clusters.Shortcomings & Future Work:
num_diloco_fragments.Tests
test_streaming_diloco_two_slicesintests/integration/diloco_test.pythat verifies compilation works for a 2-slice topology (tpu7x-8) with Gemma2-2b andenable_streaming_diloco=True.Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.