Repository navigation
Validate pmap inputs against their mapped axes - #483
Open
Linxiushen wants to merge 1 commit into
Open
Linxiushen wants to merge 1 commit into
Linxiushen wants to merge 1 commit into
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.
When
with_pmap(..., broadcast_args_to_devices=False)receivesin_axes=1, a valid batch-major input of shape(3, 2)is rejected on two devices because the wrapper checksshape[0]. The same mismatch affects mixed argument axes and PyTree prefixes, even though nativejax.pmapaccepts these calls.Validate every mapped leaf against its selected axis, expand existing axis prefixes over subtrees, and skip unmapped and static arguments before indexing axes. Keep the existing leading-axis error wording. The regression suite covers a collective, mixed axes, leaf/prefix mappings, mapped-size errors, and a trailing static argument with the short
in_axes=(0,)form accepted by native JAX.Validation on Windows/Python 3.12.14, JAX/jaxlib 0.8.0 and NumPy 2.5.4, with two forced CPU virtual devices in one process:
02bfaa78564cdcac0bf498f40d6e39edeebacd36: 6 failures and 1 passing compatibility control. Four failures are valid positive-axis mapping paths; two check Chex's mapped-size diagnostic.chex/_src/variants_test.py: 131 passed, including all 7 new cases and 124 existing cases; no skips or reported warnings. Accepted outputs are checked against rawjax.pmapand independent NumPy expected arrays.test.shrules, the CI Flake8 selection, Ruff on both changed files, Pyink on changed line ranges, andgit diff --checkpass.This is native library CPU regression evidence. Full repository/build/docs/dependency matrix and physical GPU/distributed execution were not run; successful negative-axis mapping is not added to the supported contract. No CLA or DCO agreement was signed by the agent.
AI assistance: Codex assisted with reproduction, implementation, regression tests and review.