gsplat 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +202 -0
  3. data/README.md +236 -0
  4. data/docs/ACCEPTANCE.md +60 -0
  5. data/docs/BENCHMARKS.md +79 -0
  6. data/docs/DECISIONS.md +52 -0
  7. data/docs/MIGRATION.md +117 -0
  8. data/docs/PROFILE.md +75 -0
  9. data/docs/PROGRESS.md +199 -0
  10. data/docs/decisions/0000-template.md +17 -0
  11. data/docs/decisions/0001-pin-golden-reference-and-cpu-validation.md +27 -0
  12. data/docs/decisions/0002-retain-ruby-fallbacks-for-native-backend.md +26 -0
  13. data/docs/decisions/0003-share-projection-for-distorted-cameras.md +26 -0
  14. data/docs/decisions/0004-use-portable-world-space-reference-paths.md +26 -0
  15. data/docs/decisions/0005-reuse-ewa-core-for-2dgs.md +24 -0
  16. data/docs/decisions/0006-keep-eval3d-as-portable-reference.md +25 -0
  17. data/docs/decisions/0007-share-compositor-semantics-for-contribution-indices.md +25 -0
  18. data/examples/data/README.md +14 -0
  19. data/examples/data/colmap/images/view_000.png +0 -0
  20. data/examples/data/colmap/images/view_001.png +0 -0
  21. data/examples/data/colmap/images/view_002.png +0 -0
  22. data/examples/data/colmap/sparse/0/cameras.txt +2 -0
  23. data/examples/data/colmap/sparse/0/images.txt +6 -0
  24. data/examples/data/colmap/sparse/0/points3D.txt +17 -0
  25. data/examples/data/splats.ply +0 -0
  26. data/examples/fit_image.rb +35 -0
  27. data/examples/generate_sample_data.rb +147 -0
  28. data/examples/render_path.rb +117 -0
  29. data/examples/simple_trainer.rb +76 -0
  30. data/ext/gsplat_native/common.h +54 -0
  31. data/ext/gsplat_native/extconf.rb +39 -0
  32. data/ext/gsplat_native/gsplat_native.c +60 -0
  33. data/ext/gsplat_native/intersections.c +211 -0
  34. data/ext/gsplat_native/projection.c +199 -0
  35. data/ext/gsplat_native/raster_backward.c +129 -0
  36. data/ext/gsplat_native/raster_backward_bridge.c +69 -0
  37. data/ext/gsplat_native/raster_forward.c +150 -0
  38. data/ext/gsplat_native/rasterization.h +51 -0
  39. data/ext/gsplat_native/spherical_harmonics.c +129 -0
  40. data/gsplat.gemspec +36 -0
  41. data/lib/gsplat/autograd/context.rb +60 -0
  42. data/lib/gsplat/autograd/function.rb +68 -0
  43. data/lib/gsplat/autograd/variable.rb +159 -0
  44. data/lib/gsplat/backend/ruby/accumulate.rb +139 -0
  45. data/lib/gsplat/backend/ruby/accumulate_backward.rb +40 -0
  46. data/lib/gsplat/backend/ruby/eval3d_rasterizer.rb +175 -0
  47. data/lib/gsplat/backend/ruby/isect_tiles.rb +198 -0
  48. data/lib/gsplat/backend/ruby/projection.rb +251 -0
  49. data/lib/gsplat/backend/ruby/projection_backward.rb +190 -0
  50. data/lib/gsplat/backend/ruby/projection_covariance_vjp.rb +72 -0
  51. data/lib/gsplat/backend/ruby/projection_input_vjp.rb +252 -0
  52. data/lib/gsplat/backend/ruby/quat_scale_to_covar_preci.rb +139 -0
  53. data/lib/gsplat/backend/ruby/rasterize_to_indices_in_range.rb +121 -0
  54. data/lib/gsplat/backend/ruby/rasterize_to_pixels.rb +199 -0
  55. data/lib/gsplat/backend/ruby/rasterize_to_pixels_backward.rb +121 -0
  56. data/lib/gsplat/backend/ruby/spherical_harmonics.rb +135 -0
  57. data/lib/gsplat/backend/ruby/tile_compositor.rb +50 -0
  58. data/lib/gsplat/backend/ruby/tile_compositor_backward.rb +84 -0
  59. data/lib/gsplat/backend.rb +79 -0
  60. data/lib/gsplat/compression/grid_sort.rb +79 -0
  61. data/lib/gsplat/compression/kmeans.rb +121 -0
  62. data/lib/gsplat/compression/png.rb +147 -0
  63. data/lib/gsplat/compression/png_codec.rb +133 -0
  64. data/lib/gsplat/compression/quantizer.rb +79 -0
  65. data/lib/gsplat/io/checkpoint.rb +145 -0
  66. data/lib/gsplat/io/colmap.rb +175 -0
  67. data/lib/gsplat/io/colmap_binary.rb +98 -0
  68. data/lib/gsplat/io/colmap_text.rb +84 -0
  69. data/lib/gsplat/io/image.rb +63 -0
  70. data/lib/gsplat/io/image_backends.rb +81 -0
  71. data/lib/gsplat/io/npy.rb +189 -0
  72. data/lib/gsplat/io/ply.rb +185 -0
  73. data/lib/gsplat/io/ply_reader.rb +142 -0
  74. data/lib/gsplat/io/zip_archive.rb +183 -0
  75. data/lib/gsplat/math/camera_distortion.rb +123 -0
  76. data/lib/gsplat/math/camera_projection.rb +202 -0
  77. data/lib/gsplat/math/mat.rb +114 -0
  78. data/lib/gsplat/math/quaternion.rb +175 -0
  79. data/lib/gsplat/math/small_matrix_primitives.rb +112 -0
  80. data/lib/gsplat/math/spherical_harmonic_basis.rb +148 -0
  81. data/lib/gsplat/math/ssim.rb +153 -0
  82. data/lib/gsplat/native.rb +30 -0
  83. data/lib/gsplat/native_ops.rb +148 -0
  84. data/lib/gsplat/native_raster_ops.rb +76 -0
  85. data/lib/gsplat/ops/accumulate.rb +68 -0
  86. data/lib/gsplat/ops/eval3d_rasterize.rb +62 -0
  87. data/lib/gsplat/ops/isect_tiles.rb +38 -0
  88. data/lib/gsplat/ops/projection.rb +154 -0
  89. data/lib/gsplat/ops/quat_scale_to_covar_preci.rb +118 -0
  90. data/lib/gsplat/ops/rasterize_to_indices_in_range.rb +38 -0
  91. data/lib/gsplat/ops/rasterize_to_pixels.rb +105 -0
  92. data/lib/gsplat/ops/relocation.rb +94 -0
  93. data/lib/gsplat/ops/spherical_harmonics.rb +71 -0
  94. data/lib/gsplat/ops/tensor_shape_ops.rb +173 -0
  95. data/lib/gsplat/ops/tensor_value_ops.rb +150 -0
  96. data/lib/gsplat/optim/adam.rb +212 -0
  97. data/lib/gsplat/optim/lr_scheduler.rb +36 -0
  98. data/lib/gsplat/optim/selective_adam.rb +68 -0
  99. data/lib/gsplat/rasterization.rb +130 -0
  100. data/lib/gsplat/rasterization_2dgs.rb +140 -0
  101. data/lib/gsplat/rasterization_helpers.rb +162 -0
  102. data/lib/gsplat/rasterization_validation.rb +99 -0
  103. data/lib/gsplat/strategy/base.rb +49 -0
  104. data/lib/gsplat/strategy/default.rb +188 -0
  105. data/lib/gsplat/strategy/mcmc.rb +103 -0
  106. data/lib/gsplat/strategy/mcmc_ops.rb +143 -0
  107. data/lib/gsplat/strategy/ops.rb +165 -0
  108. data/lib/gsplat/training/config.rb +91 -0
  109. data/lib/gsplat/training/image_fitter.rb +158 -0
  110. data/lib/gsplat/training/losses.rb +191 -0
  111. data/lib/gsplat/training/scene.rb +116 -0
  112. data/lib/gsplat/training/trainer.rb +236 -0
  113. data/lib/gsplat/utils.rb +110 -0
  114. data/lib/gsplat/version.rb +6 -0
  115. data/lib/gsplat.rb +98 -0
  116. metadata +181 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 380bbee36a191ee5993fdbe80cc1f17004fe6093e097147fb6cb293014bb8f12
4
+ data.tar.gz: 379b3699938c1bab39047397b1a7ee8840a14a6f4e56ea29fd5c61d304f64497
5
+ SHA512:
6
+ metadata.gz: 6640f9ec52a5fd288ceb42bfb7c2a4a6a8f40090b50f109a2b586786fb6622a5789ebc51a34549c1239cec0cc27e46c29bc18da53e26c353f1b98fae6422a2fd
7
+ data.tar.gz: 2cd29f80081730b1692f06c64a4a86b384876b0a1a184a697df6879bf1da10c8e527474e7fcf12ff278f52e8e494ba191bb86660a8768c7e6dc01d11fd02836e
data/LICENSE.txt ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,236 @@
1
+ # Gsplat
2
+
3
+ [![CI](https://github.com/ydah/gsplat/actions/workflows/main.yml/badge.svg)](https://github.com/ydah/gsplat/actions/workflows/main.yml)
4
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE.txt)
5
+
6
+ Gsplat is a differentiable 3D Gaussian Splatting renderer and trainer for CRuby. It provides a
7
+ portable `Numo::NArray` implementation, an optional C/OpenMP fast path, reverse-mode automatic
8
+ differentiation, and training and IO utilities modeled after Python
9
+ [`gsplat`](https://github.com/nerfstudio-project/gsplat).
10
+
11
+ Gsplat currently runs on CPU. It is intended for Ruby-native graphics pipelines, reference
12
+ implementations, inspection of the rendering equations, and small training jobs.
13
+
14
+ ## Features
15
+
16
+ - Differentiable dense 3D Gaussian projection and tiled alpha compositing.
17
+ - 3DGS and 2DGS APIs with RGB, arbitrary features, spherical harmonics, depth, and normals.
18
+ - Pinhole, orthographic, equidistant fisheye, and OpenCV-distorted cameras.
19
+ - Adam, SelectiveAdam, Default densification, MCMC strategy, and multi-view training.
20
+ - COLMAP, Inria PLY, NPY/NPZ checkpoints, image IO, and PNG parameter compression.
21
+ - Portable Ruby backend and native float32/OpenMP kernels with automatic fallback.
22
+
23
+ ## Installation
24
+
25
+ Add Gsplat to your application's `Gemfile`:
26
+
27
+ ```ruby
28
+ gem "gsplat"
29
+ ```
30
+
31
+ Then install dependencies:
32
+
33
+ ```bash
34
+ bundle install
35
+ ```
36
+
37
+ Or install the gem directly:
38
+
39
+ ```bash
40
+ gem install gsplat
41
+ ```
42
+
43
+ ### Requirements
44
+
45
+ - CRuby 3.2 or newer.
46
+ - A C compiler for `numo-narray` and the packaged native extension.
47
+ - OpenMP is optional and enables parallel native raster kernels.
48
+ - Image loading and writing require either `ruby-vips` (recommended) or `chunky_png`.
49
+
50
+ The source checkout includes `chunky_png` for its runnable examples. JRuby and TruffleRuby are not
51
+ release targets.
52
+
53
+ ### Backend selection
54
+
55
+ The default `:auto` backend uses the native extension when it is available and otherwise falls back
56
+ to Ruby with a one-time warning.
57
+
58
+ ```ruby
59
+ Gsplat.backend = :auto
60
+ Gsplat.backend = :ruby
61
+ Gsplat.backend = :native
62
+ ```
63
+
64
+ The same selection can be made with `GSPLAT_BACKEND=auto|ruby|native`. Use `Numo::SFloat` for native
65
+ kernels. `Numo::DFloat` is supported for numerical checks and uses the Ruby formulas where needed.
66
+
67
+ ## Usage
68
+
69
+ ### Quick start
70
+
71
+ The following complete example renders one Gaussian and differentiates the image with respect to
72
+ its color.
73
+
74
+ <!-- quickstart:start -->
75
+ ```ruby
76
+ require "gsplat"
77
+
78
+ f = Numo::SFloat
79
+ colors = Gsplat::Autograd::Variable.new(f[[1.0, 0.2, 0.1]], requires_grad: true)
80
+
81
+ rendered, alphas, meta = Gsplat.rasterization(
82
+ means: f[[0.0, 0.0, 2.0]],
83
+ quats: f[[1.0, 0.0, 0.0, 0.0]], # wxyz
84
+ scales: f[[0.25, 0.25, 0.25]],
85
+ opacities: f[0.8], # activated opacity
86
+ colors: colors,
87
+ viewmats: f.eye(4).reshape(1, 4, 4),
88
+ ks: f[[[8.0, 0.0, 2.0], [0.0, 8.0, 2.0], [0.0, 0.0, 1.0]]],
89
+ width: 4,
90
+ height: 4
91
+ )
92
+
93
+ rendered.backward(f.ones(*rendered.data.shape))
94
+ p [rendered.data.shape, alphas.data.shape, meta.fetch(:radii).shape, colors.grad.shape]
95
+ ```
96
+ <!-- quickstart:end -->
97
+
98
+ Output:
99
+
100
+ ```text
101
+ [[1, 4, 4, 3], [1, 4, 4, 1], [1, 1, 2], [1, 3]]
102
+ ```
103
+
104
+ ### Data conventions
105
+
106
+ - Quaternions use `wxyz` order and are normalized when converted to rotations.
107
+ - `viewmats [C,4,4]` transform world coordinates into camera coordinates.
108
+ - Cameras look along positive Z; pixels are sampled at `(x + 0.5, y + 0.5)`.
109
+ - Rendering receives activated positive scales and 0–1 opacities.
110
+ - Colors are `[N,D]` or `[C,N,D]`. Spherical harmonic coefficients are `[N,K,D]`.
111
+ - Dense color outputs are `[C,H,W,D]`, alpha is `[C,H,W,1]`, and radii are `[C,N,2]`.
112
+ - An `Autograd::Variable` records a graph. Non-scalar outputs require an explicit backward gradient.
113
+
114
+ ### Image fitting
115
+
116
+ From a source checkout, run the deterministic image-fitting example:
117
+
118
+ ```bash
119
+ bundle exec ruby examples/fit_image.rb --gaussians 2000 --steps 300
120
+ ```
121
+
122
+ ### Runnable sample data
123
+
124
+ The repository includes a tiny synthetic COLMAP dataset and its matching Inria PLY, so the
125
+ multi-view examples run without downloading external data or supplying arguments:
126
+
127
+ ```bash
128
+ bundle exec ruby examples/simple_trainer.rb
129
+ bundle exec ruby examples/render_path.rb
130
+ ```
131
+
132
+ The trainer uses 10 steps and writes `results/sample/splats.ply`. The renderer creates 12 images in
133
+ `renders/sample/` from the bundled PLY. To render the newly trained PLY instead, pass
134
+ `--ply results/sample/splats.ply`. Rebuild the checked-in data at any time with:
135
+
136
+ ```bash
137
+ bundle exec ruby examples/generate_sample_data.rb
138
+ ```
139
+
140
+ ### Training a COLMAP capture
141
+
142
+ Prepare `sparse/0/{cameras,images,points3D}.bin` and an `images/` directory, then run:
143
+
144
+ ```bash
145
+ bundle exec ruby examples/simple_trainer.rb \
146
+ --data /path/to/capture \
147
+ --output results/capture \
148
+ --steps 30000 \
149
+ --data-factor 1
150
+ ```
151
+
152
+ Use `--strategy mcmc` for relocation-based densification. The trainer writes NPZ checkpoints and an
153
+ Inria-compatible `splats.ply`. Render an orbit from that PLY with:
154
+
155
+ ```bash
156
+ bundle exec ruby examples/render_path.rb \
157
+ --ply results/capture/splats.ply \
158
+ --output results/capture/path \
159
+ --frames 120
160
+ ```
161
+
162
+ ## API compatibility
163
+
164
+ | Python gsplat | Ruby |
165
+ |---|---|
166
+ | `gsplat.rasterization(...)` | `Gsplat.rasterization(...)` |
167
+ | `gsplat.rasterization_2dgs(...)` | `Gsplat.rasterization_2dgs(...)` |
168
+ | `gsplat.spherical_harmonics(...)` | `Gsplat.spherical_harmonics(...)` |
169
+ | `gsplat.quat_scale_to_covar_preci(...)` | `Gsplat.quat_scale_to_covar_preci(...)` |
170
+ | `gsplat.fully_fused_projection(...)` | `Gsplat.fully_fused_projection(...)` |
171
+ | `gsplat.isect_tiles(...)` | `Gsplat.isect_tiles(...)` |
172
+ | `gsplat.isect_offset_encode(...)` | `Gsplat.isect_offset_encode(...)` |
173
+ | `gsplat.rasterize_to_pixels(...)` | `Gsplat.rasterize_to_pixels(...)` |
174
+ | `gsplat.rasterize_to_indices_in_range(...)` | `Gsplat.rasterize_to_indices_in_range(...)` |
175
+ | `gsplat.strategy.DefaultStrategy` | `Gsplat::Strategy::Default` |
176
+ | `gsplat.strategy.MCMCStrategy` | `Gsplat::Strategy::MCMC` |
177
+ | `gsplat.compression.PngCompression` | `Gsplat::Compression::Png` |
178
+ | `torch.optim.Adam` | `Gsplat::Optim::Adam` |
179
+ | `examples/simple_trainer.py` | `Gsplat::Training::Trainer` / `examples/simple_trainer.rb` |
180
+
181
+ See [the migration guide](docs/MIGRATION.md) for differences in shapes, activation, autograd, and
182
+ training.
183
+
184
+ ## Limitations
185
+
186
+ - Rendering and training are CPU-only; CUDA/GPU execution is not implemented.
187
+ - Rendering is dense. Packed/sparse gradients and distributed rendering are not implemented.
188
+ - 2DGS auxiliary geometry is API-compatible but approximates the upstream ray-splat transform.
189
+ - Eval3d uses a shared Ruby reference implementation and a numerical geometry VJP.
190
+ - Complete upstream raster parity still requires the documented external CUDA golden-data run.
191
+
192
+ ## Documentation
193
+
194
+ - [Python migration guide](docs/MIGRATION.md)
195
+ - [Architecture Decision Records](docs/DECISIONS.md)
196
+ - [Benchmarks](docs/BENCHMARKS.md)
197
+ - [Acceptance status](docs/ACCEPTANCE.md)
198
+ - [Implementation progress](docs/PROGRESS.md)
199
+ - [Golden-data tooling](tools/README.md)
200
+
201
+ Generate the API reference locally with `bundle exec yard doc`.
202
+
203
+ ## Development
204
+
205
+ Clone the repository and install the development dependencies:
206
+
207
+ ```bash
208
+ git clone https://github.com/ydah/gsplat.git
209
+ cd gsplat
210
+ bundle install
211
+ bundle exec rake compile
212
+ ```
213
+
214
+ Run the validation suite:
215
+
216
+ ```bash
217
+ GSPLAT_BACKEND=ruby bundle exec rake test
218
+ OMP_NUM_THREADS=8 GSPLAT_BACKEND=native bundle exec rake test
219
+ bundle exec rubocop --no-server --cache false
220
+ bundle exec yard stats
221
+ gem build gsplat.gemspec
222
+ ```
223
+
224
+ Golden-data generation is pinned to Python gsplat 1.5.3. See
225
+ [`tools/README.md`](tools/README.md) for CPU and CUDA commands.
226
+
227
+ ## Contributing
228
+
229
+ Bug reports and pull requests are welcome on
230
+ [GitHub](https://github.com/ydah/gsplat). Keep behavior changes covered by tests. Changes that
231
+ establish or replace a long-lived architectural contract should include an
232
+ [ADR](docs/DECISIONS.md) created from the repository template.
233
+
234
+ ## License
235
+
236
+ Gsplat is available under the [Apache License 2.0](LICENSE.txt).
@@ -0,0 +1,60 @@
1
+ # Acceptance status
2
+
3
+ This report maps the design goals G1–G6 to reproducible evidence as of 2026-07-24. “Partial” means
4
+ the implementation and local tests exist but the exact external dataset/hardware gate has not run.
5
+
6
+ | Goal | Status | Evidence |
7
+ |---|---|---|
8
+ | G1: Python forward parity | Partial | 47-case pinned generator; analytic forward cases; reference compositor and backend-equivalence tests. CUDA-generated NPZ files are unavailable on this host, so their tests are documented skips. |
9
+ | G2: backward parity | Partial | Float64 central differences for covariance, SH, projection, rasterization, distortion, losses, and eval3d; tile-vs-reference VJPs. Python/CUDA gradient fixtures remain pending with G1. |
10
+ | G3: single-image convergence | Pass | `ImageFitterTest#test_self_consistency_fit_improves_psnr`: 11.772 → 30.878 dB in 20 monotonic reduced steps. The 50k/512²/2,000-step native timing also completes in 157.457 s. |
11
+ | G4: COLMAP training quality | Partial | Binary/text parser parity, 100-point fixture, actual fixture-based Trainer smoke path, and an eight-view synthetic Trainer reaching ≥28 dB in 80 steps. No Mip-NeRF 360/real-capture 30k quality run is available. |
12
+ | G5: compatible API surface | Pass within v1 scope | README mapping, migration guide, executable quick start, YARD 100%, low-level wrappers, strategies, optimizer, Trainer, IO, compression, 2DGS and eval3d surfaces. Unsupported upstream options are explicitly listed. |
13
+ | G6: Ruby-only completeness | Pass | Full suite passes with `GSPLAT_BACKEND=ruby`; the same full suite passes with explicit native selection. CI now builds the extension and runs both paths, while auto mode retains the Ruby fallback. |
14
+
15
+ ## Local verification
16
+
17
+ ```text
18
+ Ruby selection: 188 tests, 1,041 assertions, 0 failures, 22 documented skips
19
+ Native selection: 188 tests, 1,041 assertions, 0 failures, 22 documented skips
20
+ YARD: 129 methods, 125 attributes, 22 constants, undocumented 0
21
+ RuboCop: 132 files, no offenses
22
+ ```
23
+
24
+ ## Golden-data gate
25
+
26
+ `tools/generate_golden.py` is pinned to Python gsplat 1.5.3, uses seed 42, records provenance, and
27
+ caps compressed output at 50 MiB. The local host has no CUDA and a prior temporary PyTorch install
28
+ exceeded available disk. Consequently, tests calling `golden(...)` skip with a pointer to
29
+ `tools/README.md`; no Ruby-generated fixture is accepted as a replacement.
30
+
31
+ Run this on a compatible CUDA host to close G1/G2:
32
+
33
+ ```bash
34
+ python3 -m venv .venv-golden
35
+ .venv-golden/bin/pip install -r tools/requirements.txt
36
+ .venv-golden/bin/python tools/generate_golden.py --device cuda --require-all
37
+ bundle exec rake test
38
+ ```
39
+
40
+ ## CI matrix
41
+
42
+ `.github/workflows/main.yml` runs:
43
+
44
+ - RuboCop and the 100% YARD gate on Ruby 4.0.
45
+ - The full Ruby backend suite on CRuby 3.2, 3.3, 3.4, and 4.0.
46
+ - A native extension build and the full native suite on CRuby 4.0 with OpenMP workers.
47
+ - Focused image-fit, multi-view Trainer, and all-example smoke tests.
48
+
49
+ The same workflow runs on pushes, pull requests, manual dispatch, and a weekly scheduled trigger.
50
+ Local equivalents pass; hosted status can only be confirmed after pushing the commit.
51
+
52
+ ## Release interpretation
53
+
54
+ The package is functionally releasable for the documented CPU/dense scope. Strict completion of the
55
+ original cross-implementation and real-capture goals still requires:
56
+
57
+ 1. Generating and committing the CUDA golden set, then resolving any mismatches.
58
+ 2. Running a representative real COLMAP capture for 30,000 steps and recording quality/time.
59
+
60
+ These are external validation gates, not silently treated as passed.
@@ -0,0 +1,79 @@
1
+ # Benchmark results
2
+
3
+ ## Environment
4
+
5
+ - Date: 2026-07-24
6
+ - Ruby: CRuby 4.0.0
7
+ - Platform: arm64-darwin24 (Apple Silicon)
8
+ - Native workers: `OMP_NUM_THREADS=8`
9
+ - Dtype: `Numo::SFloat`
10
+ - Scene seed: 42
11
+
12
+ `benchmarks/bench_rasterize.rb` contains all four workloads from design section 9.1. Use `--list`
13
+ to inspect them and `--quick` for CI-sized smoke runs.
14
+
15
+ ## Raster forward and backward
16
+
17
+ Commands:
18
+
19
+ ```bash
20
+ bundle exec ruby -Ilib benchmarks/bench_rasterize.rb \
21
+ --scenario raster --backend ruby --iterations 1
22
+
23
+ OMP_NUM_THREADS=8 bundle exec ruby -Ilib benchmarks/bench_rasterize.rb \
24
+ --scenario raster --backend native --iterations 3
25
+ ```
26
+
27
+ Workload: 100,000 Gaussians, one 800×800 camera, RGB, float32. Each measurement follows one warm-up.
28
+ Forward+backward includes a fresh forward, both color/alpha VJPs, and `absgrad`.
29
+
30
+ | Backend | Forward | Target | Forward + backward | Target | Result |
31
+ |---|---:|---:|---:|---:|---|
32
+ | Ruby | 3,527.990 ms | ≤ 10,000 ms | 8,047.024 ms | ≤ 30,000 ms | Pass |
33
+ | Native, 8 workers | 30.419 ms | ≤ 150 ms | 112.573 ms | ≤ 400 ms | Pass |
34
+
35
+ Native samples over three measured calls were 28.901–32.861 ms forward and
36
+ 109.907–114.240 ms combined. The speedup over Ruby was approximately 116× forward and 71× combined
37
+ for this scene.
38
+
39
+ ## Image fitting
40
+
41
+ Command:
42
+
43
+ ```bash
44
+ OMP_NUM_THREADS=8 bundle exec ruby -Ilib benchmarks/bench_rasterize.rb \
45
+ --scenario fit_image --backend native
46
+ ```
47
+
48
+ Workload: 50,000 Gaussians, 512×512 image, 2,000 optimization steps, float32. The timed run completed
49
+ in 157.457 seconds (2 minutes 37.5 seconds), passing the ≤30 minute design target.
50
+
51
+ This timing workload optimizes only colors in a deterministic self-consistency scene. Its final
52
+ PSNR was 16.799 dB; that value is not the convergence acceptance case. The reduced convergence test
53
+ uses 64 Gaussians at 8×8 and reaches 30.878 dB in 20 monotonic steps.
54
+
55
+ ## COLMAP training
56
+
57
+ The benchmark scenario loads a real COLMAP directory and runs the production `Training::Trainer`:
58
+
59
+ ```bash
60
+ ruby -Ilib benchmarks/bench_rasterize.rb \
61
+ --scenario colmap --backend native --data /path/to/capture --steps 30000
62
+ ```
63
+
64
+ The complete 30,000-step, several-hundred-thousand-Gaussian benchmark was not run because no real
65
+ capture with reference images is present on this host. The execution path was smoke-tested with the
66
+ three-camera/100-point COLMAP fixture plus temporary 640×480 PNGs: one native step, including full
67
+ evaluation before and after training, completed in 2.584 seconds.
68
+
69
+ This smoke result demonstrates that the scenario and image/point pipeline execute; it is not a
70
+ substitute for the design's overnight wall-time or real-capture quality gate.
71
+
72
+ ## Reproducing and extending
73
+
74
+ Override workload sizes with `--gaussians`, `--width`, `--height`, `--steps`, and `--iterations`.
75
+ Use `--json PATH` to save the complete environment/result object. The benchmark rejects zero or
76
+ negative dimensions and never changes the mathematical rasterization thresholds.
77
+
78
+ The older operation-attribution and OpenMP scaling measurements remain in
79
+ [`PROFILE.md`](PROFILE.md).
data/docs/DECISIONS.md ADDED
@@ -0,0 +1,52 @@
1
+ # Architecture Decision Records
2
+
3
+ Architecture Decision Records (ADRs) capture significant technical decisions, their context, and
4
+ their consequences. The individual records live in [`docs/decisions/`](decisions/) and are never
5
+ deleted; a later ADR supersedes an earlier decision when the architecture changes.
6
+
7
+ This structure follows the concise format used by
8
+ [ydah/ibex](https://github.com/ydah/ibex/tree/main/docs/decisions).
9
+
10
+ ## Index
11
+
12
+ | ADR | Status | Date | Decision |
13
+ |---|---|---|---|
14
+ | [0001](decisions/0001-pin-golden-reference-and-cpu-validation.md) | Accepted | 2026-07-23 | Pin the golden reference and define CPU-only validation |
15
+ | [0002](decisions/0002-retain-ruby-fallbacks-for-native-backend.md) | Accepted | 2026-07-23 | Retain exact Ruby fallbacks for the native backend |
16
+ | [0003](decisions/0003-share-projection-for-distorted-cameras.md) | Accepted | 2026-07-23 | Share the Ruby projection for distorted cameras |
17
+ | [0004](decisions/0004-use-portable-world-space-reference-paths.md) | Accepted | 2026-07-24 | Use one portable reference for world-space extension paths |
18
+ | [0005](decisions/0005-reuse-ewa-core-for-2dgs.md) | Accepted | 2026-07-24 | Reuse the differentiable EWA core for 2DGS |
19
+ | [0006](decisions/0006-keep-eval3d-as-portable-reference.md) | Accepted | 2026-07-24 | Keep eval3d as a portable reference path |
20
+ | [0007](decisions/0007-share-compositor-semantics-for-contribution-indices.md) | Accepted | 2026-07-24 | Share compositor semantics for contribution indices |
21
+ ## When an ADR is required
22
+
23
+ Write an ADR when a change introduces a meaningful trade-off or establishes a long-lived contract,
24
+ including:
25
+
26
+ - public API, serialized format, or compatibility policy changes;
27
+ - backend ownership, fallback, precision, or performance boundaries;
28
+ - algorithm choices whose rejected alternatives may be reconsidered;
29
+ - validation policy changes or accepted differences from the upstream implementation;
30
+ - decisions that supersede or deprecate an existing ADR.
31
+
32
+ Routine implementation details that follow an accepted decision do not need another ADR.
33
+
34
+ ## Creating an ADR
35
+
36
+ 1. Copy [`0000-template.md`](decisions/0000-template.md).
37
+ 2. Use the next four-digit number and a lowercase kebab-case filename:
38
+ `NNNN-short-decision-title.md`.
39
+ 3. Keep the title number equal to the filename number and use an ISO `YYYY-MM-DD` date.
40
+ 4. Add the ADR to the index in the same change.
41
+ 5. Run `bundle exec ruby -Itest test/architecture_decision_records_test.rb`.
42
+
43
+ ## Status lifecycle
44
+
45
+ - `Proposed`: under review and not yet authoritative.
46
+ - `Accepted`: active architecture.
47
+ - `Rejected`: considered but not adopted.
48
+ - `Deprecated`: retained for history but no longer recommended.
49
+ - `Superseded by NNNN`: replaced by a newer ADR.
50
+
51
+ Do not rewrite an accepted ADR to represent a different decision. Add a new ADR, mark the old one
52
+ `Superseded by NNNN`, and link the records from their context or consequences.