Comments (7)
Hi @pawel21 @cosimoNigro
looking at the code of Paweł, I saw that the most external functions:
compton_kernel_jit and isotropic_kernel_jit do not have any of the numba decorators, however those are being calculated over an array of electron gamma values and an array of nu values, and thus would paralellize nicely (instead of paralelizing individual subfunctions). Was it done on purpose?
Another thing that I was thinking about is cache-ing the function values, there is a decorator for this as well. I'm not sure if this will help here, because we do not have any single parameter functions that is executed multiple times for the same values, but if it is easy we can try it with cos_psi_jit which has 3 angle parameters, but it is executed multiple times for different nus and gammas.
The third thing, compton_kernel_jit is using a number of small one-line functions, get_y, get_y_1, get_y_2, get_values that I do not think are used anywhere else. I guess there should be some overhead in Python from executing a function (especially if we use extra decorators) and those are executed all the time, so I would naively assume that moving those lines inside the main compton_kernel_jit function would speed some somewhat the code (and make it shorter as well.
from agnpy.
@pawel21 sometimes ago I sent you an invitation to become a collaborator of the project. It is still pending, can you search in your mailbox and accept it. If you accept it you'll have more edit privileges and I can assign you issues 😄
from agnpy.
@pawel21 sometimes ago I sent you an invitation to become a collaborator of the project. It is still pending, can you search in your mailbox and accept it. If you accept it you'll have more edit privileges and I can assign you issues smile
Sorry, I missed it. Could you send me again? (because where I tried accept I got error: "This invitation has expired. ")
from agnpy.
Hi,
I modified code to speed-up fit with numba
. You can find my code at branch speed_up_fit
branch . I created new file synchotron_jit
, synchrotron_self_compton_jit.py
and kernels_jit.py
, where I added numba code. Notebook: ssc fit jit . Let me know, what do you think about my solution.
from agnpy.
Thanks a lot @pawel21, I checked it.
Would you mind, instead of using the fitting notebook for testing your new class, to set-up a proper comparison just invoking the evaluate_sed_flux
functions?
You can take a look into experiments/profiling where I already set-up some small script to do test and profiling.
It would be interesting to check first the results from the non-decorated and decorated class using the basic functions computing the SED Synchrotron.evaluate_sed_flux
. This function is calling the other functions you have decorated and all the other functions to compute the SED (e.g. Synchrotron.sed_flux(nu)
) call this one anyhow.
Thanks a lot for your work!
from agnpy.
Hi, I added two scripts to profile the code with numba
profile_ec_jit and profile_ssc_jit. I added numba code for EC with ring torus. Progress in time execution time is ~ 2 times faster. What do you think? So far, I created new python files with numba code external_comptin_jit
, synchotron_self_compton_jit
and synchotron_jit.py
, but I think code should't be divide into separate file in final state. What should be next step? Add class ExternalComptonJit
(and another) to external_compton.py
, modified class ExternalCompton
?
from agnpy.
Thanks @pawel21 and sorry for having ignored you.
Last week we had the software school and I had no time at all to take a look at this.
I had a similar improvement in execution times with numba, I remember something like half of it.
Now, concerning your tests I see two problems:
- a particular one: your fork is 277 commits behind master 😨 and I did a lot of refactoring and improvements that perhaps will change (though for sure not dramatically the results). Would you mind syncing your fork and retry? If you can't or don't want we can start with your decorators from scratch in a new branch in the master and work on it together;
- a general one: adding numba will imply to have another dependency and the improvement does not look so dramatic either.
We should decide which is a decent speed-up factor that will convince us that is worth adding a new dependency.
Thanks again and let me know how you want to proceed.
from agnpy.
Related Issues (20)
- Introducing a Particle class HOT 1
- Incompatibility between astropy 5.0.1 and agnpy 0.1.8 ? HOT 1
- bug when simulation of gammapy datasets with an agnpy spectrum model HOT 9
- Absorption calculation stability HOT 1
- Add sherpa and gammapy among the dependencies (add them to install_requires in setup.py) HOT 4
- Add a CITATION.cff file?
- TypeError: __init__() got an unexpected keyword argument 'is_norm' HOT 3
- Bullet points of lists disappear on Read the Docs HOT 1
- Error in the EBL absorption HOT 1
- Error in InterpolatedDistribution HOT 11
- Discrepancy between AGNpy and LeHa code in proton synchrotron
- Add the synchrotron proton to the models available for fitting
- Issue with fitting MWL SED using agnpy HOT 7
- Return the different SED components after a fit HOT 2
- Problem about load_absorption_table in class EBL HOT 2
- Problem about load_absorption_table in class EBL
- Move the tests to the subdirectory of each module. HOT 1
- Fitting of a MWL BL Lac SED: Fit doesn't converge. HOT 1
- d_L parameter in blob definition spoiling older code and examples
- Logging is silently disabled on agnpy import HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agnpy.