Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blind output with user-provided offsets #10

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SebastianBocquet
Copy link
Contributor

@SebastianBocquet SebastianBocquet commented Apr 27, 2022

Let the user provide a set of parameter offsets for the purpose of blinding the output. This makes looking at the chains safe!

This is activated by setting apply_blinding_offsets = True in the [output] section of the parameter file. The offsets are saved as a .npy file. Add blinding_offsets = /path/to/file to the parameter file.

Caveat: The user must set the offsets corresponding to output columns such as prior like post weight to 0 manually.

The modification is mostly copied from @MCostanzi.

@SebastianBocquet
Copy link
Contributor Author

Sorry, should have run the tests offline first... Sampling works but the tests don't. I'll take a closer look.

@joezuntz
Copy link
Owner

It looks like this is because the blinding is not working for the in-memory output format.

@SebastianBocquet
Copy link
Contributor Author

I applied the same modification to in_memory_output.py and the tests now pass. However, my changes to output_base will still break other output methods (which are not covered by the tests).

@SebastianBocquet
Copy link
Contributor Author

Please let me know if you like the modification / blind scheme at all. If so, I can modify the other output options, too. If not, there's no point.

cosmosis/output/in_memory_output.py Outdated Show resolved Hide resolved
cosmosis/output/output_base.py Show resolved Hide resolved
@SebastianBocquet
Copy link
Contributor Author

It just occurred to me that offsetting the output makes resuming a chain from that output impossible. I guess cosmosis could unblind the chain internally and resume from there. I haven't looked at the code yet. We should probably fix that before merging.

@joezuntz
Copy link
Owner

Ouch, yes, this is difficult!

We could unblind on loading the chain in the resume method in the samplers that support resuming, but then we'd also have to check how that fits with the convergence diagnostics for the metropolis sampler. This might be a bit too complicated in terms of maintenance.

@SebastianBocquet
Copy link
Contributor Author

I could add an error when trying to resume with blinding_offsets. Then the user can decide to unblind the chain if a resume is necessary. Not ideal, this only gets us half-way to where we want to be... What do you think?

@joezuntz
Copy link
Owner

joezuntz commented May 5, 2022

It feels like we should do something a bit more organized, and modify the way that the chains are being resumed by adding a method to read a chain and detect if it has been blinded by looking at the header / metadata. Let me think about this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants