Handle explicit sharding in array truncation - #79
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
Conversation
sylvesterkaczmarek
marked this pull request as ready for review
August 15, 2026 18:33
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.
Fixes #70.
Explicitly-sharded JAX arrays can reject ordinary slicing when the truncated dimension is not divisible by the mesh axis. Treescope currently hits that failure in
_truncate_part_with_slicesbefore the JITout_shardingsconstraint can make the final result replicated.For explicit
NamedSharding, convert the first shrinking slice to a gather with an explicitly replicated output on the same mesh. Remaining slices then operate on a replicated intermediate, while non-explicit and older JAX paths keep the existing behavior.The regression test forces four CPU devices in a subprocess and exercises
JAXArrayAdapter.get_array_data_with_truncationwith an explicitP("tp", None)sharding, verifying the 7x7 edge data and validity mask.Local validation:
ShardingTypeErrorwith four explicit CPU shardsThe full repository CI toolchain could not be run locally because the isolated environment cannot fetch the repository's development dependencies, so this remains Draft pending upstream CI.