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
2026-04-30 per-synapse precision plan¶
The adaptive precision module now includes a conservative per-synapse planner
for the roadmap auto-adaptive precision optimiser. It assigns integer
bit_width, SC bitstream_length, sensitivity, quantisation-error bound,
stochastic-error bound, and total bound for each synapse:
import numpy as np
from sc_neurocore.compiler.adaptive_precision import (
assign_synapse_precisions,
precision_plan_manifest,
)
weights = [np.array([[0.1, 0.8], [0.0, 0.4]])]
plan = assign_synapse_precisions(weights, target_error=0.05)
manifest = precision_plan_manifest(plan)
This is a deterministic planning surface, not a training-result claim. Bounds are intentionally conservative: quantisation is bounded by half an integer step scaled by sensitivity, and stochastic sampling uses the existing Hoeffding bitstream-length helper. Custom sensitivity maps can be supplied after an external sensitivity-analysis pass.
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
| Python | |
|---|---|
35 36 37 38 39 40 41 42 43 | |
SynapsePrecision
dataclass
¶
Precision assignment and conservative error bound for one synapse.
Source code in src/sc_neurocore/compiler/adaptive_precision.py
| Python | |
|---|---|
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 | |
to_dict()
¶
Return a JSON-serialisable precision-plan row.
Source code in src/sc_neurocore/compiler/adaptive_precision.py
| Python | |
|---|---|
61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
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
| Python | |
|---|---|
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 117 118 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 | |
assign_synapse_precisions(layer_weights, layer_names=None, sensitivity_maps=None, target_error=0.01, min_bits=4, max_bits=16, min_length=32, max_length=4096, confidence=0.95)
¶
Assign per-synapse bit widths and SC lengths with error bounds.
The bound is intentionally conservative: each synapse gets a local target derived from the global target, quantisation error is bounded by half an integer-quantisation step scaled by sensitivity, and stochastic sampling error uses the existing Hoeffding bitstream-length helper.
Source code in src/sc_neurocore/compiler/adaptive_precision.py
| Python | |
|---|---|
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 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
precision_plan_manifest(assignments)
¶
Build a deterministic manifest for a per-synapse precision plan.
Source code in src/sc_neurocore/compiler/adaptive_precision.py
| Python | |
|---|---|
246 247 248 249 250 251 252 253 254 255 256 257 258 | |
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
| Python | |
|---|---|
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |