Skip to content

feat: Add U-Net building blocks with shape-consistency tests#23

Open
KrishanYadav333 wants to merge 1 commit intoML4SCI:mainfrom
KrishanYadav333:feat/unet-blocks
Open

feat: Add U-Net building blocks with shape-consistency tests#23
KrishanYadav333 wants to merge 1 commit intoML4SCI:mainfrom
KrishanYadav333:feat/unet-blocks

Conversation

@KrishanYadav333
Copy link

Summary

Part of pre-GSoC groundwork for the EXXA DDPM denoising pipeline.

Adds the three core reusable blocks that the U-Net encoder/decoder will be built from.

Changes

  • SinusoidalTimeEmbedding — log-spaced sin/cos frequency embeddings for diffusion timestep conditioning
  • ResidualBlock — GroupNorm + SiLU + Conv2d with time projection injection and 1×1 skip when channels differ
  • AttentionBlock — GroupNorm + MultiheadAttention over flattened spatial dims with residual connection

Tests

17 shape-consistency tests in tests/test_blocks.py covering:

  • Output shapes and spatial preservation
  • Variable batch sizes
  • Both skip connection paths (identity and 1×1 projection)
  • dtype correctness

All 17 pass.

Next

Next PR will assemble these blocks into the full U-Net encoder/decoder stack.

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