What is a non-auxiliary variable and how can I correctly address this warning?

I’m receiving the following warning:

UserWarning: Found non-auxiliary vars in guide but not model, consider marking these infer={'is_auxiliary': True}:
  guide_vars - aux_vars - model_vars))

I tried looking for documentation or other posts to explain what an auxiliary variable is and how to properly address this error but came up short. Can someone please explain or point me towards the documentation I couldn’t find?

Those are random latent variables in guide that is not available in model. Auxiliary variables (which is created by pyro.sample(name, dist, infer={'is_auxiliary': True}) are used internally in some special cases, which you might be not interested in. I would suggest to covert this latent variable in your guide to a parameter instead. Here is an example that will lead to that issue

def model(x, y):
    a = pyro.sample("a", dist.Normal(0, 1))
    pyro.sample("y", dist.Normal(a * x, 1), obs=y)
def guide(x, y):
    a_mean = pyro.sample("a_mean", dist.Normal(0, 1))
    a = pyro.sample("a", dist.Normal(a_mean, 1))

Here a_mean does not appear in model, which leads to the warning. You can fix it by declaring a_mean = pyro.param("a_mean", torch.tensor(0.)) e.g.