Skip to content

Integration of N5K winners into CCL#1092

Merged
paulrogozenski merged 82 commits intomasterfrom
integrate_N5K
Nov 13, 2023
Merged

Integration of N5K winners into CCL#1092
paulrogozenski merged 82 commits intomasterfrom
integrate_N5K

Conversation

@slosar
Copy link
Member

@slosar slosar commented Jun 15, 2023

This is a draft pull request, just to show you what we are doing. There is still cruft that will be removed before we do a full pull request.

A lot of heavy pulling here has been done by @paulrogozenski .

Summary of changes:

  • All reference to angpow has been removed
  • All placeholders for non-limber in the C-layer have been removed -- non-limber methods are by default pure python (but they can enter C-layer if they wish so)
  • interface to angular_cell has changed a little (more later)
  • FKEM method has been implemented
  • a pytest benchmark has been implemented in test_nonlimber.py

The main interface to non-limber is by setting l_limber to a cross-over value or "auto" in call to angular_cell.
We felt the need that non-limber optionally returns some meta value (i.e. you might be interested which cross-over ell did it actually use) and so there is an extra option return_meta, in which case it returns both cells and a dictionary with meta info (currently just l_limber, but could be more, like timing, etc). One can also specify which method to use with limber_integration_method parameter.

Here are the current questions / comments / issues:

  • Is the new interface to angular_cell appropriate?
  • For the benchmark, we took the N5K test, but just the "fullwidth" version of it. The problem with this test is that (unless we're doing something wrong), the Limber actually passes it pretty well (i.e worst chi2 is 0.3 or so). Guidance of which tests would be appropriate for these tests would be useful.
  • Caching into tracer quantities is not yet implemented, but is being worked on.
  • MATTER method, as coded in N5K is very tightly coupled to CLASS, beyond just fftlog. Not clear that reimplementing would not be easier than porting it, but this would be a significant amount of work. We're still looking at it.

Comments / suggestions are welcome at this stage.

@coveralls
Copy link

coveralls commented Jun 19, 2023

Pull Request Test Coverage Report for Build 6851440337

  • 179 of 184 (97.28%) changed or added relevant lines in 5 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 97.379%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pyccl/_nonlimber_FKEM.py 115 120 95.83%
Files with Coverage Reduction New Missed Lines %
pyccl/cells.py 1 97.92%
Totals Coverage Status
Change from base Build 6769057346: 0.01%
Covered Lines: 6316
Relevant Lines: 6486

💛 - Coveralls

Copy link
Collaborator

@damonge damonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @paulrogozenski . More review comments.

Copy link
Collaborator

@damonge damonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay @paulrogozenski . A few final comments. I think we're almost there, and I'll be on standby to review quickly.

pyccl/tracers.py Outdated
Comment on lines +725 to +742
def __init__(self):
"""By default this `Tracer` object will contain no actual
tracers
"""
# Do nothing, just initialize list of tracers
super().__init__()
self.chi_fft_dict = {}

def get_chi_fft(self, tracer, Nchi, chimin, chimax, ell):
temp = self.chi_fft_dict.get((tracer, Nchi, chimin, chimax, ell))
if temp is None:
return None, None
return temp[0], temp[1]

def set_chi_fft(self, tracer, Nchi, chimin, chimax, ell, ks, fft):
self.chi_fft_dict[(tracer, Nchi, chimin, chimax, ell)] = (ks, fft)
return ks, fft

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so FKEM right now would only work with NzTracers as input? How about the other tracer types?

Comment on lines +180 to +182
clt1.set_chi_fft(
clt1._trc[i], Nchi, chi_min, chi_max, ell, k, fk1
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last question about the algorithm itself: I fail to see what the advantage is of setting and storing these at the level of the tracers, as opposed to just precomputing them and storing them within this function.

The way I see it (and this may be where my misconception lies), Nchi, chi_min, chi_max and perhaps ell, will likely change with each new power spectrum you calculate (since e.g. chi_min and chi_max actually depend on the specific pair of tracers you're correlating, and not on an individual tracer properties). So you end up storing one of these in the tracer for each individual power spectrum you calculate. If that's the case, you don't really reuse these, so there would be no advantage to precomputing them locally within the function.

A parallel worry of storing these within the tracers is that, if what I'm saying above is correct, the associated tracer-level dictionaries may end up being huge if there's a lot of cross-correlations (if you have N tracers, the number of dictionary elements added up across all tracers would grow like N^3), which could cause memory issues.

Might be that I'm missing something, so let me know what you think.

@damonge
Copy link
Collaborator

damonge commented Nov 10, 2023

@paulrogozenski , thanks a lot again for this. I've put just one final comment above about the need to precompute certain things.

I also added one small commit in which I fixed a couple small things and streamlined the benchmark test script. The logic behind the latter is that the role of unit/benchmark tests is to test, as quickly as possible, that a given part of the code is doing what it should (in this case, in terms of accuracy too). So I think we should separate this (which can be done by limiting ourselves only to the linear bias model and avoiding the Limber test), from an example notebook that showcases how the new functionality interacts with other parts of the code (e.g. PT calculators, or how different Limber and non-Limber C_ells are). So, what I did is shrink a bit the benchmark test code, leaving only what we need to ensure the method performs as it did for the N5K challenge, and then opened a PR in CCLX where I've put your longer test, which we should then transform into a proper notebook once this branch is merged.

Copy link
Collaborator

@damonge damonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@paulrogozenski paulrogozenski merged commit 6b08a25 into master Nov 13, 2023
@damonge damonge deleted the integrate_N5K branch November 13, 2023 15:08
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.

Non-limber approximation from N5K Beyond limber for projected correlation functions

4 participants