Support mutable operations (`set`, `swap`, `addupdate`) on `ReshapeTransform` 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
C
Cristian Garcia committed
fd3802ec5aa19090402717f3340bb1a1805c1434
Parent: 05fcbe4
Committed by jax authors <google-ml-automation@google.com>
on 8/28/2026, 11:23:52 PM