You need to use synchronize (torch.cuda.synchronize, or something close to that) before and after the code being timed in order to get accurate timeit results; once you do that the speed penalty will probably be closer to 2x (depending on length/batch size). It’s still a lot, and it might be worth it to move the packing and unpacking to C eventually.