Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/assets/architecture-diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
sudo apt-get update
sudo apt-get install -y clang cmake ninja-build python3-numpy

- name: Configure & build libopenbuenos (CMake)
- name: Configure & build libfreetpu (CMake)
run: |
cmake -S libopenbuenos -B build-cmake -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake -S libfreetpu -B build-cmake -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build-cmake -j"$(nproc)"
ctest --test-dir build-cmake --output-on-failure

Expand Down Expand Up @@ -74,10 +74,10 @@ jobs:
fi
done

- name: Build & test libopenbuenos (Make)
- name: Build & test libfreetpu (Make)
run: |
make -C libopenbuenos verify-header-host host test
make -C libopenbuenos clean
make -C libfreetpu verify-header-host host test
make -C libfreetpu clean

- name: Build & test libopentpu (Make)
run: |
Expand All @@ -93,7 +93,7 @@ jobs:
clang -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror docs/kernel-abi/gcip_uapi.h
clang -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror docs/kernel-abi/edgetpu_buenos_uapi.h
clang -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror docs/kernel-abi/gxp_laguna_uapi.h
clang -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror -Ilibopenbuenos/include llama-cpp-edgetpu/openbuenos_shim.c
clang -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror -Ilibfreetpu/include llama-cpp-edgetpu/openbuenos_shim.c

- name: Run Python ISA & DGC0 tool self-tests
run: |
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
## Architecture

<p align="center">
<img src=".github/assets/architecture-diagram.svg" alt="FreeTPU execution pipeline from ggml-edgetpu through libopenbuenos and Litebuf VII to /dev/edgetpu-soc and the 4x4 serpentine PE mesh" width="100%">
<img src=".github/assets/architecture-diagram.svg" alt="FreeTPU execution pipeline from ggml-edgetpu through libfreetpu and Litebuf VII to /dev/edgetpu-soc and the 4x4 serpentine PE mesh" width="100%">
</p>

| Layer | Component | Responsibility |
| --- | --- | --- |
| **LLM Inference** | [`llama-cpp-edgetpu/`](llama-cpp-edgetpu/README.md) | `EDGETPU` GGML `ACCEL` backend (`MUL_MAT` & MoE `MUL_MAT_ID` `Q8_0`/`Q4_0`/`F32`, chained SwiGLU, `ROPE`/`GLU`, QKV `3->1` horizontal fusion, 1D bias `ADD`) |
| **Open Runtime** | [`libopenbuenos/`](libopenbuenos/include/openbuenos.h) | C11/C++17 static library: `1,286.4 MHz` DVFS + FW WakeLock, perf-core-pinned SPSC async dequant, clean-room 7-chunk PT `W8A16(FP16)` (`FP32` acc), adaptive spin, 2-tier DMA-BUF pool & LMKD single-copy weight cache, `M=1`/`M=64` GEMM + 11-chunk chained SwiGLU emitter |
| **Open Runtime** | [`libfreetpu/`](libfreetpu/include/freetpu.h) | C11/C++17 static library: `1,286.4 MHz` DVFS + FW WakeLock, perf-core-pinned SPSC async dequant, clean-room 7-chunk PT `W8A16(FP16)` (`FP32` acc), adaptive spin, 2-tier DMA-BUF pool & LMKD single-copy weight cache, `M=1`/`M=64` GEMM + 11-chunk chained SwiGLU emitter |
| **AOT Guard & SRAM** | [`aot-guard/`](aot-guard/README.md) | Zero-dep C11/C++17 5-input SHA-256 AOT cache key/container validator (`aot_cache_guard`) & `< 4 MiB` on-chip SRAM tail subgraph partitioner (`sram_partitioner`) |
| **Kernel Transport** | [`runtime/`](runtime/src/tpu_baremetal_runner.cpp) | Standalone bare-metal runner & UAPI/Litebuf VII headers (`0x0008 -> 0x00fe`, `/dev/edgetpu-soc` `0xED`) |
| **ISA Tooling** | [`tools/`](tools/emit_custom_gemm.py) | Pure-Python `DGC0` dissector/patcher, multi-tile `(M, K, N)` VLIW synthesizer, `0x640` minimax spline codec, `0xa40` chained fusion verifier, `INT4` packer |
Expand All @@ -52,16 +52,16 @@

## 60-Second Quickstart

Build `libopenbuenos`, verify strict C11/C++17 headers, and run the offline unit test suite (zero device or proprietary `.dgc0` files required):
Build `libfreetpu`, verify strict C11/C++17 headers, and run the offline unit test suite (zero device or proprietary `.dgc0` files required):

```bash
git clone https://github.com/freesilicon/freetpu.git
cd freetpu

# 1. Build & test libopenbuenos (CMake + host mock mode)
cmake -S libopenbuenos -B libopenbuenos/build/cmake-host -DCMAKE_BUILD_TYPE=Release
cmake --build libopenbuenos/build/cmake-host -j
ctest --test-dir libopenbuenos/build/cmake-host --output-on-failure
# 1. Build & test libfreetpu (CMake + host mock mode)
cmake -S libfreetpu -B libfreetpu/build/cmake-host -DCMAKE_BUILD_TYPE=Release
cmake --build libfreetpu/build/cmake-host -j
ctest --test-dir libfreetpu/build/cmake-host --output-on-failure

# 2. Build & test aot-guard (5-input AOT cache guard & <4 MiB SRAM partitioner)
make -C aot-guard test
Expand All @@ -72,10 +72,10 @@ python3 tools/spline_0x640.py --self-test --no-emit
python3 tools/pack_int4.py
```

To cross-build `libopenbuenos.a`, `tpu_baremetal_runner`, and `llama.cpp` (`llama-cli` / `llama-bench` / `test-backend-ops`) for Android ARM64 (`android-34`):
To cross-build `libfreetpu.a`, `tpu_baremetal_runner`, and `llama.cpp` (`llama-cli` / `llama-bench` / `test-backend-ops`) for Android ARM64 (`android-34`):

```bash
make -C libopenbuenos verify-header android verify-android
make -C libfreetpu verify-header android verify-android
make -C runtime verify-baremetal
```

Expand Down Expand Up @@ -113,15 +113,15 @@ See [docs/PHASE8_PERF_REPORT.md](docs/PHASE8_PERF_REPORT.md) (and [Phase 7](docs
`freetpu` is strictly **clean-room source and specification only**:

- **Zero vendor binaries**: No proprietary `.so`, `.ko`, `.img`, `.apk`, `.gguf`, `.tflite`, `.dgc0`, or firmware blobs are included in this repository.
- **Zero vendor userspace dependencies**: `libopenbuenos`, `tpu_baremetal_runner`, and `ggml-edgetpu` talk directly to the Linux kernel (`/dev/edgetpu-soc` and `/dev/dma_heap/system`).
- **Zero vendor userspace dependencies**: `libfreetpu`, `tpu_baremetal_runner`, and `ggml-edgetpu` talk directly to the Linux kernel (`/dev/edgetpu-soc` and `/dev/dma_heap/system`).
- **Host mock mode**: Setting `ob_config_t::mock_mode = 1` (or `OPENBUENOS_MOCK=1`) runs the full buffer pool, graph LRU cache, 16-credit async ring, VLIW emitter, and quantized math suites offline on macOS/Linux without TPU hardware.

### Extracting `dive_interp_rv64.bin` On-Device

Running synthesized `.dgc0` microkernels on physical Tensor G5 hardware requires the `638,977 B` RV64GCV DIVE VM interpreter image (`ext[1]`) from the user's own device. **Do not redistribute this binary.** Extract it locally on an unlocked Pixel using `libopenbuenos`:
Running synthesized `.dgc0` microkernels on physical Tensor G5 hardware requires the `638,977 B` RV64GCV DIVE VM interpreter image (`ext[1]`) from the user's own device. **Do not redistribute this binary.** Extract it locally on an unlocked Pixel using `libfreetpu`:

```c
#include "openbuenos.h"
#include "freetpu.h"
#include <stdlib.h>

size_t interp_size = 0;
Expand All @@ -130,7 +130,7 @@ uint8_t *buf = (uint8_t *)malloc(interp_size);
ob_gemm_extract_dive_interp_from_dgc0("/path/to/local_compiled.dgc0", buf, interp_size, &interp_size);
```

Or point `libopenbuenos` / `ggml-edgetpu` directly at your local extracted image (or a local `.dgc0` file) at runtime:
Or point `libfreetpu` / `ggml-edgetpu` directly at your local extracted image (or a local `.dgc0` file) at runtime:

```bash
export OPENBUENOS_DIVE_INTERP_PATH=/data/local/tmp/tpu_open_stack/dive_interp_rv64.bin
Expand Down Expand Up @@ -158,7 +158,7 @@ export OPENBUENOS_DIVE_INTERP_PATH=/data/local/tmp/tpu_open_stack/dive_interp_rv
- [DMA & TTU Bitfields](docs/isa-dma/dma_ttu_bitfields.md) — `0xa40` / `0x9c0` / `0x940` / `0x980` DMA descriptors & SRAM ring setup
- [Vector ALU ISA](docs/isa-vec/vector_alu_isa.md) — `stream125` FP32-RNE quantization & activation pipeline
- [Kernel UAPI Headers](docs/kernel-abi/README.md) — Clean-room `/dev/edgetpu-soc`, `/dev/gxp`, and GCIP IIF headers
- [`libopenbuenos` Guide](docs/libopenbuenos/README.md) & [`ggml-edgetpu` Guide](docs/llama-cpp-edgetpu/README.md)
- [`libfreetpu` Guide](docs/libfreetpu/README.md) & [`ggml-edgetpu` Guide](docs/llama-cpp-edgetpu/README.md)
- [Headless Colab TPU Tooling](docs/cloud-tpu/colab-headless-tooling.md) — Track B `v6e-1`/`v5e-1` headless harness (`tools/colab_tpu_bench.py`), Colab MCP/`v1beta` contract & Track C boundaries
- [Cloud TPU Ops: Container CDI & Prometheus Telemetry](docs/cloud-tpu/ops-container-telemetry.md) — Zero-dep `tpu-exporter` (`:9400/metrics`) & `freetpu-cdi` CNCF CDI `v0.6.0` (`freetpu.dev/tpu=all`) Docker/K8s manifests
- [FreeTPU Router v0 Guide](docs/router/README.md) — OpenAI-compatible router across Pixel Tensor G5 clusters, local hosts, and Cloud TPU slices
Expand Down
2 changes: 1 addition & 1 deletion VISION.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TPUs (`v5e`, `v6e`, `tpu7x`), and non-NVIDIA AI ASICs.

- Clean-room native C++17 userspace runtimes, VLIW ISA specifications, and
`llama.cpp` backends across edge and cloud TPUs:
- **Edge (`Pixel Tensor G5/G6`):** `libopenbuenos` + `ggml-edgetpu` directly
- **Edge (`Pixel Tensor G5/G6`):** `libfreetpu` + `ggml-edgetpu` directly
over `/dev/edgetpu-soc` with zero proprietary vendor `.so` dependencies.
- **Cloud native runtime (`v5e` / `v6e` / `tpu7x`):** `ggml-cloudtpu` over
the open C `PJRT_Api` (zero Python, JAX, or `vllm-tpu` at runtime).
Expand Down
File renamed without changes.
26 changes: 13 additions & 13 deletions freetile/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ target_link_libraries(test_select_tree_lut PRIVATE freetile)
target_compile_options(test_select_tree_lut PRIVATE -Wall -Wextra -Wpedantic -Werror)
add_test(NAME freetile_select_tree_lut_tests COMMAND test_select_tree_lut)

option(FREETILE_BUILD_BUENOS_PARITY_TEST "Build bit-exact parity test against sibling libopenbuenos" ON)
option(FREETILE_BUILD_BUENOS_PARITY_TEST "Build bit-exact parity test against sibling libfreetpu" ON)
option(FREETILE_BUILD_DIGITAL_TWIN "Build freetile-twin digital twin library, CLI, and tests" ON)

if((FREETILE_BUILD_BUENOS_PARITY_TEST OR FREETILE_BUILD_DIGITAL_TWIN)
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos/CMakeLists.txt")
set(OPENBUENOS_BUILD_TESTS OFF CACHE BOOL "" FORCE)
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu/CMakeLists.txt")
set(FREETPU_BUILD_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(
"${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos"
"${CMAKE_CURRENT_BINARY_DIR}/openbuenos_ref"
"${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu"
"${CMAKE_CURRENT_BINARY_DIR}/freetpu_ref"
EXCLUDE_FROM_ALL
)

if(FREETILE_BUILD_BUENOS_PARITY_TEST)
add_executable(test_buenos_parity
tests/test_buenos_parity.cpp
)
target_link_libraries(test_buenos_parity PRIVATE freetile openbuenos)
target_link_libraries(test_buenos_parity PRIVATE freetile freetpu)
target_include_directories(test_buenos_parity SYSTEM PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos/src"
"${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu/src"
"${CMAKE_CURRENT_SOURCE_DIR}/../docs/baremetal-vii"
"${CMAKE_CURRENT_SOURCE_DIR}/../docs/kernel-abi"
)
Expand All @@ -71,13 +71,13 @@ if((FREETILE_BUILD_BUENOS_PARITY_TEST OR FREETILE_BUILD_DIGITAL_TWIN)
add_library(freetile_twin STATIC
src/twin.cpp
)
target_link_libraries(freetile_twin PUBLIC freetile PRIVATE openbuenos)
target_link_libraries(freetile_twin PUBLIC freetile PRIVATE freetpu)
target_include_directories(freetile_twin PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)
target_include_directories(freetile_twin SYSTEM PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos/src"
"${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu/src"
"${CMAKE_CURRENT_SOURCE_DIR}/../docs/baremetal-vii"
"${CMAKE_CURRENT_SOURCE_DIR}/../docs/kernel-abi"
)
Expand All @@ -87,14 +87,14 @@ if((FREETILE_BUILD_BUENOS_PARITY_TEST OR FREETILE_BUILD_DIGITAL_TWIN)
add_executable(freetile-twin
tools/freetile_twin_cli.cpp
)
target_link_libraries(freetile-twin PRIVATE freetile_twin freetile openbuenos)
target_link_libraries(freetile-twin PRIVATE freetile_twin freetile freetpu)
target_compile_options(freetile-twin PRIVATE
-Wall -Wextra -Wpedantic -Werror -fno-exceptions -fno-rtti)

add_executable(test_freetile_twin
tests/test_freetile_twin.cpp
)
target_link_libraries(test_freetile_twin PRIVATE freetile_twin freetile openbuenos)
target_link_libraries(test_freetile_twin PRIVATE freetile_twin freetile freetpu)
target_compile_options(test_freetile_twin PRIVATE
-Wall -Wextra -Wpedantic -Werror -fno-exceptions -fno-rtti)
add_test(NAME freetile_twin_tests COMMAND test_freetile_twin)
Expand Down
10 changes: 5 additions & 5 deletions freetile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ HOST_AR ?= ar

THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
ROOT := $(abspath $(THIS_DIR)/..)
OB_DIR := $(ROOT)/libopenbuenos
OB_LIB := $(OB_DIR)/build/host/libopenbuenos.a
OB_DIR := $(ROOT)/libfreetpu
OB_LIB := $(OB_DIR)/build/host/libfreetpu.a

BUILD_DIR := $(THIS_DIR)/build/host
ROOT_BIN_DIR := $(ROOT)/build
Expand Down Expand Up @@ -57,7 +57,7 @@ TEST_PARITY := $(BUILD_DIR)/test_buenos_parity
TEST_TWIN := $(BUILD_DIR)/test_freetile_twin
TEST_SELECT_TREE := $(BUILD_DIR)/test_select_tree_lut

.PHONY: all host twin test verify-header clean openbuenos-host
.PHONY: all host twin test verify-header clean freetpu-host

all: host

Expand All @@ -66,10 +66,10 @@ host: $(FREETILE_LIB) $(FREETILE_TWIN_LIB) $(TWIN_CLI) $(ROOT_TWIN_CLI) \

twin: $(TWIN_CLI) $(ROOT_TWIN_CLI)

openbuenos-host:
freetpu-host:
$(MAKE) -C $(OB_DIR) host

$(OB_LIB): openbuenos-host
$(OB_LIB): freetpu-host

$(BUILD_DIR)/obj/%.o: $(THIS_DIR)/src/%.cpp $(CORE_HDRS)
@mkdir -p $(dir $@)
Expand Down
2 changes: 1 addition & 1 deletion freetile/src/twin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "ob_internal.h"
#include "ob_quant_unpack.hpp"
#include "openbuenos.h"
#include "freetpu.h"

#include <algorithm>
#include <array>
Expand Down
2 changes: 1 addition & 1 deletion freetile/tests/test_buenos_parity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "freetile/tile_ir.hpp"

#include "ob_internal.h"
#include "openbuenos.h"
#include "freetpu.h"

#include <cmath>
#include <cstdint>
Expand Down
Loading
Loading