Skip to content

Decouple SpheriCart from Polynomials4ML#123

Merged
cortner merged 3 commits into
mainfrom
decouple-sphericart
Jun 15, 2026
Merged

Decouple SpheriCart from Polynomials4ML#123
cortner merged 3 commits into
mainfrom
decouple-sphericart

Conversation

@cortner

@cortner cortner commented Jun 14, 2026

Copy link
Copy Markdown
Member

Decouples P4ML from SpheriCart. The spherical-harmonics wrapper and the
atomic-orbitals basis (P4ML's only SpheriCart consumer) move out, so P4ML
core no longer depends on SpheriCart at all.

Changes

  • Remove sphericart (src/sphericart.jl deleted; SpheriCart dropped
    from [deps]/[compat]). The harmonics + their evaluate interface now
    live in SpheriCart itself (Complex harmonics + ACEbase evaluate-interface extension lab-cosmo/sphericart#235).
  • natural_indices via ACEbase: import ACEbase: natural_indices
    instead of a local stub, so it is the shared generic
    (Add natural_indices to the shared evaluation interface ACEbase.jl#10). ACEbase compat → 0.4.7.
  • Extract AtomicOrbitals into a new lib/AtomicOrbitals subpackage
    (mirrors EquivariantTensors lib/ACEradials; not a P4ML dependency).
    Its angular Ylm is now a bare SpheriCart basis used purely via the
    ACEbase interface (parameter/state-free, Bumper-stack buffers keep it
    allocation-free). All dead code (commented Lux layers / hyperdual /
    evaluate_ed_dp blocks) dropped in the move.
  • Tests updated/relocated (test_sphericart.jl, test_atorbrad.jl removed
    from core; sphericart cases dropped from test_gpu/test_lux/
    test_transformed).

Breaking (version 0.5.10 → 0.6.0):
Polynomials4ML.real_solidharmonics / real_sphericalharmonics /
complex_* / AtomicOrbitals are gone. Downstream should use SpheriCart

  • ACEbase for harmonics, or lib/AtomicOrbitals for atomic-orbital bases.

Depends on ACEbase ≥ 0.4.7 (#10) and SpheriCart ≥ 0.2.4 (#235);
CI here will only resolve once those are registered.

Verified locally (deps dev'd): P4ML Pkg.test 1303/1303;
lib/AtomicOrbitals Pkg.test 141/141 (zero allocations).

🤖 Generated with Claude Code

Replaces the lib/AtomicOrbitals subpackage: the type and all Ylm-generic
logic live in src/atomicorbitals/, with the SpheriCart-specific glue
(complex value type, _rand_* fixtures) in ext/SpheriCartExt.jl behind a
[weakdeps] SpheriCart. Avoids registering a generically-named package.
@cortner

cortner commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

Update: AtomicOrbitals kept in P4ML via a SpheriCart extension (not a separate lib)

Reconsidered the lib/AtomicOrbitals extraction — a generically-named, registerable AtomicOrbitals.jl implementing only a thin ACE-specific slice would squat a prime general-purpose name. Reverted that part and kept AtomicOrbitals inside P4ML, with the SpheriCart-specific glue in a package extension.

  • AtomicOrbitals + RadialDecay/GaussianDecay/SlaterDecay and all Ylm-generic evaluation/pullback/Lux logic now live in src/atomicorbitals/ and are exported from P4ML again.
  • The only SpheriCart-typed code — the complex _ylm_valtype specialization and the _rand_* fixtures — lives in ext/SpheriCartExt.jl, loaded via [weakdeps] SpheriCart. No hard runtime dep; SpheriCart is a weakdep + test-dep only.
  • AtomicOrbitals is generic over any ACEbase-evaluate Ylm: a real fallback _ylm_valtype keeps the type usable without SpheriCart, and the extension supplies the precise complex value type.
  • lib/AtomicOrbitals/ removed; its test moved to test/test_atorbrad.jl.

This revises the earlier "no [deps]/[weakdeps] on SpheriCart" stance — a weak dependency is now allowed. P4ML still carries no SCWrapper/src/sphericart.jl code.

Pkg.test("Polynomials4ML") is green (1444 tests, incl. the Atomic Orbitals set); SpheriCartExt precompiles and loads.

🤖 Generated with Claude Code

@cortner cortner changed the title Remove SpheriCart; extract AtomicOrbitals to lib/ Decouple SpheriCart from Polynomials4ML Jun 15, 2026
- Restore src/atomicorbitals/atomicorbitals.jl name
- _rand_* builders live in core via a _default_ylm extension hook
- Re-add atomic-orbital cases to test_lux
- Document the import-SpheriCart requirement (docstring + polynomials.md)
- Fix docs build: drop stale @refs, update regression tutorial to SpheriCart
@cortner

cortner commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

Follow-up (review fixes):

  • Restored the source file name src/atomicorbitals/atomicorbitals.jl (the lib had renamed it to aorbasis.jl).
  • Moved the _rand_gaussian_basis/_rand_slater_basis/_rand_sto_basis (and _rand_basis) example builders into P4ML core. The single SpheriCart touchpoint — the default SolidHarmonics angular basis — is routed through a small _default_ylm hook (stub in core, method in ext/SpheriCartExt.jl), so the builders stay in core but still need import SpheriCart.
  • Re-added the three atomic-orbital cases to test/test_lux.jl.
  • Documented the usage: an AtomicOrbitals docstring stating you must import SpheriCart first, plus an entry in docs/src/polynomials.md.
  • Fixed the docs build: dropped stale @refs to removed harmonics functions, de-linked the now-ACEbase-owned natural_indices, and updated the regression tutorial from real_sphericalharmonics to SpheriCart.SphericalHarmonics (added SpheriCart to docs/Project.toml).

Verified: Pkg.test("Polynomials4ML") → 1459/1459 pass; docs/make.jl builds cleanly.

🤖 Generated with Claude Code

@cortner cortner merged commit 1442be5 into main Jun 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant