Skip to content

Support negative axes in microbatching - #1751

Open
anxkhn wants to merge 2 commits into
google-deepmind:mainfrom
anxkhn:fix/microbatch-negative-axis
Open

Support negative axes in microbatching#1751
anxkhn wants to merge 2 commits into
google-deepmind:mainfrom
anxkhn:fix/microbatch-negative-axis

Conversation

@anxkhn

@anxkhn anxkhn commented Aug 13, 2026

Copy link
Copy Markdown

Summary

Canonicalize negative batch axes before reshaping and slicing microbatches.

Negative in_axes values were used directly in shape slicing, producing invalid reshape targets. The fix resolves each axis against the relevant array rank in both reshape_batch_axis and _take_fn.

Tests

  • Added a regression test for in_axes=-1
  • Verified the full microbatching test module

@anxkhn

anxkhn commented Aug 13, 2026

Copy link
Copy Markdown
Author

hey @irhyl, could you please review this pr when you have a chance?

@irhyl

irhyl commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

hey @irhyl, could you please review this pr when you have a chance?

hi @anxkhn
i am not the reviewer of this project, but i did take a look at the pr. i think ur at the right track with the negative axes.

the test is a bit minimal, though. it’d be good to cover a few more shapes, including in_axes=-2. if possible, also add a sharding test. otherwise, solid catch on the canonicalization.

anxkhn added 2 commits August 20, 2026 02:01
Cover more input shapes, in_axes=-2, and explicit sharding.

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
@anxkhn
anxkhn force-pushed the fix/microbatch-negative-axis branch from fbfbe14 to a840323 Compare August 19, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants