pymc.step_methods.Metropolis.fork#
- Metropolis.fork(rng)#
Return an independent copy of this step for a new chain/thread.
Gives the copy its own
self.sharedvariables and its own storage for every compiled pytensor function it holds (viaFunction.copy(swap=...), so the compiled code is shared but not the mutable containers). Mutable tuning/adaptation state is cloned independently through thesampling_stateround-trip.The copy is not seeded from
rnghere:_iter_samplecallsset_rngon every chain’s step in all sampling modes, andset_rngadvances the passed generator (viaspawn). Seeding here as well would consume the chain’s shared RNG twice and desynchronize threaded chains from the sequential/multiprocessing results.A subclass whose extra per-chain state is not captured by
self.shared, a compiledFunctionattribute, orsampling_statemust override or re-disablefork(raiseNotImplementedError) so threaded sampling falls back to multiprocessing.