Fix sparse CG cache validation (root cause of test flakiness)#45
Merged
Conversation
The sparse CG cache only validated entry count, not content. When the index map ordering changed between code versions, stale caches were silently loaded with misaligned (l1, l2, l) triples, producing wrong output assignments — the root cause of test_sparse_matches_full failures. - Validate full entry_meta content against expected triples on cache load - Revert unnecessary randperm seeding (was masking the real issue) - Restore tight test tolerance (5e-7 atol) now that the root cause is fixed Co-authored-by: Cursor <cursoragent@cursor.com>
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 free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
~/.cache/bispectrum/sparse_cg_lmax*_selective.pt) only checkedlen(entry_meta)on load, not the actual triple content. When_build_selective_index_mapordering changed between code versions, stale caches loaded silently with misaligned(l1, l2, l)→ wrong output assignmentstest_sparse_matches_full_bispectrumfailures — NOT floating-point non-associativity (max diff is ~1.6e-8 in float32, well within 5e-7)torch.randpermseeding and tolerance loosening from Fix flaky sparse parity test and drop cu128 index #44 which were treating symptomsChanges
src/bispectrum/so3_on_s2.py: validateentry_metacontent (not just length) against expected triples; revert randperm seedingtests/test_so3_on_s2.py: restore tight tolerance (atol=5e-7, rtol=1e-5)Test plan
pytest tests/test_so3_on_s2.py— 81 passed, 22 skipped (after clearing stale caches)Made with Cursor