Skip to content

Instantly share code, notes, and snippets.

@karminski
Created November 4, 2025 09:15
Show Gist options
  • Select an option

  • Save karminski/28fdd51746d4c46a4688c57b6436b304 to your computer and use it in GitHub Desktop.

Select an option

Save karminski/28fdd51746d4c46a4688c57b6436b304 to your computer and use it in GitHub Desktop.
import time
import torch
d = 8192
x = torch.randn(size=(d, d)).to(torch.bfloat16).to("cuda")
y = torch.randn(size=(d, d)).to(torch.bfloat16).to("cuda")
def fun(x):
for _ in range(50):
x = x @ y.T
return x
for _ in range(10):
fun(x)
torch.cuda.synchronize()
tic = time.time()
for _ in range(10):
fun(x)
torch.cuda.synchronize()
toc = time.time()
s = (toc - tic)
msec = 1e3 * s
tf = (d**3) * 2 * 50 * 10 / (1024 **4)
print(f"{msec=:.3f}")
tflops = tf / s
print(f"{tflops=:.3f}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment