Nova-Prime-Kernels / benchmarks /vortex_10x_siege.py
Antigravity Agent
Blitz: THE 10X BREAKTHROUGH
2811c56
import torch
import time
import triton
import triton.language as tl
@triton.jit
def vortex_siege_kernel(X, Out, N, BLOCK_SIZE: tl.constexpr):
pid = tl.program_id(0)
offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
mask = offsets < N
# ARTISAN MONOLITH: 20+ Fused Operations
x = tl.load(X + offsets, mask=mask)
acc = x
for i in range(20):
acc = tl.sin(acc * 1.1 + 0.1)
tl.store(Out + offsets, acc, mask=mask)
def run_siege():
N = 1024 * 1024 * 128 # 128M Elements
print("--- BLITZ VORTEX: THE 10X SIEGE (H200) ---")
X = torch.randn(N, device="cuda")
Out = torch.empty_like(X)
# 1. PyTorch Eager (The "Crap" Baseline)
torch.cuda.synchronize()
start = time.time()
for _ in range(10):
curr = X
for i in range(20):
curr = torch.sin(curr * 1.1 + 0.1)
torch.cuda.synchronize()
eager_ms = (time.time() - start) / 10 * 1000
# 2. Blitz Vortex (Artisan Monolith)
grid = (triton.cdiv(N, 16384),)
torch.cuda.synchronize()
start = time.time()
for _ in range(10): vortex_siege_kernel[grid](X, Out, N, BLOCK_SIZE=16384)
torch.cuda.synchronize()
vortex_ms = (time.time() - start) / 10 * 1000
print(f"RE (HBM Utilization): {((N*4*2*21) / (vortex_ms/1000)) / 1e12:.2f} TB/s")
print(f"Eager Latency: {eager_ms:.4f}ms")
print(f"Vortex Latency: {vortex_ms:.4f}ms")
print(f"SIEGE SPEEDUP: {eager_ms/vortex_ms:.2f}x")
if __name__ == "__main__":
run_siege()