I have had a go at this as I have also implemented Custom step methods before but never tried looking at the statistics of fixed variables. Like you, I am also seeing constant sampled values for fixed step variables. On the other hand if you do
pm.draw(custom_step_var, 1000)
you do get different values for each draw. So, I tried to go into the bowels of pymc starting with a single core. In the single core setup it seems that your drawn samples are recorded inside _iter_sample in mcmc.py right at this point
point, stats = step.step(point)
trace.record(point, stats)
breaking here actually did suggest that the drawn and recorded points are different each time (for the fixed step parameter too). Indeed if you run sample with chains=4, cores=1, then the values you get for your fixed step are not constant.
So this made me think is there something we are doing wrong in initialization of the random number generator that maybe doesn’t work as intended when it is shared across cores or something. The analogous operation in the case of parallelized sampler seems to be also in mcmc.py, _mp_sample
for draw in sampler:
strace = traces[draw.chain]
strace.record(draw.point, draw.stats)
log_warning_stats(draw.stats)
if draw.is_last:
strace.close()
if callback is not None:
callback(trace=strace, draw=draw)
which does indeed always draw constant values for fixed step parameters (if you look at draw.point). Tried to understand this by going into the details of the ParallelSampler which draws the samples. Within here the drawing seems to occur at
draw = ProcessAdapter.recv_draw(self._active)
where draw is tuple whose first element is something called _proc and if you check proc._point it does contain again our constant values for the fixed step variable.
After here things became harder for me to understand but it seems that at least writing of sampled points happens inside _write_point of instance of _Process and when you check here the sampled values for fixed step variables are different! On the other hand when everything is said and done for some reason, draw has only constant values for these parameters. I am completely puzzled.
So for the time being I can only offer single core run as a solution. Maybe some of the devs will have a better idea on this.