Adaptive Precision¶
Per-layer adaptive bitstream length for mixed-precision SC networks.
AdaptivePrecisionManager— Auto-select bitstream length per layer (Hoeffding/Chebyshev/sensitivity bounds). Layers needing high precision get longer bitstreams; tolerant layers get shorter ones.
from sc_neurocore.compiler.adaptive_precision import AdaptivePrecisionManager
sc_neurocore.compiler.adaptive_precision
¶
Per-layer adaptive bitstream length for mixed-precision SC networks.
Different layers tolerate different amounts of SC quantization noise. Shallow layers (close to input) can use short bitstreams (L=64) for speed, while deep layers (close to output) need longer bitstreams (L=1024) for precision. Uniform L wastes throughput on shallow layers.
This module: 1. Analyzes per-layer sensitivity to bitstream length via sweeps 2. Assigns optimal L_i per layer using Hoeffding bounds or empirical calibration 3. Outputs a precision map for the compiler to generate per-layer Verilog with different bitstream lengths
Reference: Sim & Lee 2019 — "Adjustable Sequence Length for SC NNs"
LayerPrecision
dataclass
¶
Bitstream length assignment for one layer.
Source code in src/sc_neurocore/compiler/adaptive_precision.py
33 34 35 36 37 38 39 40 41 | |
analyze_sensitivity(layer_weights, lengths=None, n_trials=100, seed=42)
¶
Measure per-layer sensitivity to bitstream length reduction.
For each layer, compute mean output error across trial inputs when reducing bitstream length from max to min. Layers with high sensitivity need longer bitstreams.
Parameters¶
layer_weights : list of ndarray Weight matrices for each layer. lengths : list of int Bitstream lengths to sweep (default: [32, 64, 128, 256, 512, 1024]). n_trials : int Number of random input trials. seed : int Random seed.
Returns¶
list of float Per-layer sensitivity scores (higher = needs longer bitstream).
Source code in src/sc_neurocore/compiler/adaptive_precision.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
assign_lengths(layer_weights, layer_names=None, total_budget=None, min_length=32, max_length=1024, target_error=0.01, method='hoeffding')
¶
Assign per-layer bitstream lengths under a total budget.
Parameters¶
layer_weights : list of ndarray Weight matrices for each layer. layer_names : list of str, optional Human-readable layer names. total_budget : int, optional Total bitstream cycles budget. If None, each layer gets its own minimum length for target_error. min_length, max_length : int Bounds on per-layer bitstream length. target_error : float Target per-layer accuracy (probability tolerance). method : str 'hoeffding' uses Hoeffding bound, 'sensitivity' uses empirical sweep.
Returns¶
list of LayerPrecision Per-layer bitstream length assignments.
Source code in src/sc_neurocore/compiler/adaptive_precision.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |