feat(pipekit): `spectraldiffx.pipekit` scaffolding — `Spectral` carrier, transforms, `GridSpec`, contract test
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by reading the pipekit E1.2 JaxOperator contract and the implementation around Graph.describe() and JSON state round trips. Then implement the proposed spectraldiffx/pipekit/ modules and use testing.py to check transforms, pytree behavior, and operator contracts. The issue is done when the listed acceptance criteria pass, including the optional dependency error.
Written by the indexing model from the issue text.
Description
Part of epic #148. Depends on: pipekit E1.2 (pipekit_jax.JaxOperator). Not blocked by #108.
Proposal
spectraldiffx/
pipekit/
__init__.py
_src/
carrier.py # Spectral, as_hat, emit
base.py # SpectralOperator, GridSpec, build_grid
transforms.py # ToSpectral, ToPhysical
derivatives.py # #152 (E4.2)
solvers.py # #153 (E4.3)
diagnostics.py # #154 (E4.4)
testing.py # check_operator, count_transforms
class Spectral(eqx.Module):
"""Fourier coefficients of a real field. hat: complex[..., Ny, Nx(/2+1)]"""
hat: Array
real: bool = eqx.field(static=True, default=False) # True → rfft layout (#108)
# linear algebra on the carrier, so LinComb / RK stages work unchanged
def __add__(self, o): return Spectral(self.hat + o.hat, self.real)
def __sub__(self, o): return Spectral(self.hat - o.hat, self.real)
def __mul__(self, c): return Spectral(c * self.hat, self.real) # scalar only
__rmul__ = __mul__
def __neg__(self): return Spectral(-self.hat, self.real)
GridSpec = tuple # (Nx, Ny, Lx, Ly, dealias) — JSON primitives
class SpectralOperator(JaxOperator):
grid: GridSpec = eqx.field(static=True)
out: Literal["physical", "spectral"] = eqx.field(static=True, default="physical")
Carrier helpers, the single place representation is decided:
def as_hat(x, grid): # Array → transform; Spectral → as is
def emit(hat, grid, out, real): # out="spectral" → Spectral; else inverse (.real)
ToSpectral(grid): real [..., Ny, Nx] → Spectral. ToPhysical(grid): Spectral → real. Both are explicit graph nodes, so where the transforms happen is visible in Graph.describe().
testing.count_transforms(fn, *args) -> dict[str, int] counts fft_type=FFT|IFFT|RFFT|IRFFT in jax.jit(fn).lower(*args).compile().as_text(). check_operator(op, *inputs, budget=None) asserts:
- JSON
stateround-trip; - eager ≡ jit;
- leading-axis broadcast on
[2, …]stacks; - grad finite;
- if
budgetis given,count_transformsequals it.
Acceptance criteria
-
Spectralis a pytree.jax.tree.map,vmapandlax.scancarries all work, andrealsurvives round trips as static metadata. -
ToPhysical(ToSpectral(x)) == x(allclose) for random real fields, for both layouts once #108 adds rfft. - Budgets:
ToSpectral1 forward,ToPhysical1 inverse,ToPhysical ∘ ToSpectralexactly 2 (no silent extra transforms). -
import spectraldiffx.pipekitwithout pipekit raises anImportErrornaming the extra.
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