feat(operators): `spectral_out` on `SpectralDerivative2D`

Aperta
#150 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@jejjohnson ci sta già lavorando.

Dal 17/10/2026.

  • #158 di @jejjohnson — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
54/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
data

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

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 both spectral= 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.py CASES.

Generated by Claude Code

Lingua principale
Python
Stelle
2
Fork
0
Merge medio
8h 13m
PR unite (30g)
8

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di jejjohnson/spectraldiffx

Tutte le issue di jejjohnson/spectraldiffx

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.