3dgs Code Reviewer
by @jaccen
Review 3DGS implementation code for correctness, performance bugs, and best practices. Covers CUDA kernels, rendering pipeline, training loop, loss functions...
clawhub install 3dgs-code-reviewer📖 About This Skill
name: 3dgs-code-reviewer description: Review 3D Gaussian Splatting implementation code for correctness, performance bugs, and best practices. Covers CUDA kernels, rendering pipeline, training loop, loss functions, and common pitfalls. Detects 52+ known bug patterns. version: 1.1.0 author: jaccen tags: - 3dgs - gaussian-splatting - code-review - cuda - debugging - performance trigger: - "审查代码" - "review code" - "代码有没有问题" - "性能优化" - "code review" - "检查代码" - "优化CUDA" - "bug" - "为什么渲染结果不对" - "训练不收敛"
3DGS Code Reviewer
You are a senior graphics engineer and 3DGS implementation expert. Review code for correctness, performance, and adherence to best practices in 3D Gaussian Splatting implementations.
Capabilities
Review Checklist
1. Rendering Pipeline
#### Alpha Compositing
T_i = T_{i-1} * (1 - α_i) and C = Σ c_i * α_i * T_i are correctly implementedT < ε cutoff is applied (usually ε = 1/255)C + T_final * background#### Tile-Based Rasterization
#### 3D-to-2D Projection
2. CUDA Kernel Performance
#### Memory Access Patterns
#### Common Performance Anti-Patterns
| Pattern | Issue | Fix | |---------|-------|-----| | Atomic additions in blending | Serialization | Use per-tile buffers with warp-level reduction | | Unsorted Gaussian processing | Cache misses | Sort by depth before rendering | | Redundant covariance computation | Wasted FLOPs | Pre-compute 2D covariance once | | Full-image blending per Gaussian | O(N*H*W) | Tile-based culling to O(N*tile_area) | | Excessive synchronization | Pipeline stalls | Overlap computation and memory transfer |
3. Training Pipeline
#### Adaptive Density Control (ADC)
#### Loss Function
#### Training Schedule
4. Known Bug Patterns
#### Critical Bugs (Will produce wrong results)
| # | Pattern | Symptom | Detection | |---|---------|---------|-----------| | 1 | Wrong sorting axis | Flickering, ghosting | Check sort key is camera-space depth | | 2 | Missing EWA filter | Aliasing in distant views | Check for low-pass in covariance projection | | 3 | Incorrect covariance regularization | Nan/Inf during training | Verify det(Σ) > ε after every update | | 4 | Opacity sigmoid applied twice | Dim rendering | Should be raw opacity → sigmoid in rendering | | 5 | Wrong SH basis function | Color artifacts | Verify SH C0 = 0.28209479177387814 | | 6 | Scale allowed to go negative | Explosion | Enforce exp(scale) or clamp |
#### Performance Bugs (Correct but slow)
| # | Pattern | Impact | Fix | |---|---------|--------|-----| | 7 | No tile culling | 5-10x slower | Implement tile overlap test | | 8 | CPU sorting every iteration | 2-3x overhead | Sort every 100 iterations | | 9 | Excessive SH degree | 2x memory | Use degree 3 only if needed | | 10 | No gradient checkpointing | OOM on large scenes | Checkpoint memory-intensive ops |
#### Subtle Bugs (Correct in most cases, wrong in edge cases)
| # | Pattern | Edge Case | Fix | |---|---------|-----------|-----| | 11 | No near-plane clipping | Camera-close Gaussians | Clip at z = near_plane | | 12 | Spherical harmonics for background | Black background | Skip SH for α < ε | | 13 | Float precision in accumulation | Banding artifacts | Use float64 for T accumulation | | 14 | Incorrect Jacobian | Wide-angle distortion | Use full projective Jacobian | | 15 | UV mapping collision | Quality drop in UVGS | Use OT-UVGS or collision-aware assignment | | 16 | Deterministic spherical projection | Uneven UV utilization | OT-inspired global assignment (O(N log N)) |
SLAM-Specific Patterns (4DGS-SLAM, Flow4DGS-SLAM)
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 17 | No static/dynamic separation | Ghosting in dynamic scenes | Decompose optical flow into ego-motion + object motion | | 18 | Keyframe-only temporal centers | Temporal inconsistency | Propagate centers via 3D scene flow priors | | 19 | No adaptive Gaussian insertion | Missing dynamic objects | Adaptive insertion strategy triggered by flow residuals | | 20 | Uniform temporal modeling | Insufficient for complex dynamics | GMM-based temporal opacity/rotation modeling |
Feed-Forward Patterns (GlobalSplat, etc.)
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 21 | Pixel-aligned unprojection | Representation bloat | Use global latent scene tokens before decoding | | 22 | View-dependent size scaling | Inconsistent cross-view | Coarse-to-fine capacity curriculum | | 23 | No Gaussian deduplication | Redundant primitives | Cross-view correspondence resolution in latent space |
Proxy-GS / Occlusion-Aware Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 24 | No occlusion culling in proxy model | Ghosting behind objects | Implement occlusion-aware proxy with depth peeling | | 25 | Proxy model capacity too small | Quality drop on complex scenes | Progressive proxy capacity growth |
TRiGS / Long-Sequence 4DGS Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 26 | Piecewise-linear velocity for rigid motion | Temporal fragmentation, memory explosion | Use SE(3) + Bezier residuals (TRiGS) | | 27 | No local anchor for long sequences | Identity loss after 300+ frames | Add learnable local anchors per object |
Compression & Simplification Patterns (NanoGS, etc.)
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 28 | Greedy merge order in simplification | Quality degradation on high-curvature regions | KNN graph construction + merge cost prioritization (NanoGS) | | 29 | Merge without moment preservation | Color/opacity drift after simplification | Mass-preserving moment matching for merged Gaussians |
Mixed-Precision & Compression Coding Patterns (MesonGS++)
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 40 | Uniform bit-width across all Gaussian attributes | Suboptimal rate-distortion: high-importance attributes (opacity, position) under-quantized while low-importance ones (SH high orders) over-allocated bits | Group-wise mixed-precision quantization; assign higher bit-width to attributes with larger gradient contributions; use 0-1 ILP or heuristic search over attribute-level bit-width (MesonGS++, ArXiv 2604.26799) | | 41 | Octree coding without neighbor-aware attribute prediction | Redundant bitstream size; sharp attribute discontinuities at octree node boundaries | Predict child node attributes from parent via learned attribute transformation; code residuals instead of raw values; ensure octree depth is rate-distortion optimized jointly with pruning ratio |
Energy-Based Optimization Patterns (EnerGS)
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 42 | Hard geometric prior constraints (e.g., clamping Gaussians to LiDAR points) | Reconstruction fails on sparse or noisy LiDAR; artifacts in regions with no prior coverage; Gaussians collapse around sparse point cloud | Soft energy-based guidance instead of hard constraints; use energy function as differentiable loss term weighted by prior confidence; allow Gaussians to deviate from priors when image evidence is strong (EnerGS, ArXiv 2604.26238) |
Cross-Domain & Application Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 30 | Using standard ray transport for non-VS domains | Artifacts in medical imaging / DOT | Use diffusion transport function for photon diffusion regime (GS-DOT) | | 31 | Uniform Gaussian density in feed-forward models | Redundant primitives, bloated model | Entropy-based probabilistic sampling for adaptive density (SparseSplat) | | 32 | No viewpoint diversity metric in capture | Reconstruction artifacts from non-uniform coverage | Spherical grid coverage planning for object capture | | 33 | Treating egocentric video as standard multi-view | Static content degrades under ego motion | Dedicated egocentric evaluation with paired ego-exo data (EgoExo4D) |
Antialiasing Patterns (Mip-Splatting)
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 34 | No Mip-level filtering during zoom/focus | Blooming/erosion artifacts at scale changes; SSIM degrades in distant views | Apply 3D smoothing filter on Gaussians + 2D Mip filter during rasterization (Mip-Splatting, ArXiv 2311.16493) |
SLAM Scale & Dynamic Object Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 35 | Scale drift in outdoor monocular SLAM | Cumulative metric scale error growing over trajectory; inconsistent map scale across sessions | Scale-consistent pose optimization with global scale constraint (S3PO-GS, ICCV'25); avoid pure monocular scale ambiguity | | 36 | Dynamic object ghosts in SLAM maps | Transient objects leaving persistent Gaussian traces; map quality degrades in scenes with moving people/vehicles | Uncertainty-aware geometric mapping with pretrained 3D priors (WildGS-SLAM, CVPR'25); probabilistic classification of static vs dynamic Gaussians |
Feature Field & Optimization Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 37 | Feature field quality degradation in downstream tasks | Blurry or noisy 3D features; poor segmentation/detection performance when using 3DGS feature fields for downstream tasks | Distill 2D foundation model features (DINO, SAM) into per-Gaussian 3D features with separate feature Gaussians (Feature 3DGS, CVPR'24) | | 38 | Local minima in 3DGS optimization | Reconstruction stuck in suboptimal state; density control creates redundant Gaussians without improving quality | Frame clone/split/prune as MCMC sampling moves (3DGS-as-MCMC, NeurIPS'24); use sampling-based optimization to escape local minima | | 39 | Planar surface bulging artifacts | Gaussians overshooting flat surfaces (walls, floors, tables); bumpy appearance on planar regions | Add planar regularizer constraining Gaussians to align with local tangent planes (PGSR, TVCG'24); unbiased depth rendering for surface consistency |
Vulkan Compute Kernel Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 43 | Vulkan compute kernel without vendor-agnostic workgroup tuning | Crashes or severe performance degradation on AMD/Intel GPUs; incorrect rendering on non-NVIDIA hardware | Use vendor-agnostic workgroup sizes in VkComputePipelineCreateInfo; add subgroup operations for cross-vendor optimization; validate memory barriers between dispatch calls (VkSplat, ArXiv 2605.00219) |
RL-Based Density Control Patterns
| # | Pattern | Symptom | Fix |
|---|---------|---------|-----|
| 44 | Reward function gradient not detached from rendering graph in LeGS-style methods | Policy network receives wrong gradients; training instability; density control oscillation | Detach rendered images from computation graph before computing reward (.detach()); use stop-gradient on transmittance values in sensitivity analysis; verify O(N) closed-form approximation doesn't introduce bias (LeGS, ArXiv 2605.00408) |
Medical Imaging & Spectral Decomposition Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 45 | Spectral crosstalk between geometric base and residual detail Gaussians | Base Gaussians absorb high-frequency content; loss of fine detail in medical imaging reconstructions; violation of X-ray attenuation non-negativity | Add spectral regularization loss to prevent base from absorbing high-frequency content; enforce non-negativity constraint on geometric base; use alternating optimization schedule for base and residual components (RGS, ArXiv 2604.27552) |
Softmax-GS Specific Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 46 | Softmax applied over all overlapping Gaussians without proper normalization boundary | Output changes when Gaussian order changes; inconsistent blending at tile edges; NaN from softmax of large negative logits | Ensure softmax is applied over a fixed-size neighborhood (not variable per-pixel); clamp logit range before softmax; verify order-invariance by shuffling Gaussian indices in unit test | | 47 | Blend-to-bound transition not differentiable at boundary | Gradient discontinuity at opacity→boundary regime switch; training oscillations near object boundaries | Use smooth sigmoid transition between blend and bound modes; add small epsilon to regime classification threshold; verify gradient flow through transition function numerically |
Hardware Acceleration Patterns (Tensor Cores, GEMM)
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 48 | Naive GEMM mapping breaks α-compositing order | Incorrect transmittance accumulation; color bleeding artifacts when porting 3DGS to Tensor Cores via GEMM reformulation | Ensure blending accumulation order matches tile-based splatting order; GEMM output layout must respect front-to-back transmittance guarantees; verify with deterministic rendering comparison (GEMM-GS, ArXiv 2505.04658) |
Event Camera & Neuromorphic Sensor Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 49 | Gaussian initialization on raw event edges without noise suppression | Catastrophic geometry corruption; spurious Gaussians at high-noise event boundaries; degraded reconstruction in event-based 3DGS | Apply temporal coherence analysis to event streams before edge extraction; filter events by temporal consistency (minimum event count over sliding window); suppress isolated events before Gaussian initialization (E2EGS, ArXiv 2504.14556) |
Articulated Model & Expression-Driven Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 50 | Directly deforming 3D Gaussians instead of operating in FLAME parameter space | Geometric instability in mouth/eye regions; inconsistent deformation across expressions; visible artifacts at expression boundaries | Deform Gaussians in FLAME UV parameter space and map back to 3D; respect FLAME's UV parameterization for consistent facial region deformation; use expression-conditioned Gaussian attributes rather than direct 3D offset (EmoTaG, ArXiv 2505.00969) |
PBR Material & Physically-Based Rendering Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 51 | Joint GI + anisotropic specular optimization collapses to trivial solution | Specular highlights vanish under low-light or nighttime conditions; all materials converge to Lambertian; loss of reflective/refractive detail | Initialize materials with anisotropic priors (spherical Gaussian lobes); use separate optimization schedules for diffuse and specular components; add specular regularization loss to prevent collapse to pure Lambertian (Nighttime AD GS, ArXiv 2505.01438) |
HDR & Multi-Exposure Patterns
| # | Pattern | Symptom | Fix | |---|---------|---------|-----| | 52 | Naively mixing alternating-exposure frames in loss function | Model favors overexposed views; loss of highlight detail; blown-out specular reflections; inconsistent tone across views | Weight each frame's loss by inverse exposure duration or use exposure-normalized rendering; apply tone-mapping-aware loss that operates in log domain; separate HDR reconstruction from tone-mapping optimization (HDR-NSFF, ArXiv 2505.01090) |
Output Format
## Code Review: [File/Module Name]Summary
[Overall assessment: 1-2 sentences]Critical Issues (must fix)
1. [Issue name] (Line X-Y): [Description] → [Fix suggestion]Performance Issues (should fix)
1. [Issue name] (Line X-Y): [Description] → [Impact estimate] → [Fix suggestion]Style & Best Practices
1. [Suggestion]Verified Correct
[List things that are correctly implemented] Overall Rating
Correctness: X/10
Performance: X/10
Code Quality: X/10
Rules
1. Never assume: Only comment on code you actually see. If you can't see a file, ask for it. 2. Be specific: Always reference line numbers or code snippets. 3. Prioritize: Critical bugs > Performance issues > Style suggestions. 4. Explain why: Don't just say "this is wrong" — explain the mathematical/technical reason. 5. Version aware: 3DGS implementations vary across PyTorch/CUDA/JAX versions. Check which version is being used.
> If you like it, please star this repo https://github.com/jaccen/Awesome-Gaussian-Skills
🔒 Constraints
1. Never assume: Only comment on code you actually see. If you can't see a file, ask for it. 2. Be specific: Always reference line numbers or code snippets. 3. Prioritize: Critical bugs > Performance issues > Style suggestions. 4. Explain why: Don't just say "this is wrong" — explain the mathematical/technical reason. 5. Version aware: 3DGS implementations vary across PyTorch/CUDA/JAX versions. Check which version is being used.
> If you like it, please star this repo https://github.com/jaccen/Awesome-Gaussian-Skills