Skip to content

Switch default optimizer to CG with multi-start#1284

Open
Marius1311 wants to merge 2 commits intomainfrom
feat/cg-optimizer-default
Open

Switch default optimizer to CG with multi-start#1284
Marius1311 wants to merge 2 commits intomainfrom
feat/cg-optimizer-default

Conversation

@Marius1311
Copy link
Collaborator

Summary

Switch the default GPCCA rotation optimizer from Nelder-Mead to conjugate gradient (CG) with 10 random restarts. This makes compute_macrostates() scale to large numbers of macrostates (m > 15) where Nelder-Mead becomes impractical.

Changes

  • Default optimizer: "Nelder-Mead""CG"
  • Default n_starts: 110 (with perturbation_scale=0.1)
  • New parameters on compute_macrostates(): n_starts, perturbation_scale, seed — these were already supported by pyGPCCA but not exposed in CellRank
  • fit() method: Now forwards optimizer parameters to compute_macrostates() (previously always used hardcoded defaults)
  • .gitignore: Added uv.lock and .github/prompts/

Benchmark results

Validated on pancreas (2,531 cells) and bone marrow (5,780 cells) datasets:

m NM 1× crispness (time) CG 10×0.1 crispness (time)
5 0.513 (0.1s) 0.477 (0.2s)
10 0.234 (1.6s) 0.243 (0.4s)
15 0.123 (13.7s) 0.221 (2.2s)
50 infeasible 0.063 (30.0s)
  • CG 10×0.1 matches or beats NM on crispness at m ≥ 8
  • High membership agreement: mean Pearson r ≥ 0.94, Jaccard ≥ 0.70
  • All CG solutions are non-degenerate (no empty clusters)
  • Extrapolated: CG 10×0.1 at m=50, n=1M ≈ 3.3 hrs (NM infeasible)

Dependencies

Requires pyGPCCA from msmdev/pyGPCCA branch feature/gradient-optimization which implements the analytical Jacobian and multi-start SO(k) rotation perturbation.

Allow users to choose the optimization method for the GPCCA rotation
matrix via the new 'optimizer' parameter. Valid options: 'Nelder-Mead'
(default), 'L-BFGS-B', 'BFGS', 'CG'. Warns when using Nelder-Mead
with n_states > 15 as it scales poorly.
- Change default optimizer from Nelder-Mead to CG (conjugate gradient)
- Change default n_starts from 1 to 10 with perturbation_scale=0.1
- Add n_starts, perturbation_scale, seed parameters to compute_macrostates
- Forward optimizer parameters from fit() to compute_macrostates()
- Update docstrings with factual complexity descriptions
- Add .gitignore entries for uv.lock and .github/prompts/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant