Skip to content

omnivoice: review-round fixes for the rknn_zeroop weight cache - #1303

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
wOvAN:omnivoice-rknn-cache-round2
Nov 16, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
wOvAN:omnivoice-rknn-cache-round2

Conversation

@wOvAN

@wOvAN wOvAN commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #1302 (which merged the pre-review commit): the five review-round fixes to the same
disk cache, validated on the RK3588 board in the same session as the parent PR.

What is fixed

  • Temp-file leak: a process killed mid-cold-pack left its publish temps
    (<file>.tmp.XXXXXX, up to 112 x ~7 MB) in the cache dir forever - only exact final names are
    ever read back, so nothing cleaned them. pack_weights() now sweeps them at entry.
  • Temp-name collision: the per-pid temp name is not unique across pid namespaces, so two
    containerized runs sharing a bind-mounted model dir wrote the same
    <file>.<pid>.tmp and raced a rename out from under each other. Publish temps come from
    mkstemp in the cache dir.
  • Silent self-heal: the warm->cold fallback (the main new path of omnivoice: harden the rknn_zeroop packed-weight disk cache #1302) named nothing - a
    missing/truncated/checksum-mismatched pack file was visible only as a pack_ms jump, and a
    failed rknn_mem_sync on the warm path (a driver-side problem) masqueraded as a plain cache
    miss. The warning now carries the file and the reason:
    cache: warm miss at <file> (read/checksum) | (device sync), repacking.
  • Uninitialized tail: the cold pack hashes and writes B.size bytes while the packer writes
    the N1*K1*subN*subK grid; equal for the current geometries, so a future librknnrt that
    rounds B.size above the grid would put fresh device-pool bytes into the file and the trailer.
    Each buffer is now zeroed before packing.
  • Docs: the zero-op section claimed a ~1.1 s warm load, measured 2.8 s with the FNV
    verification pass; corrected, plus the sweep, mkstemp, the warm-miss warning, and cache
    growth (~812 MB per fingerprint in the model dir, never pruned) are documented.

Validation (RK3588 board, twin geometry, seed 42, g=2.0)

Same twin gate as #1302 (the run is byte-deterministic when the cache path is correct), all five
gates below on this branch's binary; audio md5 31eaa272118dd19fad97ac326a72f91d everywhere.

  • Fresh install (dir removed): created, 112 files, pack_ms 8797.9 cold.
  • Warm: pack_ms 2868.9, zero cache warnings in the log.
  • Write failure (chattr +i on the cache dir): rc=0, dir left empty,
    cache: write failed for .../ovz_omnivoice-zeroop-v1-<fp>.0.0.bin logged.
  • Bit-rot (two bytes flipped mid-file, full size):
    cache: warm miss at .../ovz_...0.0.bin (read/checksum), repacking, cold repack 9831.6.
  • Killed packer (pkill -9 -x audiocpp_cli mid cold pack, 9 final + 1 temp on disk at the kill):
    rerun leaves 112 final, 0 temps (the sweep), full cold pack 8880.3.

x86: ovz_engine.cpp (stub tier) passes g++ -fsyntax-only -std=c++17 -DENGINE_HAVE_RKNN=1;
tools/check_loader_catalog_sync.py passes.

Known limitations (unchanged from #1302)

  • No cache GC across fingerprints; one bad pack file triggers the global repack (per-file
    detection, global fallback, ~8 s); no unit tests (the path needs a board).

Follow-up to 0xShug0#1302 (merged as the pre-review commit; these fixes were
validated on the board in the same session, p18-p23):

- sweep *.tmp.* temps at the start of pack_weights: a process killed
  mid-cold-pack leaked up to 112 ~7 MB temps into the cache dir forever
  (only exact final names are ever read back)
- publish temps via mkstemp instead of a per-pid name: pid namespaces
  sharing a bind-mounted model dir collide on ...bin.<pid>.tmp
- the warm->cold fallback (the main new path) now names the file in
  last_warning(): cache: warm miss at <file> (read/checksum) | (device
  sync), repacking - a silent repack was visible only as a pack_ms
  jump, and a failed device sync masqueraded as a cache miss
- zero each device buffer before pack_b so file + trailer never carry
  uninitialized device-pool bytes if a future librknnrt rounds B.size
  above the packed grid
- docs: warm load is ~2.8 s (the FNV verification pass), not ~1.1 s;
  document the sweep, mkstemp, the warm-miss warning, and cache growth
  (~812 MB per fingerprint, never pruned)

Board gates (RK3588 twin, seed 42, g=2.0, all audio md5
31eaa272118dd19fad97ac326a72f91d): fresh install cold pack 8797.9 ms,
112 files; warm 2868.9 ms, zero warnings; chattr +i dir -> rc=0, dir
empty, write-failed warning; mid-file corruption -> warm-miss warning
names the file, repack 9831.6; kill -9 at 9 final + 1 tmp -> rerun
leaves 112 final / 0 tmp, 8880.3. x86 stub tier g++ -fsyntax-only with
ENGINE_HAVE_RKNN=1 and check_loader_catalog_sync.py pass.

Co-Authored-By: Claude <[email protected]>
Performed-by: Claude-Fable-5
@0xShug0
0xShug0 merged commit 5158d43 into 0xShug0:main Nov 16, 2026
7 checks passed
@0xShug0

0xShug0 commented Nov 16, 2026

Copy link
Copy Markdown
Owner

@wOvAN Thanks! Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants