Skip to content

⚡ Bolt: Vectorize lattice fourier transform#75

Open
makskliczkowski wants to merge 1 commit into
mainfrom
bolt-ft-vectorize-14517390459703919699
Open

⚡ Bolt: Vectorize lattice fourier transform#75
makskliczkowski wants to merge 1 commit into
mainfrom
bolt-ft-vectorize-14517390459703919699

Conversation

@makskliczkowski

Copy link
Copy Markdown
Owner

💡 What: Refactored the fourier_transform_lattice function in physics/spectral/greens_function.py to eliminate a nested Python loop. Replaced O(N^2) element-wise phase updates with vectorized matrix operations.
🎯 Why: The original implementation manually iterated over all pairs of spatial coordinates r_i and r_j, accumulating the product greens_function[i, j] * exp(1j * k \cdot (r_i - r_j)). In Python, this type of O(N^2) iteration is very slow. The same calculation can be expressed as a quadratic form $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.
📊 Impact: Reduces execution time for $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.
🔬 Measurement: Verified using a local performance test script (time measured for single invocations against $N=200$). Verified correctness by running the full project test suite via python3 -m pytest.


PR created automatically by Jules for task 14517390459703919699 started by @makskliczkowski

Co-authored-by: makskliczkowski <48489493+makskliczkowski@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant