Repository navigation
Fix SliceUpdate vmap with unbatched update - #4770
Merged
zcbenz merged 1 commit intoOct 29, 2026
Merged
Conversation
zcbenz
force-pushed
the
fix-slice-update-vmap-unbatched-update
branch
from
October 27, 2026 09:28
558f0de to
9aafe07
Compare
zcbenz
approved these changes
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SliceUpdate::vmapandDynamicSliceUpdate::vmapsilently return a wrong result whensrcis batched and the update is not. The update gets a size-1 axis at the batch position but is never broadcast to the batch size, so only the first batch element is updated and the rest come back unchanged. No error is raised.Repro (CPU)
The static form (
s[1:2, 0:2] = uinside a vmapped function) has the same bug because it goes throughSliceUpdate.Fix
Both
vmaprules now broadcastupdto the batch size ofsrcafter theexpand_dims. Cases where the update is already batched are unchanged.Tests
Added
test_vmap_slice_update, which compares against a per-example loop for both the dynamic and static forms. It covers:srcbatched on axis 0, 1, and 2 with an unbatched updatesrcand the update batchedThe test fails before the fix and passes after.
test_vmap,test_autograd,test_ops,test_blas,test_compile,test_export_import, and the C++ tests all pass locally, and pre-commit is clean. My local build is CPU-only, so CI will cover Metal.