tests/cluster_kl: perturb _dist_broad fixture to clear uniformity guard
- SHA
a1d1f3268049e72825d9aa538573ad57c3978426- Parents
-
27a65fa - Tree
c66d995
a1d1f32
a1d1f3268049e72825d9aa538573ad57c397842627a65fa
c66d995| Status | File | + | - |
|---|---|---|---|
| M |
tests/unit/test_probe_cluster_kl.py
|
4 | 1 |
tests/unit/test_probe_cluster_kl.pymodified@@ -38,9 +38,12 @@ def _dist_sharp(seed_offset: int = 0) -> TokenDist: | ||
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | def _dist_broad() -> TokenDist: |
| 41 | - """Broad distribution: uniform over top-k.""" | |
| 41 | + """Broad distribution: uniform over top-k, with a tiny monotonic | |
| 42 | + perturbation so it clears ``_divergence``'s uniformity guard (a | |
| 43 | + literally-flat dist looks like a broken lm_head).""" | |
| 42 | 44 | k = 8 |
| 43 | 45 | lp = np.full(k, -math.log(k), dtype=np.float32) |
| 46 | + lp += np.linspace(-1e-4, 1e-4, k, dtype=np.float32) | |
| 44 | 47 | residual = 1.0 - float(np.exp(lp).sum()) |
| 45 | 48 | tail = math.log(residual) if residual > 1e-12 else None |
| 46 | 49 | return TokenDist( |