Pm.sample result does not work with az.plot_trace or other az functions

I would try to modify your model until you figure out what’s going on. Here’s the simplified version that I ran:

import pymc as pm

with pm.Model() as model:
    
    a = pm.TruncatedNormal('a', mu=1/50, sigma=1, lower=1/1000, upper=1, initval=1/50)
    b = pm.Normal('b', 0, 10, initval=0)
    c = pm.Normal('c', 0, 10, initval=0)
    ϵ  = pm.HalfCauchy('ϵ', 100, initval=1)
    #mu = fn(a, b, c, x)
    #pm.Potential("negative_penalty", pm.math.switch(mu<0, -np.inf, 0))
    mu = 1
    
    y_pred = pm.Gamma('y_pred', mu=mu, sigma=ϵ, observed=[1,2,3])

    idata = pm.sample()