Skip to content
This repository was archived by the owner on Aug 20, 2026. It is now read-only.
This repository was archived by the owner on Aug 20, 2026. It is now read-only.

[teeny] Regularisers: replace ~8,550 lines of hand-expanded per-D stencils with one N-D tap-table engine #50

Description

@balbasty

Agent:claude-fastfields-to-teeny

Part of the teeny-refactor umbrella (fastfields-lib#21). This was the largest remaining piece of that effort — everything else (distance, posdef, pushpull forward, resize/restrict/splinc, mesh) was already teenified; the regulariser stencil bodies were not.

STATUS: ALL SIX PHASES DONE. Closing.

Final summary

phasewhatlanded
1Field engine (matvec/diag/kernel, plain + RLS/JRLS)kernels#54, #56
2Flow engine + Lamé cross-couplingkernels#60, #61, cpu-lib#56/#57, cpu-impl#42 (closed #59)
3Impl-layer spatial-index decode via peel_front<-1>().enumerate()cpu-impl#46 (closed #43)
4Relax: predicate-skip → dense subsample colour viewscpu-impl#50 (closed #49)
5CUDA launcher consolidation (6→29 field, 6→25 flow entry points)cuda-impl#30, #31 (closed #29)
6Dispatch: macro pyramid → teeny's dispatch_valuescpu-lib#70, cuda-lib#39 (closed cpu-lib#69)

regularisers/{field,flow}/{1,2,3}d.h — 8,550 lines of hand-expanded per-D stencils, the source of at least six shipped bugs before this effort started — is gone, replaced by stap.h + regularisers/stencil.h + field/nd.h + flow/nd.h (~1,500 lines combined, one engine generic in D), a teeny-idiomatic impl layer, and a single shared dispatch header. Every phase was implemented by an Opus agent and independently re-verified by an adversarial Fable review before merge — nothing landed on the strength of the implementer's own claims alone.

Decisions this effort settled (see full history in this issue's edit log / linked PRs for the measurements behind each)

  1. diag_* computes the exact matrix diagonal, not an approximate preconditioner diagonal.
  2. Self-adjointness boundary rejection is measured, never argued, per-mechanism: bound::supports_reach(b, reach) for absolute/membrane/bending (both engines — flow's table happened to match field's, confirmed by independent measurement, not inherited by assumption), and bound::supports_lame/supports_lame_bending for Lamé's structurally different cross-channel block. Both static_assert-backed in bounds.h so the code can't drift from the measured table.
  3. Coloured relax's visit order within a colour is a non-issue (independence guarantees it), proven by exhaustive partition-equivalence testing — but the effort surfaced that the colouring's own precondition (same-colour voxels share no stencil neighbourhood) can be false under a periodic boundary with an incompatible axis length, a genuine pre-existing data race (kernels#66), preserved unchanged by both the CPU and CUDA relax ports since fixing it is a separate, deliberate design decision.

Bugs found along the way, tracked separately (none blocked any phase; several predate this whole effort)

Deliberately left open, not part of this umbrella's scope

  • fastfields-cuda-lib dispatch wiring for phase 5's new 54-entry cuda-impl surface (only the pre-existing 6 matvec/diag entries are exported and dispatch-migrated; kernel_*/relax_*/RLS/JRLS/Lamé/all are implemented and nvcc-verified at the cuda-impl header layer but not yet wired through cuda-lib's ABI or given the Decision 2 boundary-rejection check).
  • The bugs listed above under "found along the way" — each is its own tracked issue, to be picked up independently.

Thank you for the close engagement on the friction points throughout — particularly catching that the relax colouring's correctness precondition, not just its visit order, needed scrutiny (kernels#66), and the repeated insistence on independent re-measurement over trusting a prior analysis. Both materially changed what shipped.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions