Skip to content

Reduce test time #69

Description

@ohno

Summary

The test suite is dominated by first-call compilation rather than steady-state numerical work. The largest bottleneck is the nested three-dimensional quadgk calculation in test/Basis.jl.

CI timings

These timings come from the same PR #56 CI run:

Test Julia 1.10 Share Julia 1.12 Share
Basis.jl 76.6 s 42.0% 595.9 s 80.5%
VNN.jl 34.2 s 18.8% 39.7 s 5.4%
QTT.jl 30.9 s 17.0% 45.8 s 6.2%
Rayleigh-Ritz.jl 12.7 s 7.0% 20.5 s 2.8%
GEM.jl 7.9 s 4.3% 14.1 s 1.9%
Total 182.2 s 740.7 s

Basis.jl is 7.8 times slower on Julia 1.12 and accounts for about 80% of that job's test time.

Detailed measurements

The current Fourier-transform test evaluates

4 basis functions × 3 momenta × 2 polar angles × 2 azimuthal angles
= 48 nested three-dimensional adaptive integrals

On Julia 1.10:

  • complete Basis.jl: 76.18 s and 22.29 GB allocated
  • first (a, k) group: 76.24 s and 22.13 GB allocated
  • all remaining groups combined: about 0.84 s

This concentration in the first call identifies specialization of the nested quadgk closures as the dominant cost.

The other compile-heavy tests show the same first-call pattern:

Operation First call Repeated call
QTT solve 24.44 s, 2.32 GB 0.168 s
VNN solve 20.38 s, 2.20 GB 0.0007 s

The 100-iteration VNN training calculation takes 1.19 s after compilation.

Proposed change

For a spherical Gaussian, reduce the Fourier transform analytically to one radial integral,

$$(2\pi)^{-3/2}\int e^{i\boldsymbol{k}\cdot\boldsymbol{r}}\phi(r)\,d^3r = \sqrt{\frac{2}{\pi}}\int_0^\infty r^2\phi(r)j_0(kr)\,dr.$$

The replacement prototype evaluates 12 one-dimensional integrals using sphericalbesselj(0, k * r):

  • 1.29 s and 172 MB allocated
  • maximum absolute error: 7.9e-6
  • approximately 59 times faster than the current Basis.jl test

Test expikr separately against cis(k * r * cosγ) so that plane-wave geometry remains covered without the nested adaptive integration.

After this change, remeasure QTT and VNN. Their steady-state calculations are already short, so further improvement should target precompilation or parallel CI jobs rather than reducing solver iterations.

Completion criteria

  • Replace the nested three-dimensional Fourier-transform test with the radial spherical-Bessel integral.
  • Add a separate direct test for expikr.
  • Preserve the current numerical coverage and tolerances.
  • Pass the complete suite on Julia 1.10 and Julia 1.12.
  • Record the updated CI timing table.

This issue was drafted with assistance from Codex using GPT-5.6 Sol with High reasoning effort.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions