mlx
mlx copied to clipboard
Return zero VJPs for scatter indices
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