Confirmed against the C++ in engine/strata and fixed: - rust_native_general.rs group_dot_bytes_policy omitted the `gu == 23 && !avx512` multi-token branch of native_expert.cpp native_gu_rows (`nt >= mt_min && (iq512_supported || (!cpu512 && iq256_supported))`); rust_pool.rs had it since STRA-324. The choice is now one function, gu_multi_route, shared in shape with the pool. Regression: a differential test (re-runs itself with STRATA_FORCE_AVX2=1 on an AVX-512 CPU) fails with a 1-ULP difference on the old code, plus a routing-table test. - rust_legacy.rs row256 (STRATA_CPU_YMM=1 on an AVX-512 CPU) now fuses `corr += d*(hx0+hx1)` like expert.cpp row_dot (line 242) and row_dot_multi (line 294) under GCC -mfma. Regression: scalar model, fails on old code. NOT changed, unconfirmed (need the pinned ggml source, which is not in the repo): rust_kq.rs small_dot `sums += m*s`, rust_k_blocks.rs mins_sum, rust_ggml_extra.rs iq1 scalar. KAB1: new `--cases ext` (72 cases; the 40 of `all` are untouched) adds token counts 4-7 for the row-type list and IQ2_XXS / IQ2_XS at 1..8 tokens; GateUpFormat gains Iq2Xxs / Iq2Xs (additive; the runtime still admits only 18/21/22/23/42). The C++ driver edits are list-only and were NOT compiled here (no ggml). 16 tokens exceed MAXT and the KAB1 header and are not covered. New Rust-only test token_count_invariance: the first two tokens of a group are bit-identical for groups of 2..8 tokens on all 14 gate/up x down pairs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
82 lines
3.4 KiB
Rust
82 lines
3.4 KiB
Rust
//! Model-free bring-up probe of the CPU expert pool the Original serve stack opens (`CpuExpertPool::new` ->
|
|
//! `CpuPool::new(workers)`) and of its numerical consumers on every gate/up x down format pair the verifier admits.
|
|
//! Zero-filled expert blobs (valid FP16 headers, so finite) and a constant activation: nothing is compared with a
|
|
//! reference, the probe only shows that the pool starts on this CPU, every kernel path runs and returns finite rows.
|
|
//!
|
|
//! PROBE_WORKERS (default 15, the serve default) PROBE_ROWS (default 4, at most 8)
|
|
//! cargo test --locked --release -p leleka-native-cpu-expert --test cpu_pool_probe -- --ignored --nocapture
|
|
use leleka_native_cpu_expert::{CpuPool, DownFormat, GateUpFormat, PreparedJob};
|
|
|
|
const H: usize = 2560;
|
|
const FF: usize = 640;
|
|
|
|
fn env_usize(name: &str, default: usize) -> usize {
|
|
std::env::var(name).ok().and_then(|v| v.parse().ok()).unwrap_or(default)
|
|
}
|
|
|
|
fn gate_up_block(f: GateUpFormat) -> (usize, usize) {
|
|
match f {
|
|
GateUpFormat::Iq3Xxs => (256, 98),
|
|
GateUpFormat::Iq3S => (256, 110),
|
|
GateUpFormat::Iq2S => (256, 82),
|
|
GateUpFormat::Iq4Xs => (256, 136),
|
|
GateUpFormat::Iq2Xxs => (256, 66),
|
|
GateUpFormat::Iq2Xs => (256, 74),
|
|
GateUpFormat::Q2_0 => (64, 18),
|
|
}
|
|
}
|
|
|
|
fn down_block(f: DownFormat) -> (usize, usize) {
|
|
match f {
|
|
DownFormat::Iq4Nl => (32, 18),
|
|
DownFormat::Q2_0 => (64, 18),
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
#[ignore = "bring-up probe; no model"]
|
|
fn cpu_pool_runs_every_expert_format_pair() {
|
|
let workers = env_usize("PROBE_WORKERS", 15) as i32;
|
|
let rows = env_usize("PROBE_ROWS", 4).clamp(1, 8);
|
|
let mut pool = match CpuPool::new(workers) {
|
|
Ok(pool) => pool,
|
|
Err(e) => panic!("PREFLIGHT CpuPool::new({workers}) ERR: {e:?}"),
|
|
};
|
|
eprintln!("PREFLIGHT CpuPool::new({workers}) ok workers={}", pool.workers());
|
|
let gates = [GateUpFormat::Iq3Xxs, GateUpFormat::Iq3S, GateUpFormat::Iq2S, GateUpFormat::Iq4Xs, GateUpFormat::Q2_0];
|
|
let downs = [DownFormat::Iq4Nl, DownFormat::Q2_0];
|
|
for gu in gates {
|
|
for down in downs {
|
|
let (gq, gb) = gate_up_block(gu);
|
|
let (dq, db) = down_block(down);
|
|
let gsize = H / gq * gb * FF;
|
|
let dsize = FF / dq * db * H;
|
|
let input = vec![0.5f32; rows * H].into_boxed_slice();
|
|
let job = match PreparedJob::new(
|
|
gu,
|
|
down,
|
|
vec![0u8; gsize].into_boxed_slice(),
|
|
vec![0u8; gsize].into_boxed_slice(),
|
|
vec![0u8; dsize].into_boxed_slice(),
|
|
input,
|
|
rows,
|
|
) {
|
|
Ok(job) => job,
|
|
Err(e) => {
|
|
eprintln!("PREFLIGHT PreparedJob::new({gu:?}, {down:?}) ERR: {e:?}");
|
|
continue;
|
|
}
|
|
};
|
|
let started = std::time::Instant::now();
|
|
let result = pool.start(vec![job], 48 << 20).and_then(|pending| pending.join());
|
|
match result {
|
|
Ok(done) => {
|
|
let finite = done.into_iter().all(|j| j.into_values().iter().all(|v| v.is_finite()));
|
|
eprintln!("PREFLIGHT cpu expert {gu:?} x {down:?} rows={rows} ok finite={finite} in {:?}", started.elapsed());
|
|
}
|
|
Err(e) => eprintln!("PREFLIGHT cpu expert {gu:?} x {down:?} ERR: {e:?}"),
|
|
}
|
|
}
|
|
}
|
|
}
|