Epic: Chebyshev Performance Optimizations
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Refactor
- Clarity
- Needs clarification
- Activity status
- Quiet
- Tech stack
- python
- Domain
- performance
Research direction
Start by reviewing the current dense differentiation and Helmholtz solver operations described in the issue, then use sub-issues #62, #64, #65, and #66 to separate the optimization work. Done means implementing and validating the selected performance improvements while preserving the existing mathematical behavior and addressing the stated scaling bottlenecks.
Written by the indexing model from the issue text.
Description
Summary
The current Chebyshev implementation uses dense matrices and dense linear algebra throughout. While mathematically clean and correct, several well-known techniques can dramatically improve performance — especially for the Helmholtz solver (O(N^3) per call) and differentiation (O(N^2) per call).
Sub-Issues
| # | Title | Speedup | Effort | Priority |
|---|---|---|---|---|
| #62 | Pre-factored LU for Helmholtz solver | 2-10x for repeated solves | Small | P0 |
| #64 | FFT-based Chebyshev differentiation | O(N^2) -> O(N log N) | Medium | P1 |
| #65 | Scan-based matrix-vector products for time-stepping | Reduced overhead, XLA fusion | Small | P1 |
| #66 | Ultra-spherical / banded Chebyshev solvers | O(N^3) -> O(N) solves | Large | P2 |
Current Bottlenecks
Differentiation: O(N^2) dense matmul
```python
Current: D @ u where D is (N+1) x (N+1) fully dense
du_dx = D @ u # O(N^2) per derivative
d2u_dx2 = D2 @ u # O(N^2), D2 precomputed
```
Helmholtz solver: O(N^3) dense LU per call
```python
Current: fresh LU decomposition every call
A = D @ D - alpha * I # O(N^3) matmul
u = jnp.linalg.solve(A, b) # O(N^3) LU
```
| N | Matrix size | Dense LU flops | Time @ 1 TFLOP/s |
|---|---|---|---|
| 32 | 33 x 33 | ~72K | 72 ns |
| 64 | 65 x 65 | ~549K | 0.5 us |
| 128 | 129 x 129 | ~4.3M | 4.3 us |
| 256 | 257 x 257 | ~34M | 34 us |
| 512 | 513 x 513 | ~270M | 270 us |
The O(N^3) scaling becomes dominant for N > 128, especially in time-stepping loops where solve() is called thousands of times.
References
- Trefethen, "Spectral Methods in MATLAB" (2000), Chapters 6-8
- Olver & Townsend, "A fast and well-conditioned spectral method" (2013) — ultra-spherical
- Driscoll, Hale & Trefethen, "Chebfun and numerical quadrature" (2014)
- Burns et al., "Dedalus: A flexible framework for numerical simulations with spectral methods" (2020)
Depends On
- #28 (Chebyshev extensions) — these optimizations complement the feature additions
- Dominant language
- Python
- Stars
- 2
- Forks
- 0
- Avg merge
- 8h 13m
- Merged PRs (30d)
- 8
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jejjohnson/spectraldiffx
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
jejjohnson/spectraldiffx#172 ·
-
epic
Difficulty 1/5 Under an hour Newbie friendliness 62/100
jejjohnson/spectraldiffx#167 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
jejjohnson/spectraldiffx#113 ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
jejjohnson/spectraldiffx#105 ·
-
dependencies
Difficulty 4/5 3-5 days Newbie friendliness 45/100
jejjohnson/spectraldiffx#181 ·
All issues in jejjohnson/spectraldiffx
Similar issues
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
freelawproject/litigant-portal#1307 ·
Maintainers usually reply within 2 days
-
type/bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
h2oai/h2o-llmstudio#1163 ·
Maintainers usually reply within 1 day