Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Aug 20, 2026. It is now read-only.
test(reg): cover the diag_bending/diag_all corner cross-term bug - #89
Merged
Conversation
Regression test for fastfields-kernels#48 / #81: the boundary-corrected diagonal expanded each corner weight as (fx0*fy0 + fx1*fy0 + fx1*fy0 + fx1*fy1), double-counting fx1*fy0 and dropping fx0*fy1. The oracle needs no reference implementation. On a square/cubic domain with the same boundary condition and voxel size on every axis, relabelling two spatial axes maps the operator onto itself, so its diagonal must be invariant under that relabelling: * field, 2D and 3D: diag(x,y,c) == diag(y,x,c) * flow bending-only: diag(x,y,c) == diag(y,x,c) (channels uncoupled) * flow diag_all: diag(x,y,c) == diag(y,x,1-c) (the Lame terms couple the channels, so the axis swap carries a channel swap; shears == div keeps the Lame part symmetric under that simultaneous relabelling) The 3D cases matter on their own: the 3D diagonal carries three independent corner cross-terms (w110/w101/w011) rather than one, so the xy and yz swaps exercise two directly and the third by composition. Each test sweeps the whole domain rather than a single row/column, and runs under Zero, DCT2 and DST2. DCT2 is a deliberate control: it does not flip signs, so it passed even before the fix -- the error only appears where the two axes' one-sided boundary signs differ. Verified to bite. Same tests, same binaries, only the kernels headers differing: kernels test_reg_field test_reg_flow pre-fix 19250 checks / 328 failures 16347 checks / 1696 failures 1df9fd3 19250 checks / 0 failures 16347 checks / 0 failures Check counts are identical in both directions, so the only difference is pass/fail, and every failure is in the new checks -- no pre-existing test changes value. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016AjQcY78NgbagPSbPJRr6Z
Submodule staleness (non-blocking -- fastfields-lib#15)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Regression test for the defect fixed in fastfields-kernels#81 (issue fastfields-kernels#48). Test-only: +230 lines across the two test drivers, no production code touched.
The oracle — no reference implementation needed
The boundary-corrected diagonal expanded each corner weight as
(fx0*fy0 + fx1*fy0 + fx1*fy0 + fx1*fy1), double-countingfx1*fy0and droppingfx0*fy1.On a square/cubic domain with the same boundary condition and voxel size on every axis, relabelling two spatial axes maps the operator onto itself, so its diagonal must be invariant under that relabelling:
diag(x,y,c) == diag(y,x,c)shears == div == 0)diag(x,y,c) == diag(y,x,c)— channels uncoupled, isotropic voxel sizediag_alldiag(x,y,c) == diag(y,x,1-c)— the Lamé terms couple the channels, so the axis swap carries a channel swap;shears == divkeeps the Lamé part symmetric under that simultaneous relabellingThe buggy corner sum is not symmetric under the
fx <-> fyrelabelling wherever the two axes' one-sided boundary signs differ. It cancels exactly where they agree (fx0==fx1andfy0==fy1make both forms4*fx0*fy0) — which is precisely why the pre-existing interior-only diagonal checks never caught it.What this covers beyond the minimum
w110/w101/w011) rather than one; the xy and yz swaps exercise two directly and the third by composition. 9 of the 12 fixed terms live in 3D, so 2D-only coverage would leave most of the fix untested.Verification — it demonstrably bites
Same tests, same build flags, same binaries; the only thing changed between the two runs is the kernels headers:
test_reg_fieldtest_reg_flow1df9fd3(the fix)Check counts are identical in both directions, so the only difference is pass/fail. Every one of the 2024 failures is in the new checks — no pre-existing test changes value:
Discrepancies are large and unambiguous (e.g.
got 17 expected 21,got 32.3 expected 36.3) against a1e-5tolerance — not a marginal-tolerance test.Ordering
This depends on the pin chain already reaching the fix, which it now does on
main:(kernels#81 → cpu-impl#72 → cpu-lib#88, all merged.)
Provenance
An equivalent 2D-only test exists on the
teenybranch in8afcab4.fastfields-cpu-lib#53was an attempt to port it tomain, but it was filed from theclaude-fastfields-to-teenyworkstream, whose PRs must always targetteeny— so it was mis-filed, not wrong. Its oracle is sound and was useful prior art; credit to it. This PR lands equivalent (and broader — 3D, whole-domain, multi-bound) coverage onmainproperly, re-derived and re-verified from scratch.🤖 Generated with Claude Code
https://claude.ai/code/session_016AjQcY78NgbagPSbPJRr6Z
Generated by Claude Code