feat(operators): `spectral_out` on `SpectralDerivative2D`
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 54/100
Research direction
Start with SpectralDerivative2D and the existing methods named in the issue, then inspect tests/test_tracing.py and its CASES. Check how each method handles spectral input and transforms before adding the output option. Done means the equivalence checks pass for every method and both input modes, and compiled HLO has the specified transform counts.
Written by the indexing model from the issue text.
Description
Part of epic #148. The 2-D slice of #108 that the pipekit layer needs. No dependencies.
Problem
SpectralDerivative2D already takes Fourier coefficients (spectral=True), but it always returns a physical field. A pipeline that keeps fields in spectral space therefore pays an inverse → forward round trip at every node. The barotropic-vorticity prototype measured 40 transforms per RK4 step, against 20 when the output stays spectral. XLA merges identical transforms, but it does not cancel an inverse → forward pair.
Proposal
Add a keyword spectral_out: bool = False to the 2-D methods:
gradient,divergence,curl,laplacian,biharmonic,hyperviscosity,inverse_laplacian,velocity_from_streamfunction: return the coefficients and skip the inverse transform;jacobian,advection_scalar: return the dealiased coefficients of the product, which is 1 forward transform instead of 1 forward + 1 inverse.
The defaults are unchanged. apply_dealias keeps its current rule (output space = input space).
The N-D grid, the rfft layout and the exposed multipliers stay in #108.
Acceptance criteria
-
transform(op(u, spectral_out=False)) == op(u, spectral_out=True)(allclose), for every method and bothspectral=modes. - Transform counts in compiled HLO, spectral in and spectral out:
- 0 for the linear methods;
- 4 inverse + 1 forward for
jacobian.
- Added to the
tests/test_tracing.pyCASES.
Generated by Claude Code
- 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