Skip to content

Conversation

@divital-coder
Copy link
Contributor

  • Enzyme support for latest nvidia cards on GPU docker containers
  • Full test-suite support (1000 + tests, testing native julia functions around image transformations and interpolations)
  • Support for Julia 1.10 (1.10 + coming soon)
  • Refined and Added README Templates

google-labs-jules bot and others added 16 commits January 8, 2026 09:26
…tils.jl

- Add Enzyme, ChainRulesCore, and Random to dependencies.
- Fix interpolate_kernel to correctly handle spacing (convert physical coordinates to indices).
- Implement interpolate_pure and its rrule using Enzyme.autodiff.
- Update interpolate_my to use interpolate_pure for the fast path.
- Added `test/differentiability_tests/test_gradients.jl` to test gradients of all basic transformations.
- Refactored `pad_mi`, `translate_mi`, and `change_orientation` to be non-mutating to support Zygote.
- Refactored `rotate_mi` to use `interpolate_my` instead of `warp` for better differentiability.
- Added `rrule` for `resample_kernel_launch` in `src/Utils.jl`.
- Added `Zygote` and `FiniteDifferences` to test dependencies in `Project.toml`.
- Rewrote `pad_mi` in `src/Basic_transformations.jl` to use non-mutating `cat` and `ntuple`.
- Rewrote `change_orientation` in `src/Spatial_metadata_change.jl` to use non-mutating tuple construction.
- Rewrote `rotate_mi` in `src/Basic_transformations.jl` to use `interpolate_my` instead of `warp` for differentiability.
- Added `rrule` for `resample_kernel_launch` in `src/Utils.jl`.
- Added comprehensive differentiability tests in `test/differentiability_tests/test_gradients.jl` and integrated them into `test/runtests.jl`.
…esampling-13510357564736143532

Implement Enzyme-based autodifferentiation for resampling kernel
Integrates autodifferentiation support using Enzyme and Zygote from
jakubMitura14's PR JuliaHealth#51, combined with CUDA fixes from PR JuliaHealth#50.

Changes from PR JuliaHealth#51:
- Non-mutating pad_mi and rotate_mi in Basic_transformations.jl
- Non-mutating change_orientation in Spatial_metadata_change.jl
- rrule definitions for resample_kernel_launch and interpolate_pure
- New differentiability tests

Merge conflict resolutions:
- Kept CUDA.jl operation comments in Spatial_metadata_change.jl
- Combined KernelAbstractions imports with Enzyme/ChainRulesCore
- Maintained CUDA array backend handling in interpolate_my
- Uses interpolate_pure for differentiability while ensuring CUDA compatibility

Co-Authored-By: jakubMitura14 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Statistics: 1.9.0 -> 1 (supports Julia 1.10-1.12)
- julia: 1.10.3 -> 1.10 (minimum version requirement)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add explicit datetime values in tests to avoid Dates.now() during AD
- Create CPU-specific interpolation loops for Enzyme compatibility
- Add @non_differentiable for geometric helper functions:
  - get_base_indicies_arr, extract_corners
  - get_voxel_center_Julia, Rodrigues_rotation_matrix
  - build_rotation_transform, build_scale_points
  - compute_extrapolate_value
- Add rrule for change_orientation to handle dictionary lookups
- Refactor rotate_mi to use non-differentiable transformation builder
- Refactor scale_mi to use differentiable interpolation instead of imresize
- Add ChainRulesCore to Resample_to_target, Spatial_metadata_change,
  and Basic_transformations modules

All 15 gradient tests now pass:
- resample_to_image, rotate_mi, scale_mi, translate_mi
- crop_mi, pad_mi, resample_to_spacing, change_orientation

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Implement manual backward kernels for GPU gradient computation since
KernelAbstractions + Enzyme doesn't support active kernel arguments
on GPU backends.

Changes:
- Add trilinear_resample_backward_kernel! for trilinear interpolation gradients
- Add nearest_resample_backward_kernel! for nearest-neighbor gradients
- Use Atomix for race-safe atomic gradient accumulation on GPU
- Update rrule to use manual backward kernels for GPU path
- Add Atomix as a dependency
- Add GPU autodiff test file

The CPU path continues to use Enzyme.autodiff with pure Julia loops.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Remove manual backward kernels (trilinear_resample_backward_kernel!,
  nearest_resample_backward_kernel!) that used Atomix for atomic operations
- Add Enzyme-compatible forward kernels without @const annotations
  (trilinear_resample_enzyme_kernel!, nearest_resample_enzyme_kernel!)
- Add launcher functions that convert tuples to GPU arrays for Enzyme pattern
- Update rrule to use Enzyme.autodiff for GPU backward pass
- Remove unused Atomix dependency

This enables automatic differentiation through KernelAbstractions GPU kernels
using Enzyme, matching the working pattern that avoids "Active kernel arguments
not supported on GPU" errors.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
feat: enable GPU autodiff for resample operations
- Create README.typ with orange-themed frames using frame-it
- Include ASCII architecture diagram and API reference tables
- Add code examples for all major operations
- Link PDF from existing README.md

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Export 18 frame images from README.typ
- Rewrite README.md with frame image references
- Add table of contents
- Remove all emojis for professional appearance
- Match QADatasetsNormalize.jl documentation style

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Create separate frames-export.typ with only frame content
(no titles or section headings) for cleaner PNG export.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Each section now shows only the frame image without
repeating the same tables, code blocks, and text in markdown.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

❌ Patch coverage is 47.86885% with 159 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.85%. Comparing base (29b2901) to head (0cbb06d).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
src/Utils.jl 40.17% 134 Missing ⚠️
src/Spatial_metadata_change.jl 17.85% 23 Missing ⚠️
src/Basic_transformations.jl 95.91% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #53       +/-   ##
===========================================
- Coverage   76.07%   54.85%   -21.22%     
===========================================
  Files           8        8               
  Lines         514      762      +248     
===========================================
+ Hits          391      418       +27     
- Misses        123      344      +221     

☔ 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.

@jakubMitura14 jakubMitura14 merged commit 658ba65 into JuliaHealth:main Jan 19, 2026
3 of 5 checks passed
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