Page 1 of 1

Specifying manual blocking in cobaya

Posted: March 24 2020
by Alex Krolewski
I have some slow cosmology parameters and some fast bias parameters, and would like to take advantage of blocking to speed up my chains in cobaya. However, I'm having some trouble manually specifying the blocking scheme via the python interface. In the python code I specify the blocking as follows:

info['sampler']['mcmc']['blocks'] = [['logA','Omegam'],['logSN','b1','b2','alpha_cross','alpha_auto','alpha_matter']]
info['sampler']['mcmc']['oversampling_factors'] = [1,100]

which is reflected in the .updated.yaml file:

blocking: null
blocks:
- - logA
- Omegam
- - logSN
- b1
- b2
- alpha_cross
- alpha_auto
- alpha_matter
oversample: true
oversampling_factors:
- 1
- 100

but cobaya insists that it is blocking in a different way:

[mcmc] Oversampling with factors:
5 : ['logA', 'logSN', 'Omegam', 'b1', 'alpha_cross']
138 : ['b2', 'alpha_auto', 'alpha_matter']

backed up by the .checkpoint file:

sampler:
mcmc:
converged: false
Rminus1_last: .inf
proposal_scale: 2.4
blocks:
- - 0
- 1
- 2
- 3
- 5
- - 4
- 6
- 7
oversampling_factors:
- 5
- 138

What mistake am I making here?

Re: Specifying manual blocking in cobaya

Posted: April 15 2020
by Jesus Torrado
Hi Alex,

The correct setting for the blocking is `blocking`, not `blocks/oversampling_factors`, which are only used internally. Check out the docs at https://cobaya.readthedocs.io/en/latest/sampler_mcmc.html#options-and-defaults

Notice that (unless you are using devel), what is indicated in front of each block is not the oversampling factor but the speed, so you may have to tune it to get the desired oversampling factor.

Re: Specifying manual blocking in cobaya

Posted: April 21 2020
by Alex Krolewski
Hi Jesus,

Thanks! The docs you link specify the format for blocking in yaml:

blocking:
# - [speed_1, [params_1]]

How would I translate this into python ordered dicts?
Notice that (unless you are using devel), what is indicated in front of each block is not the oversampling factor but the speed, so you may have to tune it to get the desired oversampling factor.
I am using devel (from March 20)--what should I indicate in front of each block?

Re: Specifying manual blocking in cobaya

Posted: April 24 2020
by Jesus Torrado
(Sorry for the delayed answer!)
I am using devel (from March 20)--what should I indicate in front of each block?
The desired oversampling factor.
How would I translate this into python ordered dicts?
The value of blocking It should be a list of tuples (oversampling_factor, list_of_params), not a dict.

Re: Specifying manual blocking in cobaya

Posted: April 26 2020
by Alex Krolewski
Hi Jesus,

Thanks for the help--this fixed my problem!

Best,
Alex