Files
onepilot/tinygrad_repo/extra/ring_copy.py
github-actions[bot] 7fa972be6a sunnypilot v2026.02.09-4080
version: sunnypilot v2025.003.000 (dev)
date: 2026-02-09T02:04:38
master commit: 254f55ac15a40343d7255f2f098de3442e0c4a6f
2026-02-09 02:04:38 +00:00

15 lines
472 B
Python

from tinygrad import Tensor, Device, GlobalCounters
from tinygrad.helpers import Timing
N = 512
GPUS = 5
ds = tuple([f"{Device.DEFAULT}:{i+1}" for i in range(GPUS)])
t = [Tensor.ones(N, N, N, device=d).contiguous().realize() for d in ds]
for _ in range(10):
GlobalCounters.reset()
with Timing():
for ti in t:
ti.to_(ds[(ds.index(ti.device)+1+len(ds))%len(ds)])
# ti.to_(ds[(ds.index(ti.device)-1+len(ds))%len(ds)]) # reversed order
ti.realize()