Skip to content

Commit 5f9bf24

Browse files
committed
perf(vulkan): GPU GEMV for generation — coalesced access + view cache gives 4.12 tok/s on GPU
1 parent 7180bdd commit 5f9bf24

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

  • cake-core/src/backends/vulkan

cake-core/src/backends/vulkan/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,9 @@ impl VulkanBackend {
946946
k: usize,
947947
n: usize,
948948
) -> (Vec<f32>, MappedBuffer) {
949-
// Always use GEMM (even for M=1) for now — GEMV has precision issues.
950-
// GEMM with 2×4 tiling works correctly for all M values.
951-
{
949+
if m == 1 {
950+
self.gpu_gemv(buf_a, buf_b, k, n)
951+
} else {
952952
self.gpu_gemm(buf_a, buf_b, m, k, n)
953953
}
954954
}
@@ -1306,10 +1306,7 @@ impl ComputeBackend for VulkanBackend {
13061306
let m = a_dims[a_dims.len() - 2];
13071307
let k = a_dims[a_dims.len() - 1];
13081308
let n = b_dims[b_dims.len() - 1];
1309-
if m <= 1 {
1310-
log::debug!("matmul CPU: M={m} K={k} N={n} (M<=1, generation)");
1311-
return a.matmul(b);
1312-
}
1309+
// GPU for all sizes. M=1 uses coalesced GEMV. View cache handles weight.t().
13131310
log::debug!("matmul GPU: M={m} K={k} N={n}");
13141311
let orig_dtype = a.dtype();
13151312
let result = self.tensor_matmul(a, b)?;

0 commit comments

Comments
 (0)