From d9264eda110eabe1b463d00854030fabfe2c6751 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 7 Nov 2026 17:34:57 +0100 Subject: [PATCH] STRA-338: last limits fixes (3 native-cpu-expert items), baselines tightened Co-Authored-By: Claude Sonnet 5.5 --- architecture-baseline.json | 2 +- .../plan_expert_groups_fn.rs | 7 +-- .../src/impl_gateupformat.rs | 4 +- crates/native-cpu-expert/src/pool_plan.rs | 3 +- crates/native-cpu-expert/src/rust_quant.rs | 24 +++----- limits-allowlist.json | 27 +-------- limits-baseline.json | 56 ------------------- 7 files changed, 16 insertions(+), 107 deletions(-) diff --git a/architecture-baseline.json b/architecture-baseline.json index 5f0a41d6..76cd052a 100644 --- a/architecture-baseline.json +++ b/architecture-baseline.json @@ -8,7 +8,7 @@ "source": { "dyn-trait:leleka-backend-api": 1, "dyn-trait:leleka-cpu-worker": 4, - "dyn-trait:leleka-cuda-driver": 56, + "dyn-trait:leleka-cuda-driver": 52, "dyn-trait:leleka-deploy": 17, "dyn-trait:leleka-engine-core": 18, "dyn-trait:leleka-engine-fake": 1, diff --git a/crates/cuda-driver/src/original_verify_window_moe/plan_expert_groups_fn.rs b/crates/cuda-driver/src/original_verify_window_moe/plan_expert_groups_fn.rs index 23cd0e85..672dc784 100644 --- a/crates/cuda-driver/src/original_verify_window_moe/plan_expert_groups_fn.rs +++ b/crates/cuda-driver/src/original_verify_window_moe/plan_expert_groups_fn.rs @@ -240,12 +240,7 @@ fn combine_legacy(g: &OriginalVerifyGeometry, [parts, w, shared, bo]: [u64; 4]) } /// ONE `native_moe_combine_multi` launch over all rows of the group. -fn combine_batched( - arena: Arena<'_>, - g: &OriginalVerifyGeometry, - knobs: &MoeKnobs, - rows: Rows, -) -> Result> { +fn combine_batched(arena: Arena<'_>, g: &OriginalVerifyGeometry, knobs: &MoeKnobs, rows: Rows) -> Result> { let n = rows.len(); let (n_embd, k, tb) = (g.n, g.k, rows.begin); if n < 2 || !knobs.native_combine { diff --git a/crates/native-cpu-expert/src/impl_gateupformat.rs b/crates/native-cpu-expert/src/impl_gateupformat.rs index b1e5542b..f8f94d30 100644 --- a/crates/native-cpu-expert/src/impl_gateupformat.rs +++ b/crates/native-cpu-expert/src/impl_gateupformat.rs @@ -1,5 +1,5 @@ -//! Moved out of the parent module by STRA-338: impl GateUpFormat, impl DownFormat, impl PreparedJob, impl DirectCpuPool, -//! impl Drop_for_DirectCpuPool, impl CompletedJob. +//! Moved out of the parent module by STRA-338: impl GateUpFormat, impl DownFormat, impl PreparedJob, +//! impl DirectCpuPool, impl Drop_for_DirectCpuPool, impl CompletedJob. #[allow(unused_imports)] use super::*; diff --git a/crates/native-cpu-expert/src/pool_plan.rs b/crates/native-cpu-expert/src/pool_plan.rs index 4b3806ca..fa46ef2e 100644 --- a/crates/native-cpu-expert/src/pool_plan.rs +++ b/crates/native-cpu-expert/src/pool_plan.rs @@ -26,7 +26,8 @@ pub const RESERVE: usize = 1; pub struct PoolPlanInput { /// Logical processors this process may run on. pub logical: usize, - /// Physical cores this process may use per CPU package, the host thread's package first (its own core is counted); empty = unknown. + /// Physical cores this process may use per CPU package, the host thread's package first (its own core is + /// counted); empty = unknown. pub cores_per_package: Vec, /// CPUs a container quota allows (cgroup `cpu.max`); 0 = no quota. pub cpu_quota: f64, diff --git a/crates/native-cpu-expert/src/rust_quant.rs b/crates/native-cpu-expert/src/rust_quant.rs index 2a724fe0..c3b50c0c 100644 --- a/crates/native-cpu-expert/src/rust_quant.rs +++ b/crates/native-cpu-expert/src/rust_quant.rs @@ -275,22 +275,16 @@ mod tests { } } fn tie_pattern(n: usize, changed: bool) -> Vec { - let mut x = vec![0.0f32; n]; - for (i, value) in x.iter_mut().enumerate() { - *value = match i % 32 { - 0 => 127.0, - 1 => -127.0, - 2 => 0.5, - 3 => -0.5, - 4 => 1.5, - 5 => -1.5, - 6 => 0.0, - 7 => -0.0, - _ if changed => (i % 61) as f32 - 30.0, - _ => (i % 47) as f32 - 23.0, - }; + (0..n).map(|i| tie_value(i, changed)).collect() + } + /// Element `i` of the tie pattern: eight fixed rounding-tie values, then a ramp that depends on `changed`. + fn tie_value(i: usize, changed: bool) -> f32 { + const HEAD: [f32; 8] = [127.0, -127.0, 0.5, -0.5, 1.5, -1.5, 0.0, -0.0]; + match HEAD.get(i % 32) { + Some(value) => *value, + None if changed => (i % 61) as f32 - 30.0, + None => (i % 47) as f32 - 23.0, } - x } fn check_q8_one_paths(x: &[f32], actual: &mut ActQ, with_avx512: bool) { let n = x.len(); diff --git a/limits-allowlist.json b/limits-allowlist.json index fa821911..765aa737 100644 --- a/limits-allowlist.json +++ b/limits-allowlist.json @@ -1,29 +1,4 @@ { "_comment": "Functions that may miss a limit of scripts/check-limits.py because they were moved verbatim from legacy code. Every recorded number may only fall; an entry whose function is back within the limits is stale and must go (scripts/check-limits.py --update-baseline). New entries: --allowlist-add --reason ... --owner ...", - "functions": [ - { - "path": "crates/cuda-driver/src/qsa_prompt_attention/impl_qsapromptattention/impl_qsapromptattention_2_2.rs", - "name": "QsaPromptAttention::admit_inputs", - "fn_lines": 21, - "complexity": 11, - "nesting": 1, - "width": 0, - "reason": "moved verbatim by the mechanical splitter from an oversize legacy file (STRA-338 size2 merge); shrinks in the next size round", - "owner": "STRA-338" - }, - { - "path": "crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/impl_originalmtpfullowner.rs", - "name": "", - "width": 1, - "reason": "moved verbatim by the mechanical splitter from an oversize legacy file (STRA-338 size2 merge); shrinks in the next size round", - "owner": "STRA-338" - }, - { - "path": "crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/impl_originalfirstdraftengine_for_originalservee/impl_originalservesettings.rs", - "name": "", - "width": 8, - "reason": "moved verbatim by the mechanical splitter from an oversize legacy file (STRA-338 size2 merge); shrinks in the next size round", - "owner": "STRA-338" - } - ] + "functions": [] } diff --git a/limits-baseline.json b/limits-baseline.json index 66b53cc4..fbb72e80 100644 --- a/limits-baseline.json +++ b/limits-baseline.json @@ -8,71 +8,15 @@ }, "census": { "prod": { - "leleka-backend-api": { - "width": 1 - }, - "leleka-cuda-driver": { - "width": 516, - "fn_lines": 1, - "complexity": 4 - }, "leleka-deploy": { "width": 33 }, - "leleka-engine-qwen35-cuda": { - "width": 427, - "fn_lines": 5, - "complexity": 2 - }, - "leleka-libc-shim": { - "width": 9 - }, - "leleka-runtime": { - "width": 2 - }, "python": { "complexity": 1, "width": 2 } }, "test": { - "leleka-context": { - "fn_lines": 5, - "complexity": 1 - }, - "leleka-cuda-driver": { - "fn_lines": 106, - "complexity": 31, - "width": 60, - "nesting": 5 - }, - "leleka-engine-core": { - "fn_lines": 11, - "width": 2, - "complexity": 3, - "nesting": 1 - }, - "leleka-engine-qwen35-cuda": { - "fn_lines": 76, - "width": 77, - "complexity": 12, - "nesting": 6 - }, - "leleka-memory": { - "fn_lines": 5, - "complexity": 1, - "nesting": 1, - "width": 13 - }, - "leleka-model-format": { - "fn_lines": 69, - "width": 25, - "complexity": 13, - "nesting": 4 - }, - "leleka-runtime-client": { - "fn_lines": 2 - }, "python": { "width": 1 }