Skip to content

Add cross-size covariance audit and research diagnostics - #46

Closed
LightChainr wants to merge 9 commits into
mainfrom
research/threshold-rank-covariance-audit-20260828
Closed

Add cross-size covariance audit and research diagnostics#46
LightChainr wants to merge 9 commits into
mainfrom
research/threshold-rank-covariance-audit-20260828

Conversation

@LightChainr

@LightChainr LightChainr commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Purpose

Measure the implicit cross-size coupling in the historical P33 threshold-rank batches and preserve a covariance-aware diagnostic path on main.

This is research analysis infrastructure, not a general-purpose calibrated statistics library. Its outputs are suitable for comparing the historical full-covariance and diagonal diagnostics and for planning new runs. Strong paper-facing p-values or near-singular generic covariance cases can be hardened later if they become decision-critical.

Added

  • reconstruction of batchwise Delta M, mean M', root-gap jackknife pseudo-values, A_M, B, and angular-normalized A_p;
  • measured cross-size covariance/correlation matrices;
  • full-covariance versus diagonal held-out diagnostics for the historical P33 data;
  • root-doubling diagnostic outputs;
  • archive validation and synthetic regression tests;
  • a dedicated workflow for the covariance archive.

Current empirical takeaway

Historical P33 cross-size correlations are real but modest (maximum absolute correlation about 0.22). Using the measured covariance changes the old low-stat scores only modestly:

A_M:          5.530 full vs 5.273 diagonal
A_p:          5.552 full vs 5.293 diagonal
root doubling 3.462 full vs 3.442 diagonal

So the old radial tension was not created by ignoring a huge hidden cross-size correlation.

Scope

For the committed archive the batch design is aligned and validated. Future production should use the simpler policy in #39: domain-separate distinct N by default, or retain deliberate coupling with aligned batches when covariance reduction is useful.

Numerical hardening such as rank-aware pseudoinverses or finite-sample calibration is welcome follow-up work, but it is no longer a merge blocker for this exploratory audit.

@LightChainr
LightChainr force-pushed the research/threshold-rank-covariance-audit-20260828 branch from 11bd6b5 to 7d73a2f Compare August 28, 2026 12:22
@LightChainr

Copy link
Copy Markdown
Owner Author

Independent execution review completed on a029993:

  • full repository suite: 59/59 passed;
  • audit completed on the committed P33 10M/size, 100-batch histogram;
  • missing/misaligned batches are rejected and training-to-holdout covariance is propagated into the residual score.

Measured cross-size correlations are real but moderate (roughly -0.18 to +0.26 across the retained metrics). They do not reverse the radial conclusion:

metric diagonal held-out chi-square full-covariance held-out chi-square
A_M 5.273 / 2 5.530 / 2
A_p 5.302 / 2 5.561 / 2

For A_p, the full-covariance training amplitude is 0.3025 +/- 0.0635; held-out N=145,170 observations are 0.6221, 0.8816. Thus the old diagonal treatment was incomplete, but covariance is not the source of the visible drift. The current 10M pilot remains underpowered/borderline and motivates the frozen high-stat test in #45.

Recommendation: merge the audit tool. Commit its generated P33 audit outputs before selecting the #39 replay policy, and keep both diagonal/full scores in the report as specified.

@LightChainr

Copy link
Copy Markdown
Owner Author

Follow-up after the branch was rewritten to 7d73a2f:

  • rerun full suite: 60/60 passed;
  • rerun P33 audit confirms root_gap_method=delete_one_jackknife_pseudovalues;
  • updated A_p held-out scores are diagonal 5.29288/2, full covariance 5.55159/2 (the earlier a029 result differed only in the third decimal);
  • A_M remains diagonal 5.27335/2, full 5.53002/2.

The merge recommendation remains positive. One nonblocking integrity improvement: --seed-label is currently declarative and the tool does not ingest metadata. Before using arbitrary/concatenated files, validate that all sizes share the declared RNG schema, seed, counter interval, per-batch counter ranges and samples per batch; otherwise equal batch IDs need not imply measurable cross-size coupling. The committed single-file P33 use is auditable, but the CLI should state or enforce this trust boundary.

Copy link
Copy Markdown
Owner Author

Review: methodology is sound; add four robustness gates before interpreting the output

The main correction is correct: aligned cross-size batches must be treated jointly, nonlinear root gaps should use delete-one jackknife pseudo-values, and the held-out residual covariance must include covariance between the fitted training amplitude and held-out observations.

Before this becomes the authoritative P33/P35 score, please add or explicitly report the following.

1. Equal-batch-weight contract

covariance_of_mean() is an unweighted equal-batch estimator. _orientation_batches() checks equality between the two orientations inside each (N,batch), but it does not currently assert that all aligned batches across all sizes have the same sample count.

Either:

  • assert a single common samples_per_batch across the complete aligned matrix; or
  • implement a declared weighted/cluster-robust estimator.

Do not silently give unequal batches equal statistical weight.

2. Near-singular covariance handling

Common counter streams can make the cross-size covariance nearly singular. The current hand-written Gauss–Jordan inverse should not be the only path used for scientific scores.

Please emit:

  • covariance eigenvalues or singular values;
  • condition number/effective rank;
  • score sensitivity to a prespecified eigenvalue cutoff;
  • a stable Cholesky/SVD/pseudoinverse implementation where necessary.

A failed inversion or large condition number is itself a result and should remain in the report.

3. Estimated-covariance calibration

The reported quadratic form uses a covariance matrix estimated from about 100 batches. Label the resulting chi-square as a plug-in/asymptotic score. Add at least one of:

  • batch bootstrap calibration of the held-out statistic;
  • Hotelling/F-type finite-batch calibration where applicable;
  • a sensitivity table comparing plug-in chi-square with bootstrap quantiles.

This matters most for the two-dimensional held-out test when the covariance has strong off-diagonal structure.

4. Stronger synthetic regression

The current cross-covariance test verifies that the residual off-diagonal is nonzero and the score is finite. Add a synthetic case with an analytically known answer where off-diagonal training/held-out covariance materially changes the fitted amplitude or held-out score. Assert the exact expected full-covariance and diagonal-only values.

Requested result artifact

After these gates pass, run the audit on the committed P33 histogram and commit:

results/server-20260828/P33-cross-size-covariance/

The report should compare, for both A_M and angular-normalized A_p:

  • full covariance;
  • diagonal-only covariance;
  • covariance eigenstructure;
  • plug-in and bootstrap-calibrated held-out scores;
  • the original published diagonal result.

Do not overwrite the previous analysis. This audit should determine whether the apparent radial root-amplitude tension survives the actual coupling policy.

@LightChainr LightChainr left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result review: scientific conclusion is now clear; robustness requirements remain open

The committed P33 audit answers the immediate scientific question. Cross-size correlations are real but modest and mixed-sign (the largest absolute values are about 0.22). Including them does not materially change the previous low-stat radial conclusions:

A_M held-out chi2: full 5.5300 / 2; diagonal 5.2733 / 2
A_p held-out chi2: full 5.5516 / 2; diagonal 5.2929 / 2
root doubling:     full 3.4625 / 2; diagonal 3.4417 / 2

Thus the old diagonal approximation was not the source of the apparent P33 radial/root tension. The P33 data are simply underpowered/noisy for those asymptotic questions. This is an important negative audit result.

The implementation correctly uses delete-one jackknife pseudo-values for nonlinear roots and propagates training/held-out cross-covariance. The result files and workflow are useful and should be retained.

However, the four robustness gates from the earlier review are still not implemented in the current head:

  1. _orientation_batches() checks equal samples only between first/second orientations inside one (N,batch), not a common batch weight across all aligned sizes. Assert one common sample count for the complete matrix or implement explicit weights.
  2. Scientific scores still rely on a hand-written Gauss–Jordan inverse. Emit eigen/singular values, condition number/effective rank, and use a stable Cholesky/SVD/pseudoinverse path.
  3. The chi-square values remain plug-in/asymptotic with covariance estimated from 100 batches. Add batch-bootstrap or an explicit finite-batch calibration/sensitivity table.
  4. The synthetic off-diagonal test still checks only that a covariance entry is nonzero and the score is finite. Add an analytically known example asserting exact full-covariance and diagonal-only amplitudes/scores.

I therefore regard the empirical audit conclusion as valid, but not yet the general-purpose scoring implementation as fully hardened. After these four items, the PR is suitable as the authoritative covariance tool. Future production should preserve same-N orientation coupling while domain-separating distinct N by default, unless a prespecified pilot demonstrates useful parent/child covariance for the exact target statistic.

Copy link
Copy Markdown
Owner Author

治理审查:该 PR 的 empirical archive 有价值,但当前 generic covariance/scoring path 还不应合并。阻断项如下:

  1. 核心计算必须强制 equal batch weights / sample counts。 _orientation_batches 目前只检查同一 N 下 first/second 的 samples 相等,没有检查所有 N、所有 aligned batch 使用同一 sample count;随后 covariance_of_mean 却按等权 batch 处理。archive validator 虽然会拒绝不等样本数,但通用 audit API 仍可能静默产出错误 covariance/score。请在核心路径直接 fail closed,或实现并测试严格的 weighted estimator。
  2. 协方差数值稳定性要进入 scorer 本身。 目前 _solve/_inverse 是通用 Gauss–Jordan,核心 scoring path 没有 SPD/condition/rank 检查;不能把这个安全门只放在事后的 archive validator。建议 Cholesky-first;若支持半正定/近奇异情况,则使用明确定义的 rank-aware pseudoinverse,并报告 effective rank / eigenvalue cutoff。
  3. 有限 batch 的统计量不要无条件称作校准的 chi-square。 这里 covariance 本身来自约 100 个 batch。可以将其明确称为 covariance-weighted quadratic-form diagnostic,或加入预注册的有限样本校准(Hotelling/F、parametric/bootstrap calibration 等,取决于适用假设)。不要据此生成未经校准的 p-value。
  4. 补 exact synthetic regressions。 至少加入:(a) 真正 diagonal covariance 时 full 与 diagonal score 必须逐位/容差内一致;(b) 一个有解析答案的 correlated case;(c) unequal sample-count 输入必须在 core audit 层失败;(d) near-singular covariance 的 fail-closed/rank-aware 行为。
  5. 更新到当前 server head 后再重跑归档验证。 Regression-test the fresh P37 doubling result #53 已经并入 server/huawei-analysis-20260828;该 PR 当前相对 base 已 diverged。修订后请从当前 base 重放,并重新生成/校验 checksums 和 archive contract。

这些是统计基础设施的合并门槛,不是否定已记录的经验结论。现有 cross-size correlation 结果可继续作为 provenance 保留。

@LightChainr
LightChainr marked this pull request as draft August 28, 2026 13:05
@LightChainr LightChainr changed the title Audit cross-size covariance in threshold-rank batches Add cross-size covariance audit and research diagnostics Aug 28, 2026
@LightChainr
LightChainr changed the base branch from server/huawei-analysis-20260828 to main August 28, 2026 13:27

Copy link
Copy Markdown
Owner Author

已由 #69 以 current-main 单提交方式迁入:covariance audit、root-doubling diagnostics、历史输出、validator 和 tests 都已在 main。旧 PR 的分叉历史不再需要继续维护;更泛化的数值 hardening 以后按实际 precision-sensitive 需求做。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant