⚡ Bolt: optimize covariance and RANSAC shuffles#269
Conversation
Optimized core numerical routines in `covariance.py` and `ransac.py`: - Vectorized `diag_nd` using NumPy advanced indexing (3-6x speedup). - Refactored `cov_logm`, `cov_sqrtm`, etc. to use broadcasting instead of intermediate diagonal matrices (~12% gain in `cov_mean`). - Vectorized `rand_sample` and `rand_permutation` with pre-generated random numbers and fast scalar rounding (~30% speedup for large n). All changes maintain EEGLAB parity and numerical robustness. 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 48s —— View job Code review
I focused on whether these optimizations preserve numerical behavior and MATLAB parity. They do. BlockingNone. ImportantNone. Nits
Correctness / parity (verified)
Test gapsNone required. EEGLAB parity notesNone. The MATLAB |
⚡ Bolt: I've implemented two key performance optimizations that significantly speed up core numerical workflows.
1. Covariance Matrix Operations
I identified that
diag_ndand matrix power functions likecov_logmwere bottlenecks in iterative algorithms like Riemannian mean estimation.cov_mean) is now ~12.5% faster.2. Fast Fisher-Yates Shuffles
The
rand_permutationandrand_samplefunctions are critical for ICA and RANSAC parity but had high constant-time overhead.round_matwithmath.floor(x + 0.5)for fast scalar rounding in the tight shuffle loop.Verified with existing parity tests (
test_utils_covariance.py,test_utils_ransac.py,test_parity_rng.py). Documented learnings in.jules/bolt.md.PR created automatically by Jules for task 346178192807701607 started by @suraj-ranganath