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