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 theTraced
monad
- Inlines to
prior
,extractWeight
,flatten
&applyWeight
ofBayes.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 theControl.Monad.Coroutine
module.
- Added bang-patterns to
Params
datatype ofPmmhHmm.hs
. AddedINLINABLE
toawait
ofControl.Monad.Coroutine.SuspensionFunctors
. Unpacked and added bang-patterns to all possible parameters of theTrace
datatype ofBayes.Traced.Common
.
-
INLINABLE
pragmas were added torunPopulation
,explicitPopulation
,extractEvidence
,proper
,evidence
, andcollapse
ofBayes.Population
.Also, the arguments of the
Traced
datatype fromBayes.Traced.Static
were made strict. This made things slower (so these changes were undone.)
- Implemented and integrated CPS version of
StateT
monad.