Clean up config, CI, correctness, and API surface#48
Open
johmathe wants to merge 2 commits into
Open
Conversation
Tier 1 — config + style:
- Unify ruff line-length to 120 (drop pre-commit override; reformat repo).
- Remove dead nbstripout hook (no .ipynb files in repo).
- Swap archived pre-commit/mirrors-prettier for rbubley/mirrors-prettier.
- Drop lone `from __future__ import annotations` in `_cg.py`.
- Delete orphan `docs/selective_so3_on_s2_completeness.log`.
- Convert all `_index_map` storage to immutable tuples; drop O(N) defensive
copies on every `index_map` property access across all 6 modules.
Tier 2 — wire up the linters:
- Add `typecheck` and `lockfile` jobs to tests.yml.
- Expand test matrix to ubuntu + macos-14.
- Add per-module mypy overrides for register_buffer Tensor|Module false
positives and torch.special's `Any` returns; ignore_missing_imports for
torch_harmonics. Strict everywhere else.
- Fix the 4 real type errors mypy surfaced (no-any-return in `_bessel`,
redef + missing list type arg in `so3_on_s2`, shadowed loop variable
in `dn_on_dn`).
- Track `uv.lock`; CI verifies via `uv lock --check`.
Tier 3 — correctness:
- `SO3onS2._cuda_graph_cache`: cache key is now
`(batch_size, dtype, device, grad_enabled)` and validates
`is_contiguous()` on replay; failed captures use a finite cooldown
(`_CUDA_GRAPH_RETRY_INTERVAL = 256` calls) instead of a permanent
`{'batch_size': -1}` sentinel that disables the path forever.
- `rotate_spherical_function` now emits a UserWarning on fp64 input
about the silent grid_sample fp32 downcast; docstring documents it.
- Replace four silent `except OSError: pass` cache write/read patterns
in `_cg.py` and `so3_on_s2.py` with `logger.warning(...)`.
- Add `BISPECTRUM_CACHE_DIR` env var override for read-only home dirs.
- Add `tests/test_octa_axioms.py` (16 tests) verifying `_ELEMENTS_3x3`,
`_CAYLEY` (matches matmul on all 576 pairs, associative on all 13824
triples, every row/col is a permutation), `_INVERSE` (involutive,
equals transpose), and `_RHO4_SIGNS` (homomorphism). All pass.
- Add 5 new tests for the new cuda graph cache key invalidation and
cooldown behavior.
Tier 4 — honest API:
- Add `supports_inversion: bool` class attribute to all 7 modules
(True except SO3onS2). Programmatic check for the open math problem
noted in the README.
- README: add `Inversion` column to supported-groups table with footnote
about SO(3) on S^2; replace "uniform interface" claim with one that
documents `supports_inversion` and the `selective=True` requirement.
- README: add `Compatibility` section above Installation documenting
Python 3.12 only, torch >= 2.10, CUDA driver, and
`BISPECTRUM_CACHE_DIR` override — currently users hit these as
install-time failures.
Final: 593 passed, 22 skipped (pre-existing CUDA skips). Mypy clean.
Pre-commit clean across all 19 hooks. `uv lock --check` clean.
Out of scope (separate decisions):
- Loosening Python floor / making torch_harmonics optional.
- GPU CI runner.
- Sphinx/mkdocs site.
- Hypothesis property-based tests.
- Benchmarks-on-tag CI.
Co-authored-by: Cursor <cursoragent@cursor.com>
torch-harmonics 0.9 only ships manylinux_x86_64 wheels — no macOS, no
Windows, no Linux ARM. Adding macos-14 to the matrix in the previous
commit was wrong; uv pip install fails at resolve time:
Because torch-harmonics==0.9.0 has no wheels with a matching platform
tag (e.g., `macosx_14_0_arm64`)...
Document the platform constraint in tests.yml (so the next person
doesn't re-add macOS) and in README.md Compatibility section. Will
revisit when torch-harmonics ships broader wheels OR when we move it
to an extras_require.
Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #48 +/- ##
=======================================
Coverage 95.50% 95.50%
=======================================
Files 11 11
Lines 2135 2160 +25
=======================================
+ Hits 2039 2063 +24
- Misses 96 97 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Tiered cleanup pass. Each tier is a self-contained section of the diff and could in principle be split into separate PRs; collected here for reviewer convenience.
Tier 1 — config + style nits
--line-length=99override that was fightingpyproject.toml; reformat the repo).nbstripoutpre-commit hook (no.ipynbfiles in the repo).pre-commit/mirrors-prettierforrbubley/mirrors-prettier@v3.6.2.from __future__ import annotationsin_cg.py(requires-python>=3.12makes it unnecessary).docs/selective_so3_on_s2_completeness.log._index_mapstorage to immutable tuples; drop O(N) defensive copies on everyindex_mapproperty access across all 6 modules.Tier 2 — wire up the linters that already exist
typecheckandlockfilejobs to.github/workflows/tests.yml.ubuntu-latest + macos-14.register_buffer'sTensor | Modulefalse positives andtorch.special'sAnyreturns;ignore_missing_importsfortorch_harmonics(no py.typed marker upstream). Strict everywhere else._bessel, redef + missing list type arg inso3_on_s2, shadowed loop variablekindn_on_dn).uv.lock; CI verifies viauv lock --check.Tier 3 — real correctness gaps
SO3onS2._cuda_graph_cacheis now keyed on(batch_size, dtype, device, grad_enabled)and validatesis_contiguous()on replay. Failed captures use a finite cooldown (_CUDA_GRAPH_RETRY_INTERVAL = 256calls) instead of the permanent{'batch_size': -1}sentinel that disabled the path forever after a single transient error.forward()docstring documents the contract.rotate_spherical_functionnow emits aUserWarningon fp64 input about the silentgrid_samplefp32 downcast; docstring documents the precision contract. Tests updated to either pass fp32 explicitly orpytest.warnsif the fp64 path is the SUT.except OSError: passcache write/read patterns in_cg.pyandso3_on_s2.pywithlogger.warning(...). A read-only~/.cache/bispectrumno longer eats the entire CG recomputation cost on every import without a peep.BISPECTRUM_CACHE_DIRenv var override for read-only home dirs (CI, containers, HPC).tests/test_octa_axioms.py(16 tests) verifies the hardcoded octahedral-group tables:_ELEMENTS_3x3are valid SO(3) matrices,_CAYLEYmatches matrix-mult on all 576 pairs, associative on all 13824 triples, every row/col is a permutation of{0..23},_INVERSEis involutive and equals transpose,_RHO4_SIGNSis a homomorphism. All pass — tables are sound. Catches future single-character transcription typos.Tier 4 — honest API surface
supports_inversion: boolclass attribute to all 7 modules (True exceptSO3onS2). Programmatic check for the open math problem instead of try/except.Inversioncolumn to the supported-groups table with a footnote about SO(3) on S². Replace the "uniform interface" claim with one that documentsModule.supports_inversionand theselective=Truerequirement.Compatibilitysection aboveInstallationdocumenting Python 3.12-only, torch >= 2.10, CUDA driver constraint, andBISPECTRUM_CACHE_DIRoverride. Currently users hit these as install-time failures.Verification
mypy src/bispectrum:Success: no issues found in 11 source files.pre-commit run --all-files: clean across all 19 hooks.uv lock --check: clean.Out of scope (separate decisions)
torch_harmonicsanextras_require. Real refactor — needs design.Test plan
test,typecheck,lockfile,pre-commitjobs.pytest tests/ -n autoagainst this branch.bispectrum, instantiate one module per group, confirmsupports_inversionmatches the README table.Made with Cursor