You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mps: clone() aliases its source, so x.clone().add_(1) changes x #97
Measured on this Mac with the real shim (develop and feat/mps-index alike): on mps, y = x.clone(); y.add_(1) changes x too; so do fill_, setitem, clone(memory_format=contiguous) and detach().clone(). cpu is correct. No compute or blit encoder runs: nothing is copied.
Cause: clone_default calls candle Tensor::copy(), whose MetalStorage::try_clone is upstream's Ok(self.clone()), an Arc<Buffer> share. candle never writes a buffer in place, so it was safe there; torch._C does.
Done when
MetalStorage::try_clone in the candle fork copies into a fresh buffer (one blit), patch regenerated, vendor_candle.sh --check passes.
A test: every clone spelling x every in-place write leaves the source unchanged on mps; detach and alias still share (upstream semantics); a blit encoder is counted. Red before.
Activity
Merge pull request #98 from thisisthepy/feat/mps-clone-copy
b-re-w commentedon Oct 16, 2026
Landed in develop via #98
Merge origin/develop into feat/mps-int32 (PR #98's clone fix)