Merge claude/laptop-3080-finish: 3080 laptop audit, profile pin, WSL2 worker cap, profile guard, run tooling
Rust port / port-oracles (push) Failing after 26s
Linux / verify (push) Failing after 29s
Linux / keyless-cuda (push) Skipped
Linux / static-cuda-package (push) Skipped
Linux / hosted-cuda-package (push) Skipped
Linux / linux-static-cli (push) Skipped
Linux / linux-cli-container (push) Skipped
Linux / release-cli (push) Skipped
Rust port / port-typecheck (push) Successful in 59s
Linux / keyless-cuda-gate (push) Skipped
Rust port / port-fast (push) Failing after 20s
Rust port / port-linux-tests (push) Failing after 22s
Desktop foundation / core (ubuntu-latest) (push) Successful in 3m15s
Product / product (push) Failing after 13m24s

This commit is contained in:
Pavlo Ratushnyi
2026-11-13 17:53:10 +01:00
14 changed files with 412 additions and 6 deletions
+1 -1
View File
@@ -109,6 +109,6 @@ pub use parsers::probe;
#[cfg(all(not(target_os = "linux"), not(windows)))]
pub use parsers::probe;
pub use parsers::{
find_in_dirs, find_library, fs_type_for, is_slow_foreign_fs, is_wsl, parse_cgroup_max,
count_physical_cores, find_in_dirs, find_library, fs_type_for, is_slow_foreign_fs, is_wsl, parse_cgroup_max,
parse_compute_capability, parse_env_file, parse_meminfo, parse_nvidia_smi,
};
+7
View File
@@ -53,6 +53,7 @@ pub fn probe(request: &ProbeRequest) -> Facts {
facts.wsl = is_wsl(&read("/proc/version"));
facts.memory = parse_meminfo(&read("/proc/meminfo"));
facts.cpu_cores = std::thread::available_parallelism().map_or(0, |n| n.get() as u32);
facts.cpu_physical_cores = physical_cores_under_wsl(facts.wsl);
facts.cgroup_memory_max = parse_cgroup_max(&read("/sys/fs/cgroup/memory.max"));
facts.systemd_system = Path::new("/run/systemd/system").is_dir();
facts.proc_fd = Path::new("/proc/self/fd").is_dir();
@@ -196,3 +197,9 @@ fn is_executable(path: &Path) -> bool {
path.metadata()
.is_ok_and(|m| m.is_file() && m.permissions().mode() & 0o111 != 0)
}
/// Only under WSL2 (the 8-core laptop on route A) the CPU pool's workers must not outnumber the physical cores, as on
/// native Windows; other Linux hosts keep their worker counts (the 5090 server is unchanged).
fn physical_cores_under_wsl(wsl: bool) -> u32 {
if wsl { count_physical_cores(&read("/proc/cpuinfo")) } else { 0 }
}
+20
View File
@@ -89,6 +89,26 @@ pub fn is_wsl(proc_version: &str) -> bool {
lower.contains("microsoft") || lower.contains("wsl")
}
/// Physical cores of `/proc/cpuinfo`: the distinct (`physical id`, `core id`) pairs, so SMT siblings count once; 0 when
/// the file carries no core ids (some virtual machines and non-x86 kernels).
pub fn count_physical_cores(cpuinfo: &str) -> u32 {
let mut pairs = std::collections::BTreeSet::new();
let (mut package, mut core) = (None::<&str>, None::<&str>);
for line in cpuinfo.lines().chain(std::iter::once("")) {
match line.split_once(':') {
Some((key, value)) if key.trim() == "physical id" => package = Some(value.trim()),
Some((key, value)) if key.trim() == "core id" => core = Some(value.trim()),
None if line.trim().is_empty() => {
if let Some(core) = core.take() {
pairs.insert((package.unwrap_or("0"), core));
}
}
_ => {}
}
}
pairs.len() as u32
}
/// `memory.max` content: a byte count, or `max` for unlimited.
pub fn parse_cgroup_max(text: &str) -> Option<u64> {
text.trim().parse().ok()
+27
View File
@@ -93,3 +93,30 @@ fn env_file_parser_handles_comments_and_quotes() {
assert!(!env.contains_key("bad key"));
assert!(!env.contains_key("export X"));
}
#[test]
fn physical_cores_count_each_package_and_core_pair_once() {
let smt = |cpu: u32, core: u32| {
format!("processor : {cpu}
physical id : 0
core id : {core}
cpu cores : 8
")
};
let laptop: String = (0..16).map(|cpu| smt(cpu, cpu / 2)).collect();
assert_eq!(count_physical_cores(&laptop), 8, "8 cores, 2 threads each (the i9-11900H under WSL2)");
let two_packages = "physical id : 0
core id : 0
physical id : 1
core id : 0
";
assert_eq!(count_physical_cores(two_packages), 2, "the same core id in two packages is two cores");
assert_eq!(count_physical_cores("core id : 3"), 1, "no trailing blank line, no package id");
assert_eq!(count_physical_cores("processor : 0
model name : x
"), 0, "no core ids: unknown");
assert_eq!(count_physical_cores(""), 0);
}
+27 -1
View File
@@ -30,7 +30,8 @@ impl Profile {
self.validate_engine_options()?;
self.validate_expert_profile()?;
self.memory.validate()?;
self.validate_engine_env()
self.validate_engine_env()?;
self.validate_engine_env_for_the_card()
}
fn validate_sparse_memfd(&self) -> Result<(), String> {
@@ -122,8 +123,33 @@ impl Profile {
}
Ok(())
}
/// A profile whose card window ends below compute capability 12.0 (`0 < select.sm_max <= 120`; the explicit-name
/// profiles have no window, 0..0) must not switch on a kernel that exists only as sm_120 PTX and is not gated by
/// the card in the engine.
fn validate_engine_env_for_the_card(&self) -> Result<(), String> {
if self.select.sm_max == 0 || self.select.sm_max > 120 {
return Ok(());
}
match KEYS_WITHOUT_AN_SM86_COMPANION.iter().find(|key| self.engine_env.contains_key(**key)) {
Some(key) => Err(format!(
"engine_env key {key} loads sealed sm_120 PTX that has no sm_86 companion, but this profile's \
card window (sm {}..{}) is below compute capability 12.0",
self.select.sm_min, self.select.sm_max
)),
None => Ok(()),
}
}
}
/// Switches whose sealed PTX has no sm_86 companion and whose engine code does not check the card (the others of the
/// compute-capability-12 kernels are gated in `Sm120Switches::resolve` and never load their module below 12.x): with
/// either one on a card below 12.x the driver refuses the sealed sm_120 image. See
/// `crates/cuda-driver/ptx-sm86/MANIFEST.json` (`mtp_original_check_batch.ptx` has no companion;
/// `sm120_attn_daily.ptx` is "not built by design"); both switches are read straight from the environment by
/// `mtp_original_check_batch_program.rs` and `validate_scalar_prefix.rs`.
const KEYS_WITHOUT_AN_SM86_COMPANION: [&str; 2] = ["LELEKA_DRAFT_CHECK_MERGE", "LELEKA_SM120_ATTN_DAILY_MTP"];
/// LELEKA_CHAIN selects the chain-kernel group (docs/chain-kernels.md), LELEKA_SM120_* the compute-capability-12
/// kernel switches, LELEKA_DRAFT_* the draft-round ones (docs/experiments/draft-round-5090.md), LELEKA_PLE_* the
/// GGUF PLE row reader (`kar_source: none`), LELEKA_PREFILL_* the prompt-prefill switches (the loan ladder,
@@ -199,8 +199,19 @@ fn only_the_5090_profiles_default_to_global_rank_fill_and_pcie_share_065() {
assert_eq!(env.get("LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER").map(String::as_str), Some("no"), "{name}");
assert_eq!(env.get("LELEKA_ORIGINAL_SERVE_PCIE_FRAC").map(String::as_str), Some("0.65"), "{name}");
}
// the laptop pins the global rank fill, which is also the engine's own default (`ExpertTierConfig::off`), and takes
// no PCIe share: a pageable mapped bank pays more for the copies than the CPU pool does (docs/windows.md)
assert!(!laptop.engine_env.contains_key("LELEKA_ORIGINAL_SERVE_PCIE_FRAC"));
assert_ne!(laptop.engine_env.get("LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER").map(String::as_str), Some("no"));
assert_eq!(laptop.engine_env.get("LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER").map(String::as_str), Some("no"));
}
#[test]
fn the_laptop_profile_carries_exactly_the_audited_engine_env() {
// docs/laptop-profile.md "Update 2026-11-13": one pin, nothing else of the 5090 set. A new key here needs its own
// laptop measurement in that section.
let laptop = Profile::builtin("rtx3080-16g").unwrap();
let keys: Vec<&str> = laptop.engine_env.keys().map(String::as_str).collect();
assert_eq!(keys, ["LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER"]);
}
#[test]
@@ -242,6 +253,22 @@ fn engine_env_lets_through_the_two_tail_skip_keys_and_no_other_route_key() {
}
}
#[test]
fn a_profile_below_compute_capability_12_refuses_the_switches_without_an_sm86_companion() {
// `mtp_original_check_batch.ptx` has no sm_86 companion and `sm120_attn_daily.ptx` is not built for sm_86; the
// engine reads both switches without asking the card, so the driver would refuse the module on the laptop
let laptop = Profile::builtin("rtx3080-16g").unwrap();
for key in ["LELEKA_DRAFT_CHECK_MERGE", "LELEKA_SM120_ATTN_DAILY_MTP"] {
let mut bad = laptop.clone();
bad.engine_env.insert(key.into(), "1".into());
let message = bad.validate().unwrap_err();
assert!(message.contains(key) && message.contains("sm_86"), "{message}");
let mut server = Profile::builtin("rtx5090-32g").unwrap();
server.engine_env.insert(key.into(), "1".into());
server.validate().unwrap();
}
}
/// Engine switches of the compute capability 12 kernels (main attention, gate/up SwiGLU) and of the GDN side streams.
const SM120_MAIN_KERNEL_KEYS: [&str; 11] = [
"LELEKA_SM120_ATTN_DAILY",
@@ -1,6 +1,6 @@
{
"name": "rtx3080-16g",
"description": "RTX 3080 Laptop class (sm_86, 16 GB VRAM, 24-48 GB RAM, typically WSL2). The KAR archive stays an ordinary read-only file (no 55 GB memfd), routed experts are served from the memory-mapped shards. Context 262144 (the owner's real work; measured natively under the workstation preset), prompt chunk and prefix-cache grid 6144 with prompt-end checkpoints (paired 256k sessions on this laptop, docs/laptop-vs-vanilla.md: prefill 110 -> 176-290 tok/s, TTFT sum 2,100+ s -> 998-1,083 s with the conversation cache and about 5 % more with the prefix cache as shipped, against vanilla's 1,248 s; 6144 changes the rounding order of the prompt path and has no quality gate yet). Experimental (docs/laptop-profile.md): measured on one laptop, no quality claim.",
"description": "RTX 3080 Laptop class (sm_86, 16 GB VRAM, 24-48 GB RAM, typically WSL2). The KAR archive stays an ordinary read-only file (no 55 GB memfd), routed experts are served from the memory-mapped shards. Context 262144 (the owner's real work; measured natively under the workstation preset), prompt chunk and prefix-cache grid 6144 with prompt-end checkpoints (paired 256k sessions on this laptop, docs/laptop-vs-vanilla.md: prefill 110 -> 176-290 tok/s, TTFT sum 2,100+ s -> 998-1,083 s with the conversation cache and about 5 % more with the prefix cache as shipped, against vanilla's 1,248 s; 6144 changes the rounding order of the prompt path and has no quality gate yet). Expert tier layout pinned to the global rank fill (engine_env LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER=no, which is also the engine default: a pin, not a change). None of the other 5090 defaults is applied here: PCIe share 0.65, tail skip, swap bursts, PLE on chain and the sm_120 kernel switches are measured losses, lossy, unevidenced or inert on sm_86 (docs/laptop-profile.md \"Update 2026-11-13\"); the lossy route tail skip stays an opt-in key (LELEKA_ROUTE_TAIL_SKIP=7 in a copy of this profile). Experimental (docs/laptop-profile.md): measured on one laptop, no quality claim.",
"select": {"sm_min": 80, "sm_max": 120, "vram_mib_min": 14000, "vram_mib_max": 24000},
"gpu_budget_bytes": 16106127360,
"context_tokens": 262144,
@@ -15,6 +15,6 @@
"wsl_memory_gib": 32,
"expert_profile": "data/expert-profile.bin",
"expert_profile_sha256": "8f59b4aa8873209dff11c11e37bcda9529a1335b724a1afeea37bf6388975baf",
"engine_env": {},
"engine_env": {"LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER": "no"},
"memory": {"prefix_cache_mib": "auto", "prefix_cache_tail": "prompt", "prefix_cache_block": 6144, "soft_floor_mib": 4096, "hard_floor_mib": 2048, "reserve_mib": 1024, "lock": "off", "heal": false}
}
+3 -1
View File
@@ -105,7 +105,7 @@ The files live in [`deploy/rust-runtime/profiles/`](../deploy/rust-runtime/profi
| profile | selected for | GPU budget | context | KAR archive | routed experts | RAM floor (total / available at start) | other |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `rtx5090-32g` | sm_12x, >= 30 GB VRAM | 32,819,404,800 B = 31,299 MiB (needs that much free at start: 31,299 of the 32,110 MiB an idle card reports; was 30 GiB, see [vram-footprint-5090](experiments/vram-footprint-5090.md)) | 262,144 | sealed **sparse** memfd (`memfd_extents: ple_only`): only the 16.0 GB of the archive the serve path reads (the PLE rows, 2 extents), holes elsewhere; read O_DIRECT, so no page-cache copy | `resident`: page-locked RAM copy (50.3 GB) | 100 GiB / 74 GB (113 GB for `memfd_extents: full`; 58 GB when `--kar-fd` supplies the archive) | one resident copy of every model byte in host RAM (`kar-sparse-memfd.md`) |
| `rtx3080-16g` | sm_80..119, 14-24 GB VRAM | 15 GiB (needs 14,500 MiB free) | 8,192 | read-only file | `mapped`: read-only mappings of shard 0 | 22 GiB / 10 GiB; advice `.wslconfig memory=32GB` | VRAM expert tier: `up` fetches `ASSETS/data/expert-profile.bin` (pinned SHA-256 `8f59b4aa...388975baf`; `--no-expert-tier` to run without) |
| `rtx3080-16g` | sm_80..119, 14-24 GB VRAM | 15 GiB (needs 14,500 MiB free; the `workstation` preset the owner runs lowers it to 13 GiB) | 262,144 (chunk and prefix-cache grid 6144, tail `prompt`) | read-only file | `mapped`: read-only mappings of shard 0 | 22 GiB / 10 GiB; advice `.wslconfig memory=40GB swap=8GB` | VRAM expert tier: `up` fetches `ASSETS/data/expert-profile.bin` (pinned SHA-256 `8f59b4aa...388975baf`; `--no-expert-tier` to run without); one `engine_env` pin (`LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER=no`); see the laptop paragraph below |
| `rtx5090-32g-file` (experimental, never auto-selected: `--profile rtx5090-32g-file`) | none (explicit name only) | as `rtx5090-32g` | 262,144 | read-only file (`kar_source: file`; no memfd, no holder; start reads about 1 MB of it when its verification stamp is current) | `resident` | 64 GiB / 62 GB (the 55 GB archive is page cache, not a charge) | as `rtx5090-32g` except an explicit `prefix_cache_mib` 6144; [`kar-file-source.md`](kar-file-source.md): what the file form reads, its integrity guarantees, the A/B (`scripts/e2e/decode/kar-file-ab.sh`, not run) |
| `rtx5090-32g-gguf-ple` (experimental A/B arm, never auto-selected: `--profile rtx5090-32g-gguf-ple`) | none (explicit name only) | as `rtx5090-32g` | 262,144 | **no KAR archive** (`kar_source: none`): not required, checked, sealed or passed; the engine loads `qwen4exp-native-mtp-v1` and reads the PLE rows from GGUF shard 1 (page cache, `LELEKA_PLE_DIRECT=0`) | `resident` | 64 GiB / 62 GB (the 28.8 GB PLE table is page cache) | as `rtx5090-32g` except an explicit `prefix_cache_mib` 6144, no memfd lock/heal; `--kar-fd` is refused; [`experiments/kar-off-ab-5090.md`](experiments/kar-off-ab-5090.md): the paired speed and quality A/B against `rtx5090-32g` (no claim before that page says so) |
@@ -115,6 +115,8 @@ The files live in [`deploy/rust-runtime/profiles/`](../deploy/rust-runtime/profi
**Tier swap bursts, on by default in the 5090 profiles (owner decision 2026-11-13, placement class).** The three 5090 profiles (`rtx5090-32g`, `-file`, `-gguf-ple`) set `LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=2` and `LELEKA_ORIGINAL_SERVE_ADAPT_SWAPS=48` as `engine_env` keys (both under the allowed `LELEKA_ORIGINAL_SERVE_` prefix); both appear in the `engine environment` line of `leleka up`. What it does: the adaptive expert tier swaps up to 48 experts every 2 rounds instead of up to 96 every 4 rounds (the engine's own defaults, `ADAPT_EVERY` 4 and `ADAPT_SWAPS` 96 when the keys are absent): the same swap throughput per round in bursts of about 1.65 ms that fit under the draft chain, so the host waits less for the copies. Evidence (stage 6c, release 83bdd85bb482, 67k replay, `docs/experiments/host-round.md` sections 5 and 6): swap wait (`round.apply_pending`) 0.351 -> 0.098 ms per round, paired decode +1.53 % (95% CI +0.26..+2.79, 3 blocks). Quality gate: it is a placement-class change (which experts sit in VRAM), judged by the control-relative rule of H4 on the teacher-forced 256k session. Against the worst of three ordinary controls (PCIe share 0.35 / 0.55 / 0.75) it passes: limits p99 0.2745, max 1.027, flips 2.31 %; variant 0.1915 / 0.796 / 1.73 %. It did NOT pass against the single 0.55 control alone (max 0.796 against 0.497); the owner accepted this explicitly (judged against the worst ordinary control, as for the PCIe 0.65 default). The tier cadence allocates no VRAM, so the 256k free-VRAM floor of H4 does not apply. The laptop profile `rtx3080-16g` is unchanged. To turn it off set `LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=4` and `LELEKA_ORIGINAL_SERVE_ADAPT_SWAPS=96` (the previous defaults, in a copy of the profile with `--profile FILE.json`, or as operator `engine_env` values) or remove both keys. Row H4 and the 6c paragraph of `docs/experiments/step-ledger.md` record the decision.
**The laptop profile `rtx3080-16g` and the 5090 defaults (audit 2026-11-13, `docs/laptop-profile.md` "Update 2026-11-13").** None of the 5090 `engine_env` defaults is copied to the 3080 laptop except a pin of the expert tier layout, `LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER=no` (the engine's own default, global rank fill). Not applied: `PCIE_FRAC=0.65` (a pageable mapped bank pays more for PCIe copies than the CPU pool does: measured 25-29 % slower on this laptop with a share set), the swap bursts and `PLE_ON_CHAIN` (their gain is 0.1-0.25 ms of a 18 ms 5090 round; the laptop round is 130-240 ms), and every `LELEKA_SM120_*` / `LELEKA_DRAFT_FUSED_COMMIT` switch (inert below compute capability 12: `Sm120Switches::resolve`). `LELEKA_DRAFT_CHECK_MERGE` and `LELEKA_SM120_ATTN_DAILY_MTP` are not gated by the card and have no sm_86 companion PTX, so `Profile::validate` refuses them in a profile whose card window ends below sm_120. The LOSSY route tail skip is an opt-in for the laptop (copy the profile, add `LELEKA_ROUTE_TAIL_SKIP=7` and `LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED=100`, pass `--profile FILE`); there is no quality gate for the laptop's small tier and it is not in the shipped profile. Under WSL2 the planner now caps the CPU expert workers at the physical cores minus one (7 on the i9-11900H, as on native Windows; it was 12 under `workstation`).
Both profiles also carry a `memory` section (prefix cache `auto`, soft/hard floors 4096/2048 MiB, reserve, lock and heal of the sealed memfd): the engine sizes its caches from the memory left after the fixed footprint, sheds and refuses under pressure, and refuses to start with numbers when the footprint does not fit ([`memory-safety.md`](memory-safety.md)). The unit sets `LimitMEMLOCK=infinity`, which is what lets the lock keep the 55 GB memfd out of swap.
Both profiles run `--backend-mode original` and the level-2 archive; the routed-expert bank must be admitted before the Original stack opens, which `leleka-inference` now does from `--expert-source resident|mapped` (see section 10, finding 1). They select documented switches only (budget, context, archive form, the
+77
View File
@@ -248,3 +248,80 @@ for every miss; the VM already swaps anonymous pages (1.8-2.5 GB) with 40 GB of
seed swaps 1,024, prefix cache budget under the memory governor.
4. Stability: 30 mixed requests and the 1-hour soak in 15-minute segments with `LELEKA_LAPTOP_SEQUENCE` / `LELEKA_LAPTOP_SOAK_S`
(`mem.tsv` at 1 Hz holds RSS, VRAM, swap, clocks, power, temperature).
## Update 2026-11-13: audit of the 5090 defaults for sm_86 / 16 GB / PCIe laptop, and the profile as it now ships
Owner request 2026-11-13: finish the 3080 laptop. Scope of this section: which of the current 5090 `engine_env` defaults and engine switches can apply to this machine
(sm_86, 16 GiB, a pageable file-mapped expert bank, PCIe x8 gen4 measured, 48 GB RAM, WSL2 or native Windows), read from the code of this tree
(`crates/engine-qwen35-cuda`, `crates/cuda-driver`, `crates/deploy`), and the live check of the ones that are candidates. Part 1 is the audit (no GPU).
### 1. Audit (no GPU): verdict per key
Basis: the 5090 profile `rtx5090-32g.json` `engine_env` (25 keys), the laptop profile as it was (`engine_env` empty), `ExpertTierConfig` (`tail_skip_rank.rs`), `Sm120Switches::resolve`
(`original_verify_window_sm120.rs`), the sm_86 companion manifest (`crates/cuda-driver/ptx-sm86/MANIFEST.json`, `python scripts/gpu-bringup/sm86_assets.py check`), the profile allow-list
(`crates/deploy/src/profile/profile_limits.rs`) and the planners (`plan.rs`, `preflight.rs`, `resources/sizing.rs`, `reconfigure`).
| key (5090 value) | what it is | on this laptop | verdict |
| --- | --- | --- | --- |
| `LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER=no` | tier filled in global rank order, not a uniform per-layer quota | `ExpertTierConfig::off()` has `per_layer: false`, so the engine already fills globally when the key is absent (a start log line says `global` or `per layer`); only `yes`/`1`/`on` turn the quota on. The key is an explicit pin, not a change | pin it (no behavioural change; the 5090 +8.2 % of ledger H4 was measured together with PCIe 0.65 and is not claimed here) |
| `LELEKA_ORIGINAL_SERVE_PCIE_FRAC=0.65` | share of the tier's misses that go over PCIe | `pcie_num_for(pageable_source)` returns 0 for a pageable (mapped) bank unless the share is set explicitly; a set share sends pageable pieces through the driver on the window thread. Measured on this laptop (2026-10-27, native, section above in `docs/windows.md`): share 0.45 is 25-29 % slower than unset, 0.65 the slowest row of the single-request table (4.0-4.3 against 6.5-9.1 tok/s), `LOCKED_ONLY` + 0.6 about +8 % in 9 runs and not proven | **do not set** (0.65 was tuned for a page-locked 50 GB bank on PCIe 5; here it is a measured loss) |
| `LELEKA_ROUTE_TAIL_SKIP=7`, `..._MAX_CACHED=100` | LOSSY: missed experts that every token of the window routes at rank 7+ are not computed | works on any card; applies while less than 100 % of the experts are in VRAM (here about 10 %), so it skips the most on this machine; vanilla Strata ships it on and gets 30-40 % of its decode from it (`docs/laptop-vs-vanilla.md` section 11). Its quality gate was passed only by the owner's override on the 5090 (logit flips 3.6 % against the Original's 2.8 %); no gate exists for the laptop tier | **opt-in, documented, not in the profile**; speed measured in this update (below), quality not |
| `LELEKA_ORIGINAL_SERVE_ADAPT_EVERY=2`, `..._ADAPT_SWAPS=48` | tier swap bursts | the 5090 gain is 0.25 ms of swap wait in a 18 ms round; the laptop round is 130-240 ms and its swap copies come from a pageable bank, nothing measured | not applied (no evidence; engine defaults 4 and 96) |
| `LELEKA_PLE_ON_CHAIN=on` | next window's PLE rows gathered behind the draft chain (bit-identical) | saves 0.13 ms per round on the 5090; the laptop round is 130-240 ms, so < 0.1 % | not applied |
| `LELEKA_SM120_ATTN_DAILY`, `_GU_SWIGLU`, `_SIDE_MIXER`, `_SIDE_QSA`, `_SIDE_SHARED`, `_FUSED_QSA_PRELUDE`, `_COMBINE_VEC4`, `_DOWN_SUB16`, `_HITS_IN_COMBINE`, `_HEAD_CHAIN_BATCH` | sm_120 decode kernels and side streams | inert: `Sm120Switches::resolve` takes `capable = major >= 12`, so on cc 8.6 every switch reads false whatever the variable says (unit test `a_switch_variable_wins_in_both_directions_on_any_card`); their PTX is "not built for sm_86 by design" in the manifest | not applied (no effect; the vanilla sm_86 equivalents are other kernels, `experiments/2026-10-28-s3-5-sm86-switch-audit.md`: nine upstream defaults, none ported) |
| `LELEKA_SM120_ATTN_DAILY_MTP=1` | draft-step attention from sm_120 PTX | **not gated by the card**: `validate_scalar_prefix.rs::daily_mtp` reads the variable directly and loads `sm120_attn_daily.ptx`, which has no sm_86 companion, so the driver refuses the module | forbidden on a profile below cc 12 (new check in `Profile::validate`) |
| `LELEKA_DRAFT_CHECK_MERGE=1` | one batched guard launch in the draft step | not gated by the card, and `mtp_original_check_batch.ptx` has no sm_86 companion (`sm86_assets.py check` fails on it today) | forbidden on a profile below cc 12 (same check) |
| `LELEKA_DRAFT_FUSED_COMMIT=1` | fused commit graph | `record_commit` fuses only on cc 12; `draft_commit*.ptx` are "not built by design" | inert, not applied |
| `LELEKA_CHAIN=all` | chain kernels of the verify window | `chain_window.ptx` has an sm_86 companion now (the "no sm_86 record" remark in `windows.md` is stale; the check fails on `mtp_original_check_batch.ptx` only); never run on the 3080 inside the product; STRA-235 (sm_86 stream-K faults in the live pipeline) shows that a kernel that is clean elsewhere needs its own laptop run | not applied; an A/B candidate, not run here |
| `LELEKA_PREFILL_LOAN_TIERS=1` | smaller prompt loans for smaller chunks | lossless (chunk residual hashes equal, paired n=10: -150 ms per small request on the 5090). The laptop refills the lent slots from a pageable bank after every prompt, so the saving per small agent turn should be larger here | candidate, checked live below |
| `LELEKA_PREFIX_PARK_FAST=1` | prefix-cache park drains once, same bytes | lossless (row B3); the laptop parks 6144-token grid points | candidate, checked live below |
| `LELEKA_DECODE_GRAPH_REUSE=1` | keep the decode graph set between requests | "not run on a device" in its own document; it keeps the verifier arena and pins shared experts between requests, on a card where free VRAM is the scarce resource (459 MiB free in the vanilla reference) | not applied |
| `STRATA_PREFILL_STREAM_MIN=1536` | smallest chunk that streams every non-resident expert | the 5090's tuning for small chunks; the laptop's chunk is 6144, the effect is on tails below 4096 rows, never measured here | not applied |
| `LELEKA_ORIGINAL_SERVE_SEED=off` | no prompt-routing seed of the tier | the engine default is on; the 5090 measured +27 % decode at 45-247k prompts; the laptop tier is 2-3 k slots and has no measurement | candidate, checked live below |
| prefix cache (`auto`, tail `prompt`, grid 6144), chunk 6144, workers 7 (preset), `lock off` | | already set by the profile and the preset (`docs/laptop-vs-vanilla.md` section 12) | unchanged |
The CPU expert kernel fixes (AVX-512 rows, adaptive page-touch pass) are engine defaults and apply as they are. The three Windows-native open fixes of the 2026-10-25 run are all in the tree:
`probe_libraries` (`facts/windows.rs`) finds `%LOCALAPPDATA%\leleka\cublas\bin` for `up --native` as `doctor` does; `plan_windows_mapped` (`resources/sizing.rs`) sets
`resident_budget_gib` from the available RAM minus the desktop reserve and the engine's fixed footprint (never the greedy auto value); `reconfigure` refuses up front on a starved host
(`refuse_starved_host`, HTTP 409, nothing changed) and exits the engine (code 70, the supervisor restarts it) when the reopen and the rollback both fail (`reconfigure_parts.rs`).
### 2. Fixes (code, no GPU)
* The three Windows-native open fixes of 2026-10-25 (cuBLAS probe of `up --native` against `doctor`, greedy resident budget, `reconfigure` bricking the engine) were already in the tree; the status with the places and the tests is in `docs/windows.md` ("The three open fixes ... status checked 2026-11-13"). Nothing was left to finish there; the memory note that still lists them as open is stale.
* New, found by this audit: **route A planned 12 CPU expert workers** on the 8-core laptop under the `workstation` preset (native Windows plans 7: the pool pins to the physical cores left after the host thread and spins the rest). `facts/linux.rs` now fills `cpu_physical_cores` from `/proc/cpuinfo` when it runs under WSL2 only (`count_physical_cores`, test `physical_cores_count_each_package_and_core_pair_once`); `leleka up --dry-run --preset workstation` in WSL plans `LELEKA_ORIGINAL_SERVE_CPU_WORKERS=7`, chunk 6144, budget 13 GiB. The 5090 server and every non-WSL Linux host are unchanged (the field stays 0 there). Effect on speed not measured here (the GPU run did not happen, below); the 7-worker figure is the one measured natively (+5 to +18 % decode, `docs/laptop-vs-vanilla.md` section 12).
* New: `Profile::validate` refuses `LELEKA_DRAFT_CHECK_MERGE` and `LELEKA_SM120_ATTN_DAILY_MTP` in a profile whose card window ends below sm_120 (`select.sm_max` 1..=120): neither is gated by the card in the engine and neither has an sm_86 companion PTX, so the driver would refuse the module. The three explicit-name 5090 profiles (window 0..0) and `rtx5090-32g` (120..130) are unaffected. Test `a_profile_below_compute_capability_12_refuses_the_switches_without_an_sm86_companion`. The engine itself still reads both variables without a card check; that is a one-line gate for the owner of `mtp_original_check_batch_program.rs` / `validate_scalar_prefix.rs`, not changed here.
* Gates: `python scripts/check-limits.py` 0 errors, `python scripts/check-architecture.py` 0 errors (2 baselined violations unchanged); `cargo test -p leleka-deploy --lib` in WSL (target dir in the worktree): 200 passed, 0 failed, 2 ignored. The route A binaries (`scripts/laptop/build-route-a.sh`, sm86) were built from current main inside WSL and `leleka up --dry-run` was run with them.
### 3. Profile: what changed in `rtx3080-16g.json`
| | before | now |
| --- | --- | --- |
| `engine_env` | `{}` | `{"LELEKA_ORIGINAL_SERVE_EXPERT_PER_LAYER": "no"}` (a pin of the engine default; no behavioural change expected: the start log's `global` / `per layer` line confirms it on the first run) |
| everything else | | unchanged (context 262144, chunk and grid 6144, tail `prompt`, mapped experts, KAR file, floors) |
No lossy key and no unmeasured speed key was added: the evidence that exists for the 5090 does not transfer (section 1), and the laptop run that would give evidence did not happen (section 4). `docs/deploy.md` section 4 (table row and the laptop paragraph) and a profile test (`the_laptop_profile_carries_exactly_the_audited_engine_env`) record this: a new key needs its own laptop measurement in this document.
### 4. Live validation: NOT RUN (machine state), and how to run it
**No GPU job was started.** The preflight of the safety protocol refused: `nvidia-smi -q -d PERFORMANCE,POWER` on 2026-11-13 (17:45-17:55 local, six readings) read **Current Power Limit 30.00 W** (default 115, max 140), P5, SW Power Cap / SW Thermal Slowdown intermittently active at idle, while Windows reported AC online (`PowerOnline True`) and the battery as discharging, the power plan "Turbo" and the OEM mode evidently not Performance. This is the signature of the OEM 30 W profile that preceded both 0x19C blue screens (state table at the top of the 2026-10-24 update) and that invalidated run d of `laptop-vs-vanilla.md`. System settings are the owner's; nothing was changed. Other conditions at the time: other agents' `cargo`/`rustc` builds were running on Windows and in WSL, Windows had 9-19 GB free.
Found while preparing: a Leleka user service from 2026-10-25 (old binaries, `--context-tokens 8192`, enabled, started by WSL at boot, idle for 5.5 h) held 14.4 GB of VRAM and 12 GB of RAM; I stopped it with `leleka down`. It is `enabled`, so it starts again whenever the WSL VM boots; `leleka up` with the new binaries replaces it, `systemctl --user disable leleka` removes the autostart (owner's choice).
What is ready for the run (all in the repository, nothing needs a rebuild except `leleka` itself for a profile change; arms are `--profile FILE`):
| file | what |
| --- | --- |
| `scripts/laptop/build-route-a.sh` | the six Linux binaries for sm_86 inside WSL, target dir in the worktree |
| `scripts/laptop/make_arm_profiles.py OUT [BASE]` | arm profiles: A-before (empty `engine_env`), B-shipped, C-lossless (+ `LELEKA_PREFILL_LOAN_TIERS=1`, `LELEKA_PREFIX_PARK_FAST=1`), D-seed-off (C + `LELEKA_ORIGINAL_SERVE_SEED=off`), E-tail7 (C + tail skip 7, LOSSY, speed only) |
| `scripts/laptop/lap_guard.sh OUT.tsv ENGINE_LOG LELEKA_BIN` | 15 s sampler: stops the engine (`leleka down`) at 85 C, at P5 with a power cap and memory clock < 2 GHz, at a limit < 100 W under load, below 2.5 GB MemAvailable, at a 300 s log stall with the GPU busy, and at a sampler gap |
| `scripts/laptop/lap_replay.py` | agent-shaped replay over `/v1/responses`: one cold turn of N tokens of real source, then small follow-up turns that hit the prefix cache; records input / cached / new tokens, TTFT, wall, decode tok/s, prefill tok/s per turn, the corpus digest |
Procedure (one arm per stretch, <= 15 min, ABBA over A-before and B-shipped with a 2 min cool-down, 30k then ~64k first turn, 3 follow-ups of ~1,500 tokens, 200 output tokens; start with `leleka up --profile ARM.json --assets ~/leleka-assets --preset workstation --cublas-dir ~/cublas-12.9.1.4/x/libcublas-linux-x86_64-12.9.1.4-archive/lib`, stop with `leleka down`):
only when `nvidia-smi -q -d PERFORMANCE,POWER` shows a limit >= 100 W with no SW cap at idle, no `cargo`/`rustc`/`link` on Windows or in WSL, and >= 10 GB free. Expected from the earlier native runs (not claims): cold prefill 200-300 tok/s at chunk 6144, decode 6-9 tok/s, TTFT of a 30k cold turn about 100-150 s.
### 5. What the owner must change, and what stays open
* **Power mode**: put the laptop in the OEM Performance / Turbo mode (limit >= 100 W at idle) and keep it on the charger before any GPU run; the 30 W cap is also what makes every number in this document unusable. This is the single blocker of the live validation.
* `.wslconfig`: `memory=40GB`, `swap=8GB` is applied and sufficient; do not raise it while Windows has under ~12 GB free with the desktop running.
* Autostart: the old `leleka.service` user unit starts at every WSL boot with whatever profile it was installed with; `leleka up` (new binaries) reinstalls it, or disable it.
* Open: the A/B of `LOAN_TIERS` + `PARK_FAST` (lossless candidates), `SEED=off`, the opt-in tail skip (speed and, separately, a quality gate on the small tier), `DECODE_RESERVE_MIB`, `LELEKA_CHAIN` on sm_86, the worker count 7 against 12 under WSL, route B (native) rebuild and sanity run. None was run.
+13
View File
@@ -388,6 +388,19 @@ had 0.2 GiB available (engine 32 GiB resident): the machine runs at its memory l
What the start check needs on this laptop: fixed footprint 29.4 GiB (the mapped working set is estimated at MemTotal/2 = 23.9 GiB, pinned K/V 3.1 GiB, pools) plus the floor and reserve
(4 GiB with the lowered Windows floors). With less than about 34 GiB available the engine refuses to start and says so; close the browser and Docker Desktop first.
### The three open fixes of 2026-10-25: status checked 2026-11-13 (code read, tests run, no GPU)
| open fix | in the tree | where / test |
| --- | --- | --- |
| `up --native` said cuBLAS missing while `doctor` found it | done | `facts/windows.rs::probe_libraries` searches `--cublas-dir`, the binary folder, `%LOCALAPPDATA%\leleka\cublasin` (falls back to `%USERPROFILE%\AppData\Local`), `PATH`, System32; `preflight/cuda_libraries.rs` judges `cublas64_12.dll` / `cublasLt64_12.dll` from those facts (test `a_windows_laptop_is_judged_natively_with_dll_names_and_no_systemd_or_memfd`) |
| greedy page-locked complement of the mapped bank | done | `resources/sizing.rs::plan_windows_mapped`: `resident_budget_gib = (available - desktop reserve - engine fixed) / GiB`, at most 24; 12 GiB reserve (`dedicated`) or 18 GiB (`workstation`); tests in `resources/tests/windows_presets.rs` |
| `reconfigure` left the engine unusable on a starved host | done | `reconfigure_parts.rs`: `refuse_starved_host` refuses with a message before the old stack is closed; when the reopen and the rollback both fail the engine exits with code 70 two seconds after the reply and the supervisor restarts it (`exit_for_restart`). The exit path itself has no unit test (it ends the process); the refusal text is `starved_host_error` |
One more gap found by the same audit and closed here: under WSL2 (route A) the planner did not know the physical cores, so the `workstation` preset asked for **12** CPU expert workers on the 8-core laptop,
where native Windows gets 7 (the pool pins to the 7 physical cores left after the host thread and spins the other 5 unpinned, `docs/upstream-port-plan.md` row 2.3). `facts/linux.rs` now reads the
distinct (`physical id`, `core id`) pairs of `/proc/cpuinfo` when it runs under WSL2 (other Linux hosts are unchanged, the 5090 server keeps its 15); `leleka up --dry-run --preset workstation` in WSL now plans 7
workers (it said 12). Test `physical_cores_count_each_package_and_core_pair_once`.
### Workstation preset on Windows (planned, not yet measured)
The laptop is also the owner's work machine (coding agent, IDE, browser), so it runs `--preset workstation`; the 5090 server runs `dedicated`. In the
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Linux release binaries for route A (the WSL2 bridge) of the 3080 laptop, built inside WSL for sm_86.
#
# wsl -d Ubuntu -- bash /mnt/c/Users/pavel/work/leleka/.git/wt/<worktree>/scripts/laptop/build-route-a.sh
#
# The target directory is inside the worktree (AGENTS.md: keep WSL builds in the work folder); the result is
# <worktree>/target/release/{leleka,leleka-inference,leleka-daemon,leleka-cli,leleka-seal-exec,strata-next}.
# Check first that no other build runs (`pgrep -a cargo`) and never start it during a GPU run.
set -euo pipefail
# shellcheck disable=SC1090
source "$HOME/.cargo/env"
worktree=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
cd "$worktree"
export CARGO_TARGET_DIR="$worktree/target"
export CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-10}"
cargo build --release --locked -p strata-desktop-core --features sm86 \
--bin leleka-inference --bin leleka-daemon --bin leleka-cli --bin leleka-seal-exec
cargo build --release --locked -p strata-control --bin strata-next
cargo build --release --locked -p leleka-deploy --bin leleka
echo BUILD-DONE
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Safety sampler for a laptop GPU run of the product engine (`leleka up`, route A inside WSL2). Run it in the background for
# the length of one stretch; it samples the GPU, the VM memory and the engine log, and on a trip it stops the engine.
#
# lap_guard.sh OUT.tsv ENGINE_LOG LELEKA_BIN [INTERVAL_S=15] (stop it with: touch OUT.tsv.done)
#
# Trips (the owner's safety protocol, docs/laptop-profile.md "Update 2026-11-13"):
# TEMP GPU temperature >= 85 C
# P5CAP performance state P5 with the SW power cap / SW thermal slowdown reasons (0x4 | 0x20) and the memory clock under 2 GHz
# (the OEM profile of the 0x19C blue screens); a plain P5 at idle is not a trip
# LIMIT power limit under 100 W while the GPU is busy
# MEM MemAvailable of the VM under 2,500 MiB
# STALL the engine log has not grown for 300 s while the GPU utilisation was >= 95 % in the last 8 samples
# GAP two samples more than 4 intervals apart (the machine stalled): all GPU work must stop
# A trip writes OUT.tsv.abort and runs `LELEKA_BIN down`, then TERMs leleka-inference. Columns of OUT.tsv: unix time, temperature,
# pstate, SM MHz, memory MHz, power W, limit W, throttle reasons, utilisation, VRAM MiB, MemAvailable MiB, engine log bytes.
set -u
out="$1"; log="$2"; bin="$3"; interval="${4:-15}"
rm -f "$out.abort" "$out.done"
printf 't\ttemp_c\tpstate\tsm_mhz\tmem_mhz\tpower_w\tlimit_w\tthrottle\tutil\tvram_mib\tavail_mib\tlog_bytes\n' > "$out"
trip() {
echo "$1 at $(date -u +%FT%TZ)" > "$out.abort"
echo "GUARD TRIP: $1" >&2
"$bin" down >> "$out.abort" 2>&1 || true
pkill -TERM -x leleka-inference 2>/dev/null || true
exit 3
}
prev=$(date +%s); busy=0; log_size=0; log_changed=$prev
while [ ! -e "$out.done" ]; do
IFS=, read -r temp ps smc memc pw thr lim util vram < <(nvidia-smi \
--query-gpu=temperature.gpu,pstate,clocks.sm,clocks.mem,power.draw,clocks_throttle_reasons.active,power.limit,utilization.gpu,memory.used \
--format=csv,noheader,nounits 2>/dev/null | tr -d ' ')
now=$(date +%s)
avail=$(awk '$1=="MemAvailable:" {printf "%d", $2/1024}' /proc/meminfo)
size=$(stat -c %s "$log" 2>/dev/null || echo 0)
if [ "$size" != "$log_size" ]; then log_size=$size; log_changed=$now; fi
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$now" "${temp:-0}" "${ps:-}" "${smc:-0}" "${memc:-0}" "${pw:-0}" "${lim:-0}" \
"${thr:-0x0}" "${util:-0}" "${vram:-0}" "$avail" "$size" >> "$out"
if [ "${util:-0}" -ge 95 ] 2>/dev/null; then busy=$((busy + 1)); else busy=0; fi
[ $((now - prev)) -gt $((interval * 4)) ] && trip "GAP $((now - prev)) s between samples"
[ "${temp:-0}" -ge 85 ] 2>/dev/null && trip "TEMP ${temp} C"
[ "${ps:-}" = P5 ] && [ "${memc:-0}" -lt 2000 ] 2>/dev/null && [ $(( ${thr:-0x0} & 0x24 )) -ne 0 ] 2>/dev/null && trip "P5CAP reasons ${thr}"
[ "${util:-0}" -ge 50 ] 2>/dev/null && awk -v l="${lim:-0}" 'BEGIN {exit !(l+0 > 0 && l+0 < 100)}' && trip "LIMIT ${lim} W"
[ "$avail" -lt 2500 ] && trip "MEM ${avail} MiB"
[ "$busy" -ge 8 ] && [ $((now - log_changed)) -gt 300 ] && trip "STALL log idle $((now - log_changed)) s with the GPU busy"
prev=$now
sleep "$interval"
done
+99
View File
@@ -0,0 +1,99 @@
#!/usr/bin/env python3
"""Agent-shaped replay for the laptop engine: one conversation that starts big and then grows by small agent turns.
Turn 1 is a cold prompt of --first-tokens tokens of real Rust source (the repository's crates/ directory, in a fixed file order,
corpus digest recorded); every following turn appends --followup-tokens more source plus a question, so the prefix cache serves the
earlier turns the way a coding agent's session does. Per turn it records the input / cached / new tokens, TTFT, wall time, decode
tok/s (output tokens over the stream time after the first token) and prefill tok/s (new tokens over TTFT, which includes the
first token's own step). The reply text is never stored, only its hash.
lap_replay.py --label A-30k --first-tokens 30000 --followups 3 --out RESULTS.jsonl
E2E_BASE_URL (default http://127.0.0.1:8081), E2E_API_KEY or --key-file, E2E_MODEL (default: the first /v1/models id)
Test tooling for docs/laptop-profile.md; it reuses the streaming client of scripts/e2e/long_session.py.
"""
import argparse
import hashlib
import json
import os
import pathlib
import sys
import urllib.request
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent / "e2e"))
import long_session as ls # noqa: E402
CHARS_PER_TOKEN = 3.3
def model_id(base, key):
request = urllib.request.Request(base + "/v1/models", headers={"Authorization": "Bearer " + key})
with urllib.request.urlopen(request, timeout=30) as response:
return json.load(response)["data"][0]["id"]
def corpus_digest(files, src):
digest = hashlib.sha256()
for path in files:
data = pathlib.Path(path).read_bytes()
digest.update(os.path.relpath(path, src).replace("\\", "/").encode() + b"\0" + hashlib.sha256(data).digest())
return digest.hexdigest()
def build_turns(files, first_tokens, followups, followup_tokens):
"""The user texts of every turn (source chunks + a question), sized with the fixed 3.3 characters per token estimate."""
sizes = [first_tokens] + [followup_tokens] * followups
texts, position = [], 0
for turn, tokens in enumerate(sizes):
chunk, position = ls.take(files, position, int(tokens * CHARS_PER_TOKEN))
texts.append(chunk + "\n\n" + ls.QUESTIONS[turn % len(ls.QUESTIONS)])
return texts
def one_turn(args, base, key, model, items):
info, reply = ls.stream(base, key, model, items, args.max_output)
new_tokens = (info.get("input_tokens") or 0) - (info.get("cached_tokens") or 0)
if info.get("ttft_s") and new_tokens > 0:
info["new_tokens"] = new_tokens
info["prefill_tok_s"] = round(new_tokens / info["ttft_s"], 1)
return info, reply
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--label", required=True)
parser.add_argument("--src", default=str(pathlib.Path(__file__).resolve().parents[2] / "crates"))
parser.add_argument("--first-tokens", type=int, default=30000)
parser.add_argument("--followups", type=int, default=3)
parser.add_argument("--followup-tokens", type=int, default=1500)
parser.add_argument("--max-output", type=int, default=200)
parser.add_argument("--key-file")
parser.add_argument("--out", required=True)
args = parser.parse_args()
base = os.environ.get("E2E_BASE_URL", "http://127.0.0.1:8081")
key = os.environ.get("E2E_API_KEY") or pathlib.Path(args.key_file).read_text().strip()
model = os.environ.get("E2E_MODEL") or model_id(base, key)
files = ls.collect(args.src)
if not files:
print("lap_replay: no .rs file under " + args.src, file=sys.stderr)
return 2
header = {"label": args.label, "corpus_sha256": corpus_digest(files, args.src), "files": len(files), "model": model}
items, failed = [], False
with open(args.out, "a", encoding="utf-8") as out:
out.write(json.dumps(header) + "\n")
for turn, text in enumerate(build_turns(files, args.first_tokens, args.followups, args.followup_tokens), 1):
items.append({"role": "user", "content": [{"type": "input_text", "text": text}]})
info, reply = one_turn(args, base, key, model, items)
info.update(label=args.label, turn=turn)
out.write(json.dumps(info) + "\n")
out.flush()
print(json.dumps(info), flush=True)
if "error" in info:
failed = True
break
items.append({"role": "assistant", "content": [{"type": "output_text", "text": reply}]})
return 1 if failed else 0
if __name__ == "__main__":
sys.exit(main())
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
"""Writes the arm profiles of the laptop A/B (docs/laptop-profile.md "Update 2026-11-13") next to each other, for `leleka up --profile FILE`.
make_arm_profiles.py OUT_DIR [BASE_PROFILE.json] (default base: deploy/rust-runtime/profiles/rtx3080-16g.json)
Arms (each is one engine start; the arm name is the file name):
A-before engine_env empty: the profile as it was before 2026-11-13
B-shipped the profile as shipped now (one pin: global rank fill, which is the engine default)
C-lossless B + LELEKA_PREFILL_LOAN_TIERS=1 + LELEKA_PREFIX_PARK_FAST=1 (identity-gated on the 5090, not yet run on the 3080)
D-seed-off C + LELEKA_ORIGINAL_SERVE_SEED=off (placement class)
E-tail7 C + LELEKA_ROUTE_TAIL_SKIP=7 + LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED=100 (LOSSY, opt-in; speed only)
Offline tooling; the engine and `leleka up` need no Python.
"""
import json
import pathlib
import sys
LOSSLESS = {"LELEKA_PREFILL_LOAN_TIERS": "1", "LELEKA_PREFIX_PARK_FAST": "1"}
ARMS = {
"A-before": lambda env: {},
"B-shipped": lambda env: dict(env),
"C-lossless": lambda env: {**env, **LOSSLESS},
"D-seed-off": lambda env: {**env, **LOSSLESS, "LELEKA_ORIGINAL_SERVE_SEED": "off"},
"E-tail7": lambda env: {**env, **LOSSLESS, "LELEKA_ROUTE_TAIL_SKIP": "7", "LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED": "100"},
}
def main(argv):
out = pathlib.Path(argv[1])
base = pathlib.Path(argv[2]) if len(argv) > 2 else pathlib.Path(__file__).resolve().parents[2] / "deploy/rust-runtime/profiles/rtx3080-16g.json"
profile = json.loads(base.read_text(encoding="utf-8"))
out.mkdir(parents=True, exist_ok=True)
for name, make in ARMS.items():
arm = dict(profile, engine_env=make(profile["engine_env"]))
(out / f"{name}.json").write_text(json.dumps(arm, indent=2) + "\n", encoding="utf-8")
print(name, arm["engine_env"])
if __name__ == "__main__":
main(sys.argv)