Initial ForgeLM import

This commit is contained in:
Evandro Fonseca Junior committed 2026-03-29 19:10:57 -03:00
commit a392b9dc60
4296 files changed
+1212675

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
/// Predefined runtime profiles matching the plan targets.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RuntimeProfile {
/// Qwen3.5-4B – maximum TPS, text-only, flash attention, moderate context.
Turbo4B,
/// Qwen3.5-9B – balanced quality/speed, tuned KV cache.
Balanced9B,
/// CPU-only fallback for machines without a GPU.
CpuFallback,
}
impl RuntimeProfile {
/// Returns sensible defaults for each profile.
pub fn defaults(&self) -> ProfileDefaults {
match self {
Self::Turbo4B => ProfileDefaults {
n_gpu_layers: 999,
n_ctx: 4096,
n_batch: 512,
n_ubatch: 128,
flash_attn: true,
n_threads: 8,
},
Self::Balanced9B => ProfileDefaults {
n_gpu_layers: 999,
n_ctx: 2048,
n_batch: 256,
n_ubatch: 64,
flash_attn: true,
n_threads: 8,
},
Self::CpuFallback => ProfileDefaults {
n_gpu_layers: 0,
n_ctx: 2048,
n_batch: 128,
n_ubatch: 32,
flash_attn: false,
n_threads: num_cpus(),
},
}
}
}
fn num_cpus() -> i32 {
// Simple fallback; replace with `num_cpus` crate if needed.
std::thread::available_parallelism()
.map(|n| n.get() as i32)
.unwrap_or(4)
}
#[derive(Debug, Clone)]
pub struct ProfileDefaults {
pub n_gpu_layers: i32,
pub n_ctx: u32,
pub n_batch: u32,
pub n_ubatch: u32,
pub flash_attn: bool,
pub n_threads: i32,
}