diff --git a/tinygrad/runtime/ops_metal.py b/tinygrad/runtime/ops_metal.py index 027e5080ab..9e453eb729 100644 --- a/tinygrad/runtime/ops_metal.py +++ b/tinygrad/runtime/ops_metal.py @@ -221,6 +221,9 @@ class MetalAllocator(LRUAllocator[MetalDevice]): msg("setLabel:")(src_command_buffer, to_ns_str(f"COPY {src_dev.device} -> {dest_dev.device}")) msg("commit")(src_command_buffer) src_dev.mtl_buffers_in_flight.append(src_command_buffer) + # Transfers currently synchronize the completion. Otherwise, copies can sometimes lead to incorrect values. + # There is no real metal multidevice support for now, so transfer is used only for tests. + src_dev.synchronize() def _cp_mv(self, dst, src, prof_desc): with cpu_profile(prof_desc, self.dev.device, is_copy=True): dst[:] = src def _as_buffer(self, src:MetalBuffer) -> memoryview: