Skip to content

Add fast trap_burden mode with lightweight bulk/original-basis computation#371

Open
charlesmartin14 wants to merge 3 commits intomasterfrom
codex/investigate-pr370-workflow-performance-issues
Open

Add fast trap_burden mode with lightweight bulk/original-basis computation#371
charlesmartin14 wants to merge 3 commits intomasterfrom
codex/investigate-pr370-workflow-performance-issues

Conversation

@charlesmartin14
Copy link
Copy Markdown
Member

Motivation

  • Provide a lightweight "fast" mode for trap burden analysis optimized for ablation/sweep scenarios to avoid expensive original-basis diagnostics and full bulk reconstruction loops.
  • Avoid redundant SVD work by allowing reuse of a precomputed SVD when identifying and analyzing trap modes.
  • Make trap analysis behavior configurable so callers can choose between full diagnostics and a faster approximate path.

Description

  • Added a trap_burden_mode argument (default "full") and flags compute_original_basis, compute_full_bulk_reference, bulk_mode_sample, and compute_original_trap_svd to analyze_traps interfaces in both weightwatcher.analyze_traps and trap_analysis.analyze_traps and wired defaults so "fast" disables expensive work.
  • Changed remove_traps.identify_trap_mode_indices to accept optional svals to avoid recomputing the SVD when available.
  • Added compute_fast_bulk_trap_reference_metrics which computes bulk-mode statistics from precomputed U,S,Vh (with optional sampling) to replace full bulk reconstruction in fast mode.
  • Modified apply_analyze_traps to optionally skip compute_original_basis_for_traps, precompute the permuted SVD once, call identify_trap_mode_indices with svals, and conditionally call the fast or full bulk metric functions.
  • Enhanced analyze_single_trap to accept a precomputed_svd and a compute_original_trap_svd toggle so the method can avoid extra SVDs and fall back to permuted-mode-derived metrics when the original basis is not computed.
  • When the original basis is unavailable, fallback computations for overlap statistics use the permuted singular values to populate ov_* fields and several new output columns were added: B_absDelta_ipr_ovlamvar, B_absDelta_logtop5_ovlamvar, B_evalsq_logtop5_ovrank, and B_old_pr359_paper.
  • Updated tests in tests/test_analyze_traps.py to assert that fast mode skips the original-basis and full bulk-reference computations and that full mode still provides full diagnostics.

Testing

  • Ran the trap analysis unit tests with pytest tests/test_analyze_traps.py including the new tests test_analyze_traps_fast_mode_skips_original_basis, test_analyze_traps_fast_mode_skips_full_bulk_reference, and test_analyze_traps_full_mode_allows_full_diagnostics and the suite completed successfully.
  • Existing trap-analysis related tests in tests/test_analyze_traps.py were executed and passed.

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant