MAPED data merging with Torch#204
Conversation
…eeds to be overloaded is set_optimizer for PPLR cases
…to do the matching in set_optimizer instead of parsing in optimizer_params maybe?
… to check: Look at object_models.py and see how the optimizer matching should be handled. It seems like set_optimizers doesn't really do what it's supposed to do.
… probably have to do TV loss computation within the model?
…es. Also overloaded reconnecting optimizers
…well. Only things to ask Corneel about is multiscale res since this adds a significant amount of compute. Should I be doing variable num_samples_per_ray?
…t DDP, clean-up KPlanes, fix up object_models.py since it's insanely cluttered now
|
Happy to review and also address the remaining bottleneck. @henrygbell |
|
@gvarnavi seems like CI tests aren't running on branch PRs, could we also add automated workflows? I want to ensure that this torch refactoring doesn't break the existing maped pytest. |
bobleesj
left a comment
There was a problem hiding this comment.
@henrygbell I spent 15-20 mins reviewing. Before I run with real data, I noticed that new utility torch functions were added. It is not required to write unit tests for each (if you want, better if you compare against scipy/numpy) but at least we need to know that we maintain parity after refactoring. Please see the drift PR below where torching was done but no API/accuracy was changed
Ref: https://github.com/electronmicroscopy/quantem/pull/206/changes#r3040892988.
After your feedback, I will test with the data we collected at snsf.
| pad_val: str | float = 0.0, | ||
| shift_method: str = "bilinear", | ||
| ): | ||
| class MAPEDTorch(AutoSerialize): |
There was a problem hiding this comment.
general comment - we need an end-to-end test either with synthetic data or data that used before refactoring w/ torch to ensure nothing broke in this PR. Then I would be more comfortable reviewing this.
There was a problem hiding this comment.
second comment is that did the API or is it just torching without any user behavior modified? Please indicate that so that we don't need to worry about backward compatability in your PR comment
|
|
||
| Parameters | ||
| ---------- | ||
| edge_blend |
There was a problem hiding this comment.
pls follow numpy docstring - parameter type missing.
There was a problem hiding this comment.
important for doc api doc rendering automated
|
|
||
| Stores | ||
| ------ | ||
| self.scales : torch.tensor |
There was a problem hiding this comment.
yeah here i see paramters
| - compute mean BF and mean DP summaries, | ||
| - choose/find diffraction origins, | ||
| - align diffraction space and real space, | ||
| - merge datasets into a single composite Dataset4dstem. |
| stack[ind] = np.fft.ifft2(F * ramp).real | ||
| Parameters | ||
| ---------- | ||
| origins |
| mode="constant", | ||
| cval=0.0, | ||
| prefilter=False, | ||
| Stores |
| return w | ||
| if alpha >= 1: | ||
| return torch.hann_window(N, device=device, dtype=dtype) | ||
|
|
There was a problem hiding this comment.
just code comment - no extra whitespace needed, fewer lines better in general so that we don't have to scroll too much. I
…ositionModel ABC, make sure to have a property for which kind of tensor decomposition method is being used. SO3Params are moved to a different file, thinking of making a kplanes_utils.py. Starting reorganization of object_models.py to have ObjectINR and ObjectTensorDecomp
…p-level Tomography
… of parameters now that helps with type-setting. The main reason for having model_base.py as is it is right now is if we ever wanted to go do TensoRF or something just to validate
This reverts commit 140c563.
…on to stop forced switch to CPU memory
|
@henrygbell seems like we are having some PR synching issues here as well. A few things to check
This `upstream/nanobeam' is getting a bit too old where problems are starting to occur |
What does this PR do?
This PR is the torchified version of PR-169. For my data it speeds the merge_datasets method up by ~10x or more and adds batching.
Example notebook
maped_test_nb_torch.ipynb
Data for that notebook
Download here
For reviewers:
Please test the code on your own datasets! Check the code for accuracy. Let me know if you have any suggestions
TODO next: