Fix batched Gaussian state accumulation - #1051
Open
tandede wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
DefaultStrategystate accumulation when non-packed rasterization outputs include leading batch dimensions.For the original
[C, N]visibility mask,torch.where(sel)[1]identifies the Gaussian dimension. With batched inputs, however, the mask is shaped[..., C, N], so coordinate 1 can be a batch or camera coordinate instead. Gradients and visibility counts are consequently accumulated into the wrong Gaussians without raising an error.Approach
Use the last coordinate returned by
torch.where(sel)as the Gaussian ID. The final mask dimension is alwaysN, independent of the number of leading batch and camera dimensions.The existing masked gradient and radius selection remains unchanged, so every visible batch-camera observation continues to contribute independently to the accumulated gradient and visibility count. The observations are not collapsed across batches because doing so would change the averaging semantics used by the densification strategy.
Regression coverage
Add a CPU regression with:
Before the fix, the strategy assigns observations according to camera coordinates, producing counts
[2, 2, 0]and accumulated gradients[8, 12, 0]. With the fix, observations are assigned by Gaussian index, producing the expected counts[2, 1, 1]and gradients[10, 4, 6].Test results
pytest -q tests/test_strategy.py: 2 passed, 2 skippedpytest -q tests: 539 passed, 342 skippedblack --check --diff --required-version 22.3.0 gsplat/strategy/default.py tests/test_strategy.pygit diff --checkThe skipped tests require CUDA or native CUDA kernels and are unrelated to this CPU state-accumulation path.
Fixes #854