Skip to content

[CUDA] Fix gather_mm with sorted_indices=True - #4771

Open
luciusacarr wants to merge 2 commits into
ml-explore:mainfrom
luciusacarr:fix-gather-mm-sorted-lda
Open

luciusacarr wants to merge 2 commits into
ml-explore:mainfrom
luciusacarr:fix-gather-mm-sorted-lda

Conversation

@luciusacarr

Copy link
Copy Markdown
Contributor

Fixes #4727

With sorted_indices=True, gather_mm returned the wrong rows when xs size-1 axis came from expand_dimsor x[:, None, :]. This is becauseensure_batch_contiguous returnedx.strides(-2)for row contiguous inputs. On a size-1 axis, that stride is arbitrary. By returningx.shape(-1)` instead, we read the real row step for row contiguous data. A test is added to avoid future regressions.

On my 5090 on CUDA 13.3, this fix made the number of wrong rows go from 60/64 to 0/64.

  • ☑️ I understand it is strictly prohibited to use AI to write PR description
  • AI usage disclosure: AI was used for initial diagnosis and to reason that tests were sufficient.

@luciusacarr luciusacarr reopened this Nov 2, 2026

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CUDA] gather_mm with sorted_indices=True gives wrong rows when x's size-1 axis comes from expand_dims

1 participant