mbi.marginal_oracles.bulk_variable_elimination

mbi.marginal_oracles.bulk_variable_elimination(potentials: CliqueVector, marginal_queries: list[tuple[str, ...]], total: float = 1.0, mesh: Mesh | None = None) CliqueVector[source]

Compute the marginals of the graphical model with the given potentials.

Unlike other marginal oracles, which only compute marginals for cliques in the potentials vector, this function can compute arbitrary marginals from an arbitrary model. Both runtime and compilation time can be expensive when there are a large number of marginal queries. This function compiles and runs variable_elimination for one query at a time, using parallelism and asyncronous computation do do the compilation in the background, while running variable_eliminatoin sequentially one query at a time.

Parameters:
  • potentials – The (log-space) potentials of a Graphical Model.

  • marginal_queries – A list of cliques to obtain marginals for.

  • total – The normalization factor.

  • mesh – The mesh over which the computation should be sharded.

Returns:

A CliqueVector with the marginals computed over the specified cliques.