|
| 1 | +# Phase 20: Learning & Self-Tuning Fabric |
| 2 | + |
| 3 | +## Overview |
| 4 | +Phase 20 introduces the **Learning Layer** to the Ternary Fabric. It moves beyond fixed heuristics and implements a self-tuning feedback loop that optimizes the co-processor's behavior based on real-time execution metrics. |
| 5 | + |
| 6 | +## 1. Adaptive Cost Coefficients |
| 7 | +The scheduler's decision-making process relies on a set of projection coefficients (`weight_cost`, `mem_read_cost`, etc.). In Phase 20, these are no longer static. |
| 8 | + |
| 9 | +- **Mechanism:** Hill-climbing feedback loop. |
| 10 | +- **Feedback Signal:** Error delta between `projected_cost` and actual measured `fabric_cost`. |
| 11 | +- **Goal:** Minimize projection error to ensure the scheduler always selects the truly optimal tile. |
| 12 | + |
| 13 | +## 2. Dynamic Scheduler Weighting |
| 14 | +Each tile maintains a set of kernel-specific performance multipliers. |
| 15 | + |
| 16 | +- **Learning:** After each kernel execution, the tile's performance multiplier is adjusted based on its **Economic Efficiency** relative to the moving average. |
| 17 | +- **Decay:** Multipliers slowly decay back toward 1.0 to ensure the fabric remains responsive to changing workload patterns. |
| 18 | +- **Result:** The fabric "learns" tile preferences automatically, favoring tiles that have historically performed best for specific operations. |
| 19 | + |
| 20 | +## 3. Feedback-Driven Eviction |
| 21 | +The eviction policy uses a composite score to determine which memory blocks to keep resident. |
| 22 | + |
| 23 | +- **Scoring Formula:** `Score = W_freq * Frequency + W_age * Recency + W_success * Success_Rate` |
| 24 | +- **Tuning:** If the fabric experiences high residency misses, it automatically increases the weight of success and frequency to protect critical weights. |
| 25 | +- **Result:** Automatically protected hot weights that contribute most to system efficiency. |
| 26 | + |
| 27 | +## 4. Temporal Pipeline Optimization (Auto-Batching) |
| 28 | +The asynchronous execution engine dynamically tunes its batch size. |
| 29 | + |
| 30 | +- **Objective Function:** `0.7 * Economic Efficiency + 0.3 * Throughput` |
| 31 | +- **Exploration:** The engine occasionally (5% of the time) tries a slightly different batch size. |
| 32 | +- **Adaptation:** If the exploration yields a better composite score, the "base" batch size is updated in that direction. |
| 33 | + |
| 34 | +## 5. Economic Introspection |
| 35 | +The `economic_metrics.csv` log has been expanded to track the evolution of these learning parameters over time. |
| 36 | + |
| 37 | +| Field | Description | |
| 38 | +| :--- | :--- | |
| 39 | +| `projected_cost` | The cost predicted by the scheduler. | |
| 40 | +| `batch_size` | The auto-tuned batch size used for the operation. | |
| 41 | +| `weight_cost` | The current value of the learned weight cost coefficient. | |
| 42 | +| `eviction_scores` | The scores assigned to blocks during the last eviction event. | |
| 43 | + |
| 44 | +## 6. Interpreting the Learning Curve |
| 45 | +When analyzing logs, a healthy "learning" phase should show: |
| 46 | +1. `projected_cost` converging toward `fabric_cost`. |
| 47 | +2. `economic_efficiency` steadily increasing as the scheduler favors better tiles. |
| 48 | +3. `dynamic_batch_size` stabilizing at a value that balances latency and throughput. |
0 commit comments