⚡ Bolt: Vectorize lattice fourier transform#75
Conversation
Co-authored-by: makskliczkowski <48489493+makskliczkowski@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Refactored the$P^T G P^*$ where the vector $P_i = \exp(i k \cdot r_i)$ , moving the workload entirely into optimized C/BLAS routines via NumPy.$N=200$ from ~130ms to ~0.5ms (a roughly 250x speedup), avoiding heavy Python loop overhead. Memory allocation is slightly improved by doing fewer per-element allocations.$N=200$ ). Verified correctness by running the full project test suite via
fourier_transform_latticefunction inphysics/spectral/greens_function.pyto eliminate a nested Python loop. ReplacedO(N^2)element-wise phase updates with vectorized matrix operations.🎯 Why: The original implementation manually iterated over all pairs of spatial coordinates
r_iandr_j, accumulating the productgreens_function[i, j] * exp(1j * k \cdot (r_i - r_j)). In Python, this type ofO(N^2)iteration is very slow. The same calculation can be expressed as a quadratic form📊 Impact: Reduces execution time for
🔬 Measurement: Verified using a local performance test script (time measured for single invocations against
python3 -m pytest.PR created automatically by Jules for task 14517390459703919699 started by @makskliczkowski