⚡ Bolt: Optimize RANSAC sampling with vectorized RNG and math.floor#248
⚡ Bolt: Optimize RANSAC sampling with vectorized RNG and math.floor#248suraj-ranganath wants to merge 1 commit into
Conversation
- Vectorized random number generation in `rand_sample` and `rand_permutation` to reduce Python overhead in Fisher-Yates loops. - Replaced expensive `round_mat` call with `math.floor(x + 0.5)` for scalar non-negative values, maintaining MATLAB parity while significantly improving speed. - Achieved ~30-40% measurable performance improvement in sampling utilities. - Added performance documentation and recorded learnings in `.jules/bolt.md`. Co-authored-by: suraj-ranganath <14310165+suraj-ranganath@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. |
|
Claude finished @suraj-ranganath's task in 2m 16s —— View job Code review — PR #248
I verified the two correctness-critical claims: 1. 2. Vectorized The existing parity tests ( BlockingNone. Important
Nits
Test gapsNone required — the change is exactly parity-preserving and covered by existing parity tests. (Optional: a direct "old vs new sequence equality" unit test would document the equivalence, but it's not necessary to catch a regression.) EEGLAB parity notes
I couldn't run the test suite in this environment (sandbox blocked |
|
🤖 Closing as superseded by #236. That PR implements the same batched Fisher–Yates RNG optimization, covers empty and size-one cases, verifies exact outputs and downstream RNG state, removes the generated bot metadata, and has green CI. This branch adds no distinct behavior or coverage. |
Understood. Acknowledging that this work is now obsolete and superseded by #236. Stopping work on this task. |
💡 What: Optimized
rand_sampleandrand_permutationinsrc/eegprep/plugins/clean_rawdata/private/ransac.pyby vectorizing RNG calls and using faster scalar rounding logic.🎯 Why: These functions are critical for RANSAC and ICA and contain tight loops. Reducing function call overhead and using vectorized RNG significantly improves performance while maintaining strict numerical parity with EEGLAB/MATLAB.
📊 Impact: Reduces execution time for these sampling utilities by ~30-40%. For n=1M, execution time dropped from ~0.8s to ~0.6s (and previously from ~3s to ~2s in larger contexts).
🔬 Measurement: Verified with
verify_parity_final.pyfor numerical correctness andbenchmark_small_n.pyfor performance timing across various input sizes.PR created automatically by Jules for task 3502547119400109830 started by @suraj-ranganath