Commit Graph
8 Commits
Author SHA1 Message Date
Pavlo Ratushnyi 1b05aba13a STRA-338 params p03: group parameters into named structs (context, cuda-model, engine-core, model-format, quant-core, sampler-ref, tokenizer, worker-protocol, kar-codec) and fix the call sites 2026-11-08 00:26:53 +01:00
Pavlo Ratushnyi d27f96d07d STRA-338 size6 m01: examples, gguf, resident, plan and reader tests split into helpers 2026-11-07 17:04:15 +01:00
Pavlo Ratushnyi cdfec56460 STRA-338 size: the engine crates are rustfmt-clean at 120 columns (per-crate rustfmt.toml: max_width 120, Max heuristics); width violations 6869 -> 2862 prod, 1273 -> 717 test; files that grew are re-split. Reasons for the raised census numbers: fn_lines +119 and complexity +14 are functions that cross 30 lines / 10 branches only because rustfmt put their one-line bodies on several lines (nothing was added); test lists identical (1793), 800 tests pass, the same 5 known failures; bring-up print gate lookback 20 -> 30 lines for the same reason 2026-11-06 13:03:51 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 48a3811c89 Merge claude/unattended into single-copy (O_DIRECT bulk reads for the sealed copy, extents sealed through the same reader)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-02 21:53:29 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 cc60ad1d45 Soak: a process fault is recovered only when the process was replaced (a hung engine keeps answering /ready until the API has given up on it); digest reference: LEN 0 means to the end of the file
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-02 21:24:10 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 40fc3eab2b Fast cold load: large-block, deep-queue reads for the sealed archive copy, the expert bank and the hash passes
The cold start of the 5090 server is dominated by reading two things: the 55 GB KAR archive (copied into the sealed memfd) and the 50 GB of
routed-expert tensors of shard 0 (copied into the page-locked bank). A plain read() loop asks the NVMe for one 128 KiB readahead window
at a time (queue depth 1-2; the drive's max_sectors_kb is 128): 8-35 MB/s after a reboot, 2003.8 s for the first holder
(docs/experiments/baseline-pair-5090.md section 9).

* model-format/bulk_read.rs (new, no unsafe): N threads each read blocks of 8 MiB. Direct (default): O_DIRECT through the open file's
  /proc/self/fd entry (no path lookup) into 4 KiB-aligned bounce buffers, so the page cache is never touched and nothing has to be evicted;
  Advise: buffered pread with POSIX_FADV_WILLNEED ahead and DONTNEED behind (a bounded window); Plain: large pread + DONTNEED. Direct falls
  back to Advise where O_DIRECT is refused. Memory is threads x 8 MiB. Switches for A/B in one binary: LELEKA_LOAD_READ=direct|advise|plain,
  LELEKA_LOAD_THREADS, LELEKA_LOAD_CHUNK_MIB, LELEKA_LOAD_AHEAD_MIB; LELEKA_LOAD_READ=legacy keeps the old sequential loop for the bank.
* deploy/sealed.rs: the memfd fill uses it (seal_file_report also returns how the file was read; seal_file_with_identity is unchanged).
* gguf.rs read_file_span_into: spans of 64 MiB and more (the expert tensors) use it; smaller spans and every failure mode are as before.
* readahead.rs (the SHA-256/CRC passes of a first verification): WILLNEED 512 MiB ahead of the reader thread.
* examples/bulk_read_bench.rs + bulk_read_digest.py: offline cold-read measurement with a reproducible digest (SHA-256 over the SHA-256 of
  consecutive blocks), device-level read/write accounting so a shared disk shows.

Measured on rnr5090 (Lexar NM610PRO, DRAM-less, HMB; kernel 7.0.0-38; another agent's jobs share the drive, so every figure carries its
"other" volume; page cache of the span evicted first with posix_fadvise(DONTNEED), never drop_caches):
* whole KAR file, 51.5 GiB, new default (direct, 32 x 8 MiB): 152.9 s (362 MB/s) and 159.8 s (346 MB/s, with the digest), nothing else on the
  drive; Cached 62 -> 59 GiB (no cache growth). Target < 5 min met.
* old patterns, same day: one thread, 16-32 MiB reads (the holder's pattern) 65, 86, 105, 154 MB/s on 2-8 GiB cold slices (55 GB in 6-14 min);
  8 threads x 32 MiB buffered (the old sealed.rs pattern) 240 MB/s while sharing the drive; the recorded cold-after-reboot holder 2003.8 s.
* strategy matrix (4 rounds x 7 configs, fresh 2 GiB regions, MB/s per round, median of 4): advise 16x16 MiB 230 574 194 1126 (402);
  direct 32x8 185 554 1133 113 (369); advise 32x8 277 454 229 510 (365); plain 16x16 385 257 979 207 (321); direct 16x8 180 311 351 174 (245);
  direct 8x32 149 317 271 138 (210); one thread 65 201 123 86 (105). The drive's speed varies 10x between regions and moments whatever the
  strategy, so the multi-thread configs are indistinguishable here; every one of them beats one thread. Direct is the default because it
  leaves the page cache untouched (nothing to evict, the machine's free-memory state is not changed), not because it is faster.
* identity: an 8 GiB slice read with the new code has the same block-digest chain as a plain sequential pass in Python
  (8b8b21b830cf938b1f0cec60a5a8127d2489e33e1f853cd792b18497b2b081a6, both); unit tests compare every strategy with the source for aligned and
  ragged spans. The engine's own SHA-256/CRC check of the sealed memfd and the replay gate are in the GPU run recorded in docs/unattended.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-02 20:54:28 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 4c1b10e2b7 model-format: KAR serve-read extents, census example, sparse-copy verification
The serve path reads one thing from the 55.3 GB archive: the PLE rows (scales + two planes), plus header, directory
and two small books. kar_extents.rs derives those byte ranges from the directory alone (the same VerifiedPart geometry
as read_rows_chunk), page-aligns and merges them, and defines the pinned digest of a sparse copy (SHA-256 over a domain
tag, the extent list and the extent bytes). VerifiedKarPleArtifact::verify_sparse verifies a copy that holds only the
extents against that digest and refuses a read range outside them; the full-archive verifier does not accept a sparse
copy.

examples/kar_census.rs prints the directory (every record, kind, size, offset, bytes the serve path reads, totals per
kind) reading only the header, names and directory; --hash-extents additionally reads the extents (throttled) and prints
the digest to pin. Synthetic-archive tests (CPU only): row reads through a copy holding only the extents equal the full
file for every row, hole bytes are never hashed, any changed extent byte / wrong pin / wrong length is refused.

PLE_EXTENTS_SHA256 is zero until measured on the real archive.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 12:03:30 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 88401e1663 test(kar): run the real kar_decode_levels.cu on the CPU against the kernel model
nvcc and a GPU are unavailable, and the kernel's only executable evidence was a
Rust transcription of it. This harness compiles the actual .cu with clang
through a small shim (threads for CUDA threads, a barrier for __syncthreads,
atomics for atomicOr) and replays model-generated cases: random valid windows
at levels 2..5, non-finite scales/books, ~1k corrupted launch-parameter sets,
multiply and SwiGLU. 17k cases (ASan build included) agree bit for bit; this
does not cover nvcc codegen or device behaviour.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 16:56:27 +02:00