Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

fix test_context_mode (#221)

eugeneb8e6cb5363d2
diff --git a/crates/uzu/src/backends/common/kernel/matmul/gemm/specialization.rs b/crates/uzu/src/backends/common/kernel/matmul/gemm/specialization.rs
index 4c349a4c2..40051d5db 100644
--- a/crates/uzu/src/backends/common/kernel/matmul/gemm/specialization.rs
+++ b/crates/uzu/src/backends/common/kernel/matmul/gemm/specialization.rs
@@ -113,7 +113,7 @@ impl Specialization {
block_rows: 32,
block_cols: 64,
block_depth: 16,
- warps_per_row: 1,
+ warps_per_row: 2,
warps_per_col: 2,
swizzle_log2: 0,
align_m: false,
@@ -124,7 +124,7 @@ impl Specialization {
block_rows: 32,
block_cols: 64,
block_depth: 16,
- warps_per_row: 1,
+ warps_per_row: 2,
warps_per_col: 2,
swizzle_log2: 0,
align_m: true,
diff --git a/crates/uzu/src/backends/metal/kernel/matmul/gemm/shaders/steel_gemm.metal b/crates/uzu/src/backends/metal/kernel/matmul/gemm/shaders/steel_gemm.metal
index 6a8becf1d..8e606f9de 100644
--- a/crates/uzu/src/backends/metal/kernel/matmul/gemm/shaders/steel_gemm.metal
+++ b/crates/uzu/src/backends/metal/kernel/matmul/gemm/shaders/steel_gemm.metal
@@ -213,10 +213,6 @@ KERNEL(MatmulGemm)(
const uint thread_z THREADS(2),
const Simd simd
) {
- if (simd.group_idx >= warps_per_row * warps_per_col) {
- return;
- }
-
gemm_impl<T, float>(
a, b, d, params,
block_rows, block_cols, block_depth,
diff --git a/crates/uzu/src/backends/metal/kernel/matmul/gemm/specialization.rs b/crates/uzu/src/backends/metal/kernel/matmul/gemm/specialization.rs
index d1ee12719..a7ffc547a 100644
--- a/crates/uzu/src/backends/metal/kernel/matmul/gemm/specialization.rs
+++ b/crates/uzu/src/backends/metal/kernel/matmul/gemm/specialization.rs
@@ -21,57 +21,47 @@ impl Specialization {
let prefer_half_or_tf32 = !is_float32 || context.tf32_enabled();
let (block_rows, block_cols, block_depth, warps_per_row, warps_per_col, swizzle_log2) =
- if context.is_nax_available() && prefer_half_or_tf32 {
- let tile_rows = (arguments.batch + 128 - 1) / 128;
- let swizzle_log2 = if tile_rows <= 3 {
- 0
- } else {
- 1
- };
- (128, 128, 512, 4, 4, swizzle_log2)
- } else {
- match context.device_class() {
- DeviceClass::Integrated | DeviceClass::Phone | DeviceClass::Unknown(_) => {
- if prefer_half_or_tf32 {
- if arguments.transpose_b {
- (64, 32, 32, 2, 2, 0)
- } else {
- (64, 64, 16, 1, 2, 0)
- }
- } else if arguments.transpose_b {
- (32, 64, 16, 1, 2, 0)
- } else {
+ match context.device_class() {
+ DeviceClass::Integrated | DeviceClass::Phone | DeviceClass::Unknown(_) => {
+ if prefer_half_or_tf32 {
+ if arguments.transpose_b {
(64, 32, 32, 2, 2, 0)
+ } else {
+ (64, 64, 16, 2, 2, 0)
}
- },
- DeviceClass::Desktop => {
- if overall_work_elements >= (1_i64 << 20) {
- if prefer_half_or_tf32 {
- if 2 * std::cmp::max(arguments.batch, arguments.output_dim) > arguments.input_dim {
- (64, 64, 16, 2, 2, 0)
- } else if arguments.transpose_b {
- (64, 32, 32, 2, 2, 0)
- } else {
- (32, 64, 16, 1, 2, 0)
- }
+ } else if arguments.transpose_b {
+ (32, 64, 16, 2, 2, 0)
+ } else {
+ (64, 32, 32, 2, 2, 0)
+ }
+ },
+ DeviceClass::Desktop => {
+ if overall_work_elements >= (1_i64 << 20) {
+ if prefer_half_or_tf32 {
+ if 2 * std::cmp::max(arguments.batch, arguments.output_dim) > arguments.input_dim {
+ (64, 64, 16, 2, 2, 0)
} else if arguments.transpose_b {
- (32, 64, 16, 1, 2, 0)
- } else {
- (64, 32, 32, 2, 2, 0)
- }
- } else if prefer_half_or_tf32 {
- if arguments.transpose_b {
(64, 32, 32, 2, 2, 0)
} else {
- (64, 64, 16, 1, 2, 0)
+ (32, 64, 16, 2, 2, 0)
}
} else if arguments.transpose_b {
- (32, 64, 16, 1, 2, 0)
+ (32, 64, 16, 2, 2, 0)
} else {
(64, 32, 32, 2, 2, 0)
}
- },
- }
+ } else if prefer_half_or_tf32 {
+ if arguments.transpose_b {
+ (64, 32, 32, 2, 2, 0)
+ } else {
+ (64, 64, 16, 2, 2, 0)
+ }
+ } else if arguments.transpose_b {
+ (32, 64, 16, 2, 2, 0)
+ } else {
+ (64, 32, 32, 2, 2, 0)
+ }
+ },
};
let m = arguments.batch;