Skip to content

Return zero VJPs for scatter indices#3612

Open
devin-lai wants to merge 1 commit into
ml-explore:mainfrom
devin-lai:fix-scatter-vjp-indices
Open

Return zero VJPs for scatter indices#3612
devin-lai wants to merge 1 commit into
ml-explore:mainfrom
devin-lai:fix-scatter-vjp-indices

Conversation

@devin-lai

Copy link
Copy Markdown

Summary

  • Return zero VJPs for scatter and scatter_axis index inputs.
  • Match gather behavior and fix gradients when scatter indices come from differentiable values.
  • Add autograd coverage for direct and derived scatter indices.

Closes #1439.

Tests

  • /opt/homebrew/bin/black --check python/tests/test_autograd.py
  • clang-format --dry-run --Werror mlx/primitives.cpp
  • git diff --check
  • PYTHONPATH=/Users/ldy/Desktop/project/mt/opencode/mlx/python:/Users/ldy/Desktop/project/mt/opencode/mlx/python/tests python3.11 -m unittest python.tests.test_autograd.TestAutograd.test_scatter_index_vjp
  • PYTHONPATH=/Users/ldy/Desktop/project/mt/opencode/mlx/python:/Users/ldy/Desktop/project/mt/opencode/mlx/python/tests python3.11 -m unittest python.tests.test_autograd

@zcbenz zcbenz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me, thanks!

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.

[BUG] ValueError: [scatter] Cannot calculate VJP with respect to indices.

2 participants