Are partition functions and guides interchangeable?

I think the question says it all, but it may also be completely ill-posed. :sweat_smile:

Essentially, I have a model (L0) which uniformly samples locations over a map. I then have a higher-order model (S1) which builds an EmpiricalMarginal over L0, then samples from it.

The model S1 should do the equivalent of pyro.factor(“S1/L0/lily”, 0. if dist(ref_lily, L0_lily) < epsilon else -99_999.). However, I’ve been noticed that this particular step makes evaluating the model painfully slow (e.g. can’t vectorize), and in other PPL circles I’ve asked around they point at this being a “partition function”.

I’ve tried using a guide to do this evaluation, but haven’t been able to get sensible results. (I can post an MRE soon.)