-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add Julia bindings #23
Comments
I have a prototype implementation, which - on small basis sizes - is about a factor 2-3 faster than my previous one based on spherical coords (for large bases they are about the same) and will make this public soon once I also have the rrules done. One could argue having the pure julia implementation here in this repo instead of a separate Julia repo. I don't particularly mind either way. We will most likely want to maintain our own implementation with the interfaces we need but if that can be made compatible with what is here then all the better. For sure I wouldn't mind getting input on performance optimizations from people who actually understand this rather than just trial-and-error. I also don't plan on a GPU implementation immediately so that would be another thing where I'd be interested in following somebody else. |
An interesting complication is that a |
If you can / are willing to "harmonize" the API, I think it'd be interesting to have it in the same repo. |
OkSo the procedure would be have a Julia package live in a subfolder I think that will then be registered with the Julia General registry. I haven't done this before but maybe it's obvious and if not maybe @Luthaf can help if he is interested in having this? One other caveat is that the Julia code should probably be MIT licensed. Regarding different hardware -- In Julia that would probably be achievable via KernelAbstractions.jl later. |
Yeah let's hear from @Luthaf and @frostedoyster . I think it'd be really good to consolidate the infrastructure we all use, and this is an easy starting point. When I was mentioning "harmonizing API" I meant just making sure function/class arguments and defaults are consistent, so users don't get too confused. We have an ongoing offline discussion as to whether we should default to solid harmonics or normalize-by-default. |
I guess for large maxL it won't matter anyhow but for small maxL it might have an impact on performance. For modelling I would want to provide both options - it's just and easy extra transformation layer. For performance optimization if you already have a splined Rnl basis then it seems pretty obvious? |
This should be fine, the web interface in https://juliahub.com/ui/Packages can take a
Sure, we could also dual license the whole thing Apache/MIT (I know this is popular in the Rust ecosystem, but I don't remember why, I'll check).
Especially if you already have a prototype, I'll be happy with also having a pure Julia implementation. If we also do bindings to the native implementation, we can have something like this in the long term sph = spherical_harmonics(xyz; backend=:Julia) # pure julia, support autodiff & multiple dispatch
sph = spherical_harmonics(xyz; backend=:Native) # native code, potentially faster, support fewer features |
I agree entirely that for performance there's no question it should be the solid harmonics, and that it's no biggie to provide both options. the discussion was about the default. I feel quite strongly that the splid harmonics are actually the more natural things and it's ok to push for the better option as default, but @frostedoyster has a (good) argument that probably most users will expect the normalized version. Anyway, for the moment it should def be default |
I'm coming around to that perspective as well.
In my Julia codes I always provide EDIT: I looked at your Python docs again. Why not create two classes, one called |
I didn't yet test on the same CPU so maybe premature, but I think the Julia codes might be in a similar ballpark as yours. I am guessing I'm somewhere in-between your general-purpose and hard-coded. This is on a 2-year old M1. I tried to run the benchmarks as described on your readme but got no useful output, only red ... Generated: (this is just basic meta-programming, no computer-algebra optimized thing)
And the dynamic but batched implementation: (vectorized, but no multi-threading yet)
TBH - I wouldn't mind feedback if anybody in your group is willing to look at this. I could make WIP-PR before I have the gradients finished. |
A WIP PR sounds like a good idea! I don't have a lot of time to look at it over the next 2 weeks, but @frostedoyster can also give the code a look! |
I don't have much experience with Julia, but I'd be happy to take a look |
Thanks - I'll prepare the PR. I propose to call the subfolder If you have any concerns about it let me know. |
Hm - maybe one more question. So far I haven't looked at your code at all to avoid license problems. Going forward, if we were to think about optimizing maybe this would become useful. This is especially true to extend the Julia codes to GPU. Does Apache-2 allow me to produce a derived product and license it under MIT? If not, then I would need your explicit permission to do so. |
Re license I don't mind dual license. Also better to do it now than after we have a bunch of contributors we can't track. Re the normalization, I suggest that for the moment we adapt the Julia API to what we have, and open an issue to refactor. As @frostedoyster says, that's a lot of refactoring and re documenting so maybe not top priority. |
Initially I'm just going to do SolidHarmonics. I'll add the wrapper for SphericalHarmonics asap. I'm not convinced the two APIs need to be identical. The two languages are too different. |
My question was more specific : I thought I'd need explicit permission from the copyright holder if I look at your code, "transpile" it and release as new code under a different license. But it seems Apache-2 is sufficiently permissive that it doesn't matter: The Apache 2.0 License is permissive. It allows you to use, modify, and distribute the licensed software, including creating derivative works, without requiring those derivative works to be licensed under the same terms. You can release the modified parts of the code under any license you prefer But let me know if I've misunderstood it. |
This will require multiple steps:
The text was updated successfully, but these errors were encountered: