nx_patch_attribution.nx
buildroot/runtime/nx_patch_attribution.nx
about
nx_patch_attribution.nx -- the COMPOST primitive.
User: "did this patch improve things if so then lets find out why
and test and integrate like how we are using a lora right now
that improves our elder ai realism image gen but i couldnt tell
you why and neither can the system".
THE answer. Given a population of "before-patch" samples and a
population of "after-patch" samples, each with per-axis
measurements, this primitive reports:
- WHICH measurement axes the patch significantly moved
- HOW MUCH each axis moved (Cohen's d effect size)
- WHETHER the movement is statistically significant after
family-wise alpha correction (Bonferroni)
The substrate's bits-up answer to the user's concrete pain:
don't ship LoRAs nobody understands; ship a decomposition that
turns the LoRA's effect into measurable named-axis changes that
can then be COMPOSTED into substrate architecture per the
patches-as-manure cardinal.
===== Workflow ===================================================
1. Run N generations WITHOUT the patch; collect per-axis
measurements via caller's measurement_fn. Call this
sample population B (before).
2. Run N generations WITH the patch; collect same measurements.
Call this population A (after).
3. nx_patch_attribute(B_data, A_data, n_axes, n_samples)
4. Result lists per-axis: mean_before, mean_after, effect_size,
significant? Tells caller EXACTLY what the patch is doing.
5. Caller then chooses: is this a useful axis movement? If
yes: ship a substrate-side primitive that achieves the
same axis movement without the LoRA. COMPOSTED.
===== Statistical methods =======================================
Cohen's d (Cohen 1988): standardised mean difference.
d = (mean_A - mean_B) / pooled_std
dependencies 5 imports · 0 importers
imports: nx_syscalls.nxnx_tier.nxnx_loop.nxnx_isqrt.nxnx_multivariate.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 108 | struct NxPatchAttributionResult |
consts
| 74 | const NX_PA_Q10: nx_int = 1024 |
| 81 | const NX_PA_EFFECT_NEGLIGIBLE: nx_int = 0 // |d| < 0.2 |
| 82 | const NX_PA_EFFECT_SMALL: nx_int = 1 // 0.2 <= |d| < 0.5 |
| 83 | const NX_PA_EFFECT_MEDIUM: nx_int = 2 // 0.5 <= |d| < 0.8 |
| 84 | const NX_PA_EFFECT_LARGE: nx_int = 3 // |d| >= 0.8 |
| 85 | const NX_PA_EFFECT_N: nx_int = 4 |
| 95 | const NX_PA_OK: nx_int = 0 |
| 96 | const NX_PA_ERR_BAD_DIMS: nx_int = 1 |
| 97 | const NX_PA_ERR_INSUFFICIENT: nx_int = 2 |
| 98 | const NX_PA_N_VERDICTS: nx_int = 3 |
| 122 | const NX_PA_RESULT_BYTES: nx_int = 88 |
functions
| 87 | func nx_pa_effect_is_valid(e: nx_int) -> nx_int called by 1: main |
| 100 | func nx_pa_verdict_is_valid(v: nx_int) -> nx_int called by 1: main |
| 126 | func _pa_classify_d(d_q10: i64) -> nx_int called by 1: nx_patch_attribute |
| 148 | func nx_patch_attribute( |
| 263 | func main() -> i64 |