Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions benchmarks/benchmark_gemv.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
)
)
def benchmark_gemv(M, K, provider):
A = torch.randn((M, K), device=DEVICE, dtype=torch.float16)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its probably worth keeping the float16 tests as well. Instead of overwriting the test, clone it and have a benchmark for fp16 and fp32.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do 👍

x = torch.randn(K, device=DEVICE, dtype=torch.float16)
y = torch.randn(M, device=DEVICE, dtype=torch.float16)
A = torch.randn((M, K), device=DEVICE, dtype=torch.float32)
x = torch.randn(K, device=DEVICE, dtype=torch.float32)
y = torch.randn(M, device=DEVICE, dtype=torch.float32)
alpha = 0.42
beta = 10
quantiles = [0.5, 0.2, 0.8]
Expand Down
51 changes: 41 additions & 10 deletions tritonblas/level2/gemv.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,70 @@ def get_autotune_config():
return [
triton.Config(
{
"BLOCK_SIZE_M": 128,
"BLOCK_SIZE_K": 64,
"BLOCK_SIZE_M": 64,
"BLOCK_SIZE_K": 128,
},
),
triton.Config(
{
"BLOCK_SIZE_M": 64,
"BLOCK_SIZE_K": 32,
"BLOCK_SIZE_M": 32,
"BLOCK_SIZE_K": 128,
},
),
triton.Config(
{
"BLOCK_SIZE_M": 128,
"BLOCK_SIZE_K": 32,
"BLOCK_SIZE_K": 128,
},
),
triton.Config(
{
"BLOCK_SIZE_M": 64,
"BLOCK_SIZE_M": 256,
"BLOCK_SIZE_K": 64,
},
),
triton.Config(
{
"BLOCK_SIZE_M": 32,
"BLOCK_SIZE_M": 256,
"BLOCK_SIZE_K": 32,
},
),

triton.Config(
{
"BLOCK_SIZE_M": 16,
"BLOCK_SIZE_K": 128,
},
),
triton.Config(
{
"BLOCK_SIZE_M": 16,
"BLOCK_SIZE_K": 256,
},
),
triton.Config(
{
"BLOCK_SIZE_M": 8,
"BLOCK_SIZE_K": 128,
},
),

triton.Config(
{
"BLOCK_SIZE_M": 32,
"BLOCK_SIZE_K": 64,
"BLOCK_SIZE_K": 256,
},
),
triton.Config(
{
"BLOCK_SIZE_M": 16,
"BLOCK_SIZE_K": 512,
},
),
triton.Config(
{
"BLOCK_SIZE_M": 8,
"BLOCK_SIZE_K": 256,
},
),
]
Expand Down Expand Up @@ -90,8 +122,7 @@ def gemv_kernel(
tiled_x = tl.load(x_block, mask=k_mask, other=0.0)

# Partial dot product
partial_result = tl.sum(tiled_a * tiled_x[None, :], axis=1)
accumulator += partial_result
accumulator += tl.sum(tiled_a * tiled_x[None, :], axis=1)

a_block += BLOCK_SIZE_K * stride_ak
x_block += BLOCK_SIZE_K * stride_x
Expand Down