Skip to content

Commit e1995ad

Browse files
authored
Merge pull request #28 from t81dev/phase-19-data-driven-adaptation-16839316173144384857
Phase 19: Data-Driven Adaptation (Cost-Aware Fabric)
2 parents 766d52e + faca0b4 commit e1995ad

5 files changed

Lines changed: 381 additions & 103 deletions

File tree

USER_MANUAL.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ Welcome to the **Ternary Fabric** user manual. This documentation is designed to
3030
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.
33-
14. **[Strategy Roadmap](docs/ROADMAP.md)**
33+
14. **[GGUF Model Optimizations](docs/14_GGUF.md)**
34+
Optimizing llama.cpp and GGUF workflows.
35+
15. **[Data-Driven Adaptation](docs/19_DATA_DRIVEN_ADAPTATION.md)**
36+
Details on Phase 19 cost-aware scheduling and adaptive residency.
37+
16. **[Strategy Roadmap](docs/ROADMAP.md)**
3438
The project roadmap detailing completed and future phases.
3539

3640
---

docs/19_DATA_DRIVEN_ADAPTATION.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Phase 19: Data-Driven Adaptation (Cost-Aware Fabric)
2+
3+
Phase 19 focuses on transforming the Fabric from a passive executor into an active, economically-driven co-processor. It leverages the telemetry established in Phase 18 to make autonomous decisions about scheduling, residency, and optimization.
4+
5+
## 1. Cost-Aware Scheduler
6+
7+
The scheduler now selects tiles based on **projected cost** rather than fixed or round-robin assignment.
8+
9+
### projected_cost(tile, kernel, tensors)
10+
- **Residency Hits:** Prefers tiles where weights or inputs are already resident.
11+
- **Broadcast Reuse:** Accounts for the cost of moving data between tiles.
12+
- **Memory Reads/Writes:** Estimates the I/O cost for the specific kernel.
13+
- **Tile Local Reuse:** Favors tiles that have previously processed similar data.
14+
15+
## 2. Residency Policy Engine
16+
17+
Adaptive memory management replaces static LRU.
18+
19+
### Scoring Heuristic
20+
Blocks are scored based on:
21+
- **Recency:** Time since last access.
22+
- **Frequency:** Total number of accesses.
23+
- **Semantic Efficiency:** How much "meaning" (active ops) the block contributes per cost unit.
24+
25+
### Policies
26+
- `keep_hot_state`: Prevents eviction of frequently used activation/state buffers.
27+
- `evict_cold_weights`: Prioritizes eviction of weights with long reuse distances.
28+
- `adaptive_pinning`: Automatically pins blocks that show high temporal locality.
29+
30+
## 3. Sparse-Regime Optimization
31+
32+
Reduces overhead for workloads where Zero-Skip is highly active.
33+
34+
- **Micro-kernel Fusion:** Fuses adjacent operations (e.g., GEMV + Bias + Activation) to reduce memory round-trips.
35+
- **Control Flow Collapse:** Batches small asynchronous tasks to minimize worker thread wake-up overhead.
36+
37+
## 4. Temporal Pipelines
38+
39+
Optimizes recurrent and agentic workloads (LSTM, RNN).
40+
41+
- **Asynchronous Hydration:** Prefetches the next step's inputs/weights while the current step is computing.
42+
- **State Persistence:** Keeps hidden states local to tiles to minimize fabric-wide broadcasts.
43+
44+
## 5. Metric-Driven Auto-Tuning
45+
46+
Rolling averages and baseline comparisons allow the fabric to "learn" the optimal configuration for a given workload over time.

docs/ROADMAP.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,24 @@ Promotion of reference kernels to full hardware acceleration.
130130
* **Deliverables:** Updated `frame_controller.v` and `ternary_lane_alu.v` with native support for 3D Convolution, LSTM, and Attention kernels.
131131
* **Features:** Squared-stride memory addressing for CONV3D and `BIAS_EN` driven state persistence for recurrent/attention workloads.
132132

133-
### Phase 18 — Ternary Workload Maturation & Measurement Plane
133+
### Phase 18 — Ternary Workload Maturation & Measurement Plane
134134
Anchoring the fabric with workload realism and a formal programming model.
135-
* **Status:** In Progress.
135+
* **Status:** Complete.
136136
* **Deliverables:**
137137
* **Three-Tier Benchmark Suite:** Synthetic, Kernel, and Application-level measurement.
138138
* **T-LSTM Promotion:** Native kernel path for recurrent stateful workloads.
139139
* **Host API Surface:** Formal C/C++ primitives for fabric orchestration.
140140
* **Cost Model:** Cycle-aware emulator tracking "fabric_cost" (ops + memory weighted).
141141

142+
### Phase 19 — Data-Driven Adaptation (Cost-Aware Fabric) ⏳
143+
Using Phase 18 metrics to drive autonomous fabric behavior and scheduling.
144+
* **Status:** In Progress.
145+
* **Deliverables:**
146+
* **Cost-Aware Scheduler:** Economic tile selection based on residency and projected cost.
147+
* **Residency Policy Engine:** Adaptive pinning and scoring-based eviction (Scoring: Recency + Frequency).
148+
* **Sparse-Regime Optimization:** Micro-kernel fusion and reduced control-flow overhead.
149+
* **Temporal Pipelines:** Overlapping memory hydration with compute for recurrent workloads.
150+
142151
---
143152

144153
# 🔑 What This Strategy Gives You

include/tfmbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ typedef struct {
7878
#define TFMBS_HINT_ZERO_SKIP_EN (1 << 17)
7979
#define TFMBS_HINT_FREE_NEG_EN (1 << 18)
8080
#define TFMBS_HINT_WEIGHT_BRDCST (1 << 19)
81+
#define TFMBS_HINT_FUSED (1 << 20)
8182

8283
/* T-CONV Specific Hints */
8384
#define TFMBS_HINT_STRIDE_MASK 0x00300000 // Bits 21:20

0 commit comments

Comments
 (0)