One function
contiguous_mops_to_view in tinygrad/tinygrad
The author described this change as “fix: don't copy on slice of DP weight (#16089)”. It counts as a record because the check below fails on the code as it stood at 1d1b726cf and passes on d11f4d0ec, with nothing else changed between the two runs.
Projecttinygrad/tinygrad
Fix saved2026-05-08
Sharing licenceMIT · LICENSE
Change size+7 −3
What the code was meant to do, written into the code itself as a docstring
CONTIGUOUS(MOPS(BUFFER)) → CONTIGUOUS(BUFFER_VIEW) when movement ops collapse to a contiguous range.
The change
| 13 | 13 | if not hasattr(Device[c.device].allocator, "_offset"): return None | |
| 14 | 14 | elif not all(hasattr(Device[d].allocator, "_offset") for d in c.device): return None | |
| 15 | 15 | ||
| 16 | + | x = src | |
| 17 | + | while x.op in GroupOp.Movement: x = x.src[0] | |
| 18 | + | # NOTE: this contiguous is removed because this BUFFER_VIEW/RESHAPE has_buffer_identity | |
| 19 | + | if x.op is not Ops.MULTI and (view := _make_buffer_view(src)) is not None: | |
| 20 | + | return view.contiguous(tag=c.tag) | |
| 21 | + | ||
| 16 | 22 | # for MULTI tensors, use multi_pm to resolve per-shard movement ops, then create BUFFER_VIEW on the resolved result | |
| 17 | 23 | if not isinstance(c.device, str): | |
| 18 | 24 | from tinygrad.schedule.multi import multi_pm | |
| ⋯ | |||
| 21 | 27 | if (view := _make_buffer_view(resolved.src[0])) is None: return None | |
| 22 | 28 | return view.multi(resolved.arg).contiguous(tag=c.tag) | |
| 23 | 29 | ||
| 24 | - | # NOTE: this contiguous is removed because this BUFFER_VIEW/RESHAPE has_buffer_identity | |
| 25 | - | if (view := _make_buffer_view(src)) is None: return None | |
| 26 | - | return view.contiguous(tag=c.tag) | |
| 30 | + | return None | |
The check that tells the two apart
fail→pass·test/null/test_schedule.py::TestBufferView::test_replicated_4_devices_is_buffer_view
Check file test/null/test_schedule.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it1d1b726cf61c81eb7f6126cc9132dba5766345e6
Broken version dated2026-05-08
Moduletinygrad.callify
Units changedcontiguous_mops_to_view
Fingerprint8277b6b4dff75be3
Checked2026-08-17 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.