-
Notifications
You must be signed in to change notification settings - Fork 127
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
Profile Sampler #342
base: master
Are you sure you want to change the base?
Profile Sampler #342
Conversation
Thanks for this (and sorry for delay in looking at it). There does seem to be quite a bit of duplicated code, could you perhaps inherit Profile from Minimize (or both from a common ancestor), so that common code can be reused? (e.g. _get_desc seems basically copied, and other code e.g. setting up minimizers could also probably be refactored into an inherited method?). |
Hello @cmbant and happy New Year :) I'll come back to you when I have relevant news (it may take some time since I am also writing my manuscript ): ) |
Hello @cmbant, I tried to inherit from Minimizer to define the Profiler and comment out all the code that was duplicated. Still, I cannot see the log from Travis to understand what is breaking. Do you have any insight? |
Can’t you see
Job #2539.1 - CobayaSampler/cobaya - Travis CI (travis-ci.com)<https://app.travis-ci.com/github/CobayaSampler/cobaya/jobs/617467186>
?
From: Giacomo Galloni ***@***.***>
Sent: Tuesday, February 27, 2024 10:36 AM
To: CobayaSampler/cobaya ***@***.***>
Cc: Antony Lewis ***@***.***>; Mention ***@***.***>
Subject: Re: [CobayaSampler/cobaya] Profile Sampler (PR #342)
Hello @cmbant<https://github.com/cmbant>, I tried to inherit from Minimizer to define the Profiler and comment out all the code that was duplicated.
Still, I cannot see the log from Travis to understand what is breaking.
I don't know if it is a problem due to me not having a subscription.
Do you have any insight?
—
Reply to this email directly, view it on GitHub<#342 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AA6GQIZ7WED6CCU34MOJZLTYVWZJBAVCNFSM6AAAAABABGVM2SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRWGI2TKNZQGI>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Yeah, I see the job, but the log only gives this message: We're sorry, but this data is not available. Please check the repository settings in Travis CI. |
Try in a new incongito window, that works fine for me: |
That worked! |
I rely on multiple initialization of Minimize to fetch the initial points and define all the relevant attributes. Then, I drop the profiled parameter from each quantity to recover the profiled case.
…into profile_sampler
Ok, now it works. I inherited from Minimize as you suggested and try to recycle as much code as possible. If I didn't miss some possible shortcuts, I should have kept only the necessary lines. To initialize the points I rely on multiple initializations of Minimize. Then, I drop the profiled parameter from the relevant quantities. This saves quite a lot of lines in the profile sampler. Let me know if you think I could improve it in some way. Still, I'll keep improving it if I can. |
Thanks, looks good. I don't think you need to inherit from CovmatSampler again as Minimize already does. Jesus suggests you consider making this an external package (which means you'd more obviously get credit for it! And reduce code bloat/maintainance in cobaya itself). You can use external samplers (as for external likelihood packages), though in this case we may need to make some small changes to run.py etc which Jesus said he could help with. |
Hi @ggalloni I am very sorry for the delay on this. Could you please create a minimal package with just the sampler code following the example repo at https://github.com/CobayaSampler/example_sampler/? And then please try to import it in the input as @cmbant the example external sampler works the same as the likelihoods. If it's a package that has been created explicitly for Cobaya, it's a bit of a shame that we need to import as |
Class can be called anything as long as returned by get_cobaya_class imported from package root
…________________________________
From: Jesús Torrado ***@***.***>
Sent: Monday, September 9, 2024 11:24:38 PM
To: CobayaSampler/cobaya ***@***.***>
Cc: Antony Lewis ***@***.***>; Mention ***@***.***>
Subject: Re: [CobayaSampler/cobaya] Profile Sampler (PR #342)
Hi @ggalloni<https://github.com/ggalloni>
I am very sorry for the delay on this.
Could you please create a minimal package with just the sampler code following the example repo at https://github.com/CobayaSampler/example_sampler/? And then please try to import it in the input as [package.Class] as in the example code? I just want to make sure that it can be imported that way. It won't work, of course, because we need to merge the changes in this PR for the general Cobaya files, but we will do that this week.
@cmbant<https://github.com/cmbant> the example external sampler works the same as the likelihoods. If it's a package that has been created explicitly for Cobaya, it's a bit of a shame that we need to import as [package.Class]. Maybe if we agree on a general class name, such as CobayaWrapper for the Sampler-inherited class, we can invoke just using the package name? Not very important, just to have your opinion.
—
Reply to this email directly, view it on GitHub<#342 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AA6GQI25PU3N3INAVNWWOO3ZVYGZNAVCNFSM6AAAAABABGVM2SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZZGEYTONBTGQ>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@cmbant Thanks! Updated. We have some many ways to interface that I often do not remember all of them. |
Hi @JesusTorrado, here you can find the module with the profile sampler. I tested it both with tests and by running locally Note that I had to specify a Let me know if you need me to do something else. |
Hi @ggalloni Sorry, I forgot to add that it works without the Let me see about the rest of the changes in the PR. I will propose another one soon handling the documentation part, but let's keep this open until then. But in any case, your profiler works now as an external package, so I would personally drop the reference to the PR in the README and make it standalone. |
Great, thanks! I'll work on the README asap 👍 |
No worries, and apologies again for the huge delay! |
Hello, as anticipated I have been working on implementing a profile likelihood pipeline within Cobaya.
This implementation is a new sampler, based on the current minimizer, but which loops over a list of requested values of a parameter. Indeed, I used
minimize
as a template to writeprofile
. Mimickingminimize
, theignore_prior
flag will control whether the profiled quantity is the likelihood or the posterior.The main modifications are:
params
block. The idea is the same asminimize
: the most convenient thing to do is to first run a Monte Carlo and afterward do a profiling. This will ensure that the starting point of each profiled point is close enough to the result (this is because even if the profiled parameter is taken different from the absolute best fit, the others will not move too much).initialize
to generate them and store them.run
which now will minimize all the sampled parameters for each requested point of the profiled one.SampleCollection
with the values of all parameters plus the profiled one. This allows the user to also have in the end the so-called co-profiles for each parameter (minimized parameter as a function of the profiled one), which for example gives interesting information on degeneracies. The name of this file will vary depending onignore_prior
: the prefix is eitherlike_profile
ofpost_profile
.test_minimize.py
and a test the new output file.profile
using againminimize
as a template. Also, I added this sampler to the index of the docs.Travis passed all tests in my fork, but I was wondering whether I should add an example in the quickstart docs. What do you think?
Let me know if the implementation is satisfactory to you or if I should make any modifications.