Skip to content

SimpleUnet bug fixes#496

Merged
swahtz merged 4 commits into
openvdb:mainfrom
swahtz:simple_unet_fixes
Mar 4, 2026
Merged

SimpleUnet bug fixes#496
swahtz merged 4 commits into
openvdb:mainfrom
swahtz:simple_unet_fixes

Conversation

@swahtz

@swahtz swahtz commented Mar 4, 2026

Copy link
Copy Markdown
Contributor
  • Use fvnn.MaxPool in SimpleUNetDown to handle -inf cleanup after max_pool instead of repeating the code in SimpleUNetDown, preventing NaN propagation into BatchNorm
  • Fix 1x1 ConvolutionPlan source/target grids in SimpleUNetDown and SimpleUNetUp to match the grid the data actually resides on
  • Remove unused imports
  • Fix non-contiguous grad_output crash in convolution_plan.py by calling .contiguous() before passing to the C++ transpose convolution backward kernel.

Add tests/unit/test_simple_unet.py with smoke tests covering forward pass, backward pass, batched grids, single-layer UNet, and reset_parameters.

  max_pool, preventing NaN propagation into BatchNorm
- Fix 1x1 ConvolutionPlan source/target grids in SimpleUNetDown and
  SimpleUNetUp to match the grid the data actually resides on
- Remove unused imports

Fix non-contiguous grad_output crash in convolution_plan.py by calling
.contiguous() before passing to the C++ transpose convolution backward
kernel.

Add tests/unit/test_simple_unet.py with smoke tests covering forward
pass, backward pass, batched grids, single-layer UNet, and
reset_parameters.

Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
@swahtz swahtz added this to the v0.2 milestone Mar 4, 2026
@swahtz swahtz requested a review from a team as a code owner March 4, 2026 07:43
@swahtz swahtz added the bug Something isn't working label Mar 4, 2026
@swahtz swahtz requested review from blackencino and harrism March 4, 2026 07:43
@swahtz swahtz added the core library Core fVDB library. i.e. anything in the _Cpp module (C++) or fvdb python module label Mar 4, 2026
Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes several bugs in the SimpleUNet implementation and adds test coverage for it. The bugs include NaN propagation via -inf values post max-pooling entering BatchNorm, incorrect ConvolutionPlan source/target grid assignments in SimpleUNetDown and SimpleUNetUp, and a crash on non-contiguous grad_output in the convolution backward kernel. It also removes unused imports.

Changes:

  • fvdb/convolution_plan.py: Added .contiguous() call on grad_output before passing it to both the regular and transposed C++ convolution backward kernels, fixing a crash on non-contiguous gradient tensors.
  • fvdb/nn/simple_unet.py: Replaced GridBatch.max_pool with fvnn.MaxPool in SimpleUNetDown (which includes -inf cleanup), fixed ConvolutionPlan source/target grid arguments in both SimpleUNetDown and SimpleUNetUp to match the grid where data actually resides after pooling, and removed several unused imports.
  • tests/unit/test_simple_unet.py: New test file with smoke tests covering forward pass, backward pass, batched grids, single-layer UNet, and reset_parameters.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
fvdb/convolution_plan.py Adds .contiguous() to grad_output in the backward pass to fix crashes with non-contiguous gradient tensors
fvdb/nn/simple_unet.py Uses fvnn.MaxPool for -inf cleanup, fixes ConvolutionPlan grid arguments, and removes unused imports
tests/unit/test_simple_unet.py New smoke/integration tests for SimpleUNet covering key behaviors

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread tests/unit/test_simple_unet.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>

@harrism harrism left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to have this fixed and tested.

@swahtz swahtz merged commit 1b600c8 into openvdb:main Mar 4, 2026
43 of 44 checks passed
@swahtz swahtz deleted the simple_unet_fixes branch March 4, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core library Core fVDB library. i.e. anything in the _Cpp module (C++) or fvdb python module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants