Skip to content

HEALPix UNet code cleanup#1326

Draft
yikwill wants to merge 3 commits into
ai2cm:mainfrom
yikwill:feature/hpx_cleanup
Draft

HEALPix UNet code cleanup#1326
yikwill wants to merge 3 commits into
ai2cm:mainfrom
yikwill:feature/hpx_cleanup

Conversation

@yikwill

@yikwill yikwill commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Several HEALPix settings were duplicated across YAML configs, mutated at build time, or lived on monolithic dataclasses where variant-specific fields were silently ignored. This PR makes configs easier to load from YAML, reason about, and extend. It refactors HEALPix UNet configuration and build path to address feedback from a previous HEALPix PR. Block configs are split into dacite discriminated unions and runtime/build-time concerns are separated.

Changes:
Build-time vs config-time separation

  • Channel counts (input_channels / output_channels) have been removed from UNetEncoderConfig, UNetDecoderConfig, and conv/downsample/upsample block configs. Insteady, they are now passed explicitly to .build() from HEALPixUNet / HEALPixUNetBuilder.
  • Config objects are no longer mutated (e.g. via .replace) when constructing the model.

Shared build context

  • Added HEALPixBuildContext and HEALPixLayerBuildContext for model-level settings (hpx_padding_mode, nside per level). They are configured once on HEALPixUNet / HEALPixUNetBuilder, then the encoder, decoder, and blocks receive per-level views via ctx.layer(level).

Discriminated union block configs

  • Monolithic block configs split into one dataclass per block_type, each with a Literal[...] discriminator for dacite union resolution. For example, the union alias DownSamplingBlockConfig has variants MaxPoolDownsamplingBlockConfig, AvgPoolDownsamplingBlockConfig, and DealiasedDownsampleBlockConfig. Each variant exposes only fields relevant to that block type.

Other

  • enable_nhwc option removed. Memory format of inputs is already hard coded.

  • Replace th calls with torch for clarity.

  • Tests added

  • If dependencies changed, "deps only" image rebuilt and "latest_deps_only_image.txt" file updated

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.

1 participant