JakobRobnik / MicroCanonicalHMC

MCHMC: sampler from an arbitrary differentiable distribution
GNU General Public License v3.0
70 stars 9 forks source link

Speed benchmarking/profiling #13

Closed reubenharry closed 1 year ago

reubenharry commented 1 year ago

It might also be useful to have a speed benchmark, so that it's clear whether a change slows or speeds up the code. For example, replacing uu/jnp.sqrt(jnp.sum(jnp.square(uu))) with uu/jnp.linalg.norm(uu) seems innocent, but may slow down code (https://stackoverflow.com/questions/64948677/why-is-np-linalg-norm-axis-1-slower-than-writing-out-the-formula-for-vecto), and this sort of thing would be good to catch automatically. Probably just running the sampler on a multivariate gaussian is fine, since we're interested here in computational efficiency, not statistical.

The usual way this works, for pure deterministic functions (which this is, thanks to Jax) is that you run the program some large number of times, and extract statistics about mean speed and variance. There are various Python libraries that do this for you.

JakobRobnik commented 1 year ago

Sure, this seems a good idea!

On Tue, Sep 5, 2023 at 8:06 AM Reuben @.***> wrote:

It might also be useful to have a speed benchmark, so that it's clear whether a change slows or speeds up the code. For example, replacing uu/jnp.sqrt(jnp.sum(jnp.square(uu))) with uu/jnp.linalg.norm(uu) seems innocent, but may slow down code ( https://stackoverflow.com/questions/64948677/why-is-np-linalg-norm-axis-1-slower-than-writing-out-the-formula-for-vecto), and this sort of thing would be good to catch automatically. Probably just running the sampler on a multivariate gaussian is fine, since we're interested here in computational efficiency, not statistical.

The usual way this works, for pure deterministic functions (which this is, thanks to Jax) is that you run the program some large number of times, and extract statistics about mean speed and variance. There are various Python libraries that do this for you.

— Reply to this email directly, view it on GitHub https://github.com/JakobRobnik/MicroCanonicalHMC/issues/13, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKIPD4ETHAEJ653BMWOBFWLXY26QFANCNFSM6AAAAAA4LHOYMM . You are receiving this because you are subscribed to this thread.Message ID: @.***>