SabaPivot's picture
download
raw
40.1 kB
"""Write the ICML reproduction logbook pages (markdown + trackio cell headers)."""
import json
import pathlib
import uuid
ROOT = pathlib.Path("/home/ubuntu/samuel/sgmcmc-uq-repro")
LB = ROOT / ".trackio/logbook/pages"
TS = "2026-07-25T14:10:00+00:00"
def cell(kind, title, body, pinned=False, extra=None):
meta = {
"type": kind,
"id": "cell_" + uuid.uuid4().hex[:12],
"created_at": TS,
"title": title,
}
if pinned:
meta["pinned"] = True
meta["pinned_at"] = TS
if extra:
meta.update(extra)
return (
"\n---\n<!-- trackio-cell\n"
+ json.dumps(meta)
+ "\n-->\n"
+ body.rstrip()
+ "\n"
)
def write(slug, heading, cells):
p = LB / slug / "page.md"
p.parent.mkdir(parents=True, exist_ok=True)
p.write_text("# " + heading + "\n\n" + "".join(cells))
print("wrote", p)
BUCKET = "https://huggingface.co/buckets/SabaPivot/sgmcmc-uq-repro-artifacts"
DOWNLOAD = """## Download the reproduction bundle
The full bundle (scripts, raw JSON outputs, figures, poster sources, the raw Boston-housing table)
lives in a Hugging Face Bucket:
<https://huggingface.co/buckets/SabaPivot/sgmcmc-uq-repro-artifacts>
```bash
hf buckets ls -R hf://buckets/SabaPivot/sgmcmc-uq-repro-artifacts/
hf buckets sync hf://buckets/SabaPivot/sgmcmc-uq-repro-artifacts/ ./sgmcmc-uq-repro
cd sgmcmc-uq-repro && pip install numpy scipy sympy matplotlib
python scripts/claim1_thm41.py # and claims 2-6, see below
```
(The auto-named bucket `<slug>-artifacts` would be 109 characters, past the Hub's 96-character
repo-name cap, so a short bucket name is used instead.)
"""
ARX = "https://arxiv.org/abs/2606.00293"
ORV = "https://openreview.net/forum?id=Zkj9ctQdMM"
GH = "https://github.com/wangyu1369/large-sample-sgmcmc-uq"
# ---------------------------------------------------------------- index ----
title = (
"Accurate Large-sample Uncertainty Quantification using Stochastic "
"Gradient Markov Chain Monte Carlo"
)
slugs = [
("executive-summary", "Executive summary"),
(
"claim-1-thm-4-1-relative-covariance-error-c-v-lambda-1-2",
"Claim 1: Thm 4.1 relative covariance error <= C_v lambda^(1/2)",
),
(
"claim-2-thm-4-3-exact-minibatch-noise-covariance",
"Claim 2: Thm 4.3 exact minibatch noise covariance",
),
(
"claim-3-thm-4-5-cor-4-6-w2-bound-a-lambda-b",
"Claim 3: Thm 4.5 / Cor 4.6 W2 bound A lambda / B",
),
("claim-4-algorithm-1-two-stage-tuning", "Claim 4: Algorithm 1 two-stage tuning"),
(
"claim-5-table-3-boston-housing-misspecification",
"Claim 5: Table 3 Boston housing misspecification",
),
(
"claim-6-prop-b-1-momentum-sgld-extension",
"Claim 6: Prop B.1 momentum SGLD extension",
),
("conclusion", "Conclusion"),
]
idx = [
"# Reproduction: " + title,
"",
f"Paper: [arXiv 2606.00293]({ARX}) · [OpenReview Zkj9ctQdMM]({ORV}) · "
f"official code: [wangyu1369/large-sample-sgmcmc-uq]({GH})",
"",
"## Pages",
"",
"| Page |",
"| --- |",
]
for s, lab in slugs:
idx.append(f"| [{lab}](#/{s}) |")
(LB / "index.md").write_text("\n".join(idx) + "\n")
print("wrote index")
# --- claim-5 numbers, loaded early so the summary and the poster agree ---
_c5 = json.load(open(ROOT / "outputs/claim5_boston.json"))
_T = {(r["loss"], r["B"], r["method"]): r for r in _c5["results"] if "cov_err_median" in r}
def M(meth, B, loss="log"):
v = _T[(loss, B, meth)]["cov_err_median"]
return "inf" if v == float("inf") else f"{v:.3f}"
DQ16, DQ50 = M("DQ+exact", 16), M("DQ+exact", 50)
CF16, CF50 = M("DQ+exact-cf", 16), M("DQ+exact-cf", 50)
CT16, CT50 = M("CT", 16), M("CT", 50)
# ------------------------------------------------------- executive summary -
poster = (ROOT / "poster/poster_embed.html").read_text()
exec_md = f"""**Outcome: the paper's core theory reproduces, and two printed statements are
reproducibly contradicted.** Working only from the paper's equations, I re-derived the
discrete-time proxy machinery as executable code and found Eq. (12) (Theorem 4.3) to be an
*exact* identity — it matches an exhaustive enumeration of all 100,000 minibatches of a small
problem to 2.0e-14 and a 1.8-million-gradient Monte Carlo to 1.9e-3 — and Eq. (11)
(Proposition 4.2) to hold to 1e-15. The Wasserstein error between the true and proxy chains
scales with fitted exponents **1.015 in λ and −1.004 in B** (both R² = 1.0000), exactly the
λ/B rate of Corollary 4.6, and the relative covariance error decays with exponent **0.933**,
comfortably inside Theorem 4.1's λ^(1/2) envelope; Algorithm 1's root-solved Λ drives the
proxy's stationary covariance onto its target to 2.4e-15 and mixes in 0.87 epochs, matching
Proposition 4.4's τ = 126 with a measured τ_int = 108. Two claims need correcting: on Boston
housing the DQ+exact accuracy reproduces ({DQ16}/{DQ50} vs. the paper's 0.337/0.352; {CF16}/{CF50}
with the authors' own closed-form Λ) and the constant-noise rule does blow up, but
**continuous-time tuning never diverged in 240 runs** and is the better method at B = 16 in the
paper's own Table 3; and **Eq. (B.3)'s temperature term is wrong for SGLD with momentum** —
the printed (1+κ²)·2Λ/β leaves a relative residual up to 0.98 and predicts a stationary
covariance that misses the simulated one by 88% at κ = 0.3, while the corrected term derived
here is exact to 2e-14 (Eq. (B.3) is exact for SGD, β = ∞, at every κ, and the κ → 0 recovery
is exact to 8e-14).
## Scope & cost
| Item | Value |
| --- | --- |
| Scope | all 6 claims reproduced independently from the paper's equations; official code read only for the Table 3 experimental protocol |
| Hardware | CPU only (no GPU, no HF Jobs, no API keys) |
| Compute time | 23.3 min total wall-clock across the six claim scripts |
| Cost | $0 |
| Scale | logistic regression N=500 D=3; N=2000 D=10 misspecified linear regression; Boston housing N=506 D=12 (full scale); exact solves up to D=12 |
| Seeds | single master seed 20260725, derived per experiment; all recorded in the JSON outputs |
"""
write(
"executive-summary",
"Executive summary",
[
cell("markdown", "Executive summary", exec_md, pinned=True),
cell(
"figure",
"Reproduction poster (poster_embed.html)",
"````html\n" + poster.rstrip() + "\n````",
pinned=True,
),
],
)
# ---------------------------------------------------------------- claim 1 --
c1 = json.load(open(ROOT / "outputs/claim1_thm41.json"))
rows = "\n".join(
f"| {r['lam']} | {r['rel_cov_err']:.5f} ± {r['rel_cov_err_se']:.5f} | "
f"{r['rel_sd_err']:.5f} | {r['Cv_emp']:.4f} | {r['eq11_residual']:.1e} |"
for r in c1["sweep"]
)
c1_md = f"""### Claim (verbatim)
> Theorem 4.1 bounds the relative error between the true stationary covariance Σ_θ and the
> discrete-time proxy covariance Σ_ψ as ‖Σ_θ − Σ_ψ‖/‖Σ_θ‖ ≤ C_v λ^(1/2), scaling with the step
> size λ (Theorem 4.1, Section 4).
### Verdict: **VERIFIED**
Fitted scaling exponent **0.933** (R² = 0.998) over a 25× range of λ. The theorem asserts the
error is *bounded* by C_v λ^(1/2); an exponent ≥ 1/2 is consistent, an exponent < 1/2 would
falsify it. sup_λ (error / λ^(1/2)) = **0.0098**, finite and stable. The marginal-standard-deviation
form, Eq. (10), decays with exponent 0.924.
### Independent method
* Σ_ψ is computed **exactly**, not simulated. The proxy's one-step second-moment identity
Σ = (I−ΛĤ)Σ(I−ΛĤ)ᵀ + Λ C(Σ) Λ + 2Λ/β is *affine* in Σ once Eq. (12) is substituted, so it is
solved as a D²-dimensional linear system. This is an independent re-derivation of
Proposition 4.2 / Eq. (11); the resulting Σ_ψ satisfies Eq. (11) to **1e-15** (last column below).
* Σ_θ is estimated by running SGD on the **true logistic loss**. The proxy is run on the *same*
minibatches (synchronous coupling), so Σ̂_θ − Σ̂_ψ is a control variate with variance orders of
magnitude below either covariance; the reported Σ_θ = Σ_ψ(exact) + (Σ̂_θ − Σ̂_ψ).
* Model: logistic regression with a Gaussian prior R(θ) = ½θᵀΓθ, Γ = 2I. This is the one GLM in
which every Assumption (A)–(C) constant is closed-form: L_n = ‖x_n‖²/4,
M_n = ‖x_n‖³/(6√3) (because sup_z|σ″(z)| = 1/(6√3)), μ = λ_min(Γ)/N. For Poisson regression
M_n = ∞ without a bounded parameter space, as the paper itself notes.
### Scale and seeds
N = 500, D = 3, B = 16, β = ∞ (SGD), Λ = λI. Six step sizes; 1,000 coupled chains each,
T = 4000 + 400/λ steps with 20% burn-in (up to 24,000 steps). Master seed 20260725; the per-λ
seed is 20260725 + round(1e5·λ). Error bars are leave-one-block-out jackknife over 10 chain blocks.
### Numerical result
| λ | ‖Σ_θ−Σ_ψ‖/‖Σ_θ‖ | max_d rel. sd error | error/λ^(1/2) | Eq. (11) residual |
| --- | --- | --- | --- | --- |
{rows}
Constants for this problem: L = {c1['constants']['L']:.4f} (so 1/(2L) = {1/(2*c1['constants']['L']):.3f}),
μ̂ = {c1['constants']['mu_hat']:.4f}, L̂ = {c1['constants']['L_hat']:.4f},
M̄ = {c1['constants']['Mbar']:.4f}, τ₄ = {c1['constants']['tau4']:.4f}.
### Expected value
Theorem 4.1 predicts an upper envelope proportional to λ^(1/2) with a λ-independent constant.
Observed: the error is far below that envelope and decays *faster* (exponent 0.93), which is what
one expects because the chain of inequalities behind Theorem 4.1 (Cor. 4.6 → Eq. (13), with
‖Σ_θ‖ = O(λ)) is loose by one factor of λ^(1/2).
### Boundary / counterexample audit
* **Step size past the stated range.** For λ·L̂ ∈ {{0.5, 1.0, 1.5}} the exact Σ_ψ stays positive
definite; at λ·L̂ ≥ 1.9 the second-moment operator's spectral radius exceeds 1 and
λ_min(Σ_ψ) < 0 (−3.8 at 1.9·/L̂). The theorem's condition λ < 1/(2L) = 1.81 is therefore
sufficient but conservative in this model — the actual variance-stability boundary is at
λ ≈ 1.9/L̂ ≈ 10.7.
* **Assumption (C) removed.** With a rank-deficient design and no prior, μ̂ falls from
{c1['audits']['strong_convexity_violation']['mu_hat_ok']:.4f} to
{c1['audits']['strong_convexity_violation']['mu_hat_violated']:.1e} and cond(Ĥ) rises to
{c1['audits']['strong_convexity_violation']['cond_H_violated']:.2e}. Because C_v inherits a 1/μ̂,
the bound becomes vacuous even though this particular chain remains stable.
* **Assumptions kept, constants inflated.** Student-t(3) covariates raise M̄ from
{c1['audits']['heavy_tailed_design']['Mbar_gauss']:.3f} to
{c1['audits']['heavy_tailed_design']['Mbar_heavy']:.3f} and τ₄ by 21%; the relative covariance
error at λ = 0.2 rises from {c1['audits']['heavy_tailed_design']['rel_cov_err_gauss']:.4f} to
{c1['audits']['heavy_tailed_design']['rel_cov_err_heavy']:.4f} (3.2×), i.e. C_v grows with the
constants exactly as the theorem's structure predicts.
### Limitation
The reachable λ range is bounded below by mixing time (τ_int ≈ 2/(λμ̂)) and above by the proxy's
own stability, so the exponent is fitted over 25× in λ rather than several decades. The estimate
of Σ_θ is Monte Carlo (jackknife SE shown); Σ_ψ is exact.
### Artifacts
`scripts/claim1_thm41.py`, `scripts/common.py`, `scripts/setup_problem.py`,
`outputs/claim1_thm41.json`, `figs/claim1_thm41.png`. Runtime {c1['runtime_s']:.0f} s on CPU.
"""
write(slugs[1][0], slugs[1][1], [cell("markdown", slugs[1][1], c1_md)])
# ---------------------------------------------------------------- claim 2 --
c2 = json.load(open(ROOT / "outputs/claim2_thm43.json"))
t1 = "\n".join(
f"| {r['design']} | {r['n_gradient_samples']:,} | {r['rel_err_formula_vs_MC']:.2e} |"
for r in c2["T1_empirical_mc"]
)
t3 = "\n".join(
f"| {r['N']} | {r['B']} | {'with' if r['replace'] else 'without'} | "
f"{r['n_minibatches']:,} | {r['rel_err']:.2e} |"
for r in c2["T3_exhaustive"]
)
t4 = "\n".join(
f"| {r['lam']} | {r['exact_vs_sim']:.4f} | {r['constnoise_vs_sim']:.4f} | "
f"{r['ziyin_vs_sim']:.4f} |"
for r in c2["T4_consequence"]
)
c2_md = f"""### Claim (verbatim)
> Theorem 4.3 derives an explicit formula for the minibatch noise covariance without assuming
> constant noise, enabling exact rather than approximate stationary covariance solutions
> (Theorem 4.3, Section 4).
### Verdict: **VERIFIED** (exact identity, machine precision)
Eq. (12) is not an approximation: it is an identity, and it holds to **1.7e-15** across 156
sampling-free configurations and to **2.0e-14** against an exhaustive enumeration of every one of
100,000 minibatches.
### Independent method
Four tests of increasing strength; the formula implemented from Eq. (12) alone.
**(T1) Fully empirical Monte Carlo.** The proxy chain is run; at every stationary state a real
minibatch is drawn, the realised proxy gradient formed, and its empirical covariance about the
exact conditional mean Ĥ(ψ−θ̂) accumulated. Nothing from Eq. (12) is used.
| covariate design | minibatch gradients | ‖C_MC − C_Eq12‖/‖C_Eq12‖ |
| --- | --- | --- |
{t1}
**(T2) Exact finite-domain check — no sampling at all.** Eq. (12) uses only E[ψ_∞ − θ̂] = 0 and
E[(ψ_∞−θ̂)(ψ_∞−θ̂)ᵀ] = Σ_ψ. So the stationary law may be replaced by a finite distribution on 2D
atoms ±√D·(chol Σ)ᵀ with equal weights, which matches those two moments exactly. Both the
expectation over ψ and the batch covariance then become finite sums, and the identity is checked
with **zero Monte Carlo error**. 156 configurations (3 covariate designs × 3 prior strengths
γ ∈ {{0, 2, 25}} × B ∈ {{1, 8, 64}} × with/without replacement × 3 choices of Σ, including random
positive-definite ones): **worst relative error 1.7e-15**.
**(T3) Exhaustive minibatch enumeration.** Every minibatch is enumerated and its exact covariance
computed by brute force.
| N | B | replacement | minibatches enumerated | relative error |
| --- | --- | --- | --- | --- |
{t3}
This also confirms the stated (N−B)/(N−1) correction for sampling without replacement.
**(T4) Consequence.** Substituting each candidate noise model into Eq. (11), solving for Σ_ψ, and
comparing with a *simulated* proxy chain (relative Frobenius error):
| λ | Eq. (12) exact | constant noise C = Î/B | Ziyin et al. Eq. (6) |
| --- | --- | --- | --- |
{t4}
### Scale and seeds
N = 400–500, D = 3–4 for T1/T2/T4; N ∈ {{6,8,9,10}} for the exhaustive T3. Master seed 20260725.
T1 pools 1.8 × 10⁶ minibatch gradients per design (600 chains × 3,000 recorded steps).
### Expected value
An exact identity: relative error at the level of floating-point round-off (T2, T3) and of Monte
Carlo error (T1). Both are observed.
### Boundary / counterexample audit
The two surrogates the paper is arguing against were scored on the same problems. The
constant-noise model C = Î/B is indistinguishable from Eq. (12) at λ = 0.05 (0.0107 vs. 0.0106,
both at the simulation's noise floor) but is 2.5× worse at λ = 0.35 — the state-dependent part of
the noise only matters once the chain wanders far from θ̂. The Ziyin et al. Eq. (6) surrogate is
off by 0.70–1.43; note in fairness that Eq. (6) is derived for *linear* regression with Gaussian
covariates and a well-specified model, none of which holds for this logistic testbed, so this is a
demonstration of its stated scope limit rather than a refutation of it.
### Limitation
T4's discriminating power at small λ is capped by the simulation's Monte Carlo error (~1%); the
exactness evidence is T2/T3, which have none.
### Artifacts
`scripts/claim2_thm43.py`, `scripts/common.py` (class `NoiseModel`),
`outputs/claim2_thm43.json`, left panel of `figs/claim24_alg1.png`. Runtime {c2['runtime_s']:.0f} s.
"""
write(slugs[2][0], slugs[2][1], [cell("markdown", slugs[2][1], c2_md)])
# ---------------------------------------------------------------- claim 3 --
c3 = json.load(open(ROOT / "outputs/claim3_w2.json"))
lr = "\n".join(
f"| {r['lam']} | {r['w2_marginal_lower']:.3e} | {r['w2_coupling_upper']:.3e} | "
f"{r['bound_A_muhat']:.3e} | {'yes' if r['within_corollary_condition'] else 'no'} |"
for r in c3["lambda_sweep"]
)
br = "\n".join(
f"| {r['B']} | {r['w2_marginal_lower']:.3e} | {r['w2_coupling_upper']:.3e} | "
f"{r['bound_A_muhat']:.3e} |"
for r in c3["batch_sweep"]
)
a14 = c3["A_finite_t_eq14"]
c3_md = f"""### Claim (verbatim)
> Theorem 4.5 and Corollary 4.6 provide non-asymptotic 2-Wasserstein distance bounds between the
> true and proxy algorithm distributions, giving W₂(π_θ,π_ψ) ≤ Aλ/B for SGD (Theorem 4.5,
> Corollary 4.6).
### Verdict: **VERIFIED**
The finite-t recursion Eq. (14) holds at **every one of 1,999 iterations** in both tested
settings. The stationary distance scales with fitted exponents **{c3['fitted_exponent_lambda']:.3f} in λ**
(R² = {c3['fit_r2_lambda']:.4f}) and **{c3['fitted_exponent_B']:.3f} in B** (R² = {c3['fit_r2_B']:.4f}),
which is exactly the λ/B rate of Corollary 4.6, and the explicit constant of Eq. (F.12) bounds the
measured distance everywhere.
### Independent method
Theorem 4.5 is proved by a **synchronous coupling** argument: it bounds E‖θ_t − ψ_t‖² when the two
chains see the same minibatch and the same injected noise, then uses W₂² ≤ E‖θ_t − ψ_t‖². This
reproduction measures exactly that quantity, which is a *stronger* test than testing W₂ itself.
The worst 1-D marginal W₂, computed from sorted quantiles, gives a valid lower bound, so the true
W₂ is bracketed.
The explicit constant is read off Eq. (F.12) and evaluated with the closed-form logistic constants:
C₀ = (2/μ)(M̄₂/(8L) + M̄²/(4μ)), A = √(96 C₀)·τ₄²/μ̂, and for β = ∞, W₂ ≤ A λ/B.
### Scale and seeds
N = 500, D = 3, β = ∞. λ sweep at B = 16 with 1,000 coupled chains; B sweep at λ = 0.05 with
R·B ≈ 16,000 held fixed and T = 12,000. Finite-t check: 4,000 coupled chains, T = 2,000, θ₀ = ψ₀ = θ̂
so the first term of Eq. (14) vanishes and C_s = E‖ψ_s − θ̂‖⁴ is measured from the same run.
Master seed 20260725.
### Numerical result
**Finite-t, Eq. (14).** At λ = 0.02: holds at all 1,999 compared iterations, minimum RHS/LHS slack
{a14[0]['min_slack_rhs_over_lhs']:.3e}. At λ = 0.05: holds at all 1,999, minimum slack
{a14[1]['min_slack_rhs_over_lhs']:.3e}. (t = 1 is excluded because θ₁ and ψ₁ are *identical* by
construction — the proxy gradient at ψ₀ = θ̂ is the true minibatch gradient — so both sides are 0
there up to 1e-34 of float noise.)
**Stationary, Corollary 4.6.** Cor 4.6 requires λ < min(Bμ̂/(200L²), 1/(4L)) = {c3['lambda_condition_at_B16']:.4f} at B = 16.
Explicit constant: A = {c3['A_with_plugin_muhat']:.4g} with the plug-in μ̂ the paper's Appendix D
prescribes, A = {c3['A_with_global_mu']:.4g} with the rigorous global μ = λ_min(Γ)/N.
| λ (B=16) | W₂ lower | W₂ upper | bound Aλ/B | inside Cor 4.6 range |
| --- | --- | --- | --- | --- |
{lr}
| B (λ=0.05) | W₂ lower | W₂ upper | bound Aλ/B |
| --- | --- | --- | --- |
{br}
### Expected value
Corollary 4.6 predicts W₂ ∝ λ/B, i.e. exponent +1 in λ and −1 in B, with the measured distance
below A λ/B. Observed exponents {c3['fitted_exponent_lambda']:.3f} and {c3['fitted_exponent_B']:.3f}.
### Boundary / counterexample audit
Half the λ grid lies *outside* Cor 4.6's stated range λ < 0.0804; the λ/B rate persists there
anyway, so the condition is sufficient rather than necessary in this model. The explicit constant
is conservative by roughly three orders of magnitude — the paper says as much about its own
Figure D.1 ("the bound captures the correct dependence on λ/B, although it is conservative in
magnitude"), and the size of the gap is driven by the 1/μ² in C₀: using the rigorous global
μ = γ/N = 0.004 instead of the plug-in μ̂ = 0.077 inflates A by a further 17×.
### Limitation
The upper bound comes from one specific (synchronous) coupling, so it is an upper bound on W₂ and
not W₂ itself; the marginal lower bound sits about 32% below it, which brackets the truth. Exact
multivariate W₂ is not computed.
### Artifacts
`scripts/claim3_w2.py`, `outputs/claim3_w2.json`, `figs/claim3_w2.png`, and the λ sweep
`outputs/claim1_lambda_sweep.npy` produced by `scripts/claim1_thm41.py`. Runtime {c3['runtime_s']:.0f} s.
"""
write(slugs[3][0], slugs[3][1], [cell("markdown", slugs[3][1], c3_md)])
# ---------------------------------------------------------------- claim 4 --
c4 = json.load(open(ROOT / "outputs/claim4_alg1.json"))
s1 = "\n".join(
f"| {r['M']} | {r['mean_rel_err']:.4f} | {r['sd']:.4f} |" for r in c4["stage1"]["rows"]
)
s2 = "\n".join(
f"| {r['B']} | {r['method']} | {r['tuning_residual']:.1e} | {r['closedform_residual']:.1e} | "
f"{r['exact_proxy_cov_vs_target']:.2e} | {r['sgd_cov_err_median']:.4g} | "
f"{r['tune_over_mcmc']:.1e} |"
for r in c4["stage2"]
)
dq16 = [r for r in c4["stage2"] if r["method"] == "DQ+exact" and r["B"] == 16][0]
dq200 = [r for r in c4["stage2"] if r["method"] == "DQ+exact" and r["B"] == 200][0]
c4_md = f"""### Claim (verbatim)
> Algorithm 1 gives a two-stage tuning procedure: offline sandwich covariance estimation from a
> subsample, followed by solving coupled equations for preconditioned step sizes (Algorithm 1).
### Verdict: **VERIFIED**
Both stages were implemented from the pseudocode and Eqs. (11)–(12). The root-solved Λ drives the
proxy's exact stationary covariance onto the target sandwich covariance to **2.4e-15**; no
competing tuning rule gets within 1e-2. Mixing takes **0.87 epochs**, matching Proposition 4.4's
prediction (τ = 126 predicted vs. τ_int = 108 measured at B = 16), and the tuning cost is
10⁻⁴–10⁻² of the sampling cost, the range of Table D.1.
### Independent method
* **Stage 1.** Subsample M of N observations, fit θ̂ on the subsample, form
Ĵ = M⁻¹Σ∇²ℓ, Î = M⁻¹Σ∇ℓ∇ℓᵀ and Ŝ = Ĵ⁻¹ÎĴ⁻¹/N.
* **Stage 2.** Solve F(Λ) = ΛĤŜ + ŜĤΛ − Λ(C̄_ψ(Ŝ) + ĤŜĤ)Λ = 0 for Λ with
`scipy.optimize.root(method='hybr')` — the Powell hybrid method Section 6 names — warm-started
from the closed form Λ₀ = (ŜĤ + ĤŜ)(C̄_ψ + ĤŜĤ)⁻¹. Then run preconditioned SGD from θ̂.
* **Internal-consistency check.** Independently of any simulation, feed the solved Λ back into the
exact Σ_ψ solver: if the procedure is correct, Σ_ψ(Λ) must equal Ŝ.
Testbed: the misspecified heteroskedastic linear regression of Section 6.1,
y_n | x_n ~ N(x_nᵀθ⋆, 1+‖x_n‖²) with 1% outliers (mean shift b = 5, variance inflation s = 5),
reduced to N = 2000, D = 10 so the D² and (2D)² linear solves stay comfortably on CPU.
### Scale and seeds
N = 2000, D = 10, 20 outliers, B ∈ {{16, 200}}, 200 epochs, 50% burn-in, 30 chains per rule.
Stage-1 study: M ∈ {{100 … 2000}}, 20 independent subsamples each. Master seed 20260725.
### Numerical result
**Stage 1 — consistency of the offline sandwich estimate**
| subsample M | ‖Ŝ_M − Ŝ_N‖_F/‖Ŝ_N‖_F | sd over 20 draws |
| --- | --- | --- |
{s1}
Fitted decay exponent in M: **{c4['stage1']['fitted_exponent']:.3f}**. Root-M consistency predicts
−0.5; the fit is steeper because at M = 1600 the subsample overlaps 80% of the full data used to
build the target, which correlates the two and drives the measured error down artificially. Over
the uncontaminated range M ≤ 400 the exponent is −0.37. Either way the estimate is consistent.
**Stage 2**
| B | tuning rule | root residual | residual of the closed-form Λ₀ | ‖Σ_ψ(Λ) − Ŝ‖/‖Ŝ‖ | SGD cov. error (median) | Λ cost / MCMC cost |
| --- | --- | --- | --- | --- | --- | --- |
{s2}
**Proposition 4.4 mixing time.** B = 16: predicted τ = {dq16['tau_pred_prop44']:.1f}, measured
τ_int = {dq16['tau_int_measured']:.1f} ({dq16['epochs_to_mix']:.2f} epochs). B = 200: predicted
τ = {dq200['tau_pred_prop44']:.1f}, measured τ_int = {dq200['tau_int_measured']:.1f}
({dq200['epochs_to_mix']:.2f} epochs). Both confirm the paper's "mixing time of tuned SG(L)D is
O(1) epochs".
### Expected value
Σ_ψ(Λ) = Ŝ exactly for DQ+exact (it is what the equations were solved for); a nonzero miss for the
approximate rules, growing with batch size for the continuous-time rule. Both observed: CT's miss
grows 8× from B = 16 (1.4e-2) to B = 200 (1.2e-1).
### Two discrepancies found
1. **The released code does not solve Eq. (11).** `robust_regression_boston.py` sets
Λ = N⁻¹(V Ĵ⁻¹ + Ĵ⁻¹V)(C + V/N)⁻¹, which is exactly the closed-form warm start Λ₀ above, not the
root of Eq. (11) that Section 6 describes. Λ₀ leaves a relative residual of
**{dq16['closedform_residual']:.1e}** in Eq. (11) and misses the target covariance; only the root
solve is exact. (Their `C_raw = mean(H_i Ŝ H_i) + V − V/N` is, however, algebraically identical
to B·C̄_ψ of Eq. (12), since ĤŜĤ = Î/N.)
2. **Algorithm 1 line 5 prints Ŝ ← Ĵ⁻¹ÎĴ⁻¹ with no 1/N.** The covariance of an N-sample estimator
needs the 1/N; the released code applies it, the pseudocode does not.
### Limitation
D = 10 rather than the paper's D = 50, so that the D²×D² operators and the (2D)² momentum solver
stay cheap; the tuning rules and the checks are otherwise identical. Only SGD (β = ∞) is tuned,
as in the paper's own experiments.
### Artifacts
`scripts/claim4_alg1.py`, `scripts/linreg.py` (tuning rules), `scripts/common.py`
(`solve_Lambda`), `outputs/claim4_alg1.json`, right panel of `figs/claim24_alg1.png`.
Runtime {c4['runtime_s']:.0f} s.
"""
write(slugs[4][0], slugs[4][1], [cell("markdown", slugs[4][1], c4_md)])
# ---------------------------------------------------------------- claim 5 --
c5 = _c5
def fmt(v):
if v != v:
return "nan"
return "∞" if v == float("inf") else (f"{v:.3f}" if v < 100 else f"{v:.2e}")
tab = {}
for r in c5["results"]:
if "cov_err_median" in r:
tab[(r["loss"], r["B"], r["method"])] = r
lines = []
for meth, papv in [
("DQ+exact", "0.337 / 0.352"),
("DQ+exact-cf", "0.337 / 0.352"),
("CT", "0.247 / 0.589"),
("LR+WS", "9.23e8 / 1.40e7"),
("DQ+const", "not in Table 3"),
]:
a, b = tab[("log", 16, meth)], tab[("log", 50, meth)]
lines.append(
f"| {meth} | {fmt(a['cov_err_median'])} ({a['n_diverged']}/30 diverged) | "
f"{fmt(b['cov_err_median'])} ({b['n_diverged']}/30 diverged) | {papv} |"
)
tbl = "\n".join(lines)
bl = []
for meth in ["DQ+exact", "CT", "LR+WS", "DQ+const"]:
for lo, nm in [
("beta", "exact integral"),
("beta_mc", "authors' fixed-z surrogate"),
]:
a, b = tab[(lo, 16, meth)], tab[(lo, 50, meth)]
bl.append(
f"| {meth} | {nm} | {fmt(a['cov_err_median'])} | {fmt(b['cov_err_median'])} |"
)
btbl = "\n".join(bl)
c5_md = f"""### Claim (verbatim)
> On the Boston housing dataset under strong model misspecification, the proposed DQ+exact method
> maintains accurate covariance estimates while competing continuous-time and constant-noise
> methods diverge (Table 3).
### Verdict: **FALSIFIED AS WORDED** — the DQ+exact half reproduces and improves on the paper; the
"continuous-time methods diverge" half is contradicted, by this reproduction *and* by the paper's
own Table 3.
* **Reproduces:** DQ+exact stays accurate, at **{DQ16} (B=16) / {DQ50} (B=50)** against the paper's
0.337 / 0.352 — and at **{CF16} / {CF50}** when Λ is computed the way the authors' released code
computes it, within 25% of the published numbers.
* **Reproduces:** a competitor does blow up. The constant-noise rule DQ+const reaches
2.1e9 / 4.8e6, and LR+WS (large-sample + well-specified), which *is* Table 3's diverging column,
reaches ∞ (30/30 runs) / 1.0e3 against the published 9.23e8 / 1.40e7.
* **Contradicted:** continuous-time tuning **never diverged** in 240 runs. It sits at {CT16} / {CT50},
within 2.8× of DQ+exact. In the paper's own Table 3, CT is 0.247 at B = 16 — *better* than the
paper's own DQ+exact value of 0.337. Table 3 contains no constant-noise column at all.
### Independent method and protocol
Boston housing from the original `lib.stat.cmu.edu/datasets/boston` table; the 12 covariates the
authors use (all columns except CHAS), standardised; response MEDV untransformed; no intercept;
N = 506, D = 12. The standardised design matrix and response are **byte-identical** to the authors'
`boston.csv` (max abs difference {c5['data_check']['max_abs_X_diff']:.0f} and
{c5['data_check']['max_abs_y_diff']:.0f}). Working Gaussian scale
σ = sd(OLS residuals) = {c5['sigma_working']:.4f}, as in their script.
Target S⋆ = Ĵ⁻¹ÎĴ⁻¹/N. 500 epochs of preconditioned SGD from θ̂, 50% burn-in, 30 seeds, error
‖Ŝ − S⋆‖_F/‖S⋆‖_F. Tuning rules implemented from the paper: CT from Eq. (3) with Ĉ = Î/B;
DQ+const from Eq. (5) with C̄_ψ = Ĵ/B; LR+WS from Eqs. (5)+(6); DQ+exact from Eqs. (11)+(12).
"-cf" rows use the closed-form Λ₀ of the released code instead of the root solve.
### Numerical result — log loss (Table 3's left block)
| tuning | B = 16 | B = ⌊0.1N⌋ = 50 | paper Table 3 |
| --- | --- | --- | --- |
{tbl}
Exact Gaussian posterior covariance σ²(XᵀX)⁻¹ vs. S⋆: **{c5['posterior_cov_error']:.4f}**
(paper: {c5['posterior_cov_error_paper']}) — reproduces the qualitative point that the model-based
posterior is badly wrong under misspecification, but not the number; the paper does not state which
σ² its "Posterior" column uses.
### Numerical result — β-loss (β = 1.5): NOT REPRODUCED
| tuning | β-loss variant | B = 16 | B = 50 |
| --- | --- | --- | --- |
{btbl}
Paper Table 3 β-loss: CT 2.054 / 3.126, LR+WS ∞ / ∞, DQ+exact 2.782 / 1.398. My errors are one to
three orders of magnitude larger for every rule, so this block is **inconclusive** rather than
contradicted. Two implementation notes that bear on it: (a) the β-divergence integral
∫f(y;θ,z)^β dy = (2πσ²)^(−(β−1)/2)β^(−1/2) does not depend on θ and therefore drops out of every
derivative, which is the "exact integral" row; (b) the authors' released code replaces it by the
plain average β⁻¹·mean_j f(z_j;θ)^β over fixed draws z_j ~ N(0,(5σ)²), which is not an unbiased
estimator of the integral and, unlike the integral, *does* depend on θ — that is the
"authors' fixed-z surrogate" row, implemented here as well. Neither reproduces the published
β-loss numbers. Under the β-loss the Hessian is indefinite (robustness downweights outliers), so
the target S⋆ is nearly singular (min eig(Ĵ) = 3e-5) and every rule's tuned Λ is large.
### Expected value
Same ordering and rough magnitudes as Table 3: DQ+exact accurate (O(0.3)), one competitor
diverging. Observed for the log loss.
### Limitation
Table 3's "NUTS" and "Sandwich Gauss" reference columns were not reproduced (NUTS needs an HMC
sampler; Sandwich Gauss is 0 by construction). The β-loss block is not reproduced, as above.
### Artifacts
`scripts/claim5_boston.py`, `scripts/linreg.py`, `data_boston_raw.txt` (raw CMU table),
`outputs/claim5_boston.json`, `figs/claim5_boston.png`. Runtime {c5['runtime_s']:.0f} s.
"""
write(slugs[5][0], slugs[5][1], [cell("markdown", slugs[5][1], c5_md)])
# ---------------------------------------------------------------- claim 6 --
c6 = json.load(open(ROOT / "outputs/claim6_propB1.json"))
su = c6["summary"]
cont = "\n".join(
f"| {r['kappa']:g} | {r['rel_diff_to_kappa0']:.3e} | {r['B3_resid']:.2e} |"
for r in c6["kappa_continuity"]
)
sim = "\n".join(
f"| {r['kappa']:g} | {r['beta']} | {r['sim_vs_exact']:.4f} | "
f"{r['B3solution_vs_sim']:.4f} |"
for r in c6["simulation"]
)
c6_md = f"""### Claim (verbatim)
> Proposition B.1 extends the covariance and error-bound results to SGLD with momentum, recovering
> the non-momentum results as the momentum parameter κ→0 (Proposition B.1, Appendix B).
### Verdict: **FALSIFIED AS WORDED for SGLD** — exact for SGD and exact in the κ→0 limit, but the
temperature term of Eq. (B.3) is wrong for the SGLD case the proposition is about.
* **κ → 0 recovery: verified exactly.** Worst ‖Σ_ψ(κ=0) − Σ_ψ(non-momentum)‖/‖·‖ over 336
configurations is **{su['worst_kappa0_recovery']:.1e}**, and at κ = 0 Eq. (B.3) reduces
algebraically to Eq. (11) (residual 1.7e-15). Continuity in κ is clean.
* **SGD (β = ∞): verified exactly.** Worst residual of Eq. (B.3) over the same 336 configurations
is **{su['worst_B3_resid_SGD']:.1e}**, at every κ up to 0.95.
* **SGLD (β < ∞), κ > 0: falsified.** The printed final term (1+κ²)·2Λ/β leaves a relative residual
with median **{su['SGLD_paper_resid_median']:.3f}** and maximum **{su['SGLD_paper_resid_max']:.3f}**.
The correct term, derived below, gives median {su['SGLD_corrected_resid_median']:.1e},
maximum {su['SGLD_corrected_resid_max']:.1e}.
### Independent method
The momentum proxy Eq. (B.2) is a linear recursion in the joint state z = (ψ_t − θ̂, ν_t) whose
driving-noise covariance is *linear* in (ψ−θ̂)(ψ−θ̂)ᵀ. Therefore E[zzᵀ] satisfies an exact
(2D)²-dimensional linear fixed point, which is solved directly — no simulation, no truncation.
Given that exact Σ_ψ, Eq. (B.3) can be evaluated to machine precision at any κ, D, λ, B and β.
Three complementary probes:
1. **Symbolic (sympy), scalar case.** With Λ = λ, Ĥ = h, the three stationary second moments
(E[u²], E[um], E[m²]) are solved in closed form. Substituting into Eq. (B.3) as printed gives
residual **exactly 0** when β = ∞. Solving for the coefficient the temperature term *must* carry
yields (2hκλ + κ³ − κ² − κ + 1)/(κ+1), which factors as (1−κ)² + 2κλh/(1+κ) — not (1+κ²).
2. **Numerical grid.** D ∈ {{1,2,3,5}} × {{Gaussian, Student-t}} designs × λ ∈ {{0.05,0.15,0.4}} ×
B ∈ {{8,64}} × κ ∈ {{0, 1e-6, 0.05, 0.2, 0.5, 0.8, 0.95}} = 336 configurations, β ∈ {{∞, 400}}.
3. **Direct simulation** of Eq. (B.2), as an independent check that the exact solver is right.
### The correction
Eq. (B.3) as printed reads
> (1−κ)(ΛĤΣ + ΣĤΛ) + κ/(1−κ²)·(ΛĤΛĤΣ + ΣĤΛĤΛ) = ΛC̄_ψΛ + (1+κ²)/(1−κ²)·ΛĤΣĤΛ + (1+κ²)·2Λ/β
Everything except the last term is exact. The last term should be
> (1−κ)²·(2Λ/β) + κ/(1+κ)·[ ΛĤ(2Λ/β) + (2Λ/β)ĤΛ ]
Both agree at κ = 0, which is why the κ→0 recovery is unaffected; they differ at first order in κ.
### Scale and seeds
N = 400, D ∈ {{1,2,3,5}}, master seed 20260725. Simulation cross-check: 3,000 chains × 8,000 steps,
2,500 burn-in, D = 3, B = 16, λ = 0.15.
### Numerical result
**κ continuity** (D = 3, λ = 0.15, B = 16, β = ∞):
| κ | ‖Σ_ψ(κ) − Σ_ψ(0)‖/‖Σ_ψ(0)‖ | Eq. (B.3) residual |
| --- | --- | --- |
{cont}
**Simulation cross-check.** "Σ from Eq. (B.3) vs. simulation" is the practical consequence of the
error: it is the covariance a user would predict from the proposition.
| κ | β | exact solver vs. simulation | Σ solving Eq. (B.3) vs. simulation |
| --- | --- | --- | --- |
{sim}
At κ = 0.3, β = 400 the covariance Eq. (B.3) predicts is **88% wrong**; at κ = 0.6 it is **337%
wrong**. The exact solver agrees with the simulation to 0.2–0.3% (Monte Carlo error) throughout.
### Expected value
If Proposition B.1 were correct as printed, the residual would be at machine precision for all κ
and all β. It is, for β = ∞; it is not, for β < ∞ and κ > 0.
### Limitation
This falsifies the *stationary covariance* statement (Eq. (B.3)) for SGLD. Theorem B.3 and
Corollary B.4 (the momentum W₂ bounds) were not separately tested; since all the paper's own
experiments use SGD (β = ∞), where Eq. (B.3) is exact, none of the paper's empirical results are
affected by this error.
### Artifacts
`scripts/claim6_propB1.py`, `scripts/common.py` (`stationary_cov_momentum`, `eqB3_residual`,
`solve_B3_for_Sigma`), `outputs/claim6_propB1.json`, `figs/claim6_propB1.png`.
Runtime {c6['runtime_s']:.0f} s.
"""
write(slugs[6][0], slugs[6][1], [cell("markdown", slugs[6][1], c6_md)])
# ------------------------------------------------------------- conclusion --
concl_md = """## Reproduction bundle and how to rerun
The bundle contains every script, every raw JSON output, the five figures, the poster sources
(`poster.html`, `poster_preview.pdf/png`, `poster_embed.html`, `GATE_REPORT.json`) and the raw
Boston-housing table.
```bash
pip install numpy scipy sympy matplotlib
python scripts/claim1_thm41.py # Thm 4.1 (~9 min)
python scripts/claim2_thm43.py # Thm 4.3 (~5 min)
python scripts/claim3_w2.py # Thm 4.5 / Cor 4.6 (~4 min, reads claim 1's sweep)
python scripts/claim4_alg1.py # Algorithm 1 (~10 s)
python scripts/claim5_boston.py # Table 3 (~2 min)
python scripts/claim6_propB1.py # Prop B.1 (~3 min)
python scripts/make_figs.py # figures
```
Everything is CPU-only, single-threaded numpy, and finishes in about 23 minutes total.
`scripts/common.py` holds the independent implementations of Eqs. (11), (12), (B.3), the exact
momentum solver and the Λ root-finder; `scripts/setup_problem.py` and `scripts/linreg.py` hold the
models. The master seed is 20260725 throughout.
## Summary of verdicts
| Claim | Verdict | Key number |
| --- | --- | --- |
| 1 — Thm 4.1, rel. cov. error ≤ C_v λ^(1/2) | verified | fitted exponent 0.933 (R² = 0.998) ≥ 1/2 |
| 2 — Thm 4.3, exact minibatch noise covariance | verified | 2.0e-14 against exhaustive enumeration of 100,000 minibatches |
| 3 — Thm 4.5 / Cor 4.6, W₂ ≤ Aλ/B | verified | exponents 1.015 in λ, −1.004 in B (R² = 1.0000) |
| 4 — Algorithm 1, two-stage tuning | verified | Σ_ψ(Λ) hits the target sandwich covariance to 2.4e-15 |
| 5 — Table 3, Boston misspecification | falsified as worded | DQ+exact 0.127/0.130 (paper 0.337/0.352), but CT never diverged (0.304/0.365) |
| 6 — Prop B.1, momentum extension | falsified as worded | Eq. (B.3) exact for SGD (8.9e-14) and as κ→0, but its SGLD temperature term is 88% wrong at κ = 0.3 |
## What would change my mind
* Claim 5: a run in which continuous-time tuning genuinely diverges on Boston under the log loss,
or a specification of Table 3's β-loss protocol that reproduces 2.054 / 2.782 / 3.126 / 1.398.
* Claim 6: a momentum convention for Eq. (B.1)–(B.2) under which the printed (1+κ²)·2Λ/β term is
exact. I tested the convention the paper writes down, m_t = κm_{t−1} + G_t(θ_{t−1}),
θ_t = θ_{t−1} − Λm_t + √(2β⁻¹Λ)ξ_{t−1}, and validated my solver against direct simulation.
## Honest notes
* Official code exists at <https://github.com/wangyu1369/large-sample-sgmcmc-uq>. It was read only
to recover the Table 3 experimental protocol (which columns, standardisation, epochs, batch
sizes, working σ). No code was copied; every equation is implemented from the paper.
* Two further discrepancies between the paper and its released code are recorded on the Claim 4
page: the code uses a closed-form Λ₀ rather than root-solving Eq. (11) as Section 6 states, and
Algorithm 1 line 5 drops the 1/N from the sandwich covariance.
* The β-loss block of Table 3 is reported as **inconclusive**, not as a contradiction.
* Scale reductions are stated on each claim page (D = 10 instead of 50 for Algorithm 1; D = 3 for
the coupling experiments). Boston housing is at full scale.
"""
write(
"conclusion",
"Conclusion",
[
cell(
"artifact",
"Reproduction bundle",
BUCKET,
extra={"artifact_type": "dataset"},
),
cell("markdown", "Download the reproduction bundle", DOWNLOAD),
cell("markdown", "Download & rerun", concl_md),
],
)
print("done")

Xet Storage Details

Size:
40.1 kB
·
Xet hash:
f5bcc394abbb925882e113c651b5177f5ba9010269c84ff24e9c82b4e1ec1199

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.