code wiki / (root) / nx_patch_attribution.nx

nx_patch_attribution.nx

buildroot/runtime/nx_patch_attribution.nx

12177 B332 linesdepth 6pulls 8 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tier.nx nx_loop.nx nx_isqrt.nx nx_multivariate.nx nx_patch_attribution.nx

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

main sys_mmap nx_prng_init nx_prng_range nx_prng_next nx_patch_attribute sys_mmap ↻ _mv_bonferroni_critical_t_ nx_isqrt_q10 nx_isqrt _pa_classify_d nx_pa_verdict_is_valid nx_pa_effect_is_valid

structs

108struct NxPatchAttributionResult

consts

74const NX_PA_Q10: nx_int = 1024
81const NX_PA_EFFECT_NEGLIGIBLE: nx_int = 0 // |d| < 0.2
82const NX_PA_EFFECT_SMALL: nx_int = 1 // 0.2 <= |d| < 0.5
83const NX_PA_EFFECT_MEDIUM: nx_int = 2 // 0.5 <= |d| < 0.8
84const NX_PA_EFFECT_LARGE: nx_int = 3 // |d| >= 0.8
85const NX_PA_EFFECT_N: nx_int = 4
95const NX_PA_OK: nx_int = 0
96const NX_PA_ERR_BAD_DIMS: nx_int = 1
97const NX_PA_ERR_INSUFFICIENT: nx_int = 2
98const NX_PA_N_VERDICTS: nx_int = 3
122const NX_PA_RESULT_BYTES: nx_int = 88

functions

87func nx_pa_effect_is_valid(e: nx_int) -> nx_int
called by 1: main
100func nx_pa_verdict_is_valid(v: nx_int) -> nx_int
called by 1: main
126func _pa_classify_d(d_q10: i64) -> nx_int
called by 1: nx_patch_attribute
148func nx_patch_attribute(
263func main() -> i64