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>
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>
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>
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>
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>
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>
* 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>
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>
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>
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>
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>
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>
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>
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>
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>