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

Library Reorganization for v0.3.0 release #243

Merged
merged 29 commits into from
Dec 27, 2023
Merged

Library Reorganization for v0.3.0 release #243

merged 29 commits into from
Dec 27, 2023

Conversation

iancze
Copy link
Collaborator

@iancze iancze commented Dec 25, 2023

Update: The first round of changes around types is now complete (from #244) and ready to merge into main from this WIP-v0.3 branch. The changes were both substantial in terms of LOC but have relatively minor impact to the overall workflow, so it makes sense to merge them into main now, close some issues, and the progress to the next coherent batch on the road to v0.3.0.

  • Closes Getting started with type hints #54 Added type hints for core modules. This should improve stability of core routines and help users when writing code using MPoL in an IDE.
  • Closes Inconsistent documentation for classes with .from_image_properties class method #233. Removed convenience classmethods from_image_properties from across the code base. The recommended workflow is to create a :class:mpol.coordinates.GridCoords object and pass that to instantiate these objects as needed, rather than passing cell_size and npix separately. For nearly all but trivially short workflows, this simplifies the number of variables the user needs to keep track and pass around revealing the central role of the :class:mpol.coordinates.GridCoords object and its useful attributes for image extent, visibility extent, etc. Most importantly, this significantly reduces the size of the codebase and the burden to maintain, test, and document multiple entry points to key nn.modules. We removed from_image_properties from
    • :class:mpol.datasets.GriddedDataset
    • :class:mpol.datasets.Dartboard
    • :class:mpol.fourier.NuFFT
    • :class:mpol.fourier.NuFFTCached
    • :class:mpol.fourier.FourierCube
    • :class:mpol.gridding.GridderBase
    • :class:mpol.gridding.DataAverager
    • :class:mpol.gridding.DirtyImager
    • :class:mpol.images.BaseCube
    • :class:mpol.images.ImageCube
  • Closes Make images.ImageCube passthrough default, remove nn.Parameter from ImageCube #246 Make the passthrough behaviour of :class:mpol.images.ImageCube the default and removed this parameter entirely. Previously, it was possible to have :class:mpol.images.ImageCube act as a layer with nn.Parameters. This functionality has effectively been replaced since the introduction of :class:mpol.images.BaseCube which provides a more useful way to parameterize pixel values. If a one-to-one mapping (including negative pixels) from nn.Parameters to output tensor is desired, then one can specify pixel_mapping=lambda x : x when instantiating :class:mpol.images.BaseCube.
  • Closes Update Python versions to follow Spec 0 #245 by requiring Python >= 3.8 for install, and only testing on 3.10 & 3.11 (torch not available on 3.12 yet).
  • Removed unused routine mpol.utils.log_stretch.
  • Made some progress converting docstrings from "Google" style format to "NumPy" style format. Ian is now convinced that NumPy style format is more readable for the type of docstrings we write in MPoL. We usually require long type definitions and long argument descriptions, and the extra indentation required for Google makes these very scrunched.

The remaining work will be re-raised in a new PR

Massive WIP branch to collect several library improvement efforts leading up to v0.3.0 release. These will most likely involve a large and coordinated change to the structure of the codebase, so I'm grouping them together so that they land as a single PR rather than incremental and uncoordinated changes to main.

These changes are grouped thematically by their aim to improve the quality of MPoL as a PyTorch library

  • improvements to stability of core routines
  • aligning core usage patterns with established PyTorch idioms (e.g., prioritizing torch.tensor ahead of numpy.array , thinking about memory locations of arrays during optimization loops) should yield speed and stability improvements
  • documentation changes to be up front about how MPoL (at least the core package) is designed to function as an interferometric imaging library for PyTorch, which might lead to further discussions about what is in/out of scope for the core 'plumbing' package, and what might make more sense in visread (pure numpy visibility manipulations and plotting) or another MPoL-dev package (as 'porcelain', to use Git's terminology).

The proposed changes under consideration are now tracked by the "Architecture + Design" GitHub project board on MPoL-dev (available internally). But here is a first assessment of planned approach:

Coverage, bug-fix, and 'foundational' changes

Changes to introduce Stochastic Gradient Descent workflow

Further documentation changes

  • Reorganize SimpleNet and the entire GriddedDataset workflow as an alternative option to SGD, with documentation about the use cases when one or the other might be preferred. Possibly remove SimpleNet in favor of a torch.nn.Sequential
  • Consolidate or remove redundant tutorials.
  • Think about what content makes sense as rendered docs (code demonstrating key library functionality, building blocks, preferably concise) or as a longer .py file in examples/ (actual workflows following official pytorch/examples. E.g.,
  • Make sure all routines render in the API docs
  • Detailed migration/updated instructions from v0.2.0 => v0.3.0 in changelog, e.g. in the style of Julia Release Notes.

Note this PR supersedes #242 after we renamed the branch from v0.2.1 to v0.3.0.

@iancze iancze marked this pull request as ready for review December 27, 2023 22:41
@iancze iancze merged commit 3a87e7d into main Dec 27, 2023
3 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
1 participant