Commit 6025c81
Fix crash when accumulated_gradient_step_counts is None during refinement (openvdb#281)
## Summary
- Add defensive None guard in `_compute_insertion_masks` to handle the
case where gradient accumulation tensors are `None` (e.g., when using
the Unscented Transform projection path for OpenCV camera models)
- Add regression test that reproduces the exact `AttributeError` from
issue openvdb#279
## Root Cause
When COLMAP datasets use non-pinhole camera models (SIMPLE_RADIAL,
RADIAL, OPENCV), fvdb maps them to `CameraModel.OPENCV_RADTAN_5`, which
forces the UT projection path in fvdb-core. The UT path does not
initialize `accumulated_gradient_step_counts` or
`accumulated_mean_2d_gradient_norms`, leaving them as `None`. At the
first refinement step, `_compute_insertion_masks()` crashes calling
`.clamp_min(1)` on `None`.
The companion fvdb-core fix is at harrism/fvdb-core#1 — these two fixes
are independent and can be merged in any order.
## Behavioral impact
When the UT projection path is used, no Gaussians will be duplicated or
split during refinement (since no gradient data is available to make
that decision). Deletion still works. Training converges, just without
adaptive densification — a reasonable degradation until fvdb-core adds
gradient accumulation to the UT kernel.
Closes openvdb#279
## Test plan
- [x] New test `test_refinement_with_none_gradient_accumulation`
reproduces the crash (red before fix, green after)
- [x] All 9 optimizer tests pass with zero regressions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Mark Harris <mharris@nvidia.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent c6d56fc commit 6025c81
2 files changed
Lines changed: 50 additions & 0 deletions
File tree
- fvdb_reality_capture/radiance_fields
- tests/unit
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
835 | 835 | | |
836 | 836 | | |
837 | 837 | | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
838 | 859 | | |
839 | 860 | | |
840 | 861 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
119 | 148 | | |
120 | 149 | | |
121 | 150 | | |
| |||
0 commit comments