|
| 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. |
0 commit comments