Skip to content

Feature/multiprocess caching#37

Open
astro-koko wants to merge 3 commits intoZeusCosmo:mainfrom
astro-koko:feature/multiprocess-caching
Open

Feature/multiprocess caching#37
astro-koko wants to merge 3 commits intoZeusCosmo:mainfrom
astro-koko:feature/multiprocess-caching

Conversation

@astro-koko
Copy link
Copy Markdown

multiprocess-caching

clxu and others added 3 commits April 15, 2026 15:46
NumPy 2.0 removed the deprecated np.trapz alias in favor of np.trapezoid.
This commit updates all occurrences across the codebase:
- tests/test_inputs.py
- zeus21/cosmology.py
- zeus21/correlations.py
- zeus21/sfrd.py
- zeus21/UVLFs.py
- zeus21/xrays.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Because CLASS stores state in C globals, fork()-based multiprocessing
can corrupt it. This commit adds a process-level cache keyed by
cosmological parameters and os.getpid(), so each spawned worker
only initializes CLASS once. Subsequent calls reuse the cached object,
giving a large speedup for Monte Carlo and inference workloads.

Also included:
- examples/benchmark_multiprocess.py: runnable before/after benchmark
- README updates with multiprocessing guidance

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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