Skip to content
Merged
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
114 changes: 73 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,82 @@
# `freesched`

**Layer 2 Cross-Accelerator Runtime & Zero-Copy `DMA-BUF` Scheduler** for [`freesilicon`](https://github.com/freesilicon).
[![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-3ECF8E?style=flat-square)](LICENSE)
[![ABI: C11 / C++17 Zero Vendor .so](https://img.shields.io/badge/ABI-C11%20%2F%20Zero%20Vendor%20.so-38BDF8?style=flat-square)](include/freesched.h)
[![Silicon: Tensor G5/G6 & Qualcomm Snapdragon](https://img.shields.io/badge/silicon-Tensor%20%7C%20Snapdragon-F0B44C?style=flat-square)](#verified-multi-vendor-silicon-results)

`freesched` coordinates heterogeneous unified-memory inference across **Vulkan GPU** (long-prompt prefill & vision), **EdgeTPU** (low-watt autoregressive token decode & in-SRAM SwiGLU), and **ARMv9 NEON / SME2 CPU** (attention softmax, RoPE, RMSNorm, control glue) on the same unified 16 GB RAM with **zero host copies**.
**Clean-room C11 cross-vendor zero-copy runtime and `ggml` scheduler** for [`freesilicon`](https://github.com/freesilicon).

## Layering & One-Way Dependencies
`freesched` coordinates heterogeneous unified-memory execution across **GPU + NPU/TPU + CPU** with **zero host copies** (`DMA-BUF` / `AHardwareBuffer` + `sync_file` fences) and **zero proprietary vendor runtime dependencies** (no QNN/QAIRT, no vendor EdgeTPU `.so`), targeting both **Qualcomm Snapdragon** (`IQ-9075`, `Arduino VENTUNO Q / IQ-8275`, `Snapdragon 8 Elite Gen 5 / SM8850`) and **Google Tensor** (`Pixel 10 / laguna`, `Pixel 11 / malibu`).

---

## Verified Multi-Vendor Silicon Results

All benchmarks below are reproducible clean-room measurements committed in [`proof/`](proof/) and mirrored as schema-validated receipts in [`twin/receipts/`](twin/receipts/):

| Target Silicon | Workload & Execution Path | Verified Hardware Result | Proof / Receipt |
| --- | --- | --- | --- |
| **Snapdragon 8 Elite Gen 5 (`SM8850`, Android 16, `uid=2000` Enforcing)** | **Adreno 840 Vulkan 1.2 -> Hexagon `v81` HMX** shader-direct `32x32` `F16Crouton_TCM` `AHardwareBuffer` VLA + 128B HVX `vmem`/`l2fetch` + `MAP_ARENA` | **`1,170 FPS` (`738 µs` p50, `M=256`)** / **`625 FPS` (`1.60 ms` p50, `M=1024`)** — **`3.88x`** faster than Adreno 840 GPU-only (`161 FPS`), **`3.41x`** faster than CPU-staged, **`112x`** DSP data-movement cut (`17.88 ms -> 159.5 µs`), **`0 B`** copy, **`0`** mismatches | [`proof/sm8850-v81-tiled-vla/PROOF.md`](proof/sm8850-v81-tiled-vla/PROOF.md) |
| **Snapdragon 8 Elite Gen 5 (`SM8850`, `uid=2000` Enforcing)** | Clean-room **Hexagon `v81` FP16 HMX** systolic GEMM (`HAP_power_set_HMX_v2`, `1.824 GHz`, `8 MiB` VTCM, freestanding LLVM ELF — same 6 FP16 opcodes as `v73`) | **`23.19 TFLOPS`** FP16 (`nmse=0`, **`0`** mismatches, **`1.94x`** Dual-HTP `IQ-9075`, hardware ReLU verified) | [`proof/sm8850-v81-hmx/PROOF.md`](proof/sm8850-v81-hmx/PROOF.md) |
| **Qualcomm `IQ-9075` (`QCS9075`, Linux)** | **Adreno 663 + Dual Hexagon `v73` HTP** 3-arm zero-copy `DMA-BUF` `SYNC_FD` VLA + Dual-HTP FP16 HMX (zero QNN/QAIRT) | **`163.0 FPS` (`M=256`)** / **`71.5 FPS` (`M=1024`)** (**`2.68x–8.85x`** vs single-chip), **`11.95 TFLOPS`** Dual-HTP (`2.000x` scaling), **`0 B`** copy, **`0`** mismatches | [`proof/multi-soc-twin-vla-abc/PROOF.md`](proof/multi-soc-twin-vla-abc/PROOF.md) |
| **Arduino VENTUNO Q (`QCS8275`, non-root Ubuntu Linux 6.8)** | Clean-room **Hexagon `v73` HMX** + open-source **Mesa Turnip `Adreno 623`** 3-way zero-copy `DMA-BUF` (zero recompile) | **`0.68 TFLOPS`** HMX FP16, `36.15 µs` HVX `M=1`, 3-way Turnip <-> CDSP zero-copy (`bit_exact=true`, `0` mismatches) | [`twin/receipts/iq8275-ventuno-q-calibrated.json`](twin/receipts/iq8275-ventuno-q-calibrated.json) |
| **Google Pixel 10 (`laguna`) & Pixel 11 (`malibu`)** | Heterogeneous **PowerVR Volcanic (`DXT`/`CXTP`) + EdgeTPU (`BUENOS_A0`/`malibu`) + ARMv9 NEON/`SME2`** zero-copy `DMA-BUF` + directional thermal/power model | **`20 µs`** GPU <-> EdgeTPU `DMA-BUF` handoff, `0` fallback copies, multi-profile thermal/power overlays | [`twin/receipts/tensor-g5-swiglu-b1.json`](twin/receipts/tensor-g5-swiglu-b1.json) |

---

## Architecture & One-Way Dependencies

```text
+-----------------------------------------------------------------------+
| llama.cpp / ggml / apps |
+-----------------------------------------------------------------------+
|
v
+-----------------------------------------------------------------------+
| freesilicon/freesched (Layer 2: Scheduler, DMA-BUF & ggml Adapter) |
| - include/freesched.h (Frozen pure C11 / C++17 ABI) |
| - include/ggml_freesilicon.h (Thin ggml backend adapter seam) |
| - twin/freesilicon-twin (Unified Computer 2 Digital Twin CLI) |
| - twin/REWARD-SCHEMA.json (freesilicon.twin.v1 GRPO RL contract) |
| - Zero-copy DMA-BUF ownership + sync_file fence state machine |
| - Cost-model router + pluggable fs_backend_ops_t vtable |
+------------------+----------------------------------+-----------------+
| (runtime plugin vtable) | (runtime plugin vtable)
v v
+-----------------------------------+ +-----------------------------------+
| freesilicon/freetpu | | freesilicon/freepvr |
| EdgeTPU (libopenbuenos/FreeTile) | | PowerVR Volcanic (FreeUSC/FreeCS)|
| EDGETPU_MAP_DMABUF (36-bit IOVA) | | VK_KHR_external_memory_fd |
+-----------------------------------+ +-----------------------------------+
+-----------------------------------------------------------------------------+
| llama.cpp / ggml / robotics VLA / apps |
+-----------------------------------------------------------------------------+
|
v
+-----------------------------------------------------------------------------+
| freesilicon/freesched (Clean-Room C11 Cross-Vendor Zero-Copy Runtime) |
| - include/freesched.h (Frozen pure C11 / C++17 ABI) |
| - include/ggml_freesilicon.h (Thin ggml backend adapter seam) |
| - include/freehexagon*.h (Clean-room v73/v81 HVX + HMX + FastRPC ABI) |
| - Zero-copy DMA-BUF / AHardwareBuffer ownership + sync_file state machine |
| - Cost-model router + pluggable fs_backend_ops_t vtable |
| - twin/freesilicon-twin (Offline functional & ABI smoke validator) |
+-------------------+---------------------------+-----------------------------+
| (runtime plugin vtable) | (clean-room freestanding)
v v
+-----------------------------------+ +--------------------------------------+
| Google Tensor Backends | | Qualcomm Snapdragon Backends |
| - freesilicon/freetpu (EdgeTPU) | | - FreeHexagon v73/v81 (HVX + HMX) |
| - freesilicon/freepvr + mesa | | - Adreno 623/663/840 Vulkan/Turnip |
| - ARMv9 NEON / SME2 | | - AHardwareBuffer / DMA-BUF SYNC_FD |
+-----------------------------------+ +--------------------------------------+
```

Dependencies stay strictly one-way: `freesched` carries zero vendor libraries, zero vendored `llama.cpp` source, and binds hardware backends through the C11 `fs_backend_ops_t` vtable.
Dependencies stay strictly one-way: `freesched` carries **zero proprietary vendor libraries**, **zero vendored `llama.cpp` source**, and binds backends through the clean-room C11 `fs_backend_ops_t` vtable and freestanding LLVM DSP skeletons.

## Hardware Profiles
---

| Profile | SoC | EdgeTPU | Vulkan GPU | CPU Extensions | Unified RAM |
## Supported Hardware Profiles

| Profile / Target | SoC | NPU / TPU | Vulkan GPU | CPU Extensions | Unified RAM |
| --- | --- | --- | --- | --- | --- |
| `FS_PROFILE_PIXEL10_LAGUNA` | `laguna` (Pixel 10) | `BUENOS_A0` (12 TOPS INT8, 1.8 W, 16 VII credits) | PowerVR `DXT-48-1536` (2.4 TFLOPS FP16, 4.5 W) | ARMv9 NEON | 16 GiB LPDDR5X |
| `FS_PROFILE_PIXEL11_MALIBU` | `malibu` (Pixel 11) | `malibu` TPU (24 TOPS INT8, 1.6 W, 16 credits) | PowerVR `CXTP-48-1536` (3.6 TFLOPS FP16, 4.2 W) | ARMv9 NEON + `SME2` | 16 GiB LPDDR5X |
| `FS_PROFILE_HOST_MOCK` | `host_mock` | Built-in mock TPU (exact reference parity) | Built-in mock Vulkan GPU | Host reference CPU | Portable macOS/Linux |
| `FS_PROFILE_QCOM_IQ9075` | `iq9075` | Dual Hexagon HTP (50 + 50 dense INT8 TOPS) | Adreno 663 Vulkan prefill | Kryo Gen 6 NEON | 36 GB LPDDR5 inline ECC |
| `sm8850-v81` | Snapdragon 8 Elite Gen 5 (`SM8850`) | Hexagon `v81` (`8x128B` HVX, `23.19 TFLOPS` FP16 HMX, `8 MiB` VTCM) | Adreno 840 (`32x32` tiled `AHardwareBuffer`) | Oryon ARMv9 | 12–16 GiB LPDDR5X |
| `FS_PROFILE_QCOM_IQ9075` | Qualcomm `IQ-9075` (`QCS9075`) | Dual Hexagon `v73` HTP (`11.95 TFLOPS` FP16 HMX, `16 MiB` VTCM) | Adreno 663 Vulkan | Kryo Gen 6 NEON | 36 GiB LPDDR5 ECC |
| `iq8275-ventuno-q` | Arduino VENTUNO Q (`QCS8275`) | Hexagon `v73` (`8 MiB` VTCM) | Adreno 623 (Mesa Turnip) | Kryo ARMv8 | Unified LPDDR5 |
| `FS_PROFILE_PIXEL10_LAGUNA` | Tensor G5 (`laguna` / Pixel 10) | `BUENOS_A0` (12 TOPS INT8, 1.8 W, 16 VII credits) | PowerVR `DXT-48-1536` (Mesa Volcanic) | ARMv9 NEON | 16 GiB LPDDR5X |
| `FS_PROFILE_PIXEL11_MALIBU` | Tensor G6 (`malibu` / Pixel 11) | `malibu` TPU (24 TOPS INT8, 1.6 W, 16 credits) | PowerVR `CXTP-48-1536` (`3.2 TFLOPS` FP16) | ARMv9 NEON + `SME2` | 16 GiB LPDDR5X |
| `FS_PROFILE_HOST_MOCK` | `host_mock` | Built-in mock accelerator (exact reference parity) | Built-in mock Vulkan GPU | Host reference CPU | Portable macOS/Linux |

---

## Routing Policy & Zero-Copy Invariants

- **Prefill & Vision (`M >= threshold`, default `32`)**: Routes `FS_OP_PREFILL_GEMM` / `FS_OP_VISION_CONV` to `FS_DEV_GPU_VK`.
- **Token Decode (`M < threshold`)**: Routes `FS_OP_DECODE_GEMV` / `FS_OP_SWIGLU` (Q8_0, Q4_0, FP16, FP32) to `FS_DEV_TPU`. On `FS_PROFILE_QCOM_IQ9075`, decode alternates across `FS_DEV_HTP0` and `FS_DEV_HTP1` (Adreno 663 keeps prefill). That profile links no QNN or QAIRT runtime.
- **Vision & Prefill (`M >= threshold`, default `32`)**: Routes `FS_OP_PREFILL_GEMM` / `FS_OP_VISION_CONV` to `FS_DEV_GPU_VK` (`Adreno` or `PowerVR Volcanic`). On Snapdragon VLA pipelines, the GPU vision stem writes directly into `F16Crouton_TCM` `32x32` tiles inside a shared `AHardwareBuffer`/`DMA-BUF` arena consumed zero-copy by Hexagon HMX.
- **Low-Watt Decode & Systolic Projections (`M < threshold` / HMX)**: Routes `FS_OP_DECODE_GEMV` / `FS_OP_SWIGLU` (`Q8_0`, `Q4_0`, `FP16`, `FP32`) to `FS_DEV_TPU` or alternating dual-HTP lanes (`FS_DEV_HTP0` / `FS_DEV_HTP1`) with zero QNN/QAIRT dependencies.
- **Attention & Control**: Routes `FS_OP_ATTN_SOFTMAX`, `FS_OP_ROPE`, `FS_OP_RMS_NORM` to `FS_DEV_CPU_SME2` (or `FS_DEV_CPU_NEON`).
- **Continuity Bonus**: Subtracts `continuity_bonus_us` when an op's input is already resident on a capable device to prevent cross-chip ping-ponging.
- **Zero-Copy `DMA-BUF` Ownership & Upfront Reconciliation**: `fs_dmabuf_reconcile()` intersects alignment, layout (`linear`/`tiled`), and coherency attributes across participating engines *before* allocation or scheduling so `fs_router.cpp` prices layout-convert copies upfront; `fs_buffer_handoff()` enforces single-owner invariants, advances `generation` on every transfer to trap use-after-handoff / double-owner races (`FS_ERR_OWNERSHIP`), models `DMA_BUF_IOCTL_SYNC` on Linux (`#ifdef __linux__`), and maintains `fallback_copies == 0` across GPU <-> CPU <-> TPU pipelines.
- **Graceful Degradation**: Disabling GPU, TPU, or both degrades cleanly to the remaining online accelerators with 100% numerical parity.
- **Upfront Zero-Copy `DMA-BUF` Reconciliation**: `fs_dmabuf_reconcile()` intersects alignment, tiling layout (`linear`/`tiled`/`F16Crouton_TCM`), and coherency attributes across participating engines *before* allocation; `fs_buffer_handoff()` enforces single-owner generation invariants (`FS_ERR_OWNERSHIP`), `DMA_BUF_IOCTL_SYNC` / `SYNC_FD`, and `fallback_copies == 0`.
- **Graceful Degradation**: Disabling GPU, NPU/TPU, or both degrades cleanly to remaining online accelerators with 100% numerical parity.

---

## 60-Second Laptop Build & Test

Expand All @@ -72,27 +100,31 @@ FREESCHED_MOCK=1 ./build-cmake/bench_heterogeneous
```

`make verify` runs:
1. Strict `-std=c11 -Wall -Wextra -Werror` and `-std=c++17 -Wall -Wextra -Werror` syntax checks on `include/freesched.h` and `include/ggml_freesilicon.h`.
1. Strict `-std=c11 -Wall -Wextra -Werror` and `-std=c++17 -Wall -Wextra -Werror` checks on `include/freesched.h` and `include/ggml_freesilicon.h`.
2. Pure C11 ABI suite (`test_c11_abi`).
3. Full C++17 unit & integration suite (`test_freesched`) covering topology, `DMA-BUF` ownership/race detection, heterogeneous prefill/attention/decode routing, bit-exact FP32/FP16/Q8_0/Q4_0 parity, graceful degradation, custom backend vtables, and the `ggml_freesilicon` adapter.
4. Heterogeneous laptop benchmark (`bench_heterogeneous`) + `twin/freesilicon-twin` Digital Twin suite & `>= 1,000 evals/min` throughput gate.
4. Heterogeneous laptop benchmark (`bench_heterogeneous`) and offline functional/ABI smoke checks (`twin/freesilicon-twin`).
5. Clean-room boundary audit (`./scripts/clean-room-audit.sh`).

---

## Offline Functional & ABI Smoke Validator (`twin/`)

`freesched` ships an offline, zero-dependency functional smoke validator ([twin/freesilicon-twin](twin/freesilicon-twin)) so contributors can verify `DMA-BUF` routing, ABI invariants, SRAM/layout bounds, and mock parity on any macOS or Linux laptop without physical hardware attached:
`freesched` includes a zero-dependency offline validator ([`twin/freesilicon-twin`](twin/freesilicon-twin)) and sanitized released-chip receipts ([`twin/receipts/`](twin/receipts/)) so contributors can validate `DMA-BUF` routing, ABI invariants, SRAM/VTCM layout bounds, and mock numerical parity on any laptop without hardware attached:

```bash
# Run offline functional & ABI smoke verification
./twin/freesilicon-twin self-test

# Evaluate Layer 2 heterogeneous schedules against native compiled bench_heterogeneous
# Evaluate heterogeneous schedules against native compiled bench_heterogeneous
make bench
./twin/freesilicon-twin sched --target laguna --native --pretty
./twin/freesilicon-twin sched --target malibu --native --pretty
```

See [twin/README.md](twin/README.md) for `FREEPVR_TWIN_DIR` and `FREETILE_TWIN_BIN` plugin discovery, and [CONTRIBUTING.md](CONTRIBUTING.md) for clean-room rules, open issues, and hardware bounties.
See [`docs/FREEHEXAGON.md`](docs/FREEHEXAGON.md), [`docs/FREEHEXAGON_HMX.md`](docs/FREEHEXAGON_HMX.md), [`twin/README.md`](twin/README.md), and [`CONTRIBUTING.md`](CONTRIBUTING.md) for clean-room rules and contributor issues.

---

## License

Expand Down
Loading