Skip to content

BUG: searchsorted: broadcast batch shapes - #1024

Open
nightcityblade wants to merge 3 commits into
data-apis:mainfrom
nightcityblade:fix/issue-1014
Open

nightcityblade wants to merge 3 commits into
data-apis:mainfrom
nightcityblade:fix/issue-1014

Conversation

@nightcityblade

Copy link
Copy Markdown
Contributor

Reference issue

Closes gh-1014.

What does this implement/fix?

Broadcast the batch dimensions of both searchsorted inputs before running the vectorized binary search. The native Torch path receives the same treatment and materializes broadcast views to avoid Torch's non-contiguous-input warning.

Add a backend-parameterized regression test for a batched sorted input and an unbatched array of search values, and document the broadcast-compatible batch-shape contract.

Additional information

Tests run locally:

  • pytest -q tests/main: 4596 passed, 10690 skipped, 18 xfailed, 2 xpassed
  • focused PyTorch regression test: 2 passed, 2 CUDA cases skipped
  • ruff check and ruff format --check on all changed Python files: passed

AI Generation Disclosure

OpenAI Codex was used to help implement the broadcasting change and regression test. I reviewed the complete diff and ran the test and lint commands listed above.

@lucascolley lucascolley changed the title fix: broadcast searchsorted batch shapes BUG: searchsorted: broadcast batch shapes Oct 17, 2026
@lucascolley lucascolley added the bug Something isn't working label Oct 17, 2026
@lucascolley
lucascolley force-pushed the fix/issue-1014 branch 2 times, most recently from 68eed33 to fe19465 Compare October 17, 2026 12:44
@lucascolley

Copy link
Copy Markdown
Member

@mdhaber please could you review?

@lucascolley lucascolley added this to the 0.12.0 milestone Oct 17, 2026

@lucascolley lucascolley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be good to go now. Thanks!

@lucascolley

Copy link
Copy Markdown
Member

@mdhaber FYI, hoping to get this released quite soon, in case you were wanting to check

This branch has not been deployed

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: searchsorted: needs to broadcast batch shapes

2 participants