Reporting & reproducibility¶
profile_packed_linear ¶
profile_packed_linear(
*,
m: int = 64,
n: int = 4096,
k: int = 4096,
reps: int = 20,
warmup: int = 5,
compare_baselines: bool = True,
) -> ProfileBreakdown
Break down pack_weight / pack_act / gemm / scale vs torch FP32 / INT8-WO.
Source code in bnn/profile.py
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 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 | |
ProfileBreakdown
dataclass
¶
Source code in bnn/profile.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
check_soft_budgets ¶
check_soft_budgets(
breakdown: ProfileBreakdown | dict[str, Any],
) -> list[str]
Return soft-budget violations (empty ⇒ within CI ceilings).
Callers decide severity: bnn eval-suite warns unless --strict-budgets;
focused pytest may assert empty violations on the tiny smoke shape so CI
still catches catastrophic regressions. Never mutates golden floors.
Source code in bnn/profile.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
check_committed_bench_soft_floors ¶
check_committed_bench_soft_floors(
bench: dict[str, Any],
*,
floor_fraction: float = SOFT_SPEEDUP_FLOOR_FRACTION,
) -> list[str]
Soft-check committed results/benchmark.json for corruption + thread curves.
floor_fraction is an absolute minimum on
speedup_compute_vs_numpy_fp32 (default SOFT_SPEEDUP_FLOOR_FRACTION),
not a fraction of a historical headline. It only rejects nonsense rows
(e.g. speedup 0). Also requires thread_scaling lists with ≥2 points.
Source code in bnn/profile.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
SOFT_BUDGETS_MS
module-attribute
¶
SOFT_BUDGETS_MS: dict[
tuple[int, int, int], dict[str, float]
] = {
(8, 256, 256): {
"gemm_ms": 25.0,
"e2e_forward_ms": 40.0,
"torch_fp32_ms": 40.0,
},
(64, 512, 512): {
"gemm_ms": 80.0,
"e2e_forward_ms": 120.0,
"torch_fp32_ms": 120.0,
},
}
memory_report ¶
memory_report(model: Module) -> MemoryReport
Per-layer resident vs theoretical footprint for model.
Only Linear/Conv-shaped modules (packed or not) are tracked as layers;
everything else — embeddings, norms, biases on other modules — is summed
into other_* so the totals still reconcile with the real model size.
Source code in bnn/memory.py
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 | |
MemoryReport
dataclass
¶
Whole-model footprint, split into packed and unpacked contributions.
Source code in bnn/memory.py
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 | |
LayerFootprint
dataclass
¶
Bytes attributable to one module.
Source code in bnn/memory.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
forward_transient_bytes ¶
forward_transient_bytes(
batch: int, in_features: int, out_features: int
) -> dict[str, float]
Transient bytes a packed Linear forward allocates, by stage.
Useful for sizing edge deployments: the weight saving is permanent, but a forward still needs packed activations and an FP32 output.
Source code in bnn/memory.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
render_summary ¶
render_summary(results_dir: Path | None = None) -> str
Source code in bnn/eval_report.py
35 36 37 38 39 40 41 42 43 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 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 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 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
write_summary ¶
write_summary(
out: Path | None = None, results_dir: Path | None = None
) -> Path
Source code in bnn/eval_report.py
224 225 226 227 228 229 | |
machine_card ¶
machine_card() -> dict[str, Any]
Source code in bnn/eval_report.py
22 23 24 25 26 27 28 29 30 31 32 | |
pareto ¶
Pareto report: accuracy / compression / latency / energy-proxy (W7.T03).
Dual-metric rule¶
compression is theoretical pack ratio. latency_ms / energy_proxy are
wall-clock / estimate — never conflate with 32× theory.
ParetoPoint
dataclass
¶
One optimiser / baseline configuration on the fair protocol.
Source code in bnn/eval/pareto.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
build_pareto_report ¶
build_pareto_report(
points: list[ParetoPoint] | list[dict[str, Any]],
*,
protocol: str = "docs/FAIR_EVAL_PROTOCOL.md",
bench_shapes_ref: str = "docs/BENCH_SHAPES.md",
warmup: int | None = None,
threads: int | None = None,
meta: dict[str, Any] | None = None,
) -> dict[str, Any]
Build a versioned Pareto JSON payload.
Source code in bnn/eval/pareto.py
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 | |
validate_pareto_report ¶
validate_pareto_report(
payload: dict[str, Any],
) -> list[str]
Return validation errors (empty ⇒ OK).
Source code in bnn/eval/pareto.py
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 | |
demo_points ¶
demo_points() -> list[ParetoPoint]
Tiny synthetic points for CI / schema smoke (not golden floors).
Source code in bnn/eval/pareto.py
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 | |
set_repro_seed ¶
set_repro_seed(
seed: int = 0,
*,
deterministic: bool = True,
force_cpu: bool = True,
) -> dict[str, Any]
Seed Python / NumPy / Torch; optionally enable deterministic algorithms.
Returns a small status dict (useful for logging in result JSON).
Source code in bnn/determinism.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 | |
pack_linear_weight ¶
pack_linear_weight(weight: Tensor) -> dict[str, Any]
Pack ±1 signs of a Linear weight into uint64 + scale alpha.
Source code in bnn/export.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |