-
Notifications
You must be signed in to change notification settings - Fork 19
API inconsistency: ProjectGaussians uses log_scales while ProjectGaussiansJagged uses scales #442
Copy link
Copy link
Open
Description
Summary
There is an API inconsistency between the two Gaussian projection paths:
ProjectGaussians(non-jagged): TakeslogScalesas input and returnsdL/d(log_scale)gradients in the backward passProjectGaussiansJagged(jagged, viagaussian_render_jagged): Takes rawscalesas input and returnsdL/d(scale)gradients in the backward pass
Background
This divergence was discovered while fixing PR #433 (chain rule for log_scale gradient). The GaussianSplat3d class internally stores mLogScales, and the scales() accessor returns exp(mLogScales). However:
- The non-jagged
ProjectGaussians::forward()directly usesmLogScales - The jagged
gaussian_render_jagged()API accepts rawscales(what the user passes), which then flows through toProjectGaussiansJagged
Current Workaround
To handle this divergence, PR #433 added a template parameter ApplyLogScaleChainRule to quaternionAndScaleToCovarianceVectorJacobianProduct:
template <typename T, bool ApplyLogScaleChainRule = true>
quaternionAndScaleToCovarianceVectorJacobianProduct(...) {
// ... compute dL/d(scale) ...
if constexpr (ApplyLogScaleChainRule) {
// Return dL/d(log_scale) = dL/d(scale) * scale
return {dLossDQuat, scale * dLossDScale};
} else {
// Return raw dL/d(scale)
return {dLossDQuat, dLossDScale};
}
}The regular backward uses ApplyLogScaleChainRule=true, while the jagged backward uses ApplyLogScaleChainRule=false.
Recommendation
Consider unifying the APIs in a future release by changing gaussian_render_jagged to accept log_scales instead of scales. This would:
- Make the API consistent with the internal representation (
mLogScales) - Simplify the gradient computation code by removing the template parameter workaround
- Match the pattern used by the non-jagged projection path
Note: This would be a breaking API change for users of gaussian_render_jagged.
Affected Files
src/fvdb/detail/ops/gsplat/GaussianUtils.cuh- Contains the workaroundsrc/fvdb/detail/ops/gsplat/GaussianProjectionBackward.cu- UsesApplyLogScaleChainRule=truesrc/fvdb/detail/ops/gsplat/GaussianProjectionJaggedBackward.cu- UsesApplyLogScaleChainRule=falsesrc/fvdb/detail/autograd/GaussianProjection.cpp- Autograd definitionssrc/fvdb/GaussianSplat3d.cpp-gaussianRenderJaggedfunctionfvdb/__init__.py- Python wrapper forgaussian_render_jagged
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels