Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enh] speed up sampling with emcee #344

Closed
MuellerSeb opened this issue Apr 8, 2024 · 0 comments · Fixed by #346
Closed

[Enh] speed up sampling with emcee #344

MuellerSeb opened this issue Apr 8, 2024 · 0 comments · Fixed by #346
Assignees
Labels
enhancement New feature or request Performance Performance related stuff.
Milestone

Comments

@MuellerSeb
Copy link
Member

MuellerSeb commented Apr 8, 2024

The EnsembleSampler of emcee has an option vectorize, to state, that the log probability function accepts vectors: https://emcee.readthedocs.io/en/v3.1.4/user/sampler/?highlight=vectorize

Since this is the case for our implementations in the covariance model class, we should use it.

I could speed up the setup of a SRF class by factor 5 to 6:

import timeit
import gstools as gs
m = gs.Matern(dim=3)
%timeit gs.SRF(m)
  • currently:
    1.23 s ± 89.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
    
  • with vectorize=True
    231 ms ± 13 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
    

For models without an analytical spectral density, this is significant:

import timeit
import gstools as gs
m = gs.Stable(dim=3)
%timeit gs.SRF(m)
  • currently:
    3.62 s ± 42.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
    
  • with vectorize=True
    449 ms ± 13.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
    
@MuellerSeb MuellerSeb added enhancement New feature or request Performance Performance related stuff. labels Apr 8, 2024
@MuellerSeb MuellerSeb added this to the 1.5.2 milestone Apr 8, 2024
@MuellerSeb MuellerSeb self-assigned this Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Performance Performance related stuff.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant