1use crate::ModelSpec;
4use crate::speech::{self, CloneMode, SpeechProfile};
5use serde::{Deserialize, Serialize};
6
7use super::{Accel, GIB, Hardware};
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
12#[serde(rename_all = "snake_case")]
13#[non_exhaustive]
14pub enum Purpose {
15 Chat,
16 Embedding,
17 Transcribe,
20 Speak,
24}
25
26impl Purpose {
27 pub const ALL: [Purpose; 4] = [Purpose::Chat, Purpose::Embedding, Purpose::Transcribe, Purpose::Speak];
29
30 pub fn as_str(&self) -> &'static str {
32 match self {
33 Purpose::Chat => "chat",
34 Purpose::Embedding => "embedding",
35 Purpose::Transcribe => "transcribe",
36 Purpose::Speak => "speak",
37 }
38 }
39
40 pub fn parse(name: &str) -> Option<Purpose> {
42 Purpose::ALL.into_iter().find(|p| p.as_str() == name)
43 }
44}
45
46impl std::fmt::Display for Purpose {
47 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
48 f.write_str(self.as_str())
49 }
50}
51
52pub const VOXTRAL_MINI_3B: &str = "voxtral-mini-3b";
55
56pub const QWEN3_TTS_0_6B_CUSTOMVOICE: &str = "qwen3-tts-0.6b-customvoice";
61pub const QWEN3_TTS_0_6B_BASE: &str = "qwen3-tts-0.6b-base";
63pub const QWEN3_TTS_1_7B_CUSTOMVOICE: &str = "qwen3-tts-1.7b-customvoice";
65pub const QWEN3_TTS_1_7B_VOICEDESIGN: &str = "qwen3-tts-1.7b-voicedesign";
67pub const QWEN3_TTS_1_7B_BASE: &str = "qwen3-tts-1.7b-base";
69pub const KOKORO_82M: &str = "kokoro-82m";
71pub const VOXCPM2: &str = "voxcpm2";
73pub const FISH_AUDIO_DRAMA_3: &str = "fish-audio-drama-3";
78
79pub const CAVELING_2_MINI: &str = "caveling-2-mini";
83
84pub const INKLING_2_MINI: &str = "inkling-2-mini";
88pub const QWEN3_VL_8B: &str = "qwen3-vl-8b";
91pub const QWEN3_8_27B_NVFP4: &str = "qwen3.8-27b-nvfp4";
94
95pub const QWEN3_ASR_1_7B: &str = "qwen3-asr-1.7b";
100pub const WHISPER_LARGE_V3_TURBO: &str = "whisper-large-v3-turbo";
103pub const COHERE_TRANSCRIBE_03_2026: &str = "cohere-transcribe-03-2026";
107
108const CAVELING_CONTEXT: u32 = 346_112;
112const LOOPED_MINI_KV_BYTES: u64 = 8 * 8 * 256 * 2;
118
119const QWEN3_TTS_TOKENIZER_BYTES: u64 = 682_293_092;
122const DRAMA_3_UPSTREAM: &str = "fishaudio/drama-3";
124
125type Shard = (&'static str, u64, &'static str);
127
128fn later_shards(id: &str) -> &'static [Shard] {
130 match id {
131 QWEN3_ASR_1_7B => &[("model-00002-of-00002.safetensors", 478_200_688, "6e0b9d9e09e2e0238e7ef3cc8a484ab387e91b90f1900bedf88bc92d7929ccfc")],
132 QWEN3_VL_8B => &[
133 ("model-00002-of-00004.safetensors", 4_915_962_496, "8be88fb5501e4d5719a6d4cc212e6a13480330e74f3e8c77daa1a68f199106b5"),
134 ("model-00003-of-00004.safetensors", 4_999_831_048, "83de00eafe6e0d57ccd009dbcf71c9974d74df2f016c27afb7e95aafd16b2192"),
135 ("model-00004-of-00004.safetensors", 2_716_270_024, "0a88b98e9f96270973f567e6a2c103ede6ccdf915ca3075e21c755604d0377a5"),
136 ],
137 QWEN3_8_27B_NVFP4 => &[
138 ("model-00002-of-00003.safetensors", 9_985_757_064, "db6146a5464fb0a891181b93c81593f0ca65c602eb14120a1c2b1b09bca11f85"),
139 ("model-00003-of-00003.safetensors", 1_970_287_672, "d3cfb92742e30c8b46564665791dbe0a86ed64cfc02b1275081530793c0c9581"),
140 ],
141 _ => &[],
142 }
143}
144
145#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
147pub struct CatalogEntry {
148 pub spec: ModelSpec,
149 pub purpose: Purpose,
150 pub quant: String,
151 pub params_b: f32,
153 pub active_params_b: f32,
154 pub kv_bytes_per_token: u64,
156 pub context: u32,
158}
159
160impl CatalogEntry {
161 pub fn id(&self) -> &str {
162 &self.spec.id
163 }
164
165 pub fn footprint(&self, slots: u32) -> u64 {
169 let kv = self.kv_bytes_per_token * self.context as u64 * slots as u64;
170 let weights = self.weights_bytes() + self.projector().map_or(0, |p| p.size) + self.companion_bytes();
171 (weights + kv) + (weights + kv) / 10
172 }
173
174 fn companion_bytes(&self) -> u64 {
175 match self.spec.id.as_str() {
176 QWEN3_TTS_0_6B_CUSTOMVOICE | QWEN3_TTS_0_6B_BASE | QWEN3_TTS_1_7B_CUSTOMVOICE | QWEN3_TTS_1_7B_VOICEDESIGN => QWEN3_TTS_TOKENIZER_BYTES,
177 _ => 0,
178 }
179 }
180
181 pub fn files(&self) -> Vec<ModelSpec> {
204 let mut files = vec![self.spec.clone()];
205 files.extend(later_shards(&self.spec.id).iter().map(|&(file, size, sha256)| ModelSpec {
206 file: file.into(),
207 size,
208 sha256: Some(sha256.into()),
209 ..self.spec.clone()
210 }));
211 files
212 }
213
214 pub fn is_sharded(&self) -> bool {
216 !later_shards(&self.spec.id).is_empty()
217 }
218
219 pub fn weights_bytes(&self) -> u64 {
222 self.spec.size + later_shards(&self.spec.id).iter().map(|s| s.1).sum::<u64>()
223 }
224
225 pub fn revision(&self) -> Option<&'static str> {
231 match self.spec.id.as_str() {
232 CAVELING_2_MINI => Some("ec4b4b4114cf8375abc1cf42d6c41971b778e2ba"),
233 INKLING_2_MINI => Some("0bdc580634ceac4c4d921f452777bf44228de9af"),
234 QWEN3_VL_8B => Some("0c351dd01ed87e9c1b53cbc748cba10e6187ff3b"),
235 QWEN3_8_27B_NVFP4 => Some("319f741cce68d7914884900c138a1fbb70a42f30"),
236 QWEN3_ASR_1_7B => Some("7278e1e70fe206f11671096ffdd38061171dd6e5"),
237 WHISPER_LARGE_V3_TURBO => Some("41f01f3fe87f28c78e2fbf8b568835947dd65ed9"),
238 COHERE_TRANSCRIBE_03_2026 => Some("d552dadc2922ba6f6c1f994f8db904d52dcaf942"),
239 _ => None,
240 }
241 }
242
243 pub fn engine_args(&self) -> &'static [&'static str] {
260 match self.spec.id.as_str() {
261 CAVELING_2_MINI | INKLING_2_MINI => &["-fa", "on", "--jinja"],
262 COHERE_TRANSCRIBE_03_2026 => &["--trust-remote-code"],
263 _ => &[],
264 }
265 }
266
267 pub fn launch_context(&self) -> Option<u32> {
272 matches!(self.spec.id.as_str(), CAVELING_2_MINI | INKLING_2_MINI).then_some(CAVELING_CONTEXT)
273 }
274
275 pub fn launch_gpu_layers(&self) -> Option<u32> {
279 matches!(self.spec.id.as_str(), CAVELING_2_MINI | INKLING_2_MINI).then_some(99)
280 }
281
282 pub fn gated(&self) -> bool {
287 self.spec.id == COHERE_TRANSCRIBE_03_2026
288 }
289
290 pub fn is_gguf(&self) -> bool {
295 self.spec.file.to_ascii_lowercase().ends_with(".gguf")
296 }
297
298 pub fn speaks(&self) -> bool {
300 self.purpose == Purpose::Speak
301 }
302
303 pub fn license(&self) -> Option<&'static str> {
309 match self.spec.id.as_str() {
310 FISH_AUDIO_DRAMA_3 => Some(speech::FISH_AUDIO_COMMUNITY),
311 WHISPER_LARGE_V3_TURBO => Some("mit"),
312 VOXTRAL_MINI_3B
313 | CAVELING_2_MINI
314 | INKLING_2_MINI
315 | QWEN3_VL_8B
316 | QWEN3_8_27B_NVFP4
317 | QWEN3_ASR_1_7B
318 | COHERE_TRANSCRIBE_03_2026
319 | QWEN3_TTS_0_6B_CUSTOMVOICE
320 | QWEN3_TTS_0_6B_BASE
321 | QWEN3_TTS_1_7B_CUSTOMVOICE
322 | QWEN3_TTS_1_7B_VOICEDESIGN
323 | QWEN3_TTS_1_7B_BASE
324 | KOKORO_82M
325 | VOXCPM2 => Some("apache-2.0"),
326 _ => None,
327 }
328 }
329
330 pub fn restricted(&self) -> bool {
335 speech::restricting_license(self.license()).is_some()
336 }
337
338 pub fn speech(&self) -> Option<SpeechProfile> {
357 if !self.speaks() {
358 return None;
359 }
360 let qwen_vllm = || speech::vllm_omni().with_languages(speech::QWEN3_TTS_LANGUAGES).with_sample_rate(24_000);
361 Some(match self.spec.id.as_str() {
362 QWEN3_TTS_0_6B_CUSTOMVOICE => qwen_vllm().with_presets(QWEN3_TTS_SPEAKERS),
363 QWEN3_TTS_1_7B_CUSTOMVOICE => qwen_vllm().with_presets(QWEN3_TTS_SPEAKERS).with_instructions(true),
364 QWEN3_TTS_1_7B_VOICEDESIGN => qwen_vllm().with_design(true),
365 QWEN3_TTS_0_6B_BASE => qwen_vllm().with_clone(CloneMode::AudioAndText),
366 QWEN3_TTS_1_7B_BASE => {
367 speech::llama_server().with_languages(speech::QWEN3_TTS_LANGUAGES).with_sample_rate(24_000).with_clone(CloneMode::Audio)
368 }
369 KOKORO_82M => speech::llama_server()
370 .with_presets(KOKORO_VOICES)
371 .with_languages(speech::KOKORO_LANGUAGES)
372 .with_raw(true)
373 .with_speed(true)
374 .with_sample_rate(24_000),
375 VOXCPM2 => speech::llama_server()
376 .with_design(true)
377 .with_clone(CloneMode::Audio)
378 .with_max_reference_seconds(30)
379 .with_languages(VOXCPM2_LANGUAGES)
380 .with_sample_rate(48_000),
381 FISH_AUDIO_DRAMA_3 => speech::llama_server()
382 .with_script_speakers(16)
383 .with_languages(DRAMA_3_LANGUAGES)
384 .with_sample_rate(44_100)
385 .with_license(speech::FISH_AUDIO_COMMUNITY),
386 _ => return None,
387 })
388 }
389
390 fn license_repos(&self) -> Vec<&str> {
393 let mut repos = vec![self.spec.repo.as_str()];
394 if self.spec.id == FISH_AUDIO_DRAMA_3 {
395 repos.push(DRAMA_3_UPSTREAM);
396 }
397 repos
398 }
399
400 pub fn projector(&self) -> Option<ModelSpec> {
406 match self.spec.id.as_str() {
407 VOXTRAL_MINI_3B => Some(spec(
408 "voxtral-mini-3b-mmproj",
409 "Voxtral Mini 3B audio encoder (Q8_0)",
410 "ggml-org/Voxtral-Mini-3B-2507-GGUF",
411 "mmproj-Voxtral-Mini-3B-2507-Q8_0.gguf",
412 715_714_080,
413 "4f24c4ef3ce929d02ed9d1cfb050ae9a7365f057c0ddec0d489580982ebe0d02",
414 )),
415 CAVELING_2_MINI => Some(spec(
416 "caveling-2-mini-mmproj",
417 "Caveling 2 Mini vision encoder (Q8_0)",
418 "caveman-so/caveling-2-mini-GGUF",
419 "mmproj-Caveling-2-Mini-Q8_0.gguf",
420 345_911_360,
421 "ff510827b8f496f6e0755a374c74d8aee0ab5186d953e0e3a6d1fb17a98d3e9f",
422 )),
423 INKLING_2_MINI => Some(spec(
424 "inkling-2-mini-mmproj",
425 "Inkling 2 Mini vision encoder (Q8_0)",
426 "ggml-org/Inkling-2-Mini-GGUF",
427 "mmproj-Inkling-2-Mini-Q8_0.gguf",
428 345_910_944,
429 "233287272ec5ac39b4168677aba54a4c024f202410f5629fac1830e1059f8abb",
430 )),
431 QWEN3_TTS_1_7B_BASE => Some(spec(
432 "qwen3-tts-1.7b-base-mmproj",
433 "Qwen3-TTS 1.7B Base speaker encoder and codec (Q8_0)",
434 "ggml-org/Qwen3-TTS-12Hz-1.7B-Base-GGUF",
435 "mmproj-Qwen3-TTS-12Hz-1.7B-Base-Q8_0.gguf",
436 446_422_912,
437 "6fd65188839bcd6ecc91b277ad471e22a0edfada4699a0fe82f1165c18cfcce2",
438 )),
439 KOKORO_82M => Some(spec(
440 "kokoro-82m-mmproj",
441 "Kokoro 82M decoder and voices (F16)",
442 "ggml-org/Kokoro-82M-GGUF",
443 "mmproj-Kokoro-82M-F16.gguf",
444 208_456_512,
445 "071d20f53b7c5d64b08a24bff5dfb77c2ea0df843a7c6c2356998a735ec6929d",
446 )),
447 VOXCPM2 => Some(spec(
448 "voxcpm2-mmproj",
449 "VoxCPM2 LocDiT and AudioVAE (BF16)",
450 "ggml-org/VoxCPM2-GGUF",
451 "mmproj-VoxCPM2-BF16.gguf",
452 2_007_741_504,
453 "2d0be367461d11e12a8544487491936a8f1d61d70d5313bb25dd50a4693be2ee",
454 )),
455 FISH_AUDIO_DRAMA_3 => Some(spec(
456 "fish-audio-drama-3-mmproj",
457 "Fish Audio Drama 3 codebook tower and codec (BF16)",
458 "ggml-org/drama-3-GGUF",
459 "mmproj-drama-3-BF16.gguf",
460 2_942_644_160,
461 "c29b9c90cf180cf81da39f31f023ba33641d54d7898e5e9be032c4d111ecbced",
462 )),
463 _ => None,
464 }
465 }
466
467 pub fn transcribes(&self) -> bool {
469 self.purpose == Purpose::Transcribe
470 }
471}
472
473fn spec(id: &str, label: &str, repo: &str, file: &str, size: u64, sha256: &str) -> ModelSpec {
474 ModelSpec { id: id.into(), label: label.into(), repo: repo.into(), file: file.into(), size, sha256: Some(sha256.into()) }
475}
476
477#[allow(clippy::too_many_arguments)]
478fn chat(spec: ModelSpec, quant: &str, params_b: f32, active_params_b: f32, kv_bytes_per_token: u64, context: u32) -> CatalogEntry {
479 CatalogEntry { spec, purpose: Purpose::Chat, quant: quant.into(), params_b, active_params_b, kv_bytes_per_token, context }
480}
481
482#[allow(clippy::too_many_arguments)]
483fn speaker_entry(spec: ModelSpec, quant: &str, params_b: f32, active_params_b: f32, kv_bytes_per_token: u64, context: u32) -> CatalogEntry {
484 CatalogEntry { spec, purpose: Purpose::Speak, quant: quant.into(), params_b, active_params_b, kv_bytes_per_token, context }
485}
486
487const QWEN3_TTS_SPEAKERS: [&str; 9] = ["vivian", "serena", "uncle_fu", "dylan", "eric", "ryan", "aiden", "ono_anna", "sohee"];
489
490const KOKORO_VOICES: [&str; 54] = [
494 "af_heart",
495 "af_alloy",
496 "af_aoede",
497 "af_bella",
498 "af_jessica",
499 "af_kore",
500 "af_nicole",
501 "af_nova",
502 "af_river",
503 "af_sarah",
504 "af_sky",
505 "am_adam",
506 "am_echo",
507 "am_eric",
508 "am_fenrir",
509 "am_liam",
510 "am_michael",
511 "am_onyx",
512 "am_puck",
513 "am_santa",
514 "bf_alice",
515 "bf_emma",
516 "bf_isabella",
517 "bf_lily",
518 "bm_daniel",
519 "bm_fable",
520 "bm_george",
521 "bm_lewis",
522 "ef_dora",
523 "em_alex",
524 "em_santa",
525 "ff_siwis",
526 "hf_alpha",
527 "hf_beta",
528 "hm_omega",
529 "hm_psi",
530 "if_sara",
531 "im_nicola",
532 "jf_alpha",
533 "jf_gongitsune",
534 "jf_nezumi",
535 "jf_tebukuro",
536 "jm_kumo",
537 "pf_dora",
538 "pm_alex",
539 "pm_santa",
540 "zf_xiaobei",
541 "zf_xiaoni",
542 "zf_xiaoxiao",
543 "zf_xiaoyi",
544 "zm_yunjian",
545 "zm_yunxi",
546 "zm_yunxia",
547 "zm_yunyang",
548];
549
550const VOXCPM2_LANGUAGES: [&str; 30] = [
552 "zh", "en", "ar", "my", "da", "nl", "fi", "fr", "de", "el", "he", "hi", "id", "it", "ja", "km", "ko", "lo", "ms", "no", "pl", "pt", "ru", "es",
553 "sw", "sv", "tl", "th", "tr", "vi",
554];
555
556const DRAMA_3_LANGUAGES: [&str; 83] = [
558 "zh", "en", "ja", "ko", "es", "pt", "ar", "ru", "fr", "de", "sv", "it", "tr", "no", "nl", "cy", "eu", "ca", "da", "gl", "ta", "hu", "fi", "pl",
559 "et", "hi", "la", "ur", "th", "vi", "jw", "bn", "yo", "sl", "cs", "sw", "nn", "he", "ms", "uk", "id", "kk", "bg", "lv", "my", "tl", "sk", "ne",
560 "fa", "af", "el", "bo", "hr", "ro", "sn", "mi", "yi", "am", "be", "km", "is", "az", "sd", "br", "sq", "ps", "mn", "ht", "ml", "sr", "sa", "te",
561 "ka", "bs", "pa", "lt", "kn", "si", "hy", "mr", "as", "gu", "fo",
562];
563
564pub fn catalog() -> Vec<CatalogEntry> {
570 let gemma = |id: &str| crate::catalog::find(id).expect("weirdnet-model ships Gemma 4");
571 vec![
572 chat(
573 spec(
574 "smollm2-135m",
575 "SmolLM2 135M instruct (Q8_0)",
576 "bartowski/SmolLM2-135M-Instruct-GGUF",
577 "SmolLM2-135M-Instruct-Q8_0.gguf",
578 144_811_360,
579 "5a1395716f7913741cc51d98581b9b1228d80987a9f7d3664106742eb06bba83",
580 ),
581 "Q8_0",
582 0.135,
583 0.135,
584 23_040,
585 8192,
586 ),
587 chat(gemma(crate::catalog::GEMMA_4_E2B), "Q4_0", 5.1, 2.0, 32_768, 8192),
588 chat(gemma(crate::catalog::GEMMA_4_E4B), "Q4_0", 8.0, 4.0, 65_536, 8192),
589 chat(
590 spec(
591 "qwen3-8b",
592 "Qwen3 8B (Q4_K_M)",
593 "unsloth/Qwen3-8B-GGUF",
594 "Qwen3-8B-Q4_K_M.gguf",
595 5_027_784_512,
596 "120307ba529eb2439d6c430d94104dabd578497bc7bfe7e322b5d9933b449bd4",
597 ),
598 "Q4_K_M",
599 8.2,
600 8.2,
601 147_456,
602 8192,
603 ),
604 chat(
605 spec(
606 "qwen3-14b",
607 "Qwen3 14B (Q4_K_M)",
608 "unsloth/Qwen3-14B-GGUF",
609 "Qwen3-14B-Q4_K_M.gguf",
610 9_001_753_984,
611 "5eaa0870bd81ed3b58a630a271234cfa604e43ffb3a19cd68e54a80dd9d52a66",
612 ),
613 "Q4_K_M",
614 14.8,
615 14.8,
616 163_840,
617 8192,
618 ),
619 chat(
620 spec(
621 "gpt-oss-20b",
622 "gpt-oss 20B (MXFP4)",
623 "ggml-org/gpt-oss-20b-GGUF",
624 "gpt-oss-20b-MXFP4.gguf",
625 12_109_566_624,
626 "27cd6c432c7672cb812a92f611cf3ba7bbc35928262bb1e1253ff4ee6ae35901",
627 ),
628 "MXFP4",
629 21.0,
630 3.6,
631 49_152,
632 8192,
633 ),
634 chat(
644 spec(
645 CAVELING_2_MINI,
646 "Caveling 2 Mini (Q4_K_M)",
647 "caveman-so/caveling-2-mini-GGUF",
648 "Caveling-2-Mini-Q4_K_M.gguf",
649 18_398_579_616,
650 "aab63d16dac44b32f57d53aa1982e9f18f130b88b992c10539f24feee87cd254",
651 ),
652 "Q4_K_M",
653 26.0,
654 3.4,
655 LOOPED_MINI_KV_BYTES,
656 CAVELING_CONTEXT,
657 ),
658 chat(
664 spec(
665 INKLING_2_MINI,
666 "Inkling 2 Mini (IQ4_NL)",
667 "ggml-org/Inkling-2-Mini-GGUF",
668 "Inkling-2-Mini-IQ4_NL.gguf",
669 17_627_940_768,
670 "cbdf3fa9dc50a4124977980f37da4f1fa764b0cfe800d275cd43d26ce2a81af4",
671 ),
672 "IQ4_NL",
673 26.0,
674 3.4,
675 LOOPED_MINI_KV_BYTES,
676 CAVELING_CONTEXT,
677 ),
678 chat(
679 spec(
680 "qwen3-30b-a3b",
681 "Qwen3 30B-A3B (Q4_K_M)",
682 "unsloth/Qwen3-30B-A3B-GGUF",
683 "Qwen3-30B-A3B-Q4_K_M.gguf",
684 18_556_686_912,
685 "9f1a24700a339b09c06009b729b5c809e0b64c213b8af5b711b3dbdfd0c5ba48",
686 ),
687 "Q4_K_M",
688 30.5,
689 3.3,
690 98_304,
691 8192,
692 ),
693 chat(
694 spec(
695 "qwen3-32b",
696 "Qwen3 32B (Q4_K_M)",
697 "unsloth/Qwen3-32B-GGUF",
698 "Qwen3-32B-Q4_K_M.gguf",
699 19_762_150_048,
700 "8df67573b2c23484e02ec7af295e39bed7ee774f3771d5fda2978265b59370e7",
701 ),
702 "Q4_K_M",
703 32.8,
704 32.8,
705 262_144,
706 8192,
707 ),
708 chat(
716 spec(
717 QWEN3_VL_8B,
718 "Qwen3-VL 8B Instruct (BF16, vLLM)",
719 "Qwen/Qwen3-VL-8B-Instruct",
720 "model-00001-of-00004.safetensors",
721 4_902_275_944,
722 "d5d0aef0eb170fc7453a296c43c0849a56f510555d3588e4fd662bb35490aefa",
723 ),
724 "BF16",
725 8.77,
726 8.77,
727 36 * 8 * 256 * 2,
728 32_768,
729 ),
730 chat(
735 spec(
736 QWEN3_8_27B_NVFP4,
737 "Qwen3.8 27B (NVFP4, vLLM, Blackwell)",
738 "RadixArk/Qwen3.8-27B-NVFP4",
739 "model-00001-of-00003.safetensors",
740 9_965_652_544,
741 "fbcdb5ba1cdda462b5f38592d071e772c4d398afea61a0aa9188b32d1a239a79",
742 ),
743 "NVFP4",
744 27.0,
745 27.0,
746 16 * 4 * 512 * 2,
747 131_072,
748 ),
749 CatalogEntry {
750 spec: spec(
751 "qwen3-embedding-0.6b",
752 "Qwen3 Embedding 0.6B (Q8_0)",
753 "Qwen/Qwen3-Embedding-0.6B-GGUF",
754 "Qwen3-Embedding-0.6B-Q8_0.gguf",
755 639_150_592,
756 "06507c7b42688469c4e7298b0a1e16deff06caf291cf0a5b278c308249c3e439",
757 ),
758 purpose: Purpose::Embedding,
759 quant: "Q8_0".into(),
760 params_b: 0.6,
761 active_params_b: 0.6,
762 kv_bytes_per_token: 114_688,
763 context: 2048,
764 },
765 CatalogEntry {
769 spec: spec(
770 VOXTRAL_MINI_3B,
771 "Voxtral Mini 3B speech to text (Q4_K_M)",
772 "ggml-org/Voxtral-Mini-3B-2507-GGUF",
773 "Voxtral-Mini-3B-2507-Q4_K_M.gguf",
774 2_473_001_920,
775 "4705be8ec22ca23d12632f4b4a3691faa95917d90a06d3cf3c3ec0e91958f1a8",
776 ),
777 purpose: Purpose::Transcribe,
778 quant: "Q4_K_M".into(),
779 params_b: 4.7,
780 active_params_b: 4.7,
781 kv_bytes_per_token: 122_880,
782 context: 16_384,
783 },
784 CatalogEntry {
791 spec: spec(
792 QWEN3_ASR_1_7B,
793 "Qwen3-ASR 1.7B speech to text (BF16, vLLM)",
794 "Qwen/Qwen3-ASR-1.7B",
795 "model-00001-of-00002.safetensors",
796 4_220_320_824,
797 "a4cd1f1a04d90b757dc7f7dd26254e69a013b19e80efe590a83c6a3bde8608d6",
798 ),
799 purpose: Purpose::Transcribe,
800 quant: "BF16".into(),
801 params_b: 2.35,
802 active_params_b: 2.35,
803 kv_bytes_per_token: 28 * 8 * 256 * 2,
804 context: 8192,
805 },
806 CatalogEntry {
811 spec: spec(
812 WHISPER_LARGE_V3_TURBO,
813 "Whisper large-v3-turbo speech to text (FP16, vLLM)",
814 "openai/whisper-large-v3-turbo",
815 "model.safetensors",
816 1_617_824_864,
817 "542566a422ae4f3fd23f1ba11add198fca01bbf82e66e6a2857b3f608b1eb9d1",
818 ),
819 purpose: Purpose::Transcribe,
820 quant: "F16".into(),
821 params_b: 0.81,
822 active_params_b: 0.81,
823 kv_bytes_per_token: 4 * 20 * 128 * 2,
824 context: 448 + 1500,
825 },
826 CatalogEntry {
831 spec: spec(
832 COHERE_TRANSCRIBE_03_2026,
833 "Cohere Transcribe 03-2026 speech to text (BF16, vLLM, gated)",
834 "CohereLabs/cohere-transcribe-03-2026",
835 "model.safetensors",
836 4_131_862_976,
837 "987bd3e141c7bfdb5a78f5db11397ee7737308357e6cc0a3f36a4979b158137a",
838 ),
839 purpose: Purpose::Transcribe,
840 quant: "BF16".into(),
841 params_b: 2.07,
842 active_params_b: 2.07,
843 kv_bytes_per_token: 28 * 8 * 256 * 2,
844 context: 4096,
845 },
846 speaker_entry(
856 spec(
857 QWEN3_TTS_0_6B_CUSTOMVOICE,
858 "Qwen3-TTS 0.6B CustomVoice (BF16, vLLM-Omni)",
859 "Qwen/Qwen3-TTS-12Hz-0.6B-CustomVoice",
860 "model.safetensors",
861 1_811_626_576,
862 "bc3c7e785eb961179c25450d1acff03f839e0002f2f3a5aeb67b5735c0fa2adb",
863 ),
864 "BF16",
865 0.6,
866 0.6,
867 114_688,
868 4096,
869 ),
870 speaker_entry(
871 spec(
872 QWEN3_TTS_0_6B_BASE,
873 "Qwen3-TTS 0.6B Base, voice cloning (BF16, vLLM-Omni)",
874 "Qwen/Qwen3-TTS-12Hz-0.6B-Base",
875 "model.safetensors",
876 1_829_344_272,
877 "180b3b10eb1c9f1b4db7806d5475bae3071c0243c299d49926bab1da3b6946f6",
878 ),
879 "BF16",
880 0.6,
881 0.6,
882 114_688,
883 4096,
884 ),
885 speaker_entry(
886 spec(
887 QWEN3_TTS_1_7B_CUSTOMVOICE,
888 "Qwen3-TTS 1.7B CustomVoice (BF16, vLLM-Omni)",
889 "Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice",
890 "model.safetensors",
891 3_833_402_552,
892 "38b1d5971bdbd982b561cccec982669a53b0537c3cf5e9bd4778ed07bb2f5137",
893 ),
894 "BF16",
895 1.7,
896 1.7,
897 114_688,
898 4096,
899 ),
900 speaker_entry(
901 spec(
902 QWEN3_TTS_1_7B_VOICEDESIGN,
903 "Qwen3-TTS 1.7B VoiceDesign (BF16, vLLM-Omni)",
904 "Qwen/Qwen3-TTS-12Hz-1.7B-VoiceDesign",
905 "model.safetensors",
906 3_833_402_552,
907 "391e8db219f292c515297cdceeb43e4eae67cdde35fa57e79a6a8a532fca0522",
908 ),
909 "BF16",
910 1.7,
911 1.7,
912 114_688,
913 4096,
914 ),
915 speaker_entry(
916 spec(
917 QWEN3_TTS_1_7B_BASE,
918 "Qwen3-TTS 1.7B Base, voice cloning (Q8_0)",
919 "ggml-org/Qwen3-TTS-12Hz-1.7B-Base-GGUF",
920 "Qwen3-TTS-12Hz-1.7B-Base-Q8_0.gguf",
921 1_847_874_400,
922 "ac7931aeb2e7aad1a6ed6602d353a5679c9d096b18ce8204ac730a8408d572e1",
923 ),
924 "Q8_0",
925 1.7,
926 1.7,
927 114_688,
928 4096,
929 ),
930 speaker_entry(
933 spec(
934 KOKORO_82M,
935 "Kokoro 82M (F32)",
936 "ggml-org/Kokoro-82M-GGUF",
937 "Kokoro-82M-F32.gguf",
938 61_774_240,
939 "be19298184f1a2577eb20e4689f1e2b315cbf474c39e113f192991fef3c85c6e",
940 ),
941 "F32",
942 0.082,
943 0.082,
944 36_864,
945 512,
946 ),
947 speaker_entry(
951 spec(
952 VOXCPM2,
953 "VoxCPM2, voice design and cloning (Q8_0)",
954 "ggml-org/VoxCPM2-GGUF",
955 "VoxCPM2-Q8_0.gguf",
956 1_565_764_064,
957 "b09cd3afab454f23922632fd474aa0d5d667e128e8bf36e81e77ec7e71fac64b",
958 ),
959 "Q8_0",
960 2.0,
961 2.0,
962 28_672 + 6_144,
963 4096,
964 ),
965 speaker_entry(
970 spec(
971 FISH_AUDIO_DRAMA_3,
972 "Fish Audio Drama 3, multi-speaker (Q4_K_M)",
973 "ggml-org/drama-3-GGUF",
974 "drama-3-Q4_K_M.gguf",
975 20_556_053_760,
976 "5b727d669a7a555713403b7f6d744402dafd6fd37154f0fe834a5310548a8b34",
977 ),
978 "Q4_K_M",
979 35.0,
980 3.0,
981 20_480 + 13_312,
982 4096,
983 ),
984 ]
985}
986
987pub fn by_purpose(purpose: Purpose) -> Vec<CatalogEntry> {
989 catalog().into_iter().filter(|e| e.purpose == purpose).collect()
990}
991
992pub fn transcriber(budget: &Budget) -> Option<CatalogEntry> {
999 by_purpose(Purpose::Transcribe)
1000 .into_iter()
1001 .filter(|e| e.is_gguf() && e.footprint(1) <= budget.usable_bytes)
1002 .max_by(|a, b| a.params_b.total_cmp(&b.params_b))
1003}
1004
1005pub fn speaker(budget: &Budget) -> Option<CatalogEntry> {
1010 by_purpose(Purpose::Speak)
1011 .into_iter()
1012 .filter(|e| e.is_gguf() && !e.restricted() && e.footprint(1) <= budget.usable_bytes)
1013 .max_by(|a, b| a.params_b.total_cmp(&b.params_b))
1014}
1015
1016pub fn restricted_license(spec: &ModelSpec) -> Option<&'static str> {
1022 catalog()
1023 .into_iter()
1024 .filter(CatalogEntry::restricted)
1025 .find(|e| {
1026 e.spec.id == spec.id
1027 || e.projector().is_some_and(|p| p.id == spec.id)
1028 || e.license_repos().iter().any(|r| r.eq_ignore_ascii_case(&spec.repo))
1029 })
1030 .and_then(|e| e.license())
1031}
1032
1033pub fn gated(spec: &ModelSpec) -> bool {
1037 catalog().iter().filter(|e| e.gated()).any(|e| e.spec.id == spec.id || e.spec.repo.eq_ignore_ascii_case(&spec.repo))
1038}
1039
1040pub fn find(id: &str) -> Option<CatalogEntry> {
1042 catalog().into_iter().find(|e| e.spec.id == id)
1043}
1044
1045#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
1047pub struct Budget {
1048 pub pool_bytes: u64,
1050 pub reserve_bytes: u64,
1052 pub usable_bytes: u64,
1053}
1054
1055pub fn budget(hw: &Hardware, memory_budget: Option<u64>, reserve: Option<u64>) -> Budget {
1058 let unified = hw.unified();
1059 let pool_bytes = if unified { hw.ram_bytes } else { hw.gpus.first().map(|g| g.memory_bytes).unwrap_or(hw.ram_bytes) };
1060 let reserve_bytes = if unified { reserve.unwrap_or_else(|| (hw.ram_bytes / 8).max(4 * GIB)) } else { 0 };
1061 let usable = pool_bytes.saturating_sub(reserve_bytes) / 100 * 85;
1062 Budget { pool_bytes, reserve_bytes, usable_bytes: memory_budget.unwrap_or(usable) }
1063}
1064
1065#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1067pub struct Plan {
1068 pub budget: Budget,
1069 pub main: Option<CatalogEntry>,
1070 pub standin: Option<CatalogEntry>,
1071 pub embedding: Option<CatalogEntry>,
1072 pub slots: u32,
1074 pub notes: Vec<String>,
1075}
1076
1077pub fn plan(hw: &Hardware, budget: Budget) -> Plan {
1081 let slots = 2;
1082 let cpu_only = hw.accel() == Accel::Cpu;
1083 let mut notes = Vec::new();
1084 let all = catalog();
1085 let fits = |e: &&CatalogEntry| e.footprint(slots) <= budget.usable_bytes;
1086 let main = all
1087 .iter()
1088 .filter(|e| e.purpose == Purpose::Chat && e.is_gguf() && e.spec.id != "smollm2-135m")
1089 .filter(|e| !cpu_only || e.active_params_b <= 4.0)
1090 .filter(fits)
1091 .max_by(|a, b| a.params_b.total_cmp(&b.params_b))
1092 .cloned();
1093 if cpu_only {
1094 notes.push("CPU only: limited to models with at most 4B active parameters".into());
1095 }
1096 if main.is_none() {
1097 notes.push("no catalog chat model fits this budget; add a smaller GGUF model".into());
1098 }
1099 let standin_id = if budget.usable_bytes >= 16 * GIB { crate::catalog::GEMMA_4_E4B } else { crate::catalog::GEMMA_4_E2B };
1100 let standin = all.iter().find(|e| e.spec.id == standin_id).filter(fits).filter(|e| main.as_ref().is_none_or(|m| m.spec.id != e.spec.id)).cloned();
1101 let embedding = all.iter().find(|e| e.purpose == Purpose::Embedding).filter(|e| e.footprint(1) <= budget.usable_bytes).cloned();
1102 Plan { budget, main, standin, embedding, slots, notes }
1103}
1104
1105#[cfg(test)]
1106mod tests {
1107 use super::*;
1108 use crate::hw::{Gpu, parse_nvidia_smi};
1109
1110 fn box_with(gpus: Vec<Gpu>, ram_gib: u64) -> Hardware {
1111 Hardware { os: "linux".into(), arch: "x86_64".into(), cpu_threads: 16, ram_bytes: ram_gib * GIB, gpus }
1112 }
1113
1114 #[test]
1115 fn rtx_3060_gets_an_8b() {
1116 let hw = box_with(parse_nvidia_smi("NVIDIA GeForce RTX 3060, 12288, 8.6, 615.78.08", 62 * GIB), 62);
1117 let b = budget(&hw, None, None);
1118 assert_eq!(b.pool_bytes, 12 * GIB);
1119 let p = plan(&hw, b);
1120 assert_eq!(p.main.unwrap().id(), "qwen3-8b");
1121 assert_eq!(p.standin.unwrap().id(), "gemma-4-e2b");
1122 assert!(p.embedding.is_some());
1123 }
1124
1125 #[test]
1126 fn spark_gets_a_big_model() {
1127 let hw = box_with(parse_nvidia_smi("NVIDIA GB10, [N/A], 12.1, 580.95.05", 128 * GIB), 128);
1128 let b = budget(&hw, None, None);
1129 assert_eq!(b.reserve_bytes, 16 * GIB);
1130 let p = plan(&hw, b);
1131 assert_eq!(p.main.unwrap().id(), "qwen3-32b");
1132 assert_eq!(p.standin.unwrap().id(), "gemma-4-e4b");
1133 }
1134
1135 #[test]
1136 fn cpu_box_prefers_few_active_params() {
1137 let hw = box_with(Vec::new(), 62);
1138 let p = plan(&hw, budget(&hw, None, None));
1139 assert_eq!(p.main.unwrap().id(), "qwen3-30b-a3b");
1140 }
1141
1142 #[test]
1143 fn tiny_box_gets_no_main() {
1144 let hw = box_with(Vec::new(), 4);
1145 let p = plan(&hw, budget(&hw, Some(GIB), None));
1146 assert!(p.main.is_none());
1147 assert!(!p.notes.is_empty());
1148 }
1149
1150 #[test]
1151 fn override_budget() {
1152 let hw = box_with(Vec::new(), 64);
1153 assert_eq!(budget(&hw, Some(10 * GIB), None).usable_bytes, 10 * GIB);
1154 assert_eq!(budget(&hw, None, Some(14 * GIB)).reserve_bytes, 14 * GIB);
1155 }
1156
1157 #[test]
1158 fn transcribe_is_a_purpose_of_its_own() {
1159 assert_eq!(serde_json::to_string(&Purpose::Transcribe).unwrap(), "\"transcribe\"");
1160 for p in Purpose::ALL {
1161 assert_eq!(serde_json::from_str::<Purpose>(&format!("\"{p}\"")).unwrap(), p);
1162 assert_eq!(Purpose::parse(p.as_str()), Some(p));
1163 }
1164 assert_eq!(Purpose::parse("speech"), None);
1165 assert_eq!(serde_json::from_str::<Purpose>("\"chat\"").unwrap(), Purpose::Chat);
1167 }
1168
1169 #[test]
1170 fn the_catalog_has_a_pinned_speech_to_text_model() {
1171 let stt: Vec<_> = by_purpose(Purpose::Transcribe).into_iter().filter(CatalogEntry::is_gguf).collect();
1172 assert_eq!(stt.len(), 1);
1173 let v = &stt[0];
1174 assert_eq!((v.id(), v.quant.as_str(), v.context), (VOXTRAL_MINI_3B, "Q4_K_M", 16_384));
1175 assert!(v.transcribes());
1176 assert_eq!(find(VOXTRAL_MINI_3B).as_ref(), Some(v));
1177 assert_eq!(v.spec.repo, "ggml-org/Voxtral-Mini-3B-2507-GGUF");
1178 assert_eq!(v.spec.sha256.as_deref().map(str::len), Some(64));
1179 let p = v.projector().expect("Voxtral needs its audio encoder");
1180 assert_eq!((p.repo.as_str(), p.file.as_str(), p.size), (v.spec.repo.as_str(), "mmproj-Voxtral-Mini-3B-2507-Q8_0.gguf", 715_714_080));
1181 assert!(p.sha256.as_deref().is_some_and(|h| h.len() == 64 && h.chars().all(|c| c.is_ascii_hexdigit())));
1182 assert_ne!(p.file, v.spec.file);
1183 assert_eq!(v.kv_bytes_per_token, 30 * 8 * 256 * 2);
1185 let without = (v.spec.size + v.kv_bytes_per_token * 16_384) * 11 / 10;
1187 assert!(v.footprint(1) > without);
1188 assert!(
1189 catalog()
1190 .iter()
1191 .filter(|e| !e.transcribes() && !e.speaks() && !matches!(e.id(), CAVELING_2_MINI | INKLING_2_MINI))
1192 .all(|e| e.projector().is_none())
1193 );
1194 let mut ids: Vec<_> = catalog().iter().map(|e| e.id().to_string()).collect();
1196 ids.sort();
1197 ids.dedup();
1198 assert_eq!(ids.len(), catalog().len());
1199 }
1200
1201 #[test]
1202 fn plans_never_pick_the_transcriber_and_it_fits_on_its_own() {
1203 for (gpus, ram) in [(parse_nvidia_smi("NVIDIA GeForce RTX 3060, 12288, 8.6, 615.78.08", 62 * GIB), 62), (Vec::new(), 62), (Vec::new(), 8)] {
1204 let hw = box_with(gpus, ram);
1205 let p = plan(&hw, budget(&hw, None, None));
1206 for e in [&p.main, &p.standin, &p.embedding].into_iter().flatten() {
1207 assert!(!e.transcribes() && !e.speaks(), "{} in a plan", e.id());
1208 }
1209 }
1210 let hw = box_with(Vec::new(), 62);
1211 assert_eq!(transcriber(&budget(&hw, None, None)).map(|e| e.spec.id), Some(VOXTRAL_MINI_3B.into()));
1212 assert_eq!(transcriber(&budget(&hw, Some(GIB), None)), None, "too small a budget");
1213 assert!(by_purpose(Purpose::Embedding).iter().all(|e| e.purpose == Purpose::Embedding));
1214 }
1215
1216 #[test]
1217 fn speak_is_a_purpose_of_its_own() {
1218 assert_eq!(serde_json::to_string(&Purpose::Speak).unwrap(), "\"speak\"");
1219 assert_eq!(Purpose::parse("speak"), Some(Purpose::Speak));
1220 assert_eq!(Purpose::Speak.to_string(), "speak");
1221 assert_eq!(Purpose::parse("tts"), None);
1222 }
1223
1224 #[test]
1225 fn the_catalog_has_cited_speech_models() {
1226 let ids: Vec<_> = by_purpose(Purpose::Speak).iter().map(|e| e.id().to_string()).collect();
1227 assert_eq!(
1228 ids,
1229 [
1230 QWEN3_TTS_0_6B_CUSTOMVOICE,
1231 QWEN3_TTS_0_6B_BASE,
1232 QWEN3_TTS_1_7B_CUSTOMVOICE,
1233 QWEN3_TTS_1_7B_VOICEDESIGN,
1234 QWEN3_TTS_1_7B_BASE,
1235 KOKORO_82M,
1236 VOXCPM2,
1237 FISH_AUDIO_DRAMA_3
1238 ]
1239 );
1240 let hex = |h: &Option<String>| h.as_deref().is_some_and(|h| h.len() == 64 && h.chars().all(|c| c.is_ascii_hexdigit()));
1241 for e in by_purpose(Purpose::Speak) {
1242 assert!(e.speaks() && !e.transcribes());
1243 assert!(hex(&e.spec.sha256), "{} pinned", e.id());
1244 let s = e.speech().unwrap_or_else(|| panic!("{} has a profile", e.id()));
1245 assert!(s.sample_rate.is_some() && !s.formats.is_empty() && s.languages.is_some(), "{}", e.id());
1246 assert!(e.license().is_some());
1247 if e.is_gguf() {
1248 let p = e.projector().unwrap_or_else(|| panic!("{} needs its projector", e.id()));
1249 assert!(hex(&p.sha256) && p.file.starts_with("mmproj-") && p.repo == e.spec.repo);
1250 assert_eq!(s.formats, [crate::speech::AudioFormat::Wav, crate::speech::AudioFormat::Pcm16], "llama-server's formats");
1251 assert!(e.footprint(1) > (e.spec.size + p.size) * 11 / 10);
1252 } else {
1253 assert!(e.projector().is_none());
1254 assert!(e.spec.repo.starts_with("Qwen/") && e.spec.file == "model.safetensors");
1255 assert!(e.footprint(1) > (e.spec.size + QWEN3_TTS_TOKENIZER_BYTES) * 11 / 10, "the speech tokenizer counts");
1256 assert!(s.formats.len() == 5 && s.speed, "vLLM-Omni's formats and speed");
1257 }
1258 }
1259 let q = |id| find(id).unwrap().speech().unwrap();
1261 assert_eq!(q(QWEN3_TTS_1_7B_CUSTOMVOICE).presets.as_ref().map(Vec::len), Some(9));
1262 assert!(q(QWEN3_TTS_1_7B_CUSTOMVOICE).instructions && !q(QWEN3_TTS_0_6B_CUSTOMVOICE).instructions);
1263 assert!(q(QWEN3_TTS_1_7B_VOICEDESIGN).design && q(QWEN3_TTS_1_7B_VOICEDESIGN).clone.is_none());
1264 assert_eq!(q(QWEN3_TTS_0_6B_BASE).clone, Some(CloneMode::AudioAndText));
1265 assert_eq!(q(QWEN3_TTS_1_7B_BASE).clone, Some(CloneMode::Audio), "ggml-org's projector has the speaker encoder only");
1266 let k = q(KOKORO_82M);
1267 assert_eq!((k.presets.as_ref().map(Vec::len), k.presets.as_ref().and_then(|p| p.first()).map(String::as_str)), (Some(54), Some("af_heart")));
1268 assert!(k.raw && k.speed);
1269 assert!(q(VOXCPM2).design && q(VOXCPM2).clone == Some(CloneMode::Audio));
1270 assert_eq!(q(VOXCPM2).languages.map(|l| l.len()), Some(30));
1271 let d = q(FISH_AUDIO_DRAMA_3);
1272 assert_eq!((d.script_speakers, d.clone, d.sample_rate), (Some(16), None, Some(44_100)));
1273 assert_eq!(d.languages.map(|l| l.len()), Some(83));
1274 let drama = find(FISH_AUDIO_DRAMA_3).unwrap();
1276 assert!(drama.restricted() && drama.license() == Some(crate::speech::FISH_AUDIO_COMMUNITY));
1277 assert_eq!(d.license.as_deref(), Some(crate::speech::FISH_AUDIO_COMMUNITY));
1278 assert_eq!(catalog().iter().filter(|e| e.restricted()).count(), 1);
1279 assert!(catalog().iter().filter(|e| !e.speaks()).all(|e| e.speech().is_none()));
1280 }
1281
1282 #[test]
1283 fn a_speaker_that_fits_and_never_a_restricted_one() {
1284 let b = |usable_bytes| Budget { pool_bytes: usable_bytes, reserve_bytes: 0, usable_bytes };
1285 assert_eq!(speaker(&b(128 * GIB)).map(|e| e.spec.id), Some(VOXCPM2.into()), "never Drama 3, however big");
1286 assert_eq!(speaker(&b(GIB * 7 / 2)).map(|e| e.spec.id), Some(QWEN3_TTS_1_7B_BASE.into()));
1287 assert_eq!(speaker(&b(GIB)).map(|e| e.spec.id), Some(KOKORO_82M.into()));
1288 assert_eq!(speaker(&b(100 << 20)), None);
1289 assert!(by_purpose(Purpose::Speak).iter().all(|e| e.footprint(1) > 0));
1290 }
1291
1292 #[test]
1293 fn downloads_under_a_restricted_license() {
1294 let drama = find(FISH_AUDIO_DRAMA_3).unwrap();
1295 let lic = Some(crate::speech::FISH_AUDIO_COMMUNITY);
1296 assert_eq!(restricted_license(&drama.spec), lic);
1297 assert_eq!(restricted_license(&drama.projector().unwrap()), lic);
1298 let mut other = drama.spec.clone();
1300 other.id = "my-drama".into();
1301 other.file = "drama-3-Q8_0.gguf".into();
1302 assert_eq!(restricted_license(&other), lic);
1303 other.repo = "FishAudio/Drama-3".into();
1304 assert_eq!(restricted_license(&other), lic);
1305 for e in catalog().iter().filter(|e| e.spec.id != FISH_AUDIO_DRAMA_3) {
1306 assert_eq!(restricted_license(&e.spec), None, "{}", e.id());
1307 }
1308 }
1309
1310 fn is_sha256(h: &Option<String>) -> bool {
1311 h.as_deref().is_some_and(|h| h.len() == 64 && h.chars().all(|c| c.is_ascii_hexdigit() && !c.is_ascii_uppercase()))
1312 }
1313
1314 #[test]
1315 fn caveling_is_a_pinned_chat_model_with_a_vision_projector() {
1316 let e = find(CAVELING_2_MINI).expect("in the catalog");
1317 assert_eq!((e.purpose, e.quant.as_str(), e.params_b, e.active_params_b), (Purpose::Chat, "Q4_K_M", 26.0, 3.4));
1318 assert!(e.is_gguf() && !e.speaks() && !e.transcribes() && !e.restricted() && !e.gated() && !e.is_sharded());
1319 assert_eq!(e.spec.repo, "caveman-so/caveling-2-mini-GGUF");
1320 assert_eq!((e.spec.file.as_str(), e.spec.size), ("Caveling-2-Mini-Q4_K_M.gguf", 18_398_579_616));
1322 assert!(!e.spec.file.to_ascii_lowercase().contains("dspark") && !e.spec.file.starts_with("imatrix"));
1323 assert!(is_sha256(&e.spec.sha256));
1324 let p = e.projector().expect("vision encoder");
1325 assert_eq!((p.repo.as_str(), p.file.as_str(), p.size), (e.spec.repo.as_str(), "mmproj-Caveling-2-Mini-Q8_0.gguf", 345_911_360));
1326 assert!(is_sha256(&p.sha256));
1327 assert_eq!(e.license(), Some("apache-2.0"));
1328 assert_eq!(e.revision(), Some("ec4b4b4114cf8375abc1cf42d6c41971b778e2ba"));
1329 assert_eq!(e.engine_args(), ["-fa", "on", "--jinja"]);
1331 assert_eq!((e.launch_context(), e.launch_gpu_layers()), (Some(346_112), Some(99)));
1332 assert_eq!(e.context, 346_112);
1333 assert_eq!(e.kv_bytes_per_token, 8 * 8 * 256 * 2);
1336 let kv = e.kv_bytes_per_token * 346_112;
1337 let want = (e.spec.size + p.size + kv) * 11 / 10;
1338 assert!(e.footprint(1).abs_diff(want) < 16, "{} vs {want}", e.footprint(1));
1339 let gemma = find(crate::catalog::GEMMA_4_E4B).unwrap();
1341 assert!(
1342 gemma.engine_args().is_empty() && gemma.launch_context().is_none() && gemma.launch_gpu_layers().is_none() && gemma.revision().is_none()
1343 );
1344 }
1345
1346 #[test]
1347 fn caveling_never_changes_what_a_plan_picks() {
1348 for (gpus, ram) in [(Vec::new(), 62), (Vec::new(), 256), (parse_nvidia_smi("NVIDIA GB10, [N/A], 12.1, 580.95.05", 128 * GIB), 128)] {
1350 let hw = box_with(gpus, ram);
1351 let p = plan(&hw, budget(&hw, None, None));
1352 assert_ne!(p.main.unwrap().id(), CAVELING_2_MINI);
1353 }
1354 }
1355
1356 #[test]
1357 fn inkling_is_the_pinned_iq4_nl_file_with_the_same_launch_values_as_caveling() {
1358 let e = find(INKLING_2_MINI).expect("in the catalog");
1359 let c = find(CAVELING_2_MINI).unwrap();
1360 assert_eq!((e.purpose, e.quant.as_str(), e.params_b, e.active_params_b), (Purpose::Chat, "IQ4_NL", 26.0, 3.4));
1361 assert!(e.is_gguf() && !e.speaks() && !e.transcribes() && !e.restricted() && !e.gated() && !e.is_sharded());
1362 assert_eq!(e.spec.repo, "ggml-org/Inkling-2-Mini-GGUF");
1363 assert_eq!((e.spec.file.as_str(), e.spec.size), ("Inkling-2-Mini-IQ4_NL.gguf", 17_627_940_768));
1365 assert_eq!(e.spec.sha256.as_deref(), Some("cbdf3fa9dc50a4124977980f37da4f1fa764b0cfe800d275cd43d26ce2a81af4"));
1366 let p = e.projector().expect("vision encoder");
1367 assert_eq!((p.repo.as_str(), p.file.as_str(), p.size), (e.spec.repo.as_str(), "mmproj-Inkling-2-Mini-Q8_0.gguf", 345_910_944));
1368 assert_eq!(p.sha256.as_deref(), Some("233287272ec5ac39b4168677aba54a4c024f202410f5629fac1830e1059f8abb"));
1369 assert_eq!(e.license(), Some("apache-2.0"));
1370 assert_eq!(e.revision(), Some("0bdc580634ceac4c4d921f452777bf44228de9af"));
1371 assert_eq!(e.engine_args(), ["-fa", "on", "--jinja"]);
1372 assert_eq!((e.launch_context(), e.launch_gpu_layers()), (Some(346_112), Some(99)));
1373 assert_eq!((e.kv_bytes_per_token, e.context), (c.kv_bytes_per_token, c.context));
1375 assert_eq!(e.engine_args(), c.engine_args());
1376 let want = (e.spec.size + p.size + e.kv_bytes_per_token * 346_112) * 11 / 10;
1377 assert!(e.footprint(1).abs_diff(want) < 16);
1378 assert_ne!(e.spec.id, "inkling-2-mini-training");
1379 assert!(catalog().iter().all(|o| !o.id().contains("training")));
1380 }
1381
1382 #[test]
1383 fn the_vllm_chat_checkpoints_are_pinned_and_never_in_a_plan() {
1384 let want = [
1385 (
1386 QWEN3_VL_8B,
1387 "Qwen/Qwen3-VL-8B-Instruct",
1388 "BF16",
1389 4,
1390 4_902_275_944 + 4_915_962_496 + 4_999_831_048 + 2_716_270_024,
1391 "0c351dd01ed87e9c1b53cbc748cba10e6187ff3b",
1392 ),
1393 (
1394 QWEN3_8_27B_NVFP4,
1395 "RadixArk/Qwen3.8-27B-NVFP4",
1396 "NVFP4",
1397 3,
1398 9_965_652_544 + 9_985_757_064 + 1_970_287_672,
1399 "319f741cce68d7914884900c138a1fbb70a42f30",
1400 ),
1401 ];
1402 for (id, repo, quant, shards, bytes, rev) in want {
1403 let e = find(id).unwrap_or_else(|| panic!("{id} in the catalog"));
1404 assert_eq!(
1405 (e.purpose, e.is_gguf(), e.spec.repo.as_str(), e.quant.as_str(), e.license()),
1406 (Purpose::Chat, false, repo, quant, Some("apache-2.0")),
1407 "{id}"
1408 );
1409 assert!(!e.restricted() && !e.gated() && e.projector().is_none() && e.engine_args().is_empty(), "{id}");
1410 assert_eq!((e.files().len(), e.weights_bytes(), e.revision()), (shards, bytes, Some(rev)), "{id}");
1411 assert!(e.files().iter().all(|f| is_sha256(&f.sha256) && f.id == id && f.repo == repo), "{id}");
1412 assert_eq!(e.files()[0], e.spec, "{id}: the first file is the spec");
1413 let kv = e.kv_bytes_per_token * e.context as u64;
1414 assert!(e.footprint(1).abs_diff((bytes + kv) * 11 / 10) < 16, "{id}");
1415 }
1416 assert_eq!(find(QWEN3_VL_8B).unwrap().kv_bytes_per_token, 36 * 8 * 256 * 2);
1417 assert_eq!(find(QWEN3_8_27B_NVFP4).unwrap().kv_bytes_per_token, 16 * 4 * 512 * 2);
1418 for id in [QWEN3_VL_8B, QWEN3_8_27B_NVFP4] {
1420 let hashes: Vec<_> = find(id).unwrap().files().into_iter().map(|f| f.sha256).collect();
1421 let mut unique = hashes.clone();
1422 unique.sort();
1423 unique.dedup();
1424 assert_eq!(unique.len(), hashes.len(), "{id}");
1425 }
1426 for (gpus, ram) in [(Vec::new(), 62), (Vec::new(), 512), (parse_nvidia_smi("NVIDIA GB10, [N/A], 12.1, 580.95.05", 128 * GIB), 128)] {
1428 let hw = box_with(gpus, ram);
1429 let p = plan(&hw, budget(&hw, None, None));
1430 for e in [&p.main, &p.standin, &p.embedding].into_iter().flatten() {
1431 assert!(e.is_gguf(), "{} in a plan", e.id());
1432 }
1433 }
1434 }
1435
1436 #[test]
1437 fn the_vllm_transcribers_are_pinned_from_the_hub() {
1438 let want = [
1439 (QWEN3_ASR_1_7B, "Qwen/Qwen3-ASR-1.7B", "apache-2.0", 2, 4_220_320_824 + 478_200_688, "7278e1e70fe206f11671096ffdd38061171dd6e5"),
1440 (WHISPER_LARGE_V3_TURBO, "openai/whisper-large-v3-turbo", "mit", 1, 1_617_824_864, "41f01f3fe87f28c78e2fbf8b568835947dd65ed9"),
1441 (
1442 COHERE_TRANSCRIBE_03_2026,
1443 "CohereLabs/cohere-transcribe-03-2026",
1444 "apache-2.0",
1445 1,
1446 4_131_862_976,
1447 "d552dadc2922ba6f6c1f994f8db904d52dcaf942",
1448 ),
1449 ];
1450 for (id, repo, license, shards, bytes, rev) in want {
1451 let e = find(id).unwrap_or_else(|| panic!("{id} in the catalog"));
1452 assert_eq!((e.purpose, e.is_gguf(), e.spec.repo.as_str(), e.license()), (Purpose::Transcribe, false, repo, Some(license)), "{id}");
1453 assert!(e.transcribes() && !e.restricted() && e.projector().is_none(), "{id}");
1454 assert_eq!((e.files().len(), e.weights_bytes(), e.revision()), (shards, bytes, Some(rev)), "{id}");
1455 assert!(e.files().iter().all(|f| is_sha256(&f.sha256) && f.id == id && f.repo == repo), "{id}");
1456 assert_eq!(e.files()[0], e.spec, "{id}: the first file is the spec");
1457 let kv = e.kv_bytes_per_token * e.context as u64;
1459 assert!(e.footprint(1).abs_diff((bytes + kv) * 11 / 10) < 16, "{id}");
1460 }
1461 }
1462
1463 #[test]
1464 fn a_sharded_entry_lists_every_shard_with_its_own_hash() {
1465 let e = find(QWEN3_ASR_1_7B).unwrap();
1466 assert!(e.is_sharded());
1467 let files = e.files();
1468 let names: Vec<_> = files.iter().map(|f| f.file.as_str()).collect();
1469 assert_eq!(names, ["model-00001-of-00002.safetensors", "model-00002-of-00002.safetensors"]);
1470 assert_eq!(files[0].sha256.as_deref(), Some("a4cd1f1a04d90b757dc7f7dd26254e69a013b19e80efe590a83c6a3bde8608d6"));
1471 assert_eq!(files[1].sha256.as_deref(), Some("6e0b9d9e09e2e0238e7ef3cc8a484ab387e91b90f1900bedf88bc92d7929ccfc"));
1472 assert_ne!(files[0].sha256, files[1].sha256);
1473 assert_eq!(files.iter().map(|f| f.size).sum::<u64>(), e.weights_bytes());
1474 assert_eq!(files[1].size, 478_200_688);
1475 let consent = crate::Consent::given(&e.spec);
1477 let store = crate::ModelStore::new(std::path::Path::new("/nonexistent-store"));
1478 for f in &files {
1479 assert_eq!(f.id, e.spec.id);
1480 assert_eq!(crate::Consent::given(f), consent);
1481 }
1482 assert_ne!(store.path(&files[0]), store.path(&files[1]));
1483 for o in catalog().iter().filter(|o| !matches!(o.id(), QWEN3_ASR_1_7B | QWEN3_VL_8B | QWEN3_8_27B_NVFP4)) {
1485 assert!(!o.is_sharded(), "{}", o.id());
1486 assert_eq!(o.files(), vec![o.spec.clone()], "{}", o.id());
1487 assert_eq!(o.weights_bytes(), o.spec.size, "{}", o.id());
1488 }
1489 }
1490
1491 #[test]
1492 fn engine_args_are_separate_per_entry() {
1493 let args = |id| find(id).unwrap().engine_args();
1494 assert_eq!(args(COHERE_TRANSCRIBE_03_2026), ["--trust-remote-code"]);
1495 assert!(args(QWEN3_ASR_1_7B).is_empty() && args(WHISPER_LARGE_V3_TURBO).is_empty() && args(VOXTRAL_MINI_3B).is_empty());
1496 let with: Vec<_> = catalog().into_iter().filter(|e| !e.engine_args().is_empty()).map(|e| e.id().to_string()).collect();
1497 assert_eq!(with, [CAVELING_2_MINI, INKLING_2_MINI, COHERE_TRANSCRIBE_03_2026]);
1498 }
1499
1500 #[test]
1501 fn only_cohere_is_gated_and_nothing_here_is_restricted() {
1502 let gated_ids: Vec<_> = catalog().into_iter().filter(|e| e.gated()).map(|e| e.id().to_string()).collect();
1503 assert_eq!(gated_ids, [COHERE_TRANSCRIBE_03_2026]);
1504 let cohere = find(COHERE_TRANSCRIBE_03_2026).unwrap();
1505 assert!(gated(&cohere.spec));
1506 let other_file = ModelSpec { id: "x".into(), file: "tokenizer.model".into(), ..cohere.spec.clone() };
1507 assert!(gated(&other_file), "another file of the gated repo");
1508 assert!(!gated(&find(WHISPER_LARGE_V3_TURBO).unwrap().spec));
1509 for id in [CAVELING_2_MINI, INKLING_2_MINI, QWEN3_VL_8B, QWEN3_8_27B_NVFP4, QWEN3_ASR_1_7B, WHISPER_LARGE_V3_TURBO, COHERE_TRANSCRIBE_03_2026]
1510 {
1511 assert!(!find(id).unwrap().restricted(), "{id}");
1512 assert_eq!(restricted_license(&find(id).unwrap().spec), None, "{id}");
1513 }
1514 }
1515
1516 #[test]
1517 fn the_transcriber_stays_a_gguf_llama_cpp_runs() {
1518 for gib in [4, 8, 16, 62, 256] {
1519 let hw = box_with(Vec::new(), gib);
1520 let t = transcriber(&budget(&hw, None, None));
1521 if let Some(t) = t {
1522 assert!(t.is_gguf() && t.id() == VOXTRAL_MINI_3B, "{gib} GiB: {}", t.id());
1523 }
1524 }
1525 let small = find(VOXTRAL_MINI_3B).unwrap().footprint(1) - 1;
1527 let budget = Budget { pool_bytes: small, reserve_bytes: 0, usable_bytes: small };
1528 assert!(find(WHISPER_LARGE_V3_TURBO).unwrap().footprint(1) <= small);
1529 assert_eq!(transcriber(&budget), None);
1530 assert_eq!(by_purpose(Purpose::Transcribe).len(), 4);
1531 }
1532}