You shouldn’t be compiling a pytensor function yourself, just use pt.as_tensor([-2, -1, 0, 1, 2, 3]) directly instead of that intermediate dummy new_shifts
...
densities = vectorize_graph(density, replace={shift: pt.as_tensor([-2, -1, 0, 1, 2, 3])})
...
You can probably vectorize a bit further along the lines of
densities = log((densities[3:][::-1] - densities[:3]) * [5/9, 3/9, 1/9])