1#[derive(Debug, Clone, PartialEq, Eq, Hash)]
14pub struct KernelTarget {
15 pub arch: &'static str,
17 pub model: &'static str,
19 pub quant: &'static str,
21}
22
23impl KernelTarget {
24 pub const GB10_QWEN3_NVFP4: Self = Self {
26 arch: "sm_121",
27 model: "qwen3-next-80b-a3b",
28 quant: "nvfp4",
29 };
30
31 pub const GB10_QWEN35_NVFP4: Self = Self {
33 arch: "sm_121",
34 model: "qwen3.5-35b-a3b",
35 quant: "nvfp4",
36 };
37
38 pub const GB10_QWEN35_122B_NVFP4: Self = Self {
40 arch: "sm_121",
41 model: "qwen3.5-122b-a10b",
42 quant: "nvfp4",
43 };
44
45 pub fn model_contains(&self, substring: &str) -> bool {
47 self.model.contains(substring)
48 }
49}
50
51impl std::fmt::Display for KernelTarget {
52 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
53 write!(f, "({}, {}, {})", self.arch, self.model, self.quant)
54 }
55}
56
57#[cfg(test)]
58mod tests {
59 use super::*;
60
61 #[test]
62 fn default_target_display() {
63 let t = KernelTarget::GB10_QWEN3_NVFP4;
64 assert_eq!(t.to_string(), "(sm_121, qwen3-next-80b-a3b, nvfp4)");
65 }
66
67 #[test]
68 fn target_equality_observes_each_dispatch_dimension() {
69 let a = KernelTarget::GB10_QWEN3_NVFP4;
70 assert_eq!(a, KernelTarget::GB10_QWEN3_NVFP4);
71 assert_ne!(
72 a,
73 KernelTarget {
74 arch: "sm_100a",
75 ..a
76 }
77 );
78 assert_ne!(
79 a,
80 KernelTarget {
81 model: "llama-70b",
82 ..a
83 }
84 );
85 assert_ne!(a, KernelTarget { quant: "fp8", ..a });
86 }
87}