Commit Graph
159 Commits
Author SHA1 Message Date
Pavlo RatushnyiandClaude Sonnet 5.5 d4c8237710 feat(serve): expert pool, committed-lineage ledger, mode17 configuration and window PLE rows
- original_serve_pool: OriginalServePool seam and the all-CPU CpuExpertPool over the pinned mapped
  routed weights (the empty-plan tier of the verifier window); pure expert planning/scatter tested.
- original_serve_ledger: the host's committed-token mirror and window state machine (Idle/Open/
  Committing, dirty flag for physical repair), free of device owners; unit tested.
- original_serve_config: RoPE constants, MTP scalar/full policies, sampler path, verifier geometry,
  prefill arena carve (INT8 KV staging runs checked against the serving geometry) and expert blob sizes.
- InputStage::original_window_ple: the PLE input rows of a verifier window from the model's own provider.
- OriginalCommittedMtpReceipt::for_published_window and OriginalDraftSession::restore_current.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:46:31 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 fd31c71735 feat(serve): publish a verified Original window into QwenSession
The verifier commit graph replays the accepted prefix into verifier-owned canonical GDN state, the
PLE history and the twelve resident QSA index/K-V owners. QwenSession::publish_original_verified is the
session half: priors derived from the CURRENT ones (original_verified_base), every GDN/PLE/QSA prior
validated at the exact end position before the first canonical assignment, predecessors and position
advanced by exactly the accepted rows. GdnPrior/PlePrior::from_original_verified and
ResidentQsaPrior::advanced/ResidentQsaLayer::from_verifier_owners (the reverse of the one-way handoff)
carry the lineage. Pure session tests run against the contextless test session.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:37:42 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 f6b74495aa feat(driver): sealed-asset probe for the Original serve stack and committed K/V prefix read
- original_serve_asset_status / unsealed_original_serve_assets: which compiled assets gate the
  Original serve path (native head x3, sampler, verifier PTX x2, MTP session x2) and whether each is
  sealed in this build. A probe only; owners keep refusing an unsealed asset themselves.
- OriginalVerifyQsaJournal::committed_mapped_prefix and OriginalQsaMappedJournal::current_prefix:
  where each resident layer's mapped K/V ends after a verifier commit, for session lineage.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:37:42 +02:00
Pavlo Ratushnyi 75b579e097 Merge branch 'claude/port-verifier-spec' into claude/port-main 2026-10-14 15:21:12 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 ec21c754b6 feat(serve): mode17 serve driver, OriginalSpecController::new selection and explicit operator factory
serve_request is generate.cpp's serve loop over any OriginalSpecEngine;
OriginalServeSettings::mode17 is the single production caller of
OriginalSpecController::new. spawn_backend_experimental_original_serve selects it
and fails closed at load until the verified-window host owners exist.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:21:00 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 af29c7416a feat(spec): native OriginalServePort binding the driver Verifier run/commit/wait_commit/completed_window
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:19:32 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 686412b4b1 feat(spec): concrete Original serve engine over a verifier/session/draft port
OriginalServeEngine<P: OriginalServePort> implements OriginalSpecEngine,
OriginalDraftEngine and OriginalFirstDraftEngine: single live window,
commit-before-draft, async commit event waited at window drain (session
publication), both checkpoint restorations independent of engine health,
adaptive begin/join pairing, one-shot MTP completion cached for the
controller's seed/chain callbacks with cell/token/stop-rule cross-checks.
Tested with a fake port and the real controller.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:16:41 +02:00
Pavlo Ratushnyi f86a70be78 Merge branch 'claude/port-mtp-loader' into claude/port-main 2026-10-14 15:10:19 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 6be1e4e38e test(mtp): Root-only GPU proofs for the RT bank and draft-head gather; first-draft adapter; gap ledger
Add compile-checked ignored device tests (placement, Original ordering, budget
and non-finite refusals, gather widths), draft_first_committed_mtp, runtime
contract tests, and update PORT-GAPS-MODE17 row 1.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:10:07 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 b5196e10e5 feat(verify): literal record_window recorder, window resource aggregate and record_all
Pure Verifier schedule (pre/post order, split-window groups, ring numbers, plan-block carve)
and the exact record_window call sequence over a WindowOps producer set, unit-tested with a
trace producer (single/split windows, PLE layer 1, pcie mode 2, last-layer write, head).
OriginalVerifyWindowResources joins the GDN/QSA/head aggregate with the embedding rows and
expert blob layout; OriginalVerifier::record_all records every T graph and the real commit
graph before run. Bound producers: verify-module copies/waits/plan/PCIe staging/doorbell,
GDN and QSA-index journals, embedding. Every producer without a capturable owner fails closed
by name (UNBOUND_PRODUCERS) instead of approximating.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:10:05 +02:00
Pavlo Ratushnyi cc5c5f17a5 Merge branch 'claude/port-rope' into claude/port-main
# Conflicts:
#	Cargo.toml
#	crates/leleka-runtime/Cargo.toml
2026-10-14 15:08:43 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 92b8eca9e7 feat(mtp): wire RT-directory MTP selection through the prompt executor and verified adapter
OriginalPromptExecutor::select_rt_mtp mirrors generate.cpp's --mtp branch: RT
bank load, executor over the exact retained roles, native-head bind with the
optional draft_vocab gather, shared scalar/full/ring layout, coupled setup and
the loaded OriginalMtpActor. The retained-weights cache can now be built from
an RT bank (kind/shape contract by name), full_forward_weights takes the real
draft head, and draft_committed_mtp drives the actor's settings and coupled
history instead of caller-supplied copies.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:07:51 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 778811ba36 docs: rewrite rope/memory plan for the applied 262144 lift, PTX regeneration list and open items
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:07:47 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 745a420327 test(context): policy-driven default, 2x256K, 1x512K YaRN, refusal and boundary tests
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:06:41 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 b8c94bc4a7 feat(runtime): thread one serving context bound through sizing, positions and MTP guards
The runtime reads the cell bound from leleka_context via contract::serving_cells()
(262144 unless configured), replacing the frozen CONTEXT/262144 literals in the QSA
index, native state, selected cache, resident index, session chunking, MTP state
and spec controller. DEVICE_PEAK becomes device_peak(): 128 MiB at the trained
context plus the extra pooled-index rows beyond it. The MTP drafter bank stays
frozen at 262144 and is refused beyond it; legacy rope ops are refused when RoPE is
scaled. serving::apply_effective_context installs the resolved context.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:05:39 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 0c1fc6173f feat(mtp): loaded OriginalMtpActor over the genuine drafter, ring, head and coupled owners
Replace the always-refusing actor shell: adopt() verifies device, vocabulary,
subset, max_t, ring mode and coupled disposition against the owners themselves,
then links idle, device, kv_restore, set_*, first_needed, draft/draft_first and
the coupled sampling/history policy. Coupled readiness now requires a setup
receipt instead of an always-failing setup_device().

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:03:36 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 9f7d7c79f3 test(spec): fake-engine coverage of the Original serve verify/commit/draft state machine
Accept/commit math, EOS/length/context endings, min_p window shrink, suffix lookup widening,
adaptive begin/join cadence, drain of every verified receipt, both-checkpoint restoration and
fail-closed behaviour on verify/commit/draft/restore failures and cancellation.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:00:15 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 7b17c5b533 feat(mtp): device RT bank, draft-head gather and device-ordinal capture
Context now records the ordinal it was created on (MtpDrafter's cudaGetDevice).
original_mtp_bank uploads the dense tensors and expert bank in the Original
order with the nine-name check last; original_mtp_draft_head gathers the
draft_vocab subset of the native head with the sealed verify gather kernels.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:59:27 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 4b97a14097 feat(driver): size the native QSA stack from the serving context; ROPE-ARGS and n_blocks ABI
- serving_context: process-wide cell count + RoPE constants (default 262144 / identity, unchanged).
- qsa_prompt_kv/host/resolver/index/device/resident*: every 262144-linear literal (staging pools,
  mapped host bytes, page tables, pooled rows, score stride, position guards, kernel max_cells)
  now derives from leleka_context::geometry; identical at the default.
- .cu: the rotating-index kernels (qsa_append_first/blocks, qsa_decode_append, qsa_rope_rows,
  qsa_decode_rope) take the five RoPE constants as trailing arguments instead of baking identity;
  leleka_qsa_stream_reset takes n_blocks. Committed PTX is NOT regenerated: the launch code inspects
  the embedded PTX (ptx_abi) and refuses scaled RoPE / pages > 65536 against the frozen entries.
- MTP drafter bank stays frozen at 262144 (documented, refused by validate_existing_int8_bank).
- dense layouts/rings accept positions below MAX_CONTEXT_CELLS (524288).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:58:44 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 d1334800ce feat(verify): public live verifier release/diagnostic owner, profile report and completed-logit readout
Port verify.cpp diag/release_gpu_waits/profile_report/copy_logits/window_logprobs (LOGPOS_TOPK):
a thread-safe registry of the mapped host words the spin kernels poll (watchdog raise + diag
without a driver call), owner-thread release_gpu_waits that refuses later windows, the
GPU-stage stamp accumulator, and a logit/logprob readout admitted only for a genuinely
completed current-generation window (capture-only graphs are refused).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:57:43 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 06af3114fc feat(mtp): RT directory reader and closed-profile load plan for the Original MTP loader
Add original_mtp_rt (dense.txt/dense.bin/experts.bin/draft_vocab.bin host side
of MtpDrafter::load/bind with fail-closed extents, finiteness and file checks)
and turn original_mtp_loader into a load plan over captured geometry/session
inputs, admitting the retained ring against the Original KV-mode plan.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:57:20 +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 e69c3e66d4 refactor: move pure rope/plan/policy modules into leleka-context, add cell geometry
The source-port runtime no longer builds on macOS, so the pure arithmetic and its
golden tests live in a platform-independent crate shared by the driver and runtime.
leleka_runtime::{rope_scaling,memory_plan,context_policy} stay as re-exports.
geometry.rs derives every frozen 262144-cell byte literal from the cell count.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:50:09 +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 9d581c441b docs: rope scaling and memory-plan port status, findings and pin-lift hunk
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:42 +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 7092d7e756 feat(runtime): add pure context/slot policy over rope resolution and the memory planner
Derives effective per-slot context, rope scaling and KV format from a request, refusing
what setup.py or the planner refuses. Does not lift the existing 262144 pin.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:42 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 86a9abac72 feat(runtime): port plan.hpp memory-admission arithmetic with strata-plan golden tests
Literal port of plan.hpp/plan_main.cpp pool derivation (INT8, byte-identical CLI output
on 78 runs) plus per-format KV bytes (fp16/int8/q4_0/k8v4/keyless) tested against the
Original's kv_pool_bytes. Adds the rope+plan golden integration test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:42 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 c738ab7667 feat(runtime): port RoPE scaling and cos/sin table builder with Original-derived golden fixtures
Pure Rust (no unsafe) port of rope_scaling.hpp, rope.cu build_rope_table and the
generate.cpp/setup.py knob resolution. Fixtures come from the Original's host code
(verbatim extraction, -ffp-contract=off). Host-side only; CUDA consumption is open.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:41 +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