Skip to content

Shifting to JAX (WIP) #23

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

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open

Shifting to JAX (WIP) #23

wants to merge 35 commits into from

Conversation

b-biswas
Copy link
Collaborator

@b-biswas b-biswas commented Feb 28, 2025

  • Use a name tuple for observation instead of ngmix
  • jax.jit metacal.py functions
  • jax.jit metadetect.py functions (maybe in a different PR?)
  • Update test suite according to the new API
  • Validate results (ongoing)

Copy link

codecov bot commented Mar 9, 2025

Codecov Report

Attention: Patch coverage is 98.39228% with 10 lines in your changes missing coverage. Please review.

Project coverage is 98.91%. Comparing base (ee4fda3) to head (05210cd).

Files with missing lines Patch % Lines
deep_field_metadetect/jaxify/jax_metacal.py 94.30% 9 Missing ⚠️
deep_field_metadetect/jaxify/observation.py 98.24% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
- Coverage   99.05%   98.91%   -0.14%     
==========================================
  Files          20       27       +7     
  Lines        1689     2305     +616     
==========================================
+ Hits         1673     2280     +607     
- Misses         16       25       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Owner

@beckermr beckermr left a comment

Choose a reason for hiding this comment

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

I left some comments and questions. A few other items.

  1. It might be good to add a series of unit tests that ensure that each function in the non-jax code that has a counterpart in the jax code gives the same answer.
  2. It appears that dk is compute from image sizes in various places? If yes, then we should be able to compute that as a compile-time constant and remove the need for us to specify it by hand.



@jax.tree_util.register_pytree_node_class
class NTObservation(NamedTuple):
Copy link
Owner

Choose a reason for hiding this comment

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

Is the goal here to make a JAX-compatible copy of the ngmix observation or maybe should we restrict this class to only the items we need for running deep-field metadetect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I agree on that we should remove the unnecessary items. But I was trying ot keep it as close to ngmix as possible until we remove all dependency from ngmix (Gaussian moments, etc...). So maybe for now we can continue with the current class?

Copy link
Owner

Choose a reason for hiding this comment

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

Yep that's fine.

Comment on lines 47 to 48
dk_w=2 * jnp.pi / (53 * 0.2) / 4,
dk_d=2 * jnp.pi / (53 * 0.2) / 4,
Copy link
Owner

Choose a reason for hiding this comment

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

Can you comment on what the various factors here are? Is the factor of 53 related to the PSF size or the image size or do they happen to be the same?

Comment on lines 56 to 59
dk_w=2 * jnp.pi / (53 * 0.2) / 4,
dk_d=2 * jnp.pi / (53 * 0.2) / 4,
nxy=201,
nxy_psf=53,
Copy link
Owner

Choose a reason for hiding this comment

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

Again I don't follow these computations.

@@ -15,13 +14,9 @@ class DFMdetObservation(NamedTuple):
bmask: Optional[jax.Array]
ormask: Optional[jax.Array]
noise: Optional[jax.Array]
jacobian: Optional[jax.Array]
aft: Optional[jax_galsim.wcs.AffineTransform]
Copy link
Owner

Choose a reason for hiding this comment

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

Looking ahead, I think we should call this wcs.

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