Skip to content

Fix the sort gradient - #20

Merged
MarcosAsh merged 1 commit into
mainfrom
fix-sort-gradient
Aug 19, 2026
Merged

MarcosAsh merged 1 commit into
mainfrom
fix-sort-gradient

Conversation

@MarcosAsh

Copy link
Copy Markdown
Collaborator

Description

mx.sort returns the right values but its vjp routes each gradient through the inverse of the sort permutation, so sort handed back gradients against the wrong elements. Gathering with argsort gives the same values and the correct gradient.

bool still goes through mx.sort since it carries no gradient.

@MarcosAsh
MarcosAsh merged commit 41a9d10 into main Aug 19, 2026
10 checks passed
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