A Python call can enqueue a Triton kernel on the GPU and return before the GPU finishes. The CPU and GPU advance independently, so wall-clock timing around the call may measure launch time rather than completed work. Synchronize before reading the end time to ensure the GPU queue has finished. section 2.2.10
import time
import torch
torch.cuda.synchronize()
start = time.time()
z = add(x, y)
torch.cuda.synchronize()
end = time.time()
print(f"elapsed: {end - start:.6f} s")
Compare wall-clock readings taken around a kernel launch with synchronization before and after the launch. section 2.2.10




































