diff --git a/crates/deploy/src/app.rs b/crates/deploy/src/app.rs index dbabf89e..33446735 100644 --- a/crates/deploy/src/app.rs +++ b/crates/deploy/src/app.rs @@ -328,6 +328,12 @@ pub async fn run_up(ctx: &Context, steps: &[Step]) -> Result { } Mode::Foreground => { if let Some(fd) = ctx.opts.kar_fd { + if config.profile.kar_source == crate::profile::KarSource::None { + return Err(format!( + "--kar-fd {fd} was given but profile {} has kar_source none (no archive is used); drop --kar-fd", + config.profile.name + )); + } crate::sealed::check_inherited_archive(fd, crate::profile::ARCHIVE_BYTES)?; } if steps::probe_ready(ctx).await { @@ -436,6 +442,8 @@ pub fn summary(ctx: &Context, config: &crate::config::RunConfig) { } ), crate::profile::KarSource::File => "a read-only file (page cache only)".to_owned(), + crate::profile::KarSource::None => + "none (EXPERIMENTAL: no archive; the PLE rows are read from the GGUF shard, qwen4exp-native-mtp-v1)".to_owned(), } )); text.push_str(&format!( @@ -1059,6 +1067,7 @@ async fn verify_quick(opts: &UpOptions) -> i32 { } let kar = paths.kar(); let kar_state = match identity_of(&kar) { + _ if config.profile.kar_source == crate::profile::KarSource::None => "not used (kar_source none)".to_owned(), None => { problems.push(format!("the archive is missing: {}", kar.display())); "MISSING".to_owned() diff --git a/crates/deploy/src/config.rs b/crates/deploy/src/config.rs index 7105bb4d..2186b8cd 100644 --- a/crates/deploy/src/config.rs +++ b/crates/deploy/src/config.rs @@ -3,7 +3,7 @@ //! `leleka.json` holds no secret. Tokens live in `runtime.env` (mode 0600) and reach the children only through //! their environment, never through argv. use crate::{ - layout::{Dirs, MODEL_DIGEST, MODEL_ID, MTP_PROFILE, Paths}, + layout::{Dirs, MODEL_DIGEST, MODEL_ID, MTP_PROFILE, NATIVE_MTP_PROFILE, Paths}, profile::{KarSource, Profile}, }; use serde::{Deserialize, Serialize}; @@ -172,6 +172,8 @@ pub enum KarArg { Fd, /// `--kar-archive-file PATH`. File, + /// No archive argument at all (`kar_source: none`): the engine reads the PLE rows from the GGUF shard. + None, } impl RunConfig { @@ -290,10 +292,15 @@ impl RunConfig { "--kar-archive-file".into(), paths.kar().display().to_string(), ]), + KarArg::None => {} + } + if kar != KarArg::None { + args.extend([ + "--kar-provenance".into(), + paths.kar_provenance().display().to_string(), + ]); } args.extend([ - "--kar-provenance".into(), - paths.kar_provenance().display().to_string(), "--mtp-pack".into(), paths.mtp_pack().display().to_string(), "--mtp-staging".into(), @@ -363,6 +370,16 @@ impl RunConfig { match self.profile.kar_source { KarSource::Memfd => KarArg::Fd, KarSource::File => KarArg::File, + KarSource::None => KarArg::None, + } + } + + /// The typed load's profile id: the KAR PLE form, or `kar_source: none`'s native-PLE form (`qwen4exp-native-mtp-v1`). + pub fn mtp_profile(&self) -> &'static str { + if self.profile.kar_source == KarSource::None { + NATIVE_MTP_PROFILE + } else { + MTP_PROFILE } } @@ -405,7 +422,7 @@ impl RunConfig { "weight_format": "gguf:iq3_s", "artifact_digest": self.model_digest, }, - "mode": {"type": "mtp", "profile_id": MTP_PROFILE}, + "mode": {"type": "mtp", "profile_id": self.mtp_profile()}, "max_context": self.profile.context_tokens, // A request to an engine that stopped answering ends with an error instead of staying open. "stall_timeout_s": self.request_limits.stall_timeout_s, @@ -585,6 +602,47 @@ mod tests { assert!(!text.contains("{FD}")); } + #[test] + fn the_gguf_ple_profile_passes_no_archive_and_loads_the_native_mtp_profile() { + let c = config("rtx5090-32g-gguf-ple"); + assert_eq!(c.kar_arg(), KarArg::None); + assert_eq!(c.mtp_profile(), "qwen4exp-native-mtp-v1"); + let args = c.engine_args(c.kar_arg()); + let text = flat(&args); + assert!( + !text.contains("--kar") && !text.contains("{FD}"), + "{text}" + ); + // the seven fixed pairs stay first and the rest follows without a gap + assert_eq!(args[12], "--context-tokens"); + assert_eq!(args[14], "--mtp-pack", "{text}"); + assert!(text.contains("--backend-mode original --expert-source resident"), "{text}"); + assert_eq!( + c.strata_json()["runtime"]["mode"]["profile_id"], + "qwen4exp-native-mtp-v1" + ); + let verify = flat(&c.verify_args(true)); + assert!(!verify.contains("--kar"), "{verify}"); + assert_eq!( + c.engine_environment().get("LELEKA_PLE_DIRECT").map(String::as_str), + Some("0") + ); + } + + #[test] + fn every_other_profile_keeps_its_archive_arguments_and_profile_id() { + for name in ["rtx5090-32g", "rtx5090-32g-file", "rtx3080-16g"] { + let c = config(name); + assert_eq!(c.mtp_profile(), "qwen4exp-kar-ple-mtp-v1", "{name}"); + let text = flat(&c.engine_args(c.kar_arg())); + assert!( + text.contains("--kar-archive-") && text.contains("--kar-provenance"), + "{name}: {text}" + ); + assert!(!c.engine_environment().contains_key("LELEKA_PLE_DIRECT"), "{name}"); + } + } + fn config_of(profile: &str) -> RunConfig { config(profile) } diff --git a/crates/deploy/src/layout.rs b/crates/deploy/src/layout.rs index 972b913f..1df46b86 100644 --- a/crates/deploy/src/layout.rs +++ b/crates/deploy/src/layout.rs @@ -40,6 +40,8 @@ pub const MTP_FILES: [&str; 4] = ["dense.bin", "dense.txt", "draft_vocab.bin", " pub const MANIFEST: &str = "qwen-iq3-s"; pub const MODEL_ID: &str = "qwen-iq3"; pub const MTP_PROFILE: &str = "qwen4exp-kar-ple-mtp-v1"; +/// The typed load of `kar_source: none` (experimental): the same MTP stack with the PLE rows read from the GGUF shard. +pub const NATIVE_MTP_PROFILE: &str = "qwen4exp-native-mtp-v1"; /// Digest of the pinned IQ3_S shard pair (`crates/leleka-runtime/src/backend.rs` `MODEL_DIGEST`). pub const MODEL_DIGEST: &str = "sha256:80d5e3333801cedbca81a5c19c24ed6bb48fd56977acd190318f66b23a1766a3"; diff --git a/crates/deploy/src/plan.rs b/crates/deploy/src/plan.rs index e6b92ee8..e0d8a951 100644 --- a/crates/deploy/src/plan.rs +++ b/crates/deploy/src/plan.rs @@ -256,6 +256,10 @@ pub fn gather(opts: &UpOptions, var: &dyn Fn(&str) -> Option) -> Context }; let (config, report) = match &mut profile { Ok(p) => { + // `kar_source: none` never needs the archive (and never builds it) + if p.kar_source == KarSource::None { + needs.kar_bytes_missing = 0; + } needs.expert_profile = if opts.no_expert_tier && p.expert_profile.is_some() { Some(ExpertProfileState::OptedOut) } else { @@ -526,7 +530,15 @@ pub fn plan_steps(ctx: &Context, fs: &FsState) -> Vec { )); let trusted = opts.trust_archive && fs.kar_present; - let kar_state = if windows { + let kar_unused = ctx + .profile + .as_ref() + .is_ok_and(|p| p.kar_source == KarSource::None); + let kar_state = if kar_unused { + StepState::Skip( + "kar_source none (experimental): no archive is used, the PLE rows are read from the GGUF shard".into(), + ) + } else if windows { if fs.kar_present { StepState::Done(format!( "{} bytes with its provenance file (the engine checks SHA-256 and CRCs at each load)", @@ -876,6 +888,7 @@ pub fn render_plan(ctx: &Context, steps: &[Step]) -> String { let kar = match config.profile.kar_source { KarSource::Memfd => KarArg::Fd, KarSource::File => KarArg::File, + KarSource::None => KarArg::None, }; out.push_str(&format!( "engine command the service runs:\n {} {}\n", diff --git a/crates/deploy/src/profile.rs b/crates/deploy/src/profile.rs index 6a074d43..c05e1692 100644 --- a/crates/deploy/src/profile.rs +++ b/crates/deploy/src/profile.rs @@ -30,7 +30,7 @@ pub fn archive_sha256() -> [u8; 32] { /// Bytes of the two pinned IQ3_S GGUF shards. pub const SHARD_BYTES: [u64; 2] = [54_817_524_224, 28_800_138_432]; -pub const BUILTIN: [(&str, &str); 3] = [ +pub const BUILTIN: [(&str, &str); 4] = [ ( "rtx5090-32g", include_str!("../../../deploy/rust-runtime/profiles/rtx5090-32g.json"), @@ -40,6 +40,11 @@ pub const BUILTIN: [(&str, &str); 3] = [ "rtx5090-32g-file", include_str!("../../../deploy/rust-runtime/profiles/rtx5090-32g-file.json"), ), + // Experimental A/B variant of the server profile without the KAR archive (the PLE rows come from GGUF shard 1): never auto-selected. + ( + "rtx5090-32g-gguf-ple", + include_str!("../../../deploy/rust-runtime/profiles/rtx5090-32g-gguf-ple.json"), + ), ( "rtx3080-16g", include_str!("../../../deploy/rust-runtime/profiles/rtx3080-16g.json"), @@ -56,6 +61,9 @@ pub enum KarSource { Memfd, /// An ordinary read-only file (`--kar-archive-file`): only the pages that are read pass through the file cache. File, + /// EXPERIMENTAL (`rtx5090-32g-gguf-ple`): no KAR archive at all. The engine reads the per-layer n-gram (PLE) rows from the GGUF shard + /// itself (`qwen4exp-native-mtp-v1`, the exact PLE of the Original); the archive is neither required, checked nor passed. + None, } impl KarSource { @@ -63,6 +71,7 @@ impl KarSource { match self { KarSource::Memfd => "memfd", KarSource::File => "file", + KarSource::None => "none", } } } @@ -365,7 +374,7 @@ impl Profile { /// Host RAM the sealed memfd holds for the life of the service (0 for a file-backed archive). pub fn memfd_bytes(&self) -> u64 { match (self.kar_source, self.memfd_extents) { - (KarSource::File, _) => 0, + (KarSource::File | KarSource::None, _) => 0, (KarSource::Memfd, MemfdExtents::Full) => ARCHIVE_BYTES, (KarSource::Memfd, MemfdExtents::PleOnly) => SPARSE_MEMFD_BYTES_ESTIMATE, } @@ -472,16 +481,17 @@ impl Profile { self.memory.validate()?; for (key, value) in &self.engine_env { // LELEKA_CHAIN selects the chain-kernel group (docs/chain-kernels.md), LELEKA_SM120_* the compute-capability-12 kernel switches - // (docs/experiments/draft-round-5090.md); every other switch is a serve-stack one + // (docs/experiments/draft-round-5090.md), LELEKA_PLE_* the GGUF PLE row reader (`kar_source: none`); every other switch is a serve-stack one if !(key.starts_with("LELEKA_ORIGINAL_SERVE_") || key.starts_with("LELEKA_SM120_") + || key.starts_with("LELEKA_PLE_") || key == "LELEKA_CHAIN") || !key .bytes() .all(|b| b.is_ascii_uppercase() || b.is_ascii_digit() || b == b'_') { return Err(format!( - "engine_env key {key} must be an upper-case LELEKA_ORIGINAL_SERVE_* or LELEKA_SM120_* name (or LELEKA_CHAIN)" + "engine_env key {key} must be an upper-case LELEKA_ORIGINAL_SERVE_*, LELEKA_SM120_* or LELEKA_PLE_* name (or LELEKA_CHAIN)" )); } if value.is_empty() || value.len() > 1024 || value.chars().any(char::is_control) { @@ -561,7 +571,7 @@ mod tests { for profile in Profile::builtins() { profile.validate().unwrap(); } - assert_eq!(Profile::builtins().len(), 3); + assert_eq!(Profile::builtins().len(), 4); } #[test] @@ -637,6 +647,48 @@ mod tests { ); } + #[test] + fn the_gguf_ple_variant_differs_from_the_server_profile_only_in_the_ple_source() { + let server = Profile::builtin("rtx5090-32g").unwrap(); + let ggufp = Profile::builtin("rtx5090-32g-gguf-ple").unwrap(); + ggufp.validate().unwrap(); + assert_eq!(ggufp.kar_source, KarSource::None); + assert_eq!(ggufp.memfd_bytes(), 0); + assert_eq!(KarSource::None.as_str(), "none"); + for (name, same) in [ + ("gpu_budget_bytes", server.gpu_budget_bytes == ggufp.gpu_budget_bytes), + ("context_tokens", server.context_tokens == ggufp.context_tokens), + ("prefill_capacity", server.prefill_capacity == ggufp.prefill_capacity), + ("spec_min_p", server.spec_min_p == ggufp.spec_min_p), + ("expert_profile", server.expert_profile == ggufp.expert_profile), + ("expert_source", server.expert_source == ggufp.expert_source), + ("prefix_cache_mib", server.memory.prefix_cache_mib == ggufp.memory.prefix_cache_mib), + ("prefix_cache_tail", server.memory.prefix_cache_tail == ggufp.memory.prefix_cache_tail), + ("prefix_cache_block", server.memory.prefix_cache_block == ggufp.memory.prefix_cache_block), + ] { + assert!(same, "{name} must match rtx5090-32g"); + } + // the engine switches are the server's plus the page-cache form of the PLE reader + let mut expected = server.engine_env.clone(); + expected.insert("LELEKA_PLE_DIRECT".into(), "0".into()); + assert_eq!(ggufp.engine_env, expected); + // experimental: never auto-selected + assert!(!ggufp.matches(&gpu("NVIDIA GeForce RTX 5090", 120, 32607))); + assert_eq!( + resolve(None, Some(&gpu("NVIDIA GeForce RTX 5090", 120, 32607))).unwrap().name, + "rtx5090-32g" + ); + // only the PLE reader family is let through next to the serve-stack switches + let mut bad = ggufp.clone(); + bad.engine_env.insert("LELEKA_PLEX".into(), "1".into()); + assert!(bad.validate().is_err()); + let mut json: serde_json::Value = serde_json::to_value(&ggufp).unwrap(); + assert_eq!(json["kar_source"], "none"); + json["kar_source"] = "memfd".into(); + let back: Profile = serde_json::from_value(json).unwrap(); + assert_eq!(back.kar_source, KarSource::Memfd); + } + #[test] fn only_the_server_profile_turns_the_prompt_routing_seed_off() { // placement-class setting (docs/experiments/decode-tail-5090.md): off for the 5090 profile, the engine default and the laptop profile are unchanged diff --git a/crates/deploy/src/resources.rs b/crates/deploy/src/resources.rs index 4addfa55..d7ab3981 100644 --- a/crates/deploy/src/resources.rs +++ b/crates/deploy/src/resources.rs @@ -248,7 +248,8 @@ pub fn compute( } // The sealed memfd holds the whole archive; a file-backed archive with a resident expert bank (rtx5090-32g-file) holds only the bank and // the engine's pins, its archive pages are page cache that the kernel gives back. The mapped file form (laptop) is already the low tier. - let resident_file = profile.kar_source == KarSource::File + // `kar_source: none` has no archive at all (the PLE table is read from the shard through the page cache): the same footprint. + let resident_file = matches!(profile.kar_source, KarSource::File | KarSource::None) && profile.expert_source == ExpertSource::Resident; if profile.kar_source == KarSource::Memfd || resident_file { let engine = if profile.expert_source == ExpertSource::Resident { diff --git a/crates/deploy/src/supervisor.rs b/crates/deploy/src/supervisor.rs index 93a2bfe8..38742585 100644 --- a/crates/deploy/src/supervisor.rs +++ b/crates/deploy/src/supervisor.rs @@ -9,7 +9,7 @@ use crate::{ config::{GATEWAY_TOKEN_ENV, KarArg, RUNTIME_TOKEN_ENV, RunConfig}, facts::parse_env_file, http, - layout::{MTP_PROFILE, Paths}, + layout::Paths, logs, profile::{ARCHIVE_BYTES, KarSource, MemfdExtents, PinSource, archive_sha256, extents_sha256}, reconfigure, sealed, watchdog, @@ -743,6 +743,19 @@ impl Supervisor { async fn drive(&mut self, kar_fd: Option) -> Result<(), Flow> { // 1. the archive self.archive = match (kar_fd, self.config.profile.kar_source) { + (Some(fd), KarSource::None) => { + return fail( + 2, + format!( + "descriptor {fd} was inherited but profile {} has kar_source none (no archive is used)", + self.config.profile.name + ), + ); + } + (None, KarSource::None) => { + self.log.line("kar_source none: no KAR archive; the PLE rows are read from the GGUF shard (qwen4exp-native-mtp-v1)"); + None + } (Some(fd), _) => { self.log.line(&format!( "using the sealed archive descriptor {fd} inherited from the parent" @@ -1085,6 +1098,7 @@ impl Supervisor { }) })?), ), + None if self.config.profile.kar_source == KarSource::None => (KarArg::None, None), None => (KarArg::File, None), }; let mut engine_args = self.config.engine_args(kar_arg); @@ -1242,7 +1256,7 @@ impl Supervisor { ); self.log.line("loading the model: leleka-cli load-mtp (the engine verifies SHA-256 of shards and archive; this takes minutes)"); let operation: Option<(String, String)> = - match self.cli(&["load-mtp", &id, MTP_PROFILE]).await { + match self.cli(&["load-mtp", &id, self.config.mtp_profile()]).await { Ok((true, text)) => parse_operation(&text), // The CLI never retries an uncertain command; neither do we. Ok((false, text)) => { diff --git a/deploy/rust-runtime/profiles/rtx5090-32g-gguf-ple.json b/deploy/rust-runtime/profiles/rtx5090-32g-gguf-ple.json new file mode 100644 index 00000000..447726d7 --- /dev/null +++ b/deploy/rust-runtime/profiles/rtx5090-32g-gguf-ple.json @@ -0,0 +1,18 @@ +{ + "name": "rtx5090-32g-gguf-ple", + "description": "RTX 5090 class server WITHOUT the KAR level-2 PLE archive (EXPERIMENTAL A/B arm, not auto-selected: pass --profile rtx5090-32g-gguf-ple; everything else is rtx5090-32g). kar_source none: no archive is required, verified, sealed or passed to the engine, and the model is loaded as qwen4exp-native-mtp-v1, whose per-layer n-gram (PLE) rows come from the 28.8 GB GGUF shard 1 exactly as the Original reads them (lossless against the shard; KAR level 2 is a quantised re-encoding of that table). The shard is read through the OS page cache (engine_env LELEKA_PLE_DIRECT 0: after the first pass the table is RAM-resident, the form vanilla Strata gets with --ple-io ram, instead of O_DIRECT reads of the SSD that the engine defaults to on Linux); the row cache and reader depth keep the engine defaults. No memfd and no holder is needed. Prefix cache explicit 6144 MiB like the server profile. No quality claim and no speed claim: the paired A/B against rtx5090-32g is docs/experiments/kar-off-ab-5090.md.", + "select": {"sm_min": 0, "sm_max": 0, "vram_mib_min": 0, "vram_mib_max": 0}, + "gpu_budget_bytes": 32819404800, + "spec_min_p": 0.0, + "expert_profile": "data/expert-profile.bin", + "context_tokens": 262144, + "prefill_capacity": 8192, + "kar_source": "none", + "expert_source": "resident", + "min_driver_major": 595, + "min_vram_total_mib": 30000, + "min_ram_total_bytes": 68719476736, + "min_ram_available_bytes": 62000000000, + "engine_env": {"LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER": "yes", "LELEKA_CHAIN": "all", "LELEKA_ORIGINAL_SERVE_SEED": "off", "LELEKA_SM120_ATTN_DAILY_MTP": "1", "LELEKA_PLE_DIRECT": "0"}, + "memory": {"prefix_cache_mib": "6144", "prefix_cache_tail": "reply", "prefix_cache_block": 8192, "soft_floor_mib": 4096, "hard_floor_mib": 2048, "reserve_mib": 2048, "lock": "off", "heal": false} +}