Skip to content
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 fused spherical harmonics #46

Closed
wants to merge 3 commits into from
Closed

add fused spherical harmonics #46

wants to merge 3 commits into from

Conversation

bhedelius
Copy link

No description provided.

@mariogeiger
Copy link
Member

Thanks for the PR in both torch and JAX. I have few questions:

  1. What is the difference between this algorithm and this one?

  2. A preliminary test on my CPU shows that the current algorithm (e3nn.sh(range(max_degree + 1), x, True, algorithm=("legendre",))) is faster than calc_Ylm(max_degree, x) when max_degree is larger than 5. For smaller degrees, the algorithm e3nn.sh(range(lmax + 1), x, True, algorithm=("recursive", "dense", "custom_jvp")) becomes faster. In which case do you see an improvement over the current algorithms?

  3. Please use the same conventions as e3nn:

x = jnp.array([[0, 0, 1.0]])

print(e3nn.sh(range(1 + 1), x, True, algorithm=("legendre",)))
# [[1.    0.    0.    1.732]]
print(calc_Ylm(1, x))
# [[0.141 0.    0.244 0.   ]]
  1. Don't use lru_cache, jax.jit will automatically optimize the constants

@bhedelius
Copy link
Author

bhedelius commented Nov 3, 2023 via email

@mariogeiger
Copy link
Member

I reorganize the code to separate the different implementation into different files.

  1. Your code is aiming to optimize the function jax.scipy.special.lpmn_values ? If so could you rearrange your code as an alternative implementation of the legendre function?
  2. Can you run those tests?
  3. Great!
  4. Yes JAX will take the computational graph and optimizing it. It's very good at: dead code elimination, common subexpression elimination, constant folding

@mariogeiger mariogeiger marked this pull request as draft November 24, 2023 09:32
@bhedelius
Copy link
Author

bhedelius commented Nov 27, 2023 via email

@mariogeiger mariogeiger closed this Feb 2, 2024
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.

2 participants