已合并
feat: 3DGS densification (DefaultStrategy) #14
feat: 3DGS densification (DefaultStrategy) #14
已合并
xieyajun创建于 24 天前
xieyajun成员
24 天前

当前PR是否有AI参与:

[x] 否

[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :

PR功能描述 / 为什么需要这个合入**:

为 3DGS 训练流程引入 稠密化策略(Densification) 持,基于 gsplat 官方 DefaultStrategy 实现。

稠密化(Densification)

  • 新增 gsplat/strategy 模块:DefaultStrategyops(duplicate/remove/split/reset_opa)
  • 在训练循环中集成 step_pre_backward(retain_grad)+ step_post_backward(refine)
  • 通过 proj_filter(packed visibility bitfield)将 COMPACTED means2d/grad 映射回原始 gaussian id,修正梯度归因
  • Config 新增 densify/prune_opa/grow_grad2d/refine_*/reset_every 参数

该PR关联的issue

希望检视人员了解:

改动类型 / Change Type

测试信息 / Testing

UT:全 10 个算子测试套件通过(含 projection 返回 proj_filter 的解包适配、rasterization 15 tests)
端到端:bicycle 30k 步稠密化训练,duplicate/split/prune/reset 四种操作均正常
精度:PSNR 24.793(+2.2 vs master),SSIM 0.7227(+0.18 vs master),LPIPS 0.224(-0.30 vs master)

检查清单 / Checklist

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 xieyajun 的贡献)
Xxieyajun成员
24 天前 创建了 pull request,commit f2a6f6b6
atomgit-bot
atomgit-bot
24 天前 评论:

变更摘要

本PR为3DGS训练流程引入基于gsplat官方DefaultStrategy的稠密化(Densification)策略,新增gsplat/strategy模块实现高斯体的复制/分裂/剔除/透明度重置四种核心操作,并在训练循环中通过proj_filter(packed visibility bitfield)将compacted空间下的梯度正确映射回原始高斯ID,从而修正梯度归因。同时扩展了Config配置与训练Runner以集成稠密化调度。

主要改动

  • 新增 gsplat/strategy 模块:添加Strategy基类(base.py)与DefaultStrategy实现(default.py),包含step_pre_backward/step_post_backward回调接口,以及_grow_gs_prune_gs_update_state等内建逻辑,支持AbsGS绝对梯度、屏幕空间剪枝、硬上限cap_max等控制参数。
  • 新增稠密化原子操作ops.py:提供duplicatesplitremovereset_opa四个函数,通过_update_param_with_optimizer统一处理参数与优化器状态的同步更新(含optimizer state的迁移),split支持revised_opacity启发式。
  • 投影算子返回proj_filter:修改gauss_splat/ops/projection_three_dims_gaussian_fused.py的forward/backward签名,额外输出proj_filter(packed bitfield),使得rendering.py中的Rasterizer能将可见性信息传递给稠密化策略,解决compacted梯度归因错误。
  • 训练Runner集成稠密化:在examples/rasterization/runner.py中初始化DefaultStrategy,训练循环内对means2d执行retain_grad,并在loss.backward()后调用step_post_backward完成稠密化refine;新增_to_CN2辅助函数做张量形状适配。
  • Config新增稠密化参数examples/rasterization/config.py新增densifyprune_opagrow_grad2drefine_start_iterrefine_stop_iterrefine_everyreset_every等字段,控制稠密化启停与调度周期。
likedislike
atomgit-bot
atomgit-bot
24 天前 评论:

代码审查

现在我已审查完所有 12 个文件。以下是最终总结:

审查总结

各文件审查结果

文件 结果
examples/gsplat/__init__.py 无问题(空白 __init__.py
examples/gsplat/strategy/__init__.py 无问题
examples/gsplat/strategy/base.py P3: 错误信息拼写 "cooresponds" → "corresponds"
examples/gsplat/strategy/default.py P3: grow_grad2d docstring 默认值与代码不一致(0.0002 vs 0.0008)
examples/gsplat/strategy/ops.py P3: reset_opa 中不必要的 tensor 创建
examples/gsplat/utils.py P3: normalized_quat_to_rotmat 内冗余的局部 import torch
examples/rasterization/config.py 无问题
examples/rasterization/runner.py 无问题(_to_CN2 + densification 集成逻辑正确;经核实 radius_culling 为 4D [B,C,nnz,2] 张量,_to_CN2 可正确处理)
gauss_splat/ops/projection_three_dims_gaussian_fused.py 无问题(forward/backward 均正确新增 proj_filter 返回值)
gauss_splat/ops/rendering.py 无问题(meta dict 新增 proj_filter/n_gaussians 字段)
tests/test_projection_3dgs_forward.py 无问题(适配新的 9 元组解包)
tests/test_rasterization.py 无问题(适配新的 9 元组解包)

按优先级统计

  • P0: 0
  • P1: 0
  • P2: 0
  • P3: 4(均为可选改进项)

整体风险评估

低风险。 核心 densification 逻辑(DefaultStrategyduplicate/split/remove/reset_opa 算子、proj_filter 梯度归因、_to_CN2 形状归一化)经过仔细审查,在正确性上没有问题。RADIUS_CULLING_DIM = 2(来自 C++ kernel 常量)证实 radii 为 4D 张量 [B,C,nnz,2]_to_CN2 可正确处理所有 C 值。4 个 P3 发现均为低影响的文档/代码清理项,不阻塞合入。

类型 数量
🔴 阻塞 1
🟡 建议 1

⛔ 需要修改

likedislike
CANN-robotCANN-robot成员
24 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
24 天前 评论:

CLA Signature Pass

xieyajun, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
此处折叠了45条消息 查看更多
wenming311成员
4 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
4 天前 添加了label:lgtm
CANN-robot
CANN-robot成员
4 天前 评论:

The MR can not be merged, because of CodeReview discussion not resolved

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
Xxieyajun成员
4 天前 解决了最后一个问题
CANN-robotCANN-robot成员
4 天前 合入了pull request