Skip to content

feat(libopenbuenos,ggml-edgetpu): zero-repack weight cache, FD bloat fix, and ob_dmabuf_map - #42

Merged
saariuslystoned merged 5 commits into
mainfrom
feat/zero-repack-weight-cache
Nov 27, 2026
Merged

saariuslystoned merged 5 commits into
mainfrom
feat/zero-repack-weight-cache

Conversation

@saariuslystoned

Copy link
Copy Markdown
Collaborator

Summary

  • Zero-repack immutable weight cache & load-time prepack (libopenbuenos, ggml-edgetpu): Register static weights immutably and prepack quantized ext[2] tiles once at load time (OPENBUENOS_PREPACK_AT_LOAD=1), eliminating runtime repack stalls.
  • Skinny micro-tile FD bloat & cache budget fixes:
    • Reject skinny projections (OPENBUENOS_MIN_TILE_DIM=128 default) cleanly to CPU NEON, eliminating ~7,776 tiny (64,64) /dmabuf FDs under RLIMIT_NOFILE=4096.
    • Add OPENBUENOS_EDGETPU_MAX_M (supporting CPU prefill + EdgeTPU decode split) and bump default weight cache entry capacity (4096 -> 16384, clamp 32768) with a 512 MiB MemAvailable headroom guard (kReserveBytes).
  • Shared-PASID external DMA-BUF mapping (ob_dmabuf_map / ob_dmabuf_unmap): Expose clean C11 APIs in openbuenos.h mapping/unmapping external DMA-BUFs directly onto ctx->tpu_fd (etdom / shared PASID) with argument validation, mock support, and teardown cleanup.

Verification

  • Host macOS & ARM64 Docker (GCC 13.3 & Clang 18.1.3 -static):
    • make -C libopenbuenos verify-header-host host test: 27/27 suites PASS (including test_zero_repack_weight_cache_and_prepack and test_external_dmabuf_map_unmap).
    • libopenbuenos CTest 3/3 PASS and freetile CTest 4/4 PASS across all 3 toolchains.
    • test_edgetpu_llm_shapes PASS and test-backend-ops -b EDGETPU 951/951 PASS (OPENBUENOS_MOCK=1).
  • Tensor G5 (laguna / Buenos A0) silicon benchmarks (16 GiB RAM, DESKTOP thermal guard):
    • PocketCoder-13B-A3B-Q4_0 standalone (-c 16384, WEIGHT_CACHE_MB=1536): 9.45 pp / 3.89 tg t/s (w_misses=0, w_evict=0, pack_us=0, 984 entries, 6.5x decode / 4.5x prefill vs prior thrashing baseline, IRQ 130/131 active, 0 TPU errors).
    • Speculative Q4_0 + DSpark-Q8_0 (OPENBUENOS_EDGETPU_MAX_M=1, -c 16384): 13.02 pp / 6.50 tg t/s (w_misses=0, w_evict=0, pack_us=0).

… budget

Add ob_gemm_prepack_quant_batch() and ob_prepack_stats_t to prepack all
scheduled horizontally-fused quantized weight tiles once at graph load using a
4-thread WorkerPool without evicting already-resident entries. Honor explicit
OPENBUENOS_WEIGHT_CACHE_MB up to (MemAvailable - 384 MiB) headroom while keeping
the default auto MemAvailable/3 ceiling.

Signed-off-by: Bobby Bones <saariuscrypto@gmail.com>
…and MoE/N gates

Automatically register USAGE_WEIGHTS EDGETPU and CPU_Mapped buffers via
ob_gemm_register_immutable_weights() with monotonic mutation versioning,
prepack cgraph sibling/SwiGLU/singleton GEMM groups once per (group, M) on
graph entry, keep oversized MoE MUL_MAT_ID (>64 MiB auto) and high-N heads
(N>65536) on CPU so dense attention + draft weights stay 100% ext[2] resident.

Signed-off-by: Bobby Bones <saariuscrypto@gmail.com>
…12 MiB headroom

Signed-off-by: Bobby Bones <saariuscrypto@gmail.com>
…MAX_M

Signed-off-by: Bobby Bones <saariuscrypto@gmail.com>
Expose external Linux DMA-BUF IOMMU map/unmap through ob_context's
already-grouped tpu_fd (owning etdom & shared PASID) for downstream runtimes
like freesched, with argument validation, deterministic 36-bit mock IOVA
allocation, teardown cleanup, and unit test coverage.

Signed-off-by: Bobby Bones <saariuscrypto@gmail.com>
@saariuslystoned
saariuslystoned merged commit 64b3fce into main Nov 27, 2026
2 checks passed
@saariuslystoned
saariuslystoned deleted the feat/zero-repack-weight-cache branch November 27, 2026 18:52
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