Skip to content

Commit 25bb7a9

Browse files
authored
Merge pull request #24 from t81dev/documentation-update-phase15-16200136749763687686
Update documentation to Phase 15 status
2 parents a8ad943 + 3abe81a commit 25bb7a9

11 files changed

Lines changed: 106 additions & 59 deletions

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export FABRIC_SHORT_CIRCUIT=1
6262
LD_PRELOAD=./libtfmbs_intercept.so ./llama-cli -m model.gguf
6363
```
6464

65-
### Telemetry Insights (Phase 9)
65+
### Telemetry Insights
6666
```text
6767
[TFMBS-Telemetry] GEMV Completed
6868
- Zero-Skips: 172,401 (65.8% reduction in total operations)
@@ -74,10 +74,11 @@ LD_PRELOAD=./libtfmbs_intercept.so ./llama-cli -m model.gguf
7474

7575
## 🏗️ Project State & Architecture
7676

77-
The project is currently in **Phase 11**, offering a high-fidelity software emulator and **ASIC-ready synthesizable RTL**.
77+
The project is currently in **Phase 15**, offering deep integration with PyTorch and GGUF, alongside native hardware acceleration for advanced kernels.
7878

79-
* **Software Layer (Emulation):** Multi-tile scaling, kernel-style IOCTLs, LRU-based paging, and transparent `LD_PRELOAD` interposer.
80-
* **Hardware Layer (RTL):** Parameterized Multi-Tile SIMD architecture with AXI4-Lite control plane and Zero-Skip TPE lanes.
79+
* **Framework Layer:** Transparent PyTorch integration via `TFMBSLinear`, supporting automatic quantization and weight residency.
80+
* **Software Layer (Emulation):** High-fidelity multi-tile emulator with IOCTL support (`/dev/tfmbs`), GGUF v2/v3 parsing, and transparent `LD_PRELOAD` interposer.
81+
* **Hardware Layer (RTL):** ASIC-ready synthesizable RTL with native support for T-GEMM, T-CONV3D, T-LSTM, and T-Attention kernels.
8182

8283
| Configuration | Lanes | Clock | Throughput (Peak) |
8384
| :--- | :--- | :--- | :--- |

TFMBS_DEVICE_SPEC.md

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,46 +40,37 @@ The primary workload for llama.cpp acceleration.
4040
- **Semantics:** Performs $y = Wx$, where $W$ is ternary, $x$ is typically binary/FP (quantized to ternary by the fabric if necessary), and $y$ is binary (accumulated results).
4141

4242
### 3.2 Async vs Sync
43-
- The interface supports both synchronous (blocking) and asynchronous (polling/interrupt) execution.
44-
- `fabric_exec_gemv` initiates the operation.
45-
- Completion is signalled via a status register or callback.
43+
- The interface supports both synchronous (blocking) and asynchronous (polling/interrupt) execution via IOCTL.
44+
- `TFMBS_IOC_SUBMIT` initiates the operation using a TFD.
45+
- `TFMBS_IOC_WAIT` blocks until completion.
46+
- Completion can also be polled via the `DONE` bit in the control register.
4647

4748
---
4849

49-
## 4. Host API (C ABI)
50+
## 4. Host API (UAPI / IOCTL)
5051

51-
The following functions define the standard interface for the Fabric Device:
52+
The normative interface for the Fabric Device is mediated via the `/dev/tfmbs` character device using the following IOCTLs:
5253

5354
```c
5455
/**
55-
* Allocate memory in the Fabric pool.
56-
* Returns a handle/pointer to Fabric-resident memory.
56+
* Submit a Ternary Frame Descriptor for execution.
57+
* Returns a unique task_id.
5758
*/
58-
void* fabric_alloc(size_t size);
59+
#define TFMBS_IOC_SUBMIT _IOW(TFMBS_IOC_MAGIC, 1, tfmbs_tfd_t)
5960

6061
/**
61-
* Free memory in the Fabric pool.
62+
* Block until the specified task is complete.
6263
*/
63-
void fabric_free(void* ptr);
64+
#define TFMBS_IOC_WAIT _IOW(TFMBS_IOC_MAGIC, 2, uint32_t)
6465

6566
/**
66-
* Copy data from Host RAM to Fabric Memory.
67-
* Handles automatic PT-5 packing if requested.
67+
* Submit a GEMV operation directly (Optimized path).
6868
*/
69-
int fabric_memcpy_to(void* dest_fabric, const void* src_host, size_t size, int pack_pt5);
70-
71-
/**
72-
* Copy data from Fabric Memory to Host RAM.
73-
* Handles automatic PT-5 unpacking if requested.
74-
*/
75-
int fabric_memcpy_from(void* dest_host, const void* src_fabric, size_t size, int unpack_pt5);
76-
77-
/**
78-
* Execute a Ternary General Matrix-Vector multiplication.
79-
*/
80-
int fabric_exec_gemv(void* weight_ptr, void* input_ptr, void* output_ptr, int rows, int cols);
69+
#define TFMBS_IOC_SUBMIT_GEMV _IOW(TFMBS_IOC_MAGIC, 3, tfmbs_gemv_t)
8170
```
8271
72+
For high-level languages, the `pytfmbs` library provides a Pythonic wrapper around these low-level calls.
73+
8374
---
8475
8576
## 5. Implementation Requirements

USER_MANUAL.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Ternary Fabric User Manual (v0.1)
1+
# Ternary Fabric User Manual (v0.2)
22

33
Welcome to the **Ternary Fabric** user manual. This documentation is designed to help hardware designers, software developers, and researchers understand and utilize the ternary-native acceleration substrate.
44

55
## 📖 Table of Contents
66

77
1. **[Project Overview](docs/00_OVERVIEW.md)**
8-
What is the Ternary Fabric? Design philosophy, core innovation, and Phase 6b status.
8+
What is the Ternary Fabric? Design philosophy, core innovation, and Phase 15 status.
99
2. **[Installation & Setup](docs/01_INSTALL.md)**
1010
Dependencies, build instructions, and environment setup.
1111
3. **[Quick Start Guide](docs/02_QUICK_START.md)**
@@ -17,17 +17,17 @@ Welcome to the **Ternary Fabric** user manual. This documentation is designed to
1717
6. **[TFD & Execution Hints](docs/05_TFD.md)**
1818
The binary interface specification, kernel flags, and packing formats.
1919
7. **[Kernel Reference](docs/06_KERNELS.md)**
20-
Usage details for Production (T-GEMM, T-CONV) and Experimental (T-LSTM, T-ATTN) kernels.
20+
Usage details for accelerated kernels (T-GEMM, T-CONV3D, T-LSTM, T-ATTN).
2121
8. **[Software API Guide](docs/07_API.md)**
2222
Comprehensive guide to the `pytfmbs` Python library.
2323
9. **[Profiling & Optimization](docs/08_PROFILING.md)**
2424
Measuring Zero-Skip effectiveness and tuning for multi-tile performance.
2525
10. **[How-To Tutorials](docs/09_TUTORIALS.md)**
2626
Step-by-step guides for quantization, multi-tile scaling, and DMA loading.
2727
11. **[Appendices](docs/10_APPENDICES.md)**
28-
Acronyms, PT-5 details, and Phase 6b verification reports.
28+
Acronyms, PT-5 details, and Phase 15 verification reports.
2929
12. **[Multi-Tile Scaling](docs/11_MULTI_TILE.md)**
30-
Details on Phase 11 multi-tile topology and masking.
30+
Details on multi-tile topology and masking.
3131
13. **[PyTorch Integration](docs/12_PYTORCH.md)**
3232
Using the Ternary Fabric within the PyTorch deep learning framework.
3333
14. **[Strategy Roadmap](docs/ROADMAP.md)**
@@ -52,9 +52,9 @@ LD_PRELOAD=./libtfmbs_intercept.so ./my_app
5252

5353
---
5454

55-
## 📊 Interpreting Telemetry (Phase 9)
55+
## 📊 Interpreting Telemetry
5656

57-
When running with the interposer, the Fabric provides real-time telemetry to `stderr`:
57+
When running with the interposer or Python API, the Fabric provides real-time telemetry:
5858

5959
* **Zero-Skips:** The number of operations eliminated because an operand was zero. Typically 50-75% for LLM workloads.
6060
* **Pool Usage:** Current consumption of the 128MB emulation pool.
@@ -63,7 +63,7 @@ When running with the interposer, the Fabric provides real-time telemetry to `st
6363

6464
---
6565

66-
## 🧠 Memory Management (Phase 7 & 8)
66+
## 🧠 Memory Management
6767

6868
### LRU Paging
6969
The Fabric emulator manages a fixed 128MB pool of "Fabric Memory". If an allocation exceeds this or the pool is full, the system uses a **Least Recently Used (LRU)** policy to evict resident PT-5 frames. Evicted frames are transparently re-hydrated if accessed again by the host.

WHITE_PAPER.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ Ternary Fabric sits at the intersection of Ternary Neural Networks (TNNs) and do
4949
* **MIT Eyeriss:** A research-focused spatial accelerator that prioritizes data movement efficiency. Like the Ternary Fabric, it values energy efficiency but remains centered on binary-encoded weights.
5050
* **AMD XDNA (AI Engine):** A tile-based architecture for Ryzen processors. XDNA offers high flexibility, but the Ternary Fabric's specialization in balanced-ternary allows for the complete elimination of multipliers, a step further in architectural optimization.
5151

52-
## 5. Future Directions & Experimental Kernels
53-
With the core multi-tile architecture (Phase 6b) now validated, the project is expanding into complex recurrent and attention-based structures. Current experimental kernels include **T-LSTM** and **T-Attention**, which are undergoing functional verification in the software reference layer before being committed to RTL.
52+
## 5. Framework Integration & Native Kernels
53+
As of Phase 15, the Ternary Fabric has achieved deep integration with high-level frameworks like PyTorch and native hardware acceleration for complex structures.
54+
- **PyTorch Integration:** The `TFMBSLinear` module enables seamless acceleration of deep learning models with automatic quantization and residency management.
55+
- **Native RTL Kernels:** Recurrent and attention-based structures, including **T-LSTM**, **T-Attention**, and **T-CONV3D**, are now natively supported in hardware, providing extreme throughput for diverse AI workloads.
5456

5557
## 6. Conclusion
56-
The Ternary Fabric provides a scalable, efficient, and high-throughput substrate for the next generation of ternary-quantized neural networks. The successful implementation of Phase 6b demonstrates that ternary-native computing can scale to meet the demands of modern AI while maintaining a fraction of the power and area overhead of binary systems.
58+
The Ternary Fabric provides a scalable, efficient, and high-throughput substrate for the next generation of ternary-quantized neural networks. The successful completion of Phase 15 demonstrates that ternary-native computing can scale to meet the demands of modern AI, from LLMs to computer vision, while maintaining a fraction of the power and area overhead of binary systems.
5759

5860
---
5961
© 2026 Ternary Fabric Project.

docs/00_OVERVIEW.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,25 @@ To save bandwidth, data is stored in a high-density **PT-5** format (5 trits per
2020
### Multi-Tile Scalability
2121
The architecture is parameterized to scale from a single tile to a large matrix of tiles. Each tile operates in lock-step, sharing a frame controller but maintaining private SRAM for local data storage and high-throughput parallel execution.
2222

23-
## 3. Project Status (Phase 9)
23+
## 3. Project Status (Phase 15)
2424

2525
The project has evolved through several key phases:
2626

2727
* **Phases 1-2:** Specification of the TFMBS ABI and development of the PT-5 codec.
28-
* **Phase 3:** RTL design of the Vector Engine and TPE lanes.
29-
* **Phase 4:** Integration with Python via `pytfmbs` and development of the quantization toolkit.
30-
* **Phase 5:** Implementation of hardware profiling counters and dynamic lane masking.
31-
* **Phase 6:** Multi-tile scaling, broadcast weight support, and ASIC-ready SRAM wrappers.
32-
* **Phase 7:** LRU-based Paging and block eviction for large models.
33-
* **Phase 8:** Asynchronous execution with a background command queue.
34-
* **Phase 9 (Current):** Integrated telemetry and proof-of-concept acceleration for binary hosts.
35-
36-
## 4. Experimental Kernels
37-
38-
Beyond the core hardware kernels, the fabric currently supports experimental reference implementations for **T-Conv3D**, **T-LSTM**, and **T-Attention**. These are wired into the `pytfmbs` API and TFMBS header, allowing for software-level verification and architectural exploration before full RTL acceleration.
28+
* **Phase 3-4:** RTL design of the Vector Engine and integration with Python via `pytfmbs`.
29+
* **Phase 5-6:** Hardware profiling, multi-tile scaling, and ASIC-ready SRAM wrappers.
30+
* **Phase 7-9:** LRU-based Paging, asynchronous execution, and integrated telemetry.
31+
* **Phase 10-11:** Transition to kernel-space IOCTL interface and multi-tile scaling.
32+
* **Phase 12-14:** PyTorch integration, large-model batching, and native GGUF support.
33+
* **Phase 15 (Current):** Native RTL acceleration for CONV3D, LSTM, and Attention kernels.
34+
35+
## 4. Accelerated Hardware Kernels
36+
37+
As of Phase 15, the fabric supports native RTL-accelerated kernels for:
38+
* **T-GEMM:** General Matrix Multiply for LLM offloading.
39+
* **T-Conv3D:** 3D Convolution with squared-stride address calculation.
40+
* **T-LSTM:** Recurrent ternary operations with hardware-managed state persistence.
41+
* **T-Attention:** Multi-head attention projections with persistent key-value caching support.
3942

4043
## 5. Key Terminology
4144

docs/01_INSTALL.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This guide covers the requirements and steps to set up the Ternary Fabric enviro
77
### Software Dependencies
88
* **Python 3.8+**
99
* **NumPy:** Used for data preparation and reference verification.
10+
* **PyTorch (1.10+):** Required for `TFMBSLinear` and framework integration.
1011
* **Setuptools:** Required to build the Python C-Extension.
1112
* **GCC:** Needed for compiling the `pytfmbs` extension.
1213

@@ -25,7 +26,7 @@ cd ternary-fabric
2526

2627
### Install Python Dependencies
2728
```bash
28-
pip install numpy setuptools pytest
29+
pip install numpy torch setuptools pytest
2930
```
3031

3132
### Build the `pytfmbs` Extension

docs/02_QUICK_START.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,26 @@ results = fabric.results(0)
4545
print(f"Result for Lane 0: {results[0]}")
4646
```
4747

48-
## 2. Running the Full Example
48+
## 2. Advanced: PyTorch & GGUF
49+
For modern workloads, use the high-level `pytfmbs` integrations.
50+
51+
### PyTorch Integration
52+
```python
53+
from pytfmbs import TFMBSLinear
54+
import torch
55+
56+
model = TFMBSLinear(784, 60) # Accelerated Linear Layer
57+
output = model(torch.randn(1, 784))
58+
```
59+
60+
### Loading GGUF Models
61+
```python
62+
import pytfmbs
63+
fabric = pytfmbs.Fabric()
64+
pytfmbs.load_gguf_tensor(fabric, "model.gguf", "blk.0.attn_q.weight", address=0x1000)
65+
```
66+
67+
## 3. Running the Full Example
4968
A complete, executable version of this walkthrough is available in the repository:
5069

5170
```bash

docs/03_HARDWARE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ Since trits are restricted to $\{-1, 0, 1\}$, multiplication is trivial:
6868
* If both are non-zero and have the same sign, the result is $+1$ (Increment Accumulator).
6969
* If they have different signs, the result is $-1$ (Decrement Accumulator/Two's Complement).
7070

71+
### Native Kernel Support (Phase 15)
72+
The Vector Engine includes specialized logic for advanced kernels:
73+
* **Squared-Stride Addressing (CONV3D):** Automatic offset calculation for 3D spatial traversal.
74+
* **State Persistence (LSTM/ATTN):** When the `BIAS_EN` hint is set, the accumulator persists its value across frame descriptors, enabling efficient recurrent and attention-based state management.
75+
7176
## 4. Pipeline Execution Flow
7277

7378
1. **Submission:** The Host writes a TFD to the AXI registers.

docs/05_TFD.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ Bits | Name | Description
5555
| `0x03` | `MUL` | Element-wise multiplication (Result is not accumulated). |
5656
| `0x04` | `CONV2D`| 2D Convolution (Uses stride/pad hints). |
5757
| `0x05` | `MAXPOOL`| Ternary Max Pooling. |
58-
| `0x06` | `TGEMM` | Matrix multiplication (Optimized accumulation). |
59-
| `0x07` | `CONV3D`| 3D Convolution (Experimental). |
60-
| `0x08` | `LSTM` | Ternary LSTM (Experimental). |
61-
| `0x09` | `ATTN` | Ternary Attention (Experimental). |
58+
| `0x06` | `TGEMM` | Matrix multiplication (Native RTL). |
59+
| `0x07` | `CONV3D`| 3D Convolution (Native RTL). |
60+
| `0x08` | `LSTM` | Ternary LSTM (Native RTL). |
61+
| `0x09` | `ATTN` | Ternary Attention (Native RTL). |
6262

6363
## 5. Packing Formats (`packing_fmt`)
6464

docs/07_API.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,33 @@ Loads data via the AXI-Stream DMA interface.
2020
* `data`: `bytes` object.
2121

2222
### `run(tfd_dict)`
23-
Submits a task and waits for completion.
23+
Submits a task and waits for completion (Synchronous).
2424
* `tfd_dict`: Dictionary with keys like `frame_len`, `exec_hints`, `tile_mask`, etc.
2525

26+
### `submit(tfd_dict)`
27+
Submits a task and returns immediately (Asynchronous). Returns a `task_id`.
28+
29+
### `wait(task_id=None)`
30+
Blocks until the specified `task_id` (or the last submitted task) is complete.
31+
32+
### `is_done(task_id=None)`
33+
Returns `True` if the specified `task_id` (or the last submitted task) has completed.
34+
35+
### `run_batch(tfd_list)`
36+
Submits a list of TFDs for optimized batch execution.
37+
2638
### `results(tile_id=0)`
2739
Returns a list of 15 integers representing the accumulated results for the specified tile. Use `tile_id=-1` to get results for all tiles.
2840

29-
## 2. Profiling Methods
41+
## 2. Framework & GGUF Integration
42+
43+
### `pytfmbs.TFMBSLinear(in_features, out_features, ...)`
44+
A PyTorch layer that offloads GEMV operations to the Ternary Fabric. Supports automatic quantization and prefetching.
45+
46+
### `pytfmbs.load_gguf_tensor(fabric, path, tensor_name, address)`
47+
Utility to load a tensor from a GGUF file directly into Fabric SRAM, with automatic dequantization and PT-5 packing.
48+
49+
## 3. Profiling Methods
3050

3151
### `profile()`
3252
Returns a dictionary with aggregated global metrics:

0 commit comments

Comments
 (0)