Skip to content

feat(libfreetpu): canonical FREETPU_* weight-cache cap, API aliases & telemetry hardening (#40) - #56

Open
saariuslystoned wants to merge 1 commit into
mainfrom
feat/40-libfreetpu-autosize-weight-cache-cap
Open

saariuslystoned wants to merge 1 commit into
mainfrom
feat/40-libfreetpu-autosize-weight-cache-cap

Conversation

@saariuslystoned

Copy link
Copy Markdown
Collaborator

Addresses #40 (Refs #40 — does not close #40; live Pixel 10 solo + DSpark silicon benchmark proof remains human-gated and open on #40).

Context

Core MemAvailable-guarded auto-sizing (1536 MiB ceiling, 512 MiB explicit OOM headroom guard) and ob_context_{set_weight_cache_cap,get_weight_cache_stats} landed in #45 prior to the libopenbuenos -> libfreetpu rename (#54 / #55). This PR completes the canonical libfreetpu weight-cache cap surface and hardens cross-alias / low-FD edge cases.

Summary

  • Canonical FREETPU_* env vars with backwards-compatible OPENBUENOS_* fallback (libfreetpu/src/ob_gemm.cpp, llama-cpp-edgetpu/ggml-edgetpu.cpp):
    • Supports FREETPU_WEIGHT_CACHE_MB, FREETPU_CACHE_CAP (> 1048576 explicit byte cap >= 1.5 GiB; 1..1048576 ggml graph-entry count), and FREETPU_WEIGHT_CACHE_ENTRIES.
    • Resolves canonical FREETPU_CACHE_CAP before interpreting units so a valid canonical graph-entry cap (<= 1048576) never falls through to a legacy OPENBUENOS_CACHE_CAP byte cap (and vice versa in ggml-edgetpu.cpp).
    • Preserves the low-RLIMIT_NOFILE device ceiling (256 entries when RLIMIT_NOFILE <= 2048) even when *_WEIGHT_CACHE_ENTRIES is overridden.
  • ABI-neutral canonical C11/C++17 aliases (libfreetpu/include/freetpu.h):
    • Exposes FREETPU_HAS_WEIGHT_CACHE_STATS, freetpu_weight_cache_stats_t, freetpu_context_set_weight_cache_cap, and freetpu_context_get_weight_cache_stats while keeping ob_config_t (48 B LP64) and ob_profile_stats_t (216 B LP64) byte-identical.
  • Tests, Make integration & proof (libfreetpu/Makefile, libfreetpu/tests/*, docs/libfreetpu/README.md, proof/libfreetpu-weight-cache-cap/PROOF.md):
    • Wires openbuenos_adversarial_test into make -C libfreetpu test.
    • Verifies Pixel 10 2688 MiB working-set (w_peak = 916 MiB) with 0 cold and 0 steady-state evictions under both auto-size (1344 MiB) and explicit FREETPU_CACHE_CAP=1610612736 (1536 MiB), plus 896 MiB thrash control, OOM headroom clamp, cross-unit alias precedence, low-FD entry ceiling, and env isolation in ob_quant_unpack_test.

Verification (Head 44fd6fca099690926694945a2ef85b69176ca184)

  • make -C libfreetpu verify-header-host host test (-Wall -Wextra -Wpedantic -Werror): PASS (28/28 host suites + openbuenos_adversarial_test + ob_quant_unpack_test + openbuenos_pool_guards_test)
  • clang -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror -Ilibfreetpu/include llama-cpp-edgetpu/openbuenos_shim.c: PASS
  • ASan + UBSan (-fsanitize=address,undefined -fno-sanitize-recover=all) on openbuenos_adversarial_test: PASS (0 errors)
  • TSan (-fsanitize=thread -fno-sanitize-recover=all) on openbuenos_adversarial_test: PASS (0 warnings)
  • Clean-room OSS boundary audit across 230 files: PASS
  • Adversarial pre-push review (codex exec -m gpt-6.2-astra, 2 rounds): Round 1 caught cross-unit CACHE_CAP fallthrough, low-FD WEIGHT_CACHE_ENTRIES bypass, quant-test env isolation, and 2688 MiB Pixel working-set coverage; Round 2 returned CLEAN for P0/P1.
  • Proof receipt: proof/libfreetpu-weight-cache-cap/PROOF.md

Remaining Human-Gated Hardware Follow-Up

  • Live Pixel 10 (Tensor G5) re-benchmark of PocketCoder-13B-A3B-Q4_0.gguf (solo + DSpark speculative decode) comparing the 896 MiB baseline against the zero-thrash libfreetpu cap was not run in this PR and remains open on #40.

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.

1 participant