Support mutable operations (set, swap, addupdate) on ReshapeTransform and BitcastTransform views during state discharge. - #40310
Merged
Conversation
copybara-service
Bot
force-pushed
the
test_972069536
branch
from
August 28, 2026 23:11
54cc21b to
5ce3281
Compare
…ansform` and `BitcastTransform` views during state discharge. Previously, `ReshapeTransform` and `BitcastTransform` were read-only during state discharge (`ref_get`). Attempting to mutate them via `ref_set`, `ref_swap`, or `ref_addupdate` failed with `NotImplementedError` because the write-back loop in `transform_swap_array` only handled `NDIndexer`. Additionally, the forward pass in `transform_swap_array` did not update the transformed value accumulator, which caused `swap` to return an un-transformed value. This change: * Implements reverse transformations (`.reshape(...)` and `bitcast(...)`) during the write-back phase in `transform_swap_array`. * Rebinds `new_val` during the forward pass in `transform_swap_array` so `swap` returns the correctly transformed previous value. * Adds support for `ReshapeTransform` in `_addupdate_discharge` and explicitly disallows `BitcastTransform` on `addupdate`. * Adds unit tests in `state_test.py` covering set, swap, sliced view mutations, and addupdate on reshaped and bitcast views. * Adds test coverage in `pallas_test.py` verifying behavior under Pallas interpret mode and explicit `NotImplementedError` under Triton. PiperOrigin-RevId: 972845721
copybara-service
Bot
force-pushed
the
test_972069536
branch
from
August 28, 2026 23:23
5ce3281 to
fd3802e
Compare
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.
Support mutable operations (
set,swap,addupdate) onReshapeTransformandBitcastTransformviews during state discharge.Previously,
ReshapeTransformandBitcastTransformwere read-only during state discharge (ref_get). Attempting to mutate them viaref_set,ref_swap, orref_addupdatefailed withNotImplementedErrorbecause the write-back loop intransform_swap_arrayonly handledNDIndexer. Additionally, the forward pass intransform_swap_arraydid not update the transformed value accumulator, which causedswapto return an un-transformed value.This change:
.reshape(...)andbitcast(...)) during the write-back phase intransform_swap_array.new_valduring the forward pass intransform_swap_arraysoswapreturns the correctly transformed previous value.ReshapeTransformin_addupdate_dischargeand explicitly disallowsBitcastTransformonaddupdate.state_test.pycovering set, swap, sliced view mutations, and addupdate on reshaped and bitcast views.pallas_test.pyverifying behavior under Pallas interpret mode and explicitNotImplementedErrorunder Triton.