Skip to content

PR-readiness fixes for ChordalGMRF#1

Open
timweiland wants to merge 7 commits intosamuelsonric:mainfrom
timweiland:pr-81-chordal
Open

PR-readiness fixes for ChordalGMRF#1
timweiland wants to merge 7 commits intosamuelsonric:mainfrom
timweiland:pr-81-chordal

Conversation

@timweiland
Copy link
Copy Markdown

Companion to your PR timweiland#81 against timweiland/GaussianMarkovRandomFields.jl. Branch is rebased on the current upstream main and adds 8 commits that get the diff CI-green.

Summary

  • Migration: drop the broken vendored deps/MooncakeSparse git-submodule reference, depend on the registered MooncakeSparse 0.1 instead. The DI/Mooncake compat that was blocking is now satisfiable (DI 0.7.17 + Mooncake 0.5.27 + MooncakeSparse 0.1.0).
  • Stale imports: drop unused chordal and triangular imports from CliqueTrees.Multifrontal (chordal was removed in CliqueTrees 1.19.2; the others are referenced).
  • Restored rrule: re-add the sum(::SymTridiagonal) rrule that was lost when src/piracy.jl was removed — still needed for the Zygote constructor tests because of the ProjectTo{SymTridiagonal} factor-of-2 bug.
  • Test isolation: rename backendschordal_backends and test_gauss_approx_pipelinetest_gauss_approx_pipeline_chordal in test_gaussian_approximation_chordal.jl so the chordal test file stops shadowing the GMRF/Zygote one at module scope.
  • Tighter dispatch: restrict the logpdf rrule from ::AbstractGMRF to ::GMRF so ChordalGMRF falls through to native Mooncake AD (which already gives correct gradients via MooncakeSparse's mul!/dot rrules) instead of crashing on a missing linsolve_cache field.
  • Hygiene: seed RNG in the NegativeBinomial Poisson-limit test (was flaky due to unseeded randn); apply runic to the 5 files CI flagged; add a ChordalGMRF docstring + reference-page entry; bump docs Turing compat to 0.40-0.44 so the docs env can resolve under Mooncake 0.5.

Verification

  • Full test suite: 3782 passing, exit 0.
  • make docs: clean, exit 0 (only pre-existing cosmetic warnings).
  • Runic: passes.

Test plan

  • Mooncake ChordalGMRF autodiff tests (20/20)
  • Gaussian Approximation - ChordalGMRF (27/27)
  • Existing GMRF/Workspace AD suites still green
  • make docs builds without errors

timweiland and others added 7 commits April 30, 2026 16:11
- Replace the broken vendored deps/MooncakeSparse submodule with the
  registered MooncakeSparse 0.1 (Mooncake 0.5.25 compat now satisfiable
  by DifferentiationInterface 0.7.17).
- Drop unused `chordal` and `triangular` imports from
  CliqueTrees.Multifrontal — `chordal` was removed in CliqueTrees 1.19.2
  and neither symbol was referenced.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Lost in 8e31503 (Zygote -> Mooncake) when src/piracy.jl was removed.
Still needed for the Zygote-tagged GMRF constructor tests:
ChainRulesCore's ProjectTo{SymTridiagonal} drops the factor of 2 from
symmetry on the off-diagonal, and the explicit sum rrule sidesteps it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add a docstring covering the role (Mooncake-friendly chordal Cholesky
backing), fields, and construction modes. Include the type in
docs/src/reference/gmrfs.md alongside GMRF.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The test asserts the NB→Poisson Hessian convergence at rtol=1e-6 with
η = randn(5). Unlucky draws push exp(η) large enough that the 1/r
correction at r=1e8 exceeds tolerance. Pin the seed so the assertion
is reproducible.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two issues prevented the chordal autodiff tests from running cleanly
once the branch was rebased onto the workspace changes on main:

1. The logpdf rrule was registered for `::AbstractGMRF`, which catches
   `ChordalGMRF` and then crashes accessing `x.linsolve_cache.alg`
   inside the fallback error message. Restrict to `::GMRF` so
   ChordalGMRF falls through to native Mooncake AD (which already gives
   correct gradients via MooncakeSparse's mul!/dot rrules).

2. The chordal test file shared two top-level names with the
   non-chordal one: `backends` and `test_gauss_approx_pipeline`. Both
   files include into the same module, so the chordal redefinitions
   shadowed the non-chordal ones at runtime — meaning the Zygote/
   ForwardDiff testsets in test_gaussian_approximation.jl ended up
   running the ChordalGMRF pipeline. Rename to `chordal_backends` and
   `test_gauss_approx_pipeline_chordal`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Turing 0.40 pins DynamicPPL ~0.37, which is incompatible with the
Mooncake 0.5.25+ this PR requires. Allowing 0.41-0.44 lets the resolver
land on Turing 0.44.4 + DynamicPPL 0.41.6, which compose with the new
stack.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@timweiland
Copy link
Copy Markdown
Author

@samuelsonric Sorry for the LLM blurb up top. With the new DI version, the dependency conflict I mentioned on your PR is gone and things work again. This PR here is just to clean some stuff up and get everything ready for a merge. Once you merge this PR here, we can merge your actual PR.

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