Skip to content

feat(tools): ggml_freesilicon.h zero-copy tensor-view adapter example for llama.cpp (#16) - #28

Merged
saariuslystoned merged 4 commits into
mainfrom
feat/16-ggml-zero-copy-adapter-example
Nov 30, 2026
Merged

saariuslystoned merged 4 commits into
mainfrom
feat/16-ggml-zero-copy-adapter-example

Conversation

@saariuslystoned

Copy link
Copy Markdown
Contributor

Closes #16.

Summary

  • Standalone zero-copy adapter example (tools/ggml_zerocopy_example.cpp): demonstrates binding external ggml-style tensor descriptors to ggml_freesilicon.h with zero vendored llama.cpp/ggml headers.
  • Upfront layout negotiation & mismatch handling: calls fs_dmabuf_reconcile() across GPU+TPU+CPU (align=128, stride=64, LINEAR), verifies explicit tiled-vs-linear mismatch rejection (layout_mismatch), and runs prefill MUL_MAT on GPU sharing one fs_dmabuf backing with decode MUL_MAT view [K,1] on TPU with fallback_copies == 0.
  • Build & CI wiring: wired into Makefile (make verify) and CMakeLists.txt (ctest).

Verification

  • make clean && make verify: PASS (0 warnings under -std=c11/-std=c++17 -Wall -Wextra -Werror, clean-room audit 0 errors, zero_copy_handoffs=2 fallback_copies=0).
  • ASan+UBSan (--self-test / --json): PASS.

Validate every ggml tensor view before narrowing ne[] to uint32:
buffer lifetime/ownership, dims in [1,UINT32_MAX], exact contiguous
strides (transposed rejected), quantized block alignment, overflow-
checked byte span versus backing, and base alignment. Replace
std::vector with calloc in graph plan/compute (-fno-exceptions safe),
harden example mock arithmetic, guard fs_buffer_alloc alignment
overflow, and add adversarial hardening tests with descriptor fuzz.
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

Adversarial Hardening & Public-Roads Audit Receipt (f187cc44)

  • Prior PR head: 6cc4b2c3 → Hardened head: f187cc44
  • 7 adapter/example/alloc bugs fixed across ggml_freesilicon.h and tests.
  • Verification: make test, make verify, CTest 12/12, ASan+UBSan 0 findings, ./scripts/clean-room-audit.sh (70 files) PASS.

@saariuslystoned
saariuslystoned merged commit bd67d19 into main Nov 30, 2026
5 checks passed
@saariuslystoned
saariuslystoned deleted the feat/16-ggml-zero-copy-adapter-example branch November 30, 2026 18:46
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.

[Screener] Add ggml_freesilicon.h zero-copy tensor-view adapter example for llama.cpp

1 participant