Commit Graph
20 Commits
Author SHA1 Message Date
Pavlo RatushnyiandClaude Sonnet 5.5 bba658f204 cpu-service: register-built single-token IQ3_S/IQ3_XXS dot (bitwise the generic tree, LELEKA_IQ_SINGLE=legacy keeps it); vectorized finiteness scan of the verify group's CPU output (LELEKA_SINK_SCAN=legacy keeps the element-wise one)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-31 18:03:19 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 9750539d4d STRA-329: native-cpu-expert AVX2 IQ4_XS multi-token route, fused Q2_0 correction, KAB1 ext case set
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>
2026-10-29 01:26:26 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 406b40a882 Merge claude/stra-318 into train-a (STRA-245)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 22:14:42 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 f3899b4f89 fix(native-cpu-expert): Rust AVX2 tree bitwise equal to the C++ AVX2 reference on KAB1 (STRA-324)
Two independent last-bit defects of the Rust AVX2 tree, visible only through a Q2_0
down projection (the int8 requantization of an IQ4_NL down hides them):

1. rust_q2::dot256: the correction chain corr += d*(hx0+hx1) was a separate mul+add;
   the pinned q2_avx2.cpp built by GCC with -mfma fuses it (vfmadd231ss) and the
   AVX-512 tree fuses it explicitly. Now d.mul_add(..).
2. IQ4_XS (23) gate/up with >= mt_min tokens on the AVX2 tree: the C++ engine takes the
   iq256 multi-token kernel (native_gu_rows: !cpu512 && iq256_supported(23)); Rust always
   used ggml's single-token dot. rust_iq::decode gains the type-23 arm and rust_pool
   dispatches dot_multi256 for gu==23 when !dispatch().avx512.

AVX-512 outputs are byte-identical before and after (40/40 EQUAL). Regression tests:
rust_q2 scalar model of the C++ AVX2 row kernel (gate/up and down widths, 1..8 tokens,
sensitivity check against the unfused form) and rust_iq IQ4_XS multi-token model.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 21:29:30 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 6d1adfa78c kernel_ab alternate: calibration chain that LLVM cannot fold, Rust cells without pool spin, per-record sibling_idle and clock bounds, rustc version fallback
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 21:25:56 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 e80528ac7a kernel_ab: Rust time mode and the alternation runner (STRA-318)
Adds the sub-commands 'time' (the Rust twin of 'kab time', same command line) and 'alternate' (fresh scrubbed pinned processes for the
cells {cpp,rust} x {avx512,avx2}, a/b replicates for the A/A pairs, seeded schedule file written before the first run, per-round
COMPONENT_KERNEL records, equality recorded per tree). No statistics. run-tree gains an optional --case.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 21:09:10 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 cf811a5185 kernel_ab example: make the file its own lint gate (deny warnings, clippy::all)
cargo clippy -- -D warnings also lints the other workspace crates (pre-existing warnings
in leleka-model-format, cuda-driver, libc-shim), so the example denies its own.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 20:45:43 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 d096ecd8e8 kernel_ab example: KAB1 reader, bitwise or pre-declared-tolerance compare, COMPONENT_KERNEL record writer (STRA-289)
Rust half of the CPU kernel A/B, part 1: crates/native-cpu-expert/examples/kernel_ab.rs
(verify, compare, internal run-tree) over the public API only; sha2 as a dev-dependency.
lib.rs untouched, unsafe_code stays deny. Timing fields of the records are explicit
NOT_MEASURED markers (STRA-318).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 20:43:05 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 a0eda0f703 serve: log the CPU kernel family per kind of logical CPU and the kernel set per CUDA device at start-up
cpu_kernel_report probes every logical CPU (pinned thread, cpuid/xgetbv), groups identical ones and names the family chosen for the
process plus the STRATA_* switches that changed it, with a warning when cores differ in AVX-512. gpu_kernel_report lists every CUDA device
with compute capability, SM count, memory and the kernel set it loads (sealed sm_120, pinned sm_86 companions, or none) and the MMQ
launch policy. Logging only.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-27 21:39:02 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 a14b57f5ec upstream port rows 0.6, 3.1, 2.3: callback-thread warm-up, experimental route tail skip, opt-in worker plan
* cuda-driver: on Linux the first stream created starts the driver's host-callback thread (one no-op cuLaunchHostFunc + synchronize) while
  the host thread is not pinned yet; LELEKA_CB_WARMUP=off skips it (A/B arm).
* leleka-runtime: EXPERIMENTAL route tail skip LELEKA_ROUTE_TAIL_SKIP=N (default off, output changing): a missed expert that every token of the window
  routes at rank >= N is neither copied nor computed (kind -2 in split_group_tail, zero row); off at >= LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED percent (90)
  of the experts in VRAM. Replay arms: spec arm suffix +tailN and replay arm flag !tailN for in-process A/B and the quality gate.
* native-cpu-expert: pool_plan (upstream pool_plan.hpp: default worker count from the physical cores, hybrid and cgroup quota), opt-in via
  LELEKA_CPU_POOL_PLAN=on; the stack default stays 15.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 17:31:05 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 34dca798f3 Windows: leleka-memory answers the governor from Win32 in /proc text, model-format maps files read-only and reads the KAR by seek_read, native-cpu-expert compiles with Win32 affinity/prefetch
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:16:24 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 95475335be docs(native-cpu-expert): SAFETY invariants, bounds asserts at the unsafe leaves, pool lifecycle tests
Documents the epoch-claim protocol behind the Shared Send/Sync impls, adds row-length, destination and alignment
asserts at the SIMD leaves and quantize_raw/float_dot/convert_bf16, and tests pool Drop joining and idle-gap stability.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 02:01:05 +02:00
Pavlo RatushnyiandClaude Opus 5.5 ae02262c08 perf(cpu-expert): specialise the AVX-512 IQ, Q2_0 and the IQ4_NL row kernels on format and token count
iq_avx512.cpp templates row_dot<TY, NT>; the Rust kernels looped over a runtime token slice with the
format matched per half block. dot_multi512, rust_q2::dot512 and iq4nl now dispatch once per row to
const-generic bodies (format x 1..8 tokens) with the same operations in the same order per token.
Proof: tests/borrowed_group_parity.rs prints a digest of every output bit of its 120 synthetic groups (all
10 format pairs, 1..8 rows); the digests of the previous and this build are identical. Model-free group
cost on the i9-11900H laptop, 7 workers: 226/250 -> 206/218 ms per 48-group round.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 19:36:35 +02:00
Pavlo RatushnyiandClaude Opus 5.5 4726afa27e perf(cpu-expert): pin the host loop once to the first physical core (session.cpp SessionLoopScratch)
The direct pool's caller drains beside the workers, which are pinned to every physical core but the
first. Like the Original's session loop, the caller is now pinned once (on its first group) to that free
core and its previous mask is restored when the pool drops; unpinned, its drain and doorbell spin can
land on a worker's core or SMT sibling (the Original measured 26.9 vs 36.3 GB/s for this). Placement
only: no arithmetic changes. LELEKA_CPU_POOL_PIN_HOST=off is the A/B arm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 19:32:17 +02:00
Pavlo RatushnyiandClaude Opus 5.5 7c584c253a perf(serve): router lookahead for the file-mapped expert source (expert_source.cpp RouterLookahead)
When the direct CPU tier starts layer l over a mapped bank, a background thread applies layer l+1's
router (BF16 host copy) to layer l's MoE input, takes each row's top-10, drops the experts the VRAM tier
holds for l+1 and advises their pages (MADV_WILLNEED) so the reads are in flight while layer l computes.
Advice only: what is computed, and how, is unchanged. Started once on the first mapped group (routers and
per-layer bank layout loaded then); a prediction still running makes the next submit skip. Off with
LELEKA_CPU_POOL_LOOKAHEAD=off (A/B arm); the resident source never starts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 19:28:31 +02:00
Pavlo RatushnyiandClaude Opus 5.5 e32c39090a perf(serve): prefetch a file-mapped expert source on all pool workers before admission and compute
With the mapped low-RAM source (load_mapped_expert_source, the Original's --mmap-experts) the direct CPU
tier opens every CPU expert of the group first without scanning it, then advises all their pages
(MADV_WILLNEED) and faults them in on every pool worker and the caller in one read-only phase
(expert_source.cpp prefetch on its fetch threads), and only then admits first-use experts and computes.
The resident source skips the phase. Trace slot 'fetch' times it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:19:48 +02:00
Pavlo RatushnyiandClaude Opus 5.5 ae2cbf454f perf(cpu-expert): borrowed single-dispatch group path (DirectCpuPool)
The native pool computes a whole layer group straight from borrowed gate/up/down matrices into the
caller's output rows: the caller's thread publishes the group and drains beside the workers (pool.cpp
host_works_), every token is quantized once (expert_source.cpp act_multi), and every borrow ends when
compute_group returns (a caught panic stops and joins the pool first). Jobs now carry the three role
pointers instead of one blob; the owned PreparedJob path points them into its blob, so its kernels read
the same row bytes as before.

tests/borrowed_group_parity.rs: the borrowed path is bit-identical to the owned batches-of-12 path on all
10 gate/up x down format pairs (120 synthetic groups, 1..8 rows, shared experts, partial CPU masks), and
refuses bad extents, overlapping or out-of-range destinations and non-finite inputs without writing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:48:27 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 c881da9887 test(bring-up): CPU expert pool probe over every gate/up x down format pair (zero blobs, finite check only)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 02:05:27 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 8651f784ef fix: first combined compile of the Original-literal source-port for x86_64-linux (lib + all test targets type-check)
Fixes: native-cpu-expert Display bound, runtime imports/visibility/lifetimes, missing MTP_ORIGINAL_WINDOW export, MmqFormat match arms, stale test constructors. cargo check --target x86_64-unknown-linux-gnu only (no link, no GPU).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:12 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 7f896a8bb8 import: Original-literal source-port snapshot (frozen 2026-10-12 06:36, uncompiled together, no GPU run)
Snapshot of target/stra169-direct-port-integration/source-port (without target/), now the tracked base for the full Strata Rust port.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:38:46 +02:00