Commit Graph
136 Commits
Author SHA1 Message Date
Pavlo RatushnyiandClaude Sonnet 5.5 debfbd0941 test(tokenizer): committed oracle differential, per-codepoint pre-tokenizer check, batch CLI
- crates/tokenizer pre_tokenize + model pre-tokenize-batch/tokenize-batch/detokenize-batch (debug/differential)
- scripts/offline/diff_tokenizer.py: every Unicode scalar x 13 contexts vs Python regex (0 real mismatches;
  14k strings differ only where regex 2026.9.10 has Unicode 17 and regex-syntax/unicodedata 16), a synthetic
  GGUF with BPE-trained merges past the heap path, 5-file extraction compare, encode/decode fuzz
- golden crates/tokenizer/tests/fixtures/tokenizer_oracle.json + integration test
- stricter-by-design: duplicate merges, missing chat template, negative special ids

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:32:23 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 f3bff3842d feat(gguf): header-reader differential, full metadata dump and Python geometry parity
- model inspect-metadata dumps every key/value (bool arrays typed); metadata_entries in model-format
- block_geometry gains Q8_K, IQ1_S, F64, MXFP4, NVFP4; ggml bridge decodes Q8_K, IQ1_S, MXFP4, NVFP4
- general.alignment must be uint32 (the Python reader accepted any width, the Rust reader ignored the rest)
- scripts/offline/diff_gguf_header.py: random GGUF vs unmodified gguf_reader.py, plus stricter-by-design list
- committed golden + integration test (headers and the geometry table)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:25:20 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 0d073e08aa feat(native-pack): match iq_pack.py conversions, add --compat-bf16/--base/--experts-bin and the exhaustive differential
- ple_conv1d inexact F32->F16 is accepted and recorded exact=false, as the oracle does
- conversions.json now carries method/exact/max_abs_err/source_shards like iq_pack.py
- opt-in --compat-bf16 (dequantize + RNE to BF16/F16/F32), --base (index_from_base, extra.bin),
  --experts-bin (+ experts.bin.src.json); receipts list the optional files present
- scripts/offline/diff_native_pack.py: 2700+ cases against the unmodified tools/iq_pack.py
- unit tests: real golden expert tables, numpy/gguf-py F16/BF16 rounding vectors
- fix three pre-existing clippy lints in leleka-model-format

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:20:15 +02:00
Pavlo Ratushnyi 7d90e0cc4f Merge branch 'claude/port-sampler' into claude/port-main 2026-10-14 14:56:20 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 3ca559cebc feat(serving): serve non-greedy requests through the Original sampler chain
backend-api carries SamplingOptions; backend.rs plans each request with the
validated SamplingParams instead of refusing temperature != 0; the output stage
bypasses the compact argmax for an armed request and draws with the bit-exact
host reference (counter = fed-token position, penalty history = prompt+generated).
MTP with sampling is refused explicitly. Desktop RPC only bounds temperature.
Docs: docs/sampler-reference.md (verified vs open).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:55:55 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 4d1594f71c fix(sampler): audit the Original-literal host sampler port against the C++ oracle
- SamplerParams moves to original_sampler_params.rs (pure) and is checked byte for
  byte against the Original struct (size, alignment, offsets, padding) and defaults.
- validate() no longer rejects top_p == 0 (the Original accepts it).
- Draft cell -1 (draft_first at position 0, counter 0) is accepted by
  coupled_draft_counter and OriginalSampler::sample_coupled.
- set_subset keeps the first index and ignores out-of-range ids like setup_coupled.
- Runtime penalty_rows / coupled helpers are compared with the Original header fixture;
  run_port_host_tests.sh runs these pure tests on macOS.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:55:55 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 7e24f41e34 feat(runtime): KAR routed-expert weight source wired into Load and the MoE stage
KarExpertSource (pinned base + optional overlay, levels 2..=5) verifies whole
archives on the retained descriptor, validates the 48-layer expert map at load,
stages exact ranges and runs one-drain device expert FFNs; ModelBinding gains a
consuming with_kar_expert_source builder, MoeExpertStage routes experts through
it (shared expert/combine unchanged, MMQ cache refused), and NativeBackendConfig
gets kar_expert_source with identity-mixed mode digest and a Load-time probe.
The pure selection, stager, expert map and CPU reference move to model-format
so they run on macOS; the CUDA program gains a SwiGLU entry and a per-context
cached module. Linux-target type-checked only; nvcc/GPU unverified, PTX unpinned.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:55:34 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 0deaad99d8 docs: KAR level-decode CUDA port status (verified vs open)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:54 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 4729159f60 feat(runtime): pure KAR level selection with overlay and scratch budget
Resolves, per tensor class policy (levels bounded 2..=5), which archive
(base or overlay) serves a NESTED record, at which level, the exact archive
byte ranges and device launch geometry for a bounded window or expert matrix,
resident-prefix bytes and a scratch ledger. Cross-checks the model-format
planner against the cuda-driver geometry derivation. Metadata only: no I/O,
no CUDA, no archive verification (loader responsibility).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:54 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 70b95659dc feat(cuda-driver): KAR level-decode closed program (levels 2..=5), unpinned
Adds kar_decode_levels.cu (range decode of a nested bit-plane record at a
runtime level 2..=5 plus the kar_expert F32 row multiply), a placeholder PTX
with a zero pin that fails closed (TODO-ROOT), pure geometry/admission/pin
code that is unit tested on any host, a Linux-gated driver wrapper (pinned
module, bounded launches, one drain, poison+leak on uncertain completion,
status and finite checks) and an ignored Root-only GPU smoke against a CPU
decode for levels 2..=5. The ffi addition is an include inside ffi::enabled;
qwen_ffi::sha256 becomes pub(super). Compiled only via cargo check for
x86_64-unknown-linux-gnu; no nvcc build, no PTX, no GPU run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:54 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 c7862fb1c1 test(sampler-ref): more full-vocabulary oracle cases
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:51 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 45bad22b88 feat(sampler-ref): CPU reference of the Original sampler chain with host-oracle fixtures
New pure-Rust crate leleka-sampler-ref: Philox draw, penalties -> top_k ->
top_p -> min_p -> temperature -> inverse-CDF pick, greedy argmax, coupled-draft
counter/ring math, penalty_rows, exact-match acceptance, and the request-level
SamplingParams validation with the Original's GEN defaults and wire keys.

Golden fixtures come from compiling the Original's sampler_parity.cpp host
reference (included unmodified) and sampler/coupled_draft headers with clang++
(-ffp-contract=off), plus the verbatim StrataEngine.sampling_keys lifted from
server.py. No GPU, no speed or quality claim.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:51 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 3006852154 test(control-plane): cross-check KAR kernel model against file-backed oracle
Writes NESTED archives with the production kar_writer, opens them with the
shared inspector and compares kernel-model windows for levels 2..=5 (partial
last groups, odd row lengths, expert rows, dial limits) bit-for-bit with
kar::decode_tensor_range. Also checks the model's f16 widening against
quant-core for all 65536 patterns. CPU only.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:43 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 664d434fca feat(model-format): KAR level-decode kernel model and nested record descriptor
Adds KarNestedRecord (section layout of a NESTED record, validated with the
inspector's formulas) and a literal CPU transcription of the planned CUDA
level-decode and F32 row-multiply kernels (window planning, packet layout,
thread/block decomposition, plane word and group scale addressing) for runtime
levels 2..=5. Randomized tests compare it with a transcription of the CPU
decode oracle, including partial last groups, word-unaligned ranges, expert
row windows and overlay-style per-archive dials. Verifies the specification
only; no CUDA build or GPU run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:42 +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
Pavlo Ratushnyi 5a06a29b9a Retain PLE and MTP outputs and memoize immutable PTX checks 2026-10-10 10:20:59 +02:00
Pavlo Ratushnyi 44d34a2307 Keep original MTP expert intermediates on CUDA through combine 2026-10-10 09:50:19 +02:00
Pavlo Ratushnyi 69fc520e3e Keep routed MoE Down products on CUDA through combine 2026-10-10 09:18:19 +02:00
Pavlo Ratushnyi 7c6cc64751 Retain GDN and MTP CUDA products through inference chains 2026-10-10 08:54:53 +02:00
Pavlo Ratushnyi 35e68653e6 Reuse sealed KAR archive across Linux inference processes 2026-10-10 08:26:46 +02:00
Pavlo Ratushnyi 6364a9ff6e Reuse QSA source and attention activations on CUDA 2026-10-10 08:07:45 +02:00
Pavlo Ratushnyi 8e4354e5ad Reuse GDN input and GR residual activations on CUDA 2026-10-10 07:50:59 +02:00
Pavlo Ratushnyi d6b99caebb Retain GDN prior and MoE activation buffers on CUDA 2026-10-10 07:09:13 +02:00
Pavlo Ratushnyi 793e4eb8d9 Batch cached PLE Key projection as one complete matrix 2026-10-10 06:06:09 +02:00
Pavlo Ratushnyi 173465d91a Reuse native routed Gate Up activations within each MoE step 2026-10-10 05:55:22 +02:00
Pavlo Ratushnyi f0e7b16475 Compare cached Qwen forward with legacy replay across session reset 2026-10-10 05:41:46 +02:00
Pavlo Ratushnyi 3b865b8426 Retain PLE weights and reuse projection scratch on the GPU 2026-10-10 05:21:51 +02:00
Pavlo Ratushnyi 58dbd1799c Retain selected Qwen weights on GPU and dispatch complete matrices 2026-10-10 04:06:45 +02:00
Pavlo Ratushnyi 3c20d1abea Buffer GGUF metadata and weight spans in 16 MiB heap chunks 2026-10-10 03:07:28 +02:00
Pavlo Ratushnyi ff5241fdb2 Verify sealed KAR SHA and section CRC in one scan 2026-10-10 02:53:06 +02:00
Pavlo Ratushnyi f9b7644c2d Load Linux KAR into sealed anonymous memory without disk staging 2026-10-10 02:37:40 +02:00
Pavlo Ratushnyi ba055f4b5a Preserve accepted generation identity before capacity refusal 2026-10-10 02:29:23 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 d94ff5d1b1 fix(runtime): refuse a forward without its output head before any row or layer work
The output-less entry used to run all 48 layers before reporting
Unsupported(Output). Check it right after the layer plan, before the input
stage, so nothing is read or staged for a step that cannot publish. The ignored
pinned-artifact test keeps asserting the same error and unchanged session
state; it is renamed because layers no longer run. No CPU ModelBinding fixture
exists, so no new CPU case is possible for this entry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-10 02:20:59 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 47a8f6f175 fix(daemon): keep a generation slot owned without a real terminal and end only a failed worker's own operation
- pump: a terminal synthesized because the backend channel ended is not a
  completion proof; on client disconnect or oversize frame it closes model
  admission and keeps the slot owned instead of clearing it.
- cancel: a request that finished between the active check and the backend call
  is acknowledged idempotently instead of failing with cancel_uncertain.
- load/unload workers that panic end exactly their own unresolved operation as
  indeterminate (LifecycleGuard is disarmed under the completion lock and only
  acts on an operation still Accepted), never a later operation.

Accepted request identities are still never forgotten; the 256-identity
capacity refusal is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-10 02:20:59 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 33ef0d2070 test(cuda): keep synthetic Qwen dispatch handles disjoint for KAR PLE slots
The first KarPleScatter buffer is 64 MiB, larger than the 16 MiB spacing used
by two fixtures, so their ranges overlapped and the alias check refused before
the intended assertion. Space handles by 256 MiB, skip the +1 misalignment case
for byte-aligned slots and offset the overlap probe by an aligned step. The
assertions and production code are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-10 02:19:36 +02:00
Pavlo Ratushnyi 8e142b6be2 Verify full Qwen vocabulary projection and output ownership refusals 2026-10-10 02:15:12 +02:00
Pavlo Ratushnyi 23e38231e7 Retain redacted phases for native and KAR load failures 2026-10-10 02:00:54 +02:00
Pavlo Ratushnyi 2646561a72 Reject increasing normalized router rank weights 2026-10-10 01:56:30 +02:00
Pavlo Ratushnyi cad2a2776f fix(runtime): read bounded MoE row tiles from retained weight spans 2026-10-10 01:28:54 +02:00
Pavlo Ratushnyi 62c683de20 feat(daemon): validate native tool calls before bounded regeneration and publication 2026-10-10 01:18:32 +02:00
Pavlo Ratushnyi 5761538c07 fix(runtime): allow verified MTP cold load its own finite budget 2026-10-10 00:49:34 +02:00
Pavlo Ratushnyi 3164493644 fix(mtp): rebuild accepted history from actual target residuals 2026-10-10 00:40:02 +02:00
Pavlo Ratushnyi 7cfce65570 feat(runtime): integrate explicit pinned MTP draft and verified generation 2026-10-10 00:26:09 +02:00
Pavlo Ratushnyi 42ce0e008e fix(kar): retain redacted phase and errno on private copy failure 2026-10-10 00:21:22 +02:00
Pavlo Ratushnyi 01c4ac6c22 feat(cuda): admit source-qualified MTP GR and scaled S2 2026-10-10 00:13:45 +02:00
Pavlo Ratushnyi 137402d42b feat(cuda): admit qualified fixed MTP input and dense attention 2026-10-10 00:03:05 +02:00
Pavlo Ratushnyi 5eb2046bc4 fix(runtime): bound explicit KAR cold loads independently 2026-10-09 23:37:36 +02:00
Pavlo Ratushnyi 2598df0335 feat(mtp): bind pinned draft weights and fence target state snapshots 2026-10-09 23:26:28 +02:00
Pavlo Ratushnyi 581baa5cc7 fix(cuda): preserve source-defined GR exponential saturation 2026-10-09 23:08:37 +02:00