⚡ Bolt: optimize Fisher-Yates shuffle with vectorized rand and math.floor#257
⚡ Bolt: optimize Fisher-Yates shuffle with vectorized rand and math.floor#257suraj-ranganath wants to merge 1 commit into
Conversation
- Vectorize random number generation using stream.rand(n) - Use math.floor(x + 0.5) for faster scalar rounding - Maintain EEGLAB/MATLAB parity - Achieve ~40-45% speedup in rand_sample and rand_permutation 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 34s —— View job Code review
I verified that the optimization keeps exact parity with the previous implementation (and therefore EEGLAB/MATLAB), by comparing old vs. new outputs and post-call RNG state across seeds Why parity holds:
BlockingNone. ImportantNone. Nits
Test gapsNone required. The change is parity-preserving, and EEGLAB parity notesParity with EEGLAB's |
💡 What: Optimized
rand_sampleandrand_permutationinsrc/eegprep/plugins/clean_rawdata/private/ransac.pyby pre-generating random numbers with vectorizedstream.rand(n)and replacing theround_matutility withmath.floor(x + 0.5)for faster scalar rounding in tight loops.🎯 Why: Iterative calls to the random number generator and high-overhead utility functions in tight Python loops create a significant performance bottleneck in RANSAC-related computations.
📊 Impact: Expected performance improvement of ~40-45% for
rand_permutationandrand_samplewhile maintaining exact parity with EEGLAB/MATLAB results.🔬 Measurement: Verified using a custom benchmark script
perf_test_v2.pyand existing parity teststests/test_parity_rng.py. Core cleaning plugin tests (ASR, channel removal) were also verified to pass.PR created automatically by Jules for task 13362875934591169015 started by @suraj-ranganath