Probabilistic Effects. λθ

Benchmark Log

PMMH Inference on HMM

This details the benchmarks for a program using monad-bayes to run PMMH inference on a HMM, whilst tactically adding various {-# INLINE #-} pragmas to functions of the monad-bayes library in response to analysing the Haskell core generated. Each benchmark is the average over 4 iterations.

Source Program

main = defaultMain [
  bgroup "runPmmh" [ bench "(100, 100, 100)"  $ whnfIO $ runPmmh (100, 100, 100)
                   ]
  ]

runPmmh :: (Int, Int, Int) -> IO ()
runPmmh (n_mhsteps, n_timesteps, n_particles) = do
  particleWeightings <- inferModel n_mhsteps n_timesteps n_particles
  print particleWeightings
  • Original Code

  • Inline pragma added to pmmh function

  • Inline pragma added to pushEvidence function

  • Inline pragma added to hoist function

  • Inline pragma added to mhTrans functions

  • Inline pragma added to Traced.Static >>= of the Traced monad

  • Inlines to prior, extractWeight, flatten & applyWeight of Bayes.Weighted.

  • Added inlines to resampleGeneric, resampleSystematic, runWeighted, sir.

  • Locally cloned Control.Monad.Coroutine module and inlined the definition of >>.

  • Adding an INLINABLE pragma to >>= of the Control.Monad.Coroutine module.

  • Added bang-patterns to Params datatype of PmmhHmm.hs. Added INLINABLE to await of Control.Monad.Coroutine.SuspensionFunctors. Unpacked and added bang-patterns to all possible parameters of the Trace datatype of Bayes.Traced.Common.

  • INLINABLE pragmas were added to runPopulation, explicitPopulation, extractEvidence, proper, evidence, and collapse of Bayes.Population.

    Also, the arguments of the Traced datatype from Bayes.Traced.Static were made strict. This made things slower (so these changes were undone.)

  • Implemented and integrated CPS version of StateT monad.

Last updated on 13 Nov 2020
Published on 13 Nov 2020