Split ev_op/init#526
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the eko.evolution_operator package by extracting the Numba-based quadrature kernel implementation (quad_ker, QuadKerBase, and related helpers) out of evolution_operator/__init__.py into a dedicated quad_ker.py module, and updates internal imports accordingly.
Changes:
- Move the quadrature-kernel logic (including
QuadKerBaseand QCD/QED kernel builders) fromevolution_operator/__init__.pyintoevolution_operator/quad_ker.py. - Slim down
evolution_operator/__init__.pyby removing large Numba-heavy definitions and importingquad_kerfrom the new module. - Update
operator_matrix_element.pyto importQuadKerBasefromquad_ker.pyinstead of from the package__init__.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/eko/evolution_operator/quad_ker.py | Hosts the extracted quadrature-kernel code, adds/relocates helper selectors and QuadKerBase, retains Numba cfunc callbacks. |
| src/eko/evolution_operator/operator_matrix_element.py | Adjusts imports to reference QuadKerBase from the new quad_ker module. |
| src/eko/evolution_operator/init.py | Removes the inlined quad-kernel implementation and imports quad_ker from quad_ker.py. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @property | ||
| def n(self): | ||
| """Returs the Mellin moment :math:`N`.""" | ||
| return self.path.n |
| sv_mode: int, `enum.IntEnum` | ||
| scale variation mode, see `eko.scale_variations.Modes` | ||
| is_threshold : boolean | ||
| is this an itermediate threshold operator? | ||
| n3lo_ad_variation : tuple |
| sv_mode: int, `enum.IntEnum` | ||
| scale variation mode, see `eko.scale_variations.Modes` | ||
| is_threshold : boolean | ||
| is this an itermediate threshold operator? | ||
| n3lo_ad_variation : tuple |
| @nb.cfunc( | ||
| CB_SIGNATURE, | ||
| cache=True, |
|
So apparently because of the three Unfortunately there is no dedicated import os
if os.environ.get("NUMBA_DISABLE_JIT", "0") == "1":
def cfunc_wrapper(sig, *args, **kwargs):
def decorator(func):
return func
return decorator
nb.cfunc = cfunc_wrapperPlease do let me know if you are satisfied with this or not so that I can start fixing patch files for |
Actually, I would say this is a feature and not a bug.
Do you agree? (and to be explicit: Copilot is telling non-sense in this case I would say) Then there is the unrelated matter of Numba+caching: this yields sometimes strange behaviour since the caching is not always consistent. See also numba/numba#8926 . Thus, the first action in debugging Numba is always to delete the (Python) cache (files) and let Numba recompile; typically it is sufficient to delete "the relevant cache" (which you need to guess) and not all, which for us can take a very long time to recompile. |
a step for #518
src/eko/evolution_operator/__init__.pyinto two parts: the new part (quad_ker.py) containing the integration kernels only and the remaining part containing only the class(EDIT: this would have been better placed in a comment, since it is not describing the PR but rather one specific problem)
@felixhekhorn @scarlehoff I have one small issue with this and hence I'd like to now if you are facing this or not. So after changing all the files I tried to run poe test and got this error:
In short, the function
select_singlet_elementis of typefunction, and not whatever numba wants it to be (i.e. njit function). I have no idea why this is taking place since the function is placed above in the file, and the structure of the file before was the same only but it did not encounter this error. I ran this and the error got fixed:So remove all the cache, and then call only the quad_ker file such that it caches without any problems. Then running
poe testdoes not result in any error.I had faced this error before. After running rustify.sh, poe test was returning the same error. I imported all the dependencies of quad_ker.py in terminal (similar way as shown above) and the error was resolved.
I have no clue why on Earth numba is showing this behaviour, but we should not split the file if the error persists.