From d33859362bd80f7d82fed16724235b9aa166a6f7 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Fri, 6 Nov 2026 13:40:54 +0100 Subject: [PATCH] STRA-338 size: cuda-driver mtp_original_full_head_dispatch: kernel-name tables as consts, selectors extracted (head_dispatch 323 -> 30 lines) --- .../src/mtp_original_full_head_dispatch.rs | 651 ++++++++++-------- 1 file changed, 346 insertions(+), 305 deletions(-) diff --git a/crates/cuda-driver/src/mtp_original_full_head_dispatch.rs b/crates/cuda-driver/src/mtp_original_full_head_dispatch.rs index 6ab89206..7b8c83f1 100644 --- a/crates/cuda-driver/src/mtp_original_full_head_dispatch.rs +++ b/crates/cuda-driver/src/mtp_original_full_head_dispatch.rs @@ -1,5 +1,347 @@ use super::*; use crate::NativeHeadDispatch; + +/// Kernel names of the IQ head kernels: `[old, c1, c2, c4, c8]` (kind 7 has the old kernel only). +const IQ_NAMES: [(u32, &[&str]); 7] = [ + (7, &["head_i7_old"]), + (16, &["head_i16_old", "head_i16_c1", "head_i16_c2", "head_i16_c4", "head_i16_c8"]), + (17, &["head_i17_old", "head_i17_c1", "head_i17_c2", "head_i17_c4", "head_i17_c8"]), + (18, &["head_i18_old", "head_i18_c1", "head_i18_c2", "head_i18_c4", "head_i18_c8"]), + (21, &["head_i21_old", "head_i21_c1", "head_i21_c2", "head_i21_c4", "head_i21_c8"]), + (22, &["head_i22_old", "head_i22_c1", "head_i22_c2", "head_i22_c4", "head_i22_c8"]), + (29, &["head_i29_old", "head_i29_c1", "head_i29_c2", "head_i29_c4", "head_i29_c8"]), +]; + +/// Kernel names of the native head kernels per kind: `[s1, s0]` for one token, then +/// `[upstream, small, large]` for each token count 2..=8 (index `2 + (t - 2) * 3 + mode - 2`). +const HEAD_NAMES_PER_KIND: usize = 23; +const HEAD_N2: [&str; HEAD_NAMES_PER_KIND] = [ + "head_n2_s1", + "head_n2_s0", + "head_n2_t2_upstream", + "head_n2_t2_small", + "head_n2_t2_large", + "head_n2_t3_upstream", + "head_n2_t3_small", + "head_n2_t3_large", + "head_n2_t4_upstream", + "head_n2_t4_small", + "head_n2_t4_large", + "head_n2_t5_upstream", + "head_n2_t5_small", + "head_n2_t5_large", + "head_n2_t6_upstream", + "head_n2_t6_small", + "head_n2_t6_large", + "head_n2_t7_upstream", + "head_n2_t7_small", + "head_n2_t7_large", + "head_n2_t8_upstream", + "head_n2_t8_small", + "head_n2_t8_large", +]; +const HEAD_N6: [&str; HEAD_NAMES_PER_KIND] = [ + "head_n6_s1", + "head_n6_s0", + "head_n6_t2_upstream", + "head_n6_t2_small", + "head_n6_t2_large", + "head_n6_t3_upstream", + "head_n6_t3_small", + "head_n6_t3_large", + "head_n6_t4_upstream", + "head_n6_t4_small", + "head_n6_t4_large", + "head_n6_t5_upstream", + "head_n6_t5_small", + "head_n6_t5_large", + "head_n6_t6_upstream", + "head_n6_t6_small", + "head_n6_t6_large", + "head_n6_t7_upstream", + "head_n6_t7_small", + "head_n6_t7_large", + "head_n6_t8_upstream", + "head_n6_t8_small", + "head_n6_t8_large", +]; +const HEAD_N8: [&str; HEAD_NAMES_PER_KIND] = [ + "head_n8_s1", + "head_n8_s0", + "head_n8_t2_upstream", + "head_n8_t2_small", + "head_n8_t2_large", + "head_n8_t3_upstream", + "head_n8_t3_small", + "head_n8_t3_large", + "head_n8_t4_upstream", + "head_n8_t4_small", + "head_n8_t4_large", + "head_n8_t5_upstream", + "head_n8_t5_small", + "head_n8_t5_large", + "head_n8_t6_upstream", + "head_n8_t6_small", + "head_n8_t6_large", + "head_n8_t7_upstream", + "head_n8_t7_small", + "head_n8_t7_large", + "head_n8_t8_upstream", + "head_n8_t8_small", + "head_n8_t8_large", +]; +const HEAD_N20: [&str; HEAD_NAMES_PER_KIND] = [ + "head_n20_s1", + "head_n20_s0", + "head_n20_t2_upstream", + "head_n20_t2_small", + "head_n20_t2_large", + "head_n20_t3_upstream", + "head_n20_t3_small", + "head_n20_t3_large", + "head_n20_t4_upstream", + "head_n20_t4_small", + "head_n20_t4_large", + "head_n20_t5_upstream", + "head_n20_t5_small", + "head_n20_t5_large", + "head_n20_t6_upstream", + "head_n20_t6_small", + "head_n20_t6_large", + "head_n20_t7_upstream", + "head_n20_t7_small", + "head_n20_t7_large", + "head_n20_t8_upstream", + "head_n20_t8_small", + "head_n20_t8_large", +]; +const HEAD_N11: [&str; HEAD_NAMES_PER_KIND] = [ + "head_n11_s1", + "head_n11_s0", + "head_n11_t2_upstream", + "head_n11_t2_small", + "head_n11_t2_large", + "head_n11_t3_upstream", + "head_n11_t3_small", + "head_n11_t3_large", + "head_n11_t4_upstream", + "head_n11_t4_small", + "head_n11_t4_large", + "head_n11_t5_upstream", + "head_n11_t5_small", + "head_n11_t5_large", + "head_n11_t6_upstream", + "head_n11_t6_small", + "head_n11_t6_large", + "head_n11_t7_upstream", + "head_n11_t7_small", + "head_n11_t7_large", + "head_n11_t8_upstream", + "head_n11_t8_small", + "head_n11_t8_large", +]; +const HEAD_N12: [&str; HEAD_NAMES_PER_KIND] = [ + "head_n12_s1", + "head_n12_s0", + "head_n12_t2_upstream", + "head_n12_t2_small", + "head_n12_t2_large", + "head_n12_t3_upstream", + "head_n12_t3_small", + "head_n12_t3_large", + "head_n12_t4_upstream", + "head_n12_t4_small", + "head_n12_t4_large", + "head_n12_t5_upstream", + "head_n12_t5_small", + "head_n12_t5_large", + "head_n12_t6_upstream", + "head_n12_t6_small", + "head_n12_t6_large", + "head_n12_t7_upstream", + "head_n12_t7_small", + "head_n12_t7_large", + "head_n12_t8_upstream", + "head_n12_t8_small", + "head_n12_t8_large", +]; +const HEAD_N13: [&str; HEAD_NAMES_PER_KIND] = [ + "head_n13_s1", + "head_n13_s0", + "head_n13_t2_upstream", + "head_n13_t2_small", + "head_n13_t2_large", + "head_n13_t3_upstream", + "head_n13_t3_small", + "head_n13_t3_large", + "head_n13_t4_upstream", + "head_n13_t4_small", + "head_n13_t4_large", + "head_n13_t5_upstream", + "head_n13_t5_small", + "head_n13_t5_large", + "head_n13_t6_upstream", + "head_n13_t6_small", + "head_n13_t6_large", + "head_n13_t7_upstream", + "head_n13_t7_small", + "head_n13_t7_large", + "head_n13_t8_upstream", + "head_n13_t8_small", + "head_n13_t8_large", +]; +const HEAD_N14: [&str; HEAD_NAMES_PER_KIND] = [ + "head_n14_s1", + "head_n14_s0", + "head_n14_t2_upstream", + "head_n14_t2_small", + "head_n14_t2_large", + "head_n14_t3_upstream", + "head_n14_t3_small", + "head_n14_t3_large", + "head_n14_t4_upstream", + "head_n14_t4_small", + "head_n14_t4_large", + "head_n14_t5_upstream", + "head_n14_t5_small", + "head_n14_t5_large", + "head_n14_t6_upstream", + "head_n14_t6_small", + "head_n14_t6_large", + "head_n14_t7_upstream", + "head_n14_t7_small", + "head_n14_t7_large", + "head_n14_t8_upstream", + "head_n14_t8_small", + "head_n14_t8_large", +]; +const HEAD_N23: [&str; HEAD_NAMES_PER_KIND] = [ + "head_n23_s1", + "head_n23_s0", + "head_n23_t2_upstream", + "head_n23_t2_small", + "head_n23_t2_large", + "head_n23_t3_upstream", + "head_n23_t3_small", + "head_n23_t3_large", + "head_n23_t4_upstream", + "head_n23_t4_small", + "head_n23_t4_large", + "head_n23_t5_upstream", + "head_n23_t5_small", + "head_n23_t5_large", + "head_n23_t6_upstream", + "head_n23_t6_small", + "head_n23_t6_large", + "head_n23_t7_upstream", + "head_n23_t7_small", + "head_n23_t7_large", + "head_n23_t8_upstream", + "head_n23_t8_small", + "head_n23_t8_large", +]; +const HEAD_N42: [&str; HEAD_NAMES_PER_KIND] = [ + "head_n42_s1", + "head_n42_s0", + "head_n42_t2_upstream", + "head_n42_t2_small", + "head_n42_t2_large", + "head_n42_t3_upstream", + "head_n42_t3_small", + "head_n42_t3_large", + "head_n42_t4_upstream", + "head_n42_t4_small", + "head_n42_t4_large", + "head_n42_t5_upstream", + "head_n42_t5_small", + "head_n42_t5_large", + "head_n42_t6_upstream", + "head_n42_t6_small", + "head_n42_t6_large", + "head_n42_t7_upstream", + "head_n42_t7_small", + "head_n42_t7_large", + "head_n42_t8_upstream", + "head_n42_t8_small", + "head_n42_t8_large", +]; + +fn iq_kernel_name(kind: u32, columns: usize, old: bool) -> Result<&'static str> { + let sel = match (old, columns) { + (true, _) => 0, + (false, 1) => 1, + (false, 2) => 2, + (false, 4) => 3, + (false, 8) => 4, + _ => return Err(Error::UnsupportedQwenOperation), + }; + let names = IQ_NAMES.iter().find(|(k, _)| *k == kind).map(|(_, names)| *names); + names.and_then(|names| names.get(sel)).copied().ok_or(Error::UnsupportedQwenOperation) +} + +/// `(div, bytes per item)` of the native head kernel family for `kind`. +fn native_head_geometry(kind: u32) -> Result<(usize, usize)> { + Ok(match kind { + 2 | 6 | 20 => (32, 64), + 8 => (32, 32), + 11..=13 => (256, 8), + 14 => (256, 4), + 23 => (256, 16), + 42 => (64, 64), + _ => return Err(Error::UnsupportedQwenOperation), + }) +} + +fn native_kernel_name(kind: u32, t: usize, mode: usize) -> Result<&'static str> { + let names = match kind { + 2 => &HEAD_N2, + 6 => &HEAD_N6, + 8 => &HEAD_N8, + 20 => &HEAD_N20, + 11 => &HEAD_N11, + 12 => &HEAD_N12, + 13 => &HEAD_N13, + 14 => &HEAD_N14, + 23 => &HEAD_N23, + 42 => &HEAD_N42, + _ => return Err(Error::UnsupportedQwenOperation), + }; + let index = if t == 1 { mode } else { 2 + (t - 2) * 3 + (mode - 2) }; + Ok(names[index]) +} + +fn iq_columns(t: usize) -> usize { + if t <= 2 { + t + } else if t <= 4 { + 4 + } else { + 8 + } +} + +fn native_head_mode(t: usize, small: bool, upstream: bool) -> usize { + if t == 1 { + usize::from(!small) + } else if upstream { + 2 + } else if small { + 3 + } else { + 4 + } +} + +fn native_head_rows(small: bool, upstream: bool) -> usize { + if upstream { + 2 + } else if small { + 4 + } else { + 1 + } +} + pub(super) fn head_dispatch( kind: u32, n: usize, @@ -11,315 +353,14 @@ pub(super) fn head_dispatch( return Err(Error::InvalidQwenShape); } if matches!(kind, 7 | 16 | 17 | 18 | 21 | 22 | 29) { - let columns = if t == 1 { - 1 - } else if t == 2 { - 2 - } else if t <= 4 { - 4 - } else { - 8 - }; - let name = match (kind, if p.old_iq || kind == 7 { 0 } else { columns }) { - (7, 0) => "head_i7_old", - (16, 0) => "head_i16_old", - (16, 1) => "head_i16_c1", - (16, 2) => "head_i16_c2", - (16, 4) => "head_i16_c4", - (16, 8) => "head_i16_c8", - (17, 0) => "head_i17_old", - (17, 1) => "head_i17_c1", - (17, 2) => "head_i17_c2", - (17, 4) => "head_i17_c4", - (17, 8) => "head_i17_c8", - (18, 0) => "head_i18_old", - (18, 1) => "head_i18_c1", - (18, 2) => "head_i18_c2", - (18, 4) => "head_i18_c4", - (18, 8) => "head_i18_c8", - (21, 0) => "head_i21_old", - (21, 1) => "head_i21_c1", - (21, 2) => "head_i21_c2", - (21, 4) => "head_i21_c4", - (21, 8) => "head_i21_c8", - (22, 0) => "head_i22_old", - (22, 1) => "head_i22_c1", - (22, 2) => "head_i22_c2", - (22, 4) => "head_i22_c4", - (22, 8) => "head_i22_c8", - (29, 0) => "head_i29_old", - (29, 1) => "head_i29_c1", - (29, 2) => "head_i29_c2", - (29, 4) => "head_i29_c4", - (29, 8) => "head_i29_c8", - _ => return Err(Error::UnsupportedQwenOperation), - }; + let name = iq_kernel_name(kind, iq_columns(t), p.old_iq || kind == 7)?; return Ok((name, [v.div_ceil(4) as u32, 1, 1], [32, 4, 1], true)); } - let (div, bpi) = match kind { - 2 => (32, 64), - 6 => (32, 64), - 8 => (32, 32), - 20 => (32, 64), - 11 => (256, 8), - 12 => (256, 8), - 13 => (256, 8), - 14 => (256, 4), - 23 => (256, 16), - 42 => (64, 64), - _ => return Err(Error::UnsupportedQwenOperation), - }; + let (div, bpi) = native_head_geometry(kind)?; let small = n / div < bpi; let upstream = t > 1 && !p.multi_exact; - let mode = if t == 1 { - if small { 0 } else { 1 } - } else if upstream { - 2 - } else if small { - 3 - } else { - 4 - }; - let name = match (kind, t, mode) { - (2, 1, 0) => "head_n2_s1", - (2, 1, 1) => "head_n2_s0", - (2, 2, 2) => "head_n2_t2_upstream", - (2, 2, 3) => "head_n2_t2_small", - (2, 2, 4) => "head_n2_t2_large", - (2, 3, 2) => "head_n2_t3_upstream", - (2, 3, 3) => "head_n2_t3_small", - (2, 3, 4) => "head_n2_t3_large", - (2, 4, 2) => "head_n2_t4_upstream", - (2, 4, 3) => "head_n2_t4_small", - (2, 4, 4) => "head_n2_t4_large", - (2, 5, 2) => "head_n2_t5_upstream", - (2, 5, 3) => "head_n2_t5_small", - (2, 5, 4) => "head_n2_t5_large", - (2, 6, 2) => "head_n2_t6_upstream", - (2, 6, 3) => "head_n2_t6_small", - (2, 6, 4) => "head_n2_t6_large", - (2, 7, 2) => "head_n2_t7_upstream", - (2, 7, 3) => "head_n2_t7_small", - (2, 7, 4) => "head_n2_t7_large", - (2, 8, 2) => "head_n2_t8_upstream", - (2, 8, 3) => "head_n2_t8_small", - (2, 8, 4) => "head_n2_t8_large", - (6, 1, 0) => "head_n6_s1", - (6, 1, 1) => "head_n6_s0", - (6, 2, 2) => "head_n6_t2_upstream", - (6, 2, 3) => "head_n6_t2_small", - (6, 2, 4) => "head_n6_t2_large", - (6, 3, 2) => "head_n6_t3_upstream", - (6, 3, 3) => "head_n6_t3_small", - (6, 3, 4) => "head_n6_t3_large", - (6, 4, 2) => "head_n6_t4_upstream", - (6, 4, 3) => "head_n6_t4_small", - (6, 4, 4) => "head_n6_t4_large", - (6, 5, 2) => "head_n6_t5_upstream", - (6, 5, 3) => "head_n6_t5_small", - (6, 5, 4) => "head_n6_t5_large", - (6, 6, 2) => "head_n6_t6_upstream", - (6, 6, 3) => "head_n6_t6_small", - (6, 6, 4) => "head_n6_t6_large", - (6, 7, 2) => "head_n6_t7_upstream", - (6, 7, 3) => "head_n6_t7_small", - (6, 7, 4) => "head_n6_t7_large", - (6, 8, 2) => "head_n6_t8_upstream", - (6, 8, 3) => "head_n6_t8_small", - (6, 8, 4) => "head_n6_t8_large", - (8, 1, 0) => "head_n8_s1", - (8, 1, 1) => "head_n8_s0", - (8, 2, 2) => "head_n8_t2_upstream", - (8, 2, 3) => "head_n8_t2_small", - (8, 2, 4) => "head_n8_t2_large", - (8, 3, 2) => "head_n8_t3_upstream", - (8, 3, 3) => "head_n8_t3_small", - (8, 3, 4) => "head_n8_t3_large", - (8, 4, 2) => "head_n8_t4_upstream", - (8, 4, 3) => "head_n8_t4_small", - (8, 4, 4) => "head_n8_t4_large", - (8, 5, 2) => "head_n8_t5_upstream", - (8, 5, 3) => "head_n8_t5_small", - (8, 5, 4) => "head_n8_t5_large", - (8, 6, 2) => "head_n8_t6_upstream", - (8, 6, 3) => "head_n8_t6_small", - (8, 6, 4) => "head_n8_t6_large", - (8, 7, 2) => "head_n8_t7_upstream", - (8, 7, 3) => "head_n8_t7_small", - (8, 7, 4) => "head_n8_t7_large", - (8, 8, 2) => "head_n8_t8_upstream", - (8, 8, 3) => "head_n8_t8_small", - (8, 8, 4) => "head_n8_t8_large", - (20, 1, 0) => "head_n20_s1", - (20, 1, 1) => "head_n20_s0", - (20, 2, 2) => "head_n20_t2_upstream", - (20, 2, 3) => "head_n20_t2_small", - (20, 2, 4) => "head_n20_t2_large", - (20, 3, 2) => "head_n20_t3_upstream", - (20, 3, 3) => "head_n20_t3_small", - (20, 3, 4) => "head_n20_t3_large", - (20, 4, 2) => "head_n20_t4_upstream", - (20, 4, 3) => "head_n20_t4_small", - (20, 4, 4) => "head_n20_t4_large", - (20, 5, 2) => "head_n20_t5_upstream", - (20, 5, 3) => "head_n20_t5_small", - (20, 5, 4) => "head_n20_t5_large", - (20, 6, 2) => "head_n20_t6_upstream", - (20, 6, 3) => "head_n20_t6_small", - (20, 6, 4) => "head_n20_t6_large", - (20, 7, 2) => "head_n20_t7_upstream", - (20, 7, 3) => "head_n20_t7_small", - (20, 7, 4) => "head_n20_t7_large", - (20, 8, 2) => "head_n20_t8_upstream", - (20, 8, 3) => "head_n20_t8_small", - (20, 8, 4) => "head_n20_t8_large", - (11, 1, 0) => "head_n11_s1", - (11, 1, 1) => "head_n11_s0", - (11, 2, 2) => "head_n11_t2_upstream", - (11, 2, 3) => "head_n11_t2_small", - (11, 2, 4) => "head_n11_t2_large", - (11, 3, 2) => "head_n11_t3_upstream", - (11, 3, 3) => "head_n11_t3_small", - (11, 3, 4) => "head_n11_t3_large", - (11, 4, 2) => "head_n11_t4_upstream", - (11, 4, 3) => "head_n11_t4_small", - (11, 4, 4) => "head_n11_t4_large", - (11, 5, 2) => "head_n11_t5_upstream", - (11, 5, 3) => "head_n11_t5_small", - (11, 5, 4) => "head_n11_t5_large", - (11, 6, 2) => "head_n11_t6_upstream", - (11, 6, 3) => "head_n11_t6_small", - (11, 6, 4) => "head_n11_t6_large", - (11, 7, 2) => "head_n11_t7_upstream", - (11, 7, 3) => "head_n11_t7_small", - (11, 7, 4) => "head_n11_t7_large", - (11, 8, 2) => "head_n11_t8_upstream", - (11, 8, 3) => "head_n11_t8_small", - (11, 8, 4) => "head_n11_t8_large", - (12, 1, 0) => "head_n12_s1", - (12, 1, 1) => "head_n12_s0", - (12, 2, 2) => "head_n12_t2_upstream", - (12, 2, 3) => "head_n12_t2_small", - (12, 2, 4) => "head_n12_t2_large", - (12, 3, 2) => "head_n12_t3_upstream", - (12, 3, 3) => "head_n12_t3_small", - (12, 3, 4) => "head_n12_t3_large", - (12, 4, 2) => "head_n12_t4_upstream", - (12, 4, 3) => "head_n12_t4_small", - (12, 4, 4) => "head_n12_t4_large", - (12, 5, 2) => "head_n12_t5_upstream", - (12, 5, 3) => "head_n12_t5_small", - (12, 5, 4) => "head_n12_t5_large", - (12, 6, 2) => "head_n12_t6_upstream", - (12, 6, 3) => "head_n12_t6_small", - (12, 6, 4) => "head_n12_t6_large", - (12, 7, 2) => "head_n12_t7_upstream", - (12, 7, 3) => "head_n12_t7_small", - (12, 7, 4) => "head_n12_t7_large", - (12, 8, 2) => "head_n12_t8_upstream", - (12, 8, 3) => "head_n12_t8_small", - (12, 8, 4) => "head_n12_t8_large", - (13, 1, 0) => "head_n13_s1", - (13, 1, 1) => "head_n13_s0", - (13, 2, 2) => "head_n13_t2_upstream", - (13, 2, 3) => "head_n13_t2_small", - (13, 2, 4) => "head_n13_t2_large", - (13, 3, 2) => "head_n13_t3_upstream", - (13, 3, 3) => "head_n13_t3_small", - (13, 3, 4) => "head_n13_t3_large", - (13, 4, 2) => "head_n13_t4_upstream", - (13, 4, 3) => "head_n13_t4_small", - (13, 4, 4) => "head_n13_t4_large", - (13, 5, 2) => "head_n13_t5_upstream", - (13, 5, 3) => "head_n13_t5_small", - (13, 5, 4) => "head_n13_t5_large", - (13, 6, 2) => "head_n13_t6_upstream", - (13, 6, 3) => "head_n13_t6_small", - (13, 6, 4) => "head_n13_t6_large", - (13, 7, 2) => "head_n13_t7_upstream", - (13, 7, 3) => "head_n13_t7_small", - (13, 7, 4) => "head_n13_t7_large", - (13, 8, 2) => "head_n13_t8_upstream", - (13, 8, 3) => "head_n13_t8_small", - (13, 8, 4) => "head_n13_t8_large", - (14, 1, 0) => "head_n14_s1", - (14, 1, 1) => "head_n14_s0", - (14, 2, 2) => "head_n14_t2_upstream", - (14, 2, 3) => "head_n14_t2_small", - (14, 2, 4) => "head_n14_t2_large", - (14, 3, 2) => "head_n14_t3_upstream", - (14, 3, 3) => "head_n14_t3_small", - (14, 3, 4) => "head_n14_t3_large", - (14, 4, 2) => "head_n14_t4_upstream", - (14, 4, 3) => "head_n14_t4_small", - (14, 4, 4) => "head_n14_t4_large", - (14, 5, 2) => "head_n14_t5_upstream", - (14, 5, 3) => "head_n14_t5_small", - (14, 5, 4) => "head_n14_t5_large", - (14, 6, 2) => "head_n14_t6_upstream", - (14, 6, 3) => "head_n14_t6_small", - (14, 6, 4) => "head_n14_t6_large", - (14, 7, 2) => "head_n14_t7_upstream", - (14, 7, 3) => "head_n14_t7_small", - (14, 7, 4) => "head_n14_t7_large", - (14, 8, 2) => "head_n14_t8_upstream", - (14, 8, 3) => "head_n14_t8_small", - (14, 8, 4) => "head_n14_t8_large", - (23, 1, 0) => "head_n23_s1", - (23, 1, 1) => "head_n23_s0", - (23, 2, 2) => "head_n23_t2_upstream", - (23, 2, 3) => "head_n23_t2_small", - (23, 2, 4) => "head_n23_t2_large", - (23, 3, 2) => "head_n23_t3_upstream", - (23, 3, 3) => "head_n23_t3_small", - (23, 3, 4) => "head_n23_t3_large", - (23, 4, 2) => "head_n23_t4_upstream", - (23, 4, 3) => "head_n23_t4_small", - (23, 4, 4) => "head_n23_t4_large", - (23, 5, 2) => "head_n23_t5_upstream", - (23, 5, 3) => "head_n23_t5_small", - (23, 5, 4) => "head_n23_t5_large", - (23, 6, 2) => "head_n23_t6_upstream", - (23, 6, 3) => "head_n23_t6_small", - (23, 6, 4) => "head_n23_t6_large", - (23, 7, 2) => "head_n23_t7_upstream", - (23, 7, 3) => "head_n23_t7_small", - (23, 7, 4) => "head_n23_t7_large", - (23, 8, 2) => "head_n23_t8_upstream", - (23, 8, 3) => "head_n23_t8_small", - (23, 8, 4) => "head_n23_t8_large", - (42, 1, 0) => "head_n42_s1", - (42, 1, 1) => "head_n42_s0", - (42, 2, 2) => "head_n42_t2_upstream", - (42, 2, 3) => "head_n42_t2_small", - (42, 2, 4) => "head_n42_t2_large", - (42, 3, 2) => "head_n42_t3_upstream", - (42, 3, 3) => "head_n42_t3_small", - (42, 3, 4) => "head_n42_t3_large", - (42, 4, 2) => "head_n42_t4_upstream", - (42, 4, 3) => "head_n42_t4_small", - (42, 4, 4) => "head_n42_t4_large", - (42, 5, 2) => "head_n42_t5_upstream", - (42, 5, 3) => "head_n42_t5_small", - (42, 5, 4) => "head_n42_t5_large", - (42, 6, 2) => "head_n42_t6_upstream", - (42, 6, 3) => "head_n42_t6_small", - (42, 6, 4) => "head_n42_t6_large", - (42, 7, 2) => "head_n42_t7_upstream", - (42, 7, 3) => "head_n42_t7_small", - (42, 7, 4) => "head_n42_t7_large", - (42, 8, 2) => "head_n42_t8_upstream", - (42, 8, 3) => "head_n42_t8_small", - (42, 8, 4) => "head_n42_t8_large", - _ => return Err(Error::UnsupportedQwenOperation), - }; - let rows = if upstream { - 2 - } else if small { - 4 - } else { - 1 - }; + let name = native_kernel_name(kind, t, native_head_mode(t, small, upstream))?; + let rows = native_head_rows(small, upstream); let nw = if upstream && t > 4 { 2 } else { 4 }; Ok((name, [v.div_ceil(rows) as u32, 1, 1], [32, nw, 1], false)) }