Commit 83296b9
authored
Provide PyTorch implementations by wrapping JAX functions (#277)
* Make spherical precompute benchmarks compatible with pytorch
* Add utilities for wrapping JAX function for use in PyTorch
* Add initial wrapped versions of torch precompute transforms
* Update array conversion in benchmarks to avoid byte alignment warning
* Remove previous torch precompute spherical transform implementations
* Make precompute Wigner benchmarks compatible with torch
* Add torch wrapper precompute Wigner transforms
* Removing docstring for now removed using_torch arg
* Correct typo in docstring
* Remove previous torch precompute Wigner transform implementations
* Update references to JAX in docstring when wrapping for torch use
* Try to infer differentiable args from annotations
* Update annotations of wrapped functions
* Remove explicit differentiable argument name defs
* Add helper function for wrapping all JAX functions in module
* Use wrappers for Torch resampling and quadrature modules
* Remove using_torch option from signal generator functions
* Update torch demo notebook to follow new wrapper interface
* Use wrappers for torch HEALPix FFT functions
* Make torch an optional dependency
* Use backwards compatible tree_map import
* Copy annotations in wrapped function and check for existence of doc
* Start on torch wrapper tests
* Add annotations futures import
* Add additional torch wrapper tests
* Make type alias Python 3.8 compatible
* Account for differing complex derivatives conventions between torch and JAX
* Add additional complex test cases and gradient checks to wrapper tests
* Ignore complex warning due to casts in tests rather than erroring
* Reduce max number iter tested for HEALPix to reduce test times
* Maintain compatibility with older JAX versions
* More maintaining compatibility with older JAX versions
* Correct typo in comment
* Explicitly cast kernels in einsum ops to avoid ComplexWarning causing test fails
* Force JAX double precision mode in Wigner precompute tests
* Add test for function checking torch available
* Fix torch optional import logic to avoid errors when not installed
* Refactor method dispatch logic in inverse transform
* Refactor method dispatch logic in HEALPix FFTs
* Expose option to use HEALPix custom primitive in inverse transform
* Pass through method to select HEALPix (I)FFT function
* Expose jax_cuda method in top-level spherical inverse function
* Refactor method dispatch logic in forward transform
* Add OTF spherical transform torch wrappers
* Make torch wrapper diff arg inferring robust to non-type annotations
* Mark use_healpix_custom_primitive arg as static
* Include torch wrappers in tests
* Refactor method dispatch logic in Wigner transforms
* Add torch wrappers for Wigner OTF transforms
* Update README and notebook to indicate wider torch support
* Pin JAX version to less than v0.6.0 due to breaking changes1 parent 351fc94 commit 83296b9
File tree
22 files changed
+941
-1412
lines changed- benchmarks
- notebooks
- s2fft
- precompute_transforms
- transforms
- utils
- tests
22 files changed
+941
-1412
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
39 | 47 | | |
40 | 48 | | |
41 | 49 | | |
| |||
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
81 | 94 | | |
82 | 95 | | |
83 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
39 | 47 | | |
40 | 48 | | |
41 | 49 | | |
| |||
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
75 | 88 | | |
76 | 89 | | |
77 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 38 | + | |
47 | 39 | | |
| 40 | + | |
| 41 | + | |
48 | 42 | | |
49 | | - | |
50 | | - | |
51 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
52 | 49 | | |
53 | 50 | | |
54 | 51 | | |
| |||
65 | 62 | | |
66 | 63 | | |
67 | 64 | | |
68 | | - | |
69 | | - | |
70 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
71 | 68 | | |
72 | 69 | | |
73 | 70 | | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
77 | | - | |
| 74 | + | |
78 | 75 | | |
79 | 76 | | |
80 | 77 | | |
81 | 78 | | |
82 | 79 | | |
83 | 80 | | |
84 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
85 | 90 | | |
86 | | - | |
87 | | - | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
93 | 97 | | |
94 | | - | |
| 98 | + | |
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
| |||
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
103 | | - | |
| 107 | + | |
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
110 | | - | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
114 | 118 | | |
115 | 119 | | |
116 | 120 | | |
117 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
118 | 130 | | |
119 | | - | |
| 131 | + | |
120 | 132 | | |
121 | 133 | | |
122 | 134 | | |
123 | 135 | | |
124 | 136 | | |
125 | 137 | | |
126 | | - | |
| 138 | + | |
127 | 139 | | |
128 | 140 | | |
129 | 141 | | |
130 | 142 | | |
131 | 143 | | |
132 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
133 | 191 | | |
134 | 192 | | |
135 | 193 | | |
136 | 194 | | |
137 | 195 | | |
138 | | - | |
| 196 | + | |
139 | 197 | | |
140 | 198 | | |
141 | 199 | | |
142 | 200 | | |
143 | | - | |
| 201 | + | |
144 | 202 | | |
145 | 203 | | |
146 | 204 | | |
147 | 205 | | |
148 | 206 | | |
149 | | - | |
| 207 | + | |
150 | 208 | | |
151 | 209 | | |
152 | 210 | | |
| |||
160 | 218 | | |
161 | 219 | | |
162 | 220 | | |
163 | | - | |
| 221 | + | |
164 | 222 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 223 | + | |
171 | 224 | | |
172 | 225 | | |
173 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
74 | 73 | | |
75 | 74 | | |
76 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
| |||
0 commit comments