hyperiax.prebuilt.bffg.continuous_refine_anchor

hyperiax.prebuilt.bffg.continuous_refine_anchor()[source]

Build the continuous anchor-refinement down-sweep (Algorithm 3 §7.1).

Walks root → leaves, writing two fields per non-root node:

  • anchor = prec_v⁻¹ ptnl_v — the BFFG-implied posterior mean at THIS vertex (child end of the incoming edge).

  • anchor_pa = parent.anchor — the parent’s just-refined anchor, cached on the child so the next up-sweep can read both endpoints inside children.map(...) without a segment-aware gather.

Because @down proceeds top-down, parent.anchor reads the parent’s UPDATED value (refined at the previous level of this sweep). The root keeps its initial anchor (it is pinned at root_val).

Return type:

SweepFn

Returns:

A hyperiax.SweepFn that writes (anchor, anchor_pa) at every non-root node. Typical usage iterates with the BF up-sweep:

for _ in range(n_lin_iters):
    tree = bf(tree, params=theta)
    tree = refine(tree, params=theta)