Skip to content

Fix jax stub compatibility - #5291

Closed
bdelwood wants to merge 1 commit into
facebook:mainfrom
bdelwood:fix/jax-stub-compatibility
Closed

bdelwood wants to merge 1 commit into
facebook:mainfrom
bdelwood:fix/jax-stub-compatibility

Conversation

@bdelwood

@bdelwood bdelwood commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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.

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

Test Plan

Added a couple of tests.

@meta-codesync

meta-codesync Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

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

@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.

This looks pretty good to me, although I think we need to work out why tests are failing and fix that.

cc @jakevdp - could you double-check this, in particular the basearray.pyi module. I want to make sure we don't introduce any masking bugs, where some names become unavailable. I have pretty limited availability this week due to Pytorch Conference.

@stroxler
stroxler removed the request for review from maggiemoss October 20, 2026 18:35
@stroxler stroxler assigned stroxler and unassigned maggiemoss Oct 20, 2026
@jakevdp

jakevdp commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Thanks – I have a similar fix underway, happy to use yours if you'd prefer.

Note however that the CI testing is still being done with jax v0.11.2: that's specified here:

jax==0.11.2
# Pinned alongside `jax`: it is a separate distribution that would otherwise
# resolve freely under a pinned `jax`.
jaxlib==0.11.2

Edit: there are actually a bunch more typing changes in JAX v0.12 that are not reflected in this PR – I think I'll send mine anyway.

@jakevdp

jakevdp commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

One comment – I think it would be better to move the changes not associated with jax v0.12 to a separate PR

@jakevdp

jakevdp commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

My JAX v0.12 updates are in #5301.

@bdelwood
bdelwood force-pushed the fix/jax-stub-compatibility branch from ae0a234 to d949e3b Compare October 21, 2026 01:10
@bdelwood bdelwood changed the title Fix jax stub compatibility for 0.12 Fix jax stub compatibility Oct 21, 2026
@github-actions github-actions Bot added size/s and removed size/s labels Oct 21, 2026
@bdelwood

Copy link
Copy Markdown
Contributor Author

@jakevdp I have split out the 0.12 specific changes in #5302 and kept this one to just the other changes. Will rebase the other when your changes merge.

meta-codesync Bot pushed a commit that referenced this pull request Oct 21, 2026
Summary:
Follows #5291.

The remaining gaps I encountered were in numpy: scalar arithmetic and conversions, array arithmetic with complex and numpy scalars, and missing arguments to arange, round, min, and max. This PR adds support for those operations without attempting to fully model numpy’s dtype promotion rules.

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

Pull Request resolved: #5292

Test Plan: Added a few tests.

Reviewed By: stroxler

Differential Revision: D126199088

fbshipit-source-id: d7219192e7336e23e4991cbef5f79ef501ad8cca

@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.

meta-codesync Bot pushed a commit that referenced this pull request Oct 21, 2026
Summary:
Builds on #5301.

Split from #5291. This adds the lax.polynomial export introduced in jax 0.12 and a test covering its use.

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

Pull Request resolved: #5302

Reviewed By: stroxler

Differential Revision: D126549442

fbshipit-source-id: 730d45131ef9836a77b1ae66ec4a92b65f978935
@meta-codesync meta-codesync Bot closed this in c6e50c3 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 c6e50c3.

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.

4 participants