Skip to content

Implement recursive decomposition (Schur-complement) log-det computation#2

Open
Balance-H wants to merge 2 commits into
mainfrom
codex/analyze-log-determinant-calculation-in-flex.py-pvqhud
Open

Implement recursive decomposition (Schur-complement) log-det computation#2
Balance-H wants to merge 2 commits into
mainfrom
codex/analyze-log-determinant-calculation-in-flex.py-pvqhud

Conversation

@Balance-H
Copy link
Copy Markdown
Owner

Motivation

  • Replace the previous flattened-atom approach with a nested, recursive evaluation of log|det Omega| that follows the decomposition formula (Schur-complement recursion) from graphical-model theory (Lauritzen) so the result matches the nested atoms/separators structure.
  • Preserve existing eigvals and dad methods while enabling an exact decomp option that operates on the decomposition tree instead of simple per-atom aggregation.

Description

  • Stop flattening the decomposition in main.py and cache the nested decomposition trees as graph_y.atoms_decomp and graph_y.seps_decomp, and print group counts using a _count_groups helper for diagnostics.
  • Add log_det_method and decomp_log_det selection flags in FlexLayer and require atoms_decomp / seps_decomp when log_det_method == "decomp".
  • Implement recursive Schur-complement log-determinant evaluation in layers/flex.py: construct the layer precision matrix Omega on the current device (respecting dist_weighted), split the nested decomposition into left/right atoms and separator, form the AA, BB, SS, AS, BS blocks, compute Schur complement blocks using Cholesky solves, and recursively evaluate -logdet(S) + logdet(left) + logdet(right) until atomic subgraphs are reached.
  • Add robust index handling and fallbacks where a split or index mapping cannot be applied, and use torch.linalg.slogdet, torch.linalg.cholesky, and torch.cholesky_solve for stable factor/solve operations.

Testing

  • No automated tests were executed for this change (environment lacked required dependencies such as torch/igraph).

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant