fix(fourier): no Python control flow on traced Fourier parameters
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Read fourier/operators.py, fourier/eigenvalues.py, fourier/grid.py, and fourier/solvers.py at the listed validation and shortcut sites, then inspect pull request #157, which is already open against this issue. The work spans traced-value handling across Fourier operators, eigenvalues, grids, and solvers. Done means the listed JIT, vmap, grad, and spectral solve cases work, with concrete invalid values raising ValueError and traced invalid values raising at runtime.
Written by the indexing model from the issue text.
Description
Part of epic #148. The Fourier-family part of #103. No dependencies.
Problem
Learnable coefficients and parameter sweeps cannot get through these checks:
jax.jit(lambda nu: d.hyperviscosity(u, nu, 2))(1e-3) # TracerBoolConversionError
| site | check |
|---|---|
fourier/operators.py::_validate_hyperviscosity (1-D / 2-D / 3-D hyperviscosity) |
if nu < 0, if order < 1 |
fourier/eigenvalues.py::_validate_L (every *_eigenvalues_ps, so every approximation="spectral" solve with traced dx) |
if L <= 0 |
fourier/grid.py check_consistency / from_L_dx |
if jnp.isclose(...) |
fourier/solvers.py::modify_rhs_1d |
if left_val == 0.0 and right_val == 0.0 |
Proposal
As #103 proposes:
- Numeric ranges. Use
eqx.error_if(x, nu < 0, …)on a traced value, and keep theValueErrorfor a concrete one.orderis an exponent, so it stays a validated Python int. - Grid checks. Use
math.iscloseon Python floats, and skip the check for tracers. modify_rhs_1d. Skip the shortcut when the values are traced.
Spherical and Chebyshev sites stay with #103.
Acceptance criteria
-
jit/vmap/gradovernuforhyperviscosity(1-D, 2-D, 3-D) equal eager to 1e-12. -
jax.jit(solve_helmholtz_dst, static_argnames="approximation")with traceddxandapproximation="spectral"works. - Concrete invalid values still raise
ValueError; traced invalid values raise at run time.
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