DRAFT: Add sharding support for data-parallelism - #166
Draft
benikm91 wants to merge 5 commits into
Draft
Conversation
benikm91
force-pushed
the
data-sharding
branch
from
September 8, 2026 12:18
e72cccc to
6961cd1
Compare
benikm91
force-pushed
the
data-sharding
branch
from
September 8, 2026 12:46
096cb8d to
4357e93
Compare
Collaborator
Author
|
Tested on virtual CPUs (mac) and on two GPUs: |
Collaborator
Author
Collaborator
Author
Collaborator
Author
|
DimWit does not support multiple GPUs. JAX has a nice Sharding solution. This PR lifts a minimal version of this solution to DimWit to allow data-parallelism, the most common parallelism, where the model is small enough to fit fully on one GPU, yet the batches can be distributed across GPUs to calculate/approximate gradients. Design decisions for this PR:
val shardedX: Tensor2[Batch |@| X, Feature, Float32] = x.shard(mesh, Axis[Batch] -> MeshAxis[X])
|
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.


This PR is a first draft to allow limited JAX sharding in DimWit, specifically to allow data-parallelism only (full model distributed across multiple GPUs to process different batches in parallel to speed up training).
Adding sharding for the model parameters requires some more effort (and understanding on my side) and is left to future work.