The KAR PLE rows of a chunk (16 per token, three random 4 KiB reads each) were read before the chunk started, through
clones of one synchronous handle, which the I/O manager runs one request at a time: 5-12 s of every 6144-token chunk.
Rows now read on independent file objects (ReOpenFile) and the next chunk's rows are fetched on a thread while this
chunk computes. Packets are a function of the archive bytes only; LELEKA_PLE_AHEAD_VERIFY=1 compares each with a direct
read (0 mismatches in 2 live turns). Default on for Windows, LELEKA_PLE_AHEAD=on|off.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Upstream's gather_batch compared its prefetch list with the batch by position and re-read reordered or duplicated rows. Our reader
has no such matching (tickets own their output slots, the row cache and the KAR GPU cache are keyed by row id); the tests pin it with
the upstream cases and with chunks that are permuted, shifted, repeated or partly new.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
LELEKA_PREFILL_GDN_MIRROR=0 keeps the canonical host upload. Final residual of every row bit-identical (PREFILL-R gate) on the laptop.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- KAR PLE rows of a whole chunk are resolved to cache slots on the host (parallel pread of the misses) and decoded by one kernel straight into the arena; each distinct token embedding is decoded once and broadcast to the four residual streams on the device (LELEKA_PREFILL_STAGED_INPUT=0 keeps the per-token path).
- GR read/inject and GDN chain guards ride on their producer kernels; GDN/QSA weight dequantization is one thread per element (LELEKA_PREFILL_FUSED_SCANS=0, LELEKA_PREFILL_FAST_DEQUANT=0 keep the originals).
- Two-barrier GDN recurrence is EXPERIMENTAL (LELEKA_PREFILL_FAST_REC=1), off by default.
- Branch-free finite check and single-copy upload of the GDN state; PREFILL-R bit gate, per-command profile tags, model-free GPU probes.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
with_moe_routed_group_source opens one routed source loan per layer group (one size observation at
begin and one at finish) and MoeRoutedSourceScope::retarget moves it from job to job with the same
member checks a fresh per-expert scope applies; inside, every job is still validated individually
(binding, its actual gate/up/down descriptors and formats, its bank spans, first-use row admission) with
the same refusals. The direct CPU tier opens its group this way, the mapped-source prefetch runs inside
the same fence, and the VRAM tier's PCIe sources of a group share one fence too.
LELEKA_CPU_POOL_FENCE=job keeps one fence per job (A/B arm).
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 serve stack's routed experts came only from `load_resident_expert_source`, a 50 GB RAM copy of the
144 shard-0 banks that `MappedExpertBank` then page-locks whole: impossible on a 32-48 GB PC.
* model-format: `ResidentTensor` storage is an owned copy or a read-only MAP_SHARED mapping of the verified
shard (`VerifiedGgufFile::map_resident_tensor`, same descriptor, bounds and size checks);
`Qwen4ExpArtifact::load_mapped_expert_source` builds the same bank catalog from mappings, no RAM
admission (generate.cpp `src.set_gguf` + `FileExpertSource::open`). The crate's lint is relaxed from
forbid to deny so exactly this mapping owner can allow its mmap/munmap/slice.
* cuda-driver: a lease of mapped banks makes `MappedExpertBank` pageable: no cuMemHostRegister; every
consumer the Original serve stack uses (`cache_source` for the prompt copy ring, VRAM tier fills/swaps,
PCIe staging) copies with cuMemcpyHtoDAsync from pageable memory; the zero-copy device aliases
(`retained_span_handle`, `copy_triplet`) are refused.
* runtime: `ModelBinding::load_mapped_expert_source`.
The bytes are the file's, so consumers see what the resident copy holds. Unit test
`mapped_tensor_is_the_files_bytes_and_a_retained_owner`; model-format --lib 128 passed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Production buffers GGUF spans in 16 MiB chunks (3c20d1a), so 128 KiB tiles
arrive as one chunk. Keep the abort/re-seek/size-mutation/retained-fd checks
by shrinking the stream buffer to 64 KiB per-thread in tests, and assert the
production single-chunk delivery explicitly.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Issue the rows before the embedding read, collect before layer 1, decode
exactly as ple_row does. Reader opens lazily with the original defaults
(1M-row cache, 64 in flight, SSD keep-alive), an O_DIRECT handle on Linux
accepted only after an inode check and aligned probe read, and falls back
to the synchronous path when unavailable. Invalid LELEKA_PLE_* values are
refused.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Literal host port of NativeDense::served_names / keep_unquantized_ple_key and the validation half of NativeDense::load
with the Original's refusal messages; the device upload stays with the runtime.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- 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>
- 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>
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>
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>
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>
Validate pinned index split summaries and tensor counts before parsing split metadata, then validate that metadata before profile and tokenizer parsing. Model-format tests, rustfmt, and strict Clippy pass.
The binder now validates split metadata from the retained owners before reading Qwen profile, topology, or tokenizer fields. Targeted model-format tests, rustfmt, and strict Clippy pass.