Thanks for the code! I wouldn’t expect such a difference, so I just rerun the code and got:
Construct fake database + query time 0.018206119537353516
fake_database shape torch.Size([2000, 256]) fake_query shape torch.Size([1000, 256])
L2 Distance time 0.00036679506301879884
Inner Product time 0.0001362919807434082

on a TitanV.