Skip to content

Preserve unknown rank when iterating arrays - #5290

Closed
bdelwood wants to merge 2 commits into
facebook:mainfrom
bdelwood:fix/gradual-array-iteration
Closed

bdelwood wants to merge 2 commits into
facebook:mainfrom
bdelwood:fix/gradual-array-iteration

Conversation

@bdelwood

Copy link
Copy Markdown
Contributor

Summary

I maintained some out-of-tree jax stubs, but am migrating the project I needed them for to these in-tree stubs. This is the start of a series of PRs to address gaps I found during that migration.

This first change concerns iteration over arrays with an unspecified shape: jax assumes scalar elements, while numpy assumes array elements, which can reject valid code. It removes the empty default from the jax iterator and reversed iterator, and puts numpy's existing gradual iterator overload first.

  • I am a human, and I fully understand the code I am submitting.

Test Plan

Added static and runtime tests for unknown-rank inputs and known vectors and matrices.

@meta-cla

meta-cla Bot commented Oct 20, 2026

Copy link
Copy Markdown

Hi @bdelwood!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@bdelwood bdelwood mentioned this pull request Oct 20, 2026
1 task done
@meta-cla meta-cla Bot added the cla signed label Oct 20, 2026
@meta-cla

meta-cla Bot commented Oct 20, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@stroxler

stroxler commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Thanks @bdelwood!

This looks pretty good to me

Could you try rebasing this? We have an auto-import hook for PRs, but it often doesn't run on a first PR before the CLA is signed. I think if you rebase, it should auto-import which will help me merge it faster (otherwise I have to import it and get a second review, which can take a while)

@bdelwood
bdelwood force-pushed the fix/gradual-array-iteration branch from 253166d to ca4ac5b Compare October 21, 2026 01:04
@github-actions github-actions Bot added size/s and removed size/s labels Oct 21, 2026
@meta-codesync

meta-codesync Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D126546793. (Because this pull request was imported automatically, there will not be any future comments.)

@bdelwood

Copy link
Copy Markdown
Contributor Author

Done!

@stroxler stroxler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@github-actions github-actions Bot added size/s and removed size/s labels Oct 21, 2026
meta-codesync Bot pushed a commit that referenced this pull request Oct 21, 2026
Summary:
Next after #5290

I found that these stubs did not always agree with jax’s own annotations, causing valid calls to be rejected. This PR makes the ones I ran into issues with consistent. It also adds support for numpy boolean scalars in arithmetic and updates the available exports for jax 0.12. I’m unsure how you prefer to handle jax version compatibility, but these changes address several issues I encountered moving my project to jax 0.12.

- [x] I am a human, and I fully understand the code I am submitting.

Pull Request resolved: #5291

Test Plan: Added a couple of tests.

Reviewed By: stroxler

Differential Revision: D126197644

fbshipit-source-id: bde88995b3c84b6007985d4e7b3fd11d5825ad3b
@meta-codesync meta-codesync Bot closed this in 70d31cf Oct 21, 2026
@meta-codesync meta-codesync Bot added the Merged label Oct 21, 2026
@meta-codesync

meta-codesync Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

This pull request has been merged in 70d31cf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants