Commit 428f496
committed
fix(dn_tree): make_probability_mask infinite-recursion at p=0.5
Latent bug surfaced during the Pillar 13 drift-check wiring (#191):
`make_probability_mask` used `p >= 0.5` to invert the (1-p) mask,
which recursed with `1.0 - 0.5 = 0.5` infinitely whenever p was
exactly 0.5. Pillar 13's independent re-derivation used the strict
`p > 0.5` and correctly fell through to the AND-cascade — that's
the canonical reference this fix matches.
Real production usage (DNConfig default lr=0.03 with boost ~30 →
effective_lr ≈ 0.9) never hit 0.5 exactly so the bug was dormant.
Now that it's fixed:
* Update Pillar 13's drift-check to use lr=0.5 (its canonical
mid-range value per the pillar spec) instead of the lr=0.25
workaround. The drift-check now exercises the previously-broken
branch and continues to pass bit-exactly.
* Add two regression tests on dn_tree itself:
- `make_probability_mask_at_half_terminates` — would
stack-overflow if the fix regresses.
- `make_probability_mask_at_half_is_bernoulli_half` —
empirical popcount mean over N=1024 lands near 32 within
16 standard errors.
No public API change. The fix is two characters: `>=` → `>`.1 parent adeba8a commit 428f496
2 files changed
Lines changed: 55 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
137 | 144 | | |
138 | 145 | | |
139 | 146 | | |
| |||
142 | 149 | | |
143 | 150 | | |
144 | 151 | | |
145 | | - | |
146 | | - | |
147 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
148 | 156 | | |
149 | 157 | | |
150 | 158 | | |
151 | | - | |
| 159 | + | |
152 | 160 | | |
153 | 161 | | |
154 | 162 | | |
| |||
543 | 551 | | |
544 | 552 | | |
545 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
546 | 589 | | |
547 | 590 | | |
548 | 591 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
489 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
490 | 495 | | |
491 | 496 | | |
492 | 497 | | |
| |||
0 commit comments