Specifying manual blocking in cobaya

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Alex Krolewski
Posts: 11
Joined: November 07 2019
Affiliation: UC Berkeley

Specifying manual blocking in cobaya

Post by Alex Krolewski » March 24 2020

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?

Jesus Torrado
Posts: 37
Joined: April 15 2013
Affiliation: RWTH Aachen
Contact:

Re: Specifying manual blocking in cobaya

Post by Jesus Torrado » April 15 2020

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.

Alex Krolewski
Posts: 11
Joined: November 07 2019
Affiliation: UC Berkeley

Re: Specifying manual blocking in cobaya

Post by Alex Krolewski » April 21 2020

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?

Jesus Torrado
Posts: 37
Joined: April 15 2013
Affiliation: RWTH Aachen
Contact:

Re: Specifying manual blocking in cobaya

Post by Jesus Torrado » April 24 2020

(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.

Alex Krolewski
Posts: 11
Joined: November 07 2019
Affiliation: UC Berkeley

Re: Specifying manual blocking in cobaya

Post by Alex Krolewski » April 26 2020

Hi Jesus,

Thanks for the help--this fixed my problem!

Best,
Alex

Post Reply