Skip to content

API inconsistency: ProjectGaussians uses log_scales while ProjectGaussiansJagged uses scales #442

@harrism

Description

@harrism

Summary

There is an API inconsistency between the two Gaussian projection paths:

  • ProjectGaussians (non-jagged): Takes logScales as input and returns dL/d(log_scale) gradients in the backward pass
  • ProjectGaussiansJagged (jagged, via gaussian_render_jagged): Takes raw scales as input and returns dL/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 uses mLogScales
  • The jagged gaussian_render_jagged() API accepts raw scales (what the user passes), which then flows through to ProjectGaussiansJagged

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:

  1. Make the API consistent with the internal representation (mLogScales)
  2. Simplify the gradient computation code by removing the template parameter workaround
  3. 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 workaround
  • src/fvdb/detail/ops/gsplat/GaussianProjectionBackward.cu - Uses ApplyLogScaleChainRule=true
  • src/fvdb/detail/ops/gsplat/GaussianProjectionJaggedBackward.cu - Uses ApplyLogScaleChainRule=false
  • src/fvdb/detail/autograd/GaussianProjection.cpp - Autograd definitions
  • src/fvdb/GaussianSplat3d.cpp - gaussianRenderJagged function
  • fvdb/__init__.py - Python wrapper for gaussian_render_jagged

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions