refactor: cleanup, dedup, and optimize Rust solver#106
Merged
Conversation
Correctness: - Extract clamp_tau_rise() guard and apply in BandedAR2, fixing a case where banded and FFT engines disagreed for tau_rise ≈ tau_decay Deduplication: - fft.rs: extract convolve_impl() shared by forward/adjoint (~85% identical) - banded.rs: collapse update() into *self = Self::new(...) - lib.rs+fista.rs: extract compute_raw_baseline()+update_baseline_ema() - kernel_est.rs: extract adjoint_spikes_kernel() (was in 2 places) - biexp_fit.rs: extract golden_bracket() for 4 near-identical phases Performance: - banded.rs: fuse normalize pass (eliminate O(N) second pass on hot path) - kernel.rs: compute_lipschitz iterates half frequencies + pre-casts kernel - lib.rs: skip banded.update() in FFT mode (~4k trig evals per param change) - kernel_est.rs: hoist z and v_f32 allocations outside loops - baseline.rs: cache MSB in FenwickTree (avoid recompute per kth() call) - filter.rs: extract forward_fft_and_cache_power(); iterator-zip loops - peak_seed.rs: combined median_and_mad() saves 2 allocs + 1 sort per trace - threshold.rs: move s_bin ownership instead of clone; fuse PVE loops Cleanup: - biexp_fit.rs: BiexpResult::sentinel(), has_fast_component(), derive Clone - biexp_fit.rs: fix stale comment (0.2 → 0.15) - threshold.rs: sort_unstable_by with total_cmp - indeca.rs: apply filter directly instead of throwaway 1-iter FISTA - indeca.rs: extract interior_slice() helper - lib.rs: extract state_byte_len() for export/load Tests: 109 pass (3 new filter-path coverage tests for indeca.rs) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
clamp_tau_rise()guard and apply inBandedAR2, fixing a case where banded and FFT engines disagreed fortau_rise ≈ tau_decayfft.rsforward/adjoint,banded.rsnew/update, baseline EMA, kernel_est adjoint, biexp_fit golden-section, indeca interior_sliceindeca::solve_traceFiles changed (14)
kernel.rsclamp_tau_rise(); halvecompute_lipschitzloopbanded.rsupdate(); fuse normalize passfft.rsconvolve_impl()shared by forward/adjointlib.rsfista.rsfilter.rsforward_fft_and_cache_power(); iterator-zipbaseline.rskernel_est.rsadjoint_spikes_kernel()biexp_fit.rsgolden_bracket();sentinel();has_fast_component(); fix commentthreshold.rssort_unstable_by+total_cmp; move s_bin; fuse PVEpeak_seed.rsmedian_and_mad()indeca.rsinterior_slice(); 3 new testsjs_indeca.rspkg/calab_solver_bg.wasmTest plan
cargo fmt --checkpasses🤖 Generated with Claude Code