-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Background
In typical KRMHD time-stepping, the Poisson bracket is called repeatedly with the same field pairs (e.g., {φ, A∥} computed at each RK4 substep). Currently, each call recomputes:
- Four derivative transforms (∂f/∂x, ∂f/∂y, ∂g/∂x, ∂g/∂y)
- Four inverse FFTs
- One forward FFT
- Dealiasing
Potential Optimizations
- Cache derivatives: If f or g unchanged, reuse ∂f/∂x, ∂f/∂y
- Batch operations: Compute multiple brackets in parallel (vmap)
- Lazy evaluation: Use SpectralField2D/3D lazy caching for derivatives
- JIT compilation: Ensure XLA optimizes repeated calls
Investigation Needed
- Profile typical time-stepping workload (RK4 with 3-4 fields)
- Measure cache hit rate if derivatives were cached
- Benchmark batch bracket evaluation vs sequential
- Check if JAX XLA already optimizes this pattern
- Estimate memory overhead of caching derivatives
Decision Criteria
Only implement if:
- Profiling shows bracket is >50% of runtime (expected)
- Cache provides >20% speedup
- Memory overhead acceptable (<2x current usage)
Related
- Issue Step 4: Poisson Bracket #4 (Poisson bracket implementation)
- Issue Step 8: Time Integrator #8 (Time integration - RK4)
- Issue Add performance benchmark for Poisson bracket #35 (Performance benchmarks)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request