gswarp 1.0.2__tar.gz

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.
gswarp-1.0.2/LICENSE ADDED
@@ -0,0 +1,184 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form,
34
+ made available under the License, as indicated by a copyright notice that is
35
+ included in or attached to the work (an example is provided in the Appendix
36
+ below).
37
+
38
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
39
+ is based on (or derived from) the Work and for which the editorial revisions,
40
+ annotations, elaborations, or other modifications represent, as a whole, an
41
+ original work of authorship. For the purposes of this License, Derivative Works
42
+ shall not include works that remain separable from, or merely link (or bind by
43
+ name) to the interfaces of, the Work and Derivative Works thereof.
44
+
45
+ "Contribution" shall mean any work of authorship, including the original
46
+ version of the Work and any modifications or additions to that Work or
47
+ Derivative Works thereof, that is intentionally submitted to Licensor for
48
+ inclusion in the Work by the copyright owner or by an individual or Legal
49
+ Entity authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal, or
51
+ written communication sent to the Licensor or its representatives, including
52
+ but not limited to communication on electronic mailing lists, source code
53
+ control systems, and issue tracking systems that are managed by, or on behalf
54
+ of, the Licensor for the purpose of discussing and improving the Work, but
55
+ excluding communication that is conspicuously marked or otherwise designated in
56
+ writing by the copyright owner as "Not a Contribution."
57
+
58
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
59
+ of whom a Contribution has been received by Licensor and subsequently
60
+ incorporated within the Work.
61
+
62
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
63
+ License, each Contributor hereby grants to You a perpetual, worldwide,
64
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
65
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
66
+ sublicense, and distribute the Work and such Derivative Works in Source or
67
+ Object form.
68
+
69
+ 3. Grant of Patent License. Subject to the terms and conditions of this
70
+ License, each Contributor hereby grants to You a perpetual, worldwide,
71
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
72
+ section) patent license to make, have made, use, offer to sell, sell, import,
73
+ and otherwise transfer the Work, where such license applies only to those
74
+ patent claims licensable by such Contributor that are necessarily infringed by
75
+ their Contribution(s) alone or by combination of their Contribution(s) with the
76
+ Work to which such Contribution(s) was submitted. If You institute patent
77
+ litigation against any entity (including a cross-claim or counterclaim in a
78
+ lawsuit) alleging that the Work or a Contribution incorporated within the Work
79
+ constitutes direct or contributory patent infringement, then any patent
80
+ licenses granted to You under this License for that Work shall terminate as of
81
+ the date such litigation is filed.
82
+
83
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
84
+ Derivative Works thereof in any medium, with or without modifications, and in
85
+ Source or Object form, provided that You meet the following conditions:
86
+
87
+ (a) You must give any other recipients of the Work or Derivative Works a copy
88
+ of this License; and
89
+
90
+ (b) You must cause any modified files to carry prominent notices stating that
91
+ You changed the files; and
92
+
93
+ (c) You must retain, in the Source form of any Derivative Works that You
94
+ distribute, all copyright, patent, trademark, and attribution notices from the
95
+ Source form of the Work, excluding those notices that do not pertain to any
96
+ part of the Derivative Works; and
97
+
98
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
99
+ any Derivative Works that You distribute must include a readable copy of the
100
+ attribution notices contained within such NOTICE file, excluding those notices
101
+ that do not pertain to any part of the Derivative Works, in at least one of the
102
+ following places: within a NOTICE text file distributed as part of the
103
+ Derivative Works; within the Source form or documentation, if provided along
104
+ with the Derivative Works; or, within a display generated by the Derivative
105
+ Works, if and wherever such third-party notices normally appear. The contents
106
+ of the NOTICE file are for informational purposes only and do not modify the
107
+ License. You may add Your own attribution notices within Derivative Works that
108
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
109
+ provided that such additional attribution notices cannot be construed as
110
+ modifying the License.
111
+
112
+ You may add Your own copyright statement to Your modifications and may provide
113
+ additional or different license terms and conditions for use, reproduction, or
114
+ distribution of Your modifications, or for any such Derivative Works as a
115
+ whole, provided Your use, reproduction, and distribution of the Work otherwise
116
+ complies with the conditions stated in this License.
117
+
118
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
119
+ Contribution intentionally submitted for inclusion in the Work by You to the
120
+ Licensor shall be under the terms and conditions of this License, without any
121
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
122
+ supersede or modify the terms of any separate license agreement you may have
123
+ executed with Licensor regarding such Contributions.
124
+
125
+ 6. Trademarks. This License does not grant permission to use the trade names,
126
+ trademarks, service marks, or product names of the Licensor, except as required
127
+ for reasonable and customary use in describing the origin of the Work and
128
+ reproducing the content of the NOTICE file.
129
+
130
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
131
+ writing, Licensor provides the Work (and each Contributor provides its
132
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
133
+ KIND, either express or implied, including, without limitation, any warranties
134
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
135
+ PARTICULAR PURPOSE. You are solely responsible for determining the
136
+ appropriateness of using or redistributing the Work and assume any risks
137
+ associated with Your exercise of permissions under this License.
138
+
139
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
140
+ tort (including negligence), contract, or otherwise, unless required by
141
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
142
+ writing, shall any Contributor be liable to You for damages, including any
143
+ direct, indirect, special, incidental, or consequential damages of any
144
+ character arising as a result of this License or out of the use or inability to
145
+ use the Work (including but not limited to damages for loss of goodwill, work
146
+ stoppage, computer failure or malfunction, or any and all other commercial
147
+ damages or losses), even if such Contributor has been advised of the
148
+ possibility of such damages.
149
+
150
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
151
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
152
+ acceptance of support, warranty, indemnity, or other liability obligations
153
+ and/or rights consistent with this License. However, in accepting such
154
+ obligations, You may act only on Your own behalf and on Your sole
155
+ responsibility, not on behalf of any other Contributor, and only if You agree
156
+ to indemnify, defend, and hold each Contributor harmless for any liability
157
+ incurred by, or claims asserted against, such Contributor by reason of your
158
+ accepting any such warranty or additional liability.
159
+
160
+ END OF TERMS AND CONDITIONS
161
+
162
+ APPENDIX: How to apply the Apache License to your work.
163
+
164
+ To apply the Apache License to your work, attach the following boilerplate
165
+ notice, with the fields enclosed by brackets "[]" replaced with your own
166
+ identifying information. (Don't include the brackets!) The text should be
167
+ enclosed in the appropriate comment syntax for the file format. We also
168
+ recommend that a file or class name and description of purpose be included on
169
+ the same "printed page" as the copyright notice for easier identification
170
+ within third-party archives.
171
+
172
+ Copyright 2025 gswarp contributors
173
+
174
+ Licensed under the Apache License, Version 2.0 (the "License");
175
+ you may not use this file except in compliance with the License.
176
+ You may obtain a copy of the License at
177
+
178
+ http://www.apache.org/licenses/LICENSE-2.0
179
+
180
+ Unless required by applicable law or agreed to in writing, software
181
+ distributed under the License is distributed on an "AS IS" BASIS,
182
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183
+ See the License for the specific language governing permissions and
184
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ include LICENSE
2
+ include NOTICE
3
+ include README.md
4
+ include README_zh.md
5
+ include pyproject.toml
6
+ recursive-include gswarp *.py
7
+ recursive-exclude gswarp __pycache__ *.py[cod]
gswarp-1.0.2/NOTICE ADDED
@@ -0,0 +1,21 @@
1
+ gswarp
2
+ Copyright 2025 gswarp contributors
3
+
4
+ This project is distributed under the Apache License 2.0.
5
+
6
+ Third-party attribution and scope notes:
7
+
8
+ - NVIDIA Warp is an external dependency used as the GPU kernel runtime.
9
+ NVIDIA Warp is licensed under Apache License 2.0.
10
+
11
+ - This repository is intended to be an independent implementation of a
12
+ differentiable Gaussian rasterization backend compatible with 3D Gaussian
13
+ Splatting style pipelines. No source code from graphdeco-inria/
14
+ gaussian-splatting is intentionally included in this repository.
15
+
16
+ - The tight AABB tile-culling approach is inspired by published research ideas.
17
+ No source code, figures, or paper text from that work are included here.
18
+
19
+ If any file in this repository is later found to contain copied third-party
20
+ code, that file remains subject to the original upstream license and must be
21
+ handled separately.
gswarp-1.0.2/PKG-INFO ADDED
@@ -0,0 +1,278 @@
1
+ Metadata-Version: 2.4
2
+ Name: gswarp
3
+ Version: 1.0.2
4
+ Summary: Pure-Python NVIDIA Warp backend for 3D Gaussian Splatting
5
+ Author: GSWarp contributors
6
+ License-Expression: Apache-2.0
7
+ Keywords: 3dgs,gaussian-splatting,warp,rasterization,pytorch
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ License-File: NOTICE
22
+ Requires-Dist: torch>=2.0
23
+ Requires-Dist: warp-lang>=1.12.0
24
+ Dynamic: license-file
25
+
26
+ # gswarp
27
+
28
+ **English** · [中文](README_zh.md)
29
+
30
+ gswarp is a pure-Python **NVIDIA Warp** backend for 3D Gaussian Splatting, reimplementing the three core CUDA modules used in 3DGS training — the rasterizer, SSIM loss, and KNN initialization. No C++/CUDA compilation required; install via pip and swap out the original CUDA implementations directly.
31
+
32
+ > **License**: [Apache License 2.0](LICENSE). Third-party attributions in [NOTICE](NOTICE).
33
+
34
+ ---
35
+
36
+ ## Table of Contents
37
+
38
+ - [Three Replacement Modules](#three-replacement-modules)
39
+ - [Requirements](#requirements)
40
+ - [Installation](#installation)
41
+ - [Replacing CUDA Backends in a 3DGS Project](#replacing-cuda-backends-in-a-3dgs-project)
42
+ - [Rasterizer](#rasterizer)
43
+ - [SSIM](#ssim)
44
+ - [KNN](#knn)
45
+ - [Recommended: Replace All at Once](#recommended-replace-all-at-once)
46
+ - [Performance](#performance)
47
+ - [Quality Metrics](#quality-metrics)
48
+ - [Detailed Documentation](#detailed-documentation)
49
+ - [Acknowledgements](#acknowledgements)
50
+
51
+ ---
52
+
53
+ ## Three Replacement Modules
54
+
55
+ | Module | Replaces | Import Path | Notes |
56
+ |--------|----------|-------------|-------|
57
+ | **Rasterizer** | `diff_gaussian_rasterization` | `gswarp` | Full differentiable Gaussian rasterization + auto-tuning |
58
+ | **SSIM** | `fused_ssim` | `gswarp.fused_ssim` | Separable Gaussian convolution with launch caching |
59
+ | **KNN** | `simple_knn` | `gswarp.knn` | Morton-sort + bounding-box pruning 3-NN |
60
+
61
+ ---
62
+
63
+ ## Requirements
64
+
65
+ | Component | Minimum |
66
+ |-----------|---------|
67
+ | Python | 3.10+ |
68
+ | NVIDIA GPU | Compute capability ≥ 7.0 (Volta) |
69
+ | PyTorch | 2.0+ (with CUDA support) |
70
+ | NVIDIA Warp | 1.12.0+ |
71
+
72
+ ---
73
+
74
+ ## Installation
75
+
76
+ ```bash
77
+ pip install gswarp
78
+ ```
79
+
80
+ This installs `warp-lang` automatically via package dependencies. If you want to pin the Warp version explicitly, use:
81
+
82
+ ```bash
83
+ pip install "warp-lang>=1.12.0" gswarp
84
+ ```
85
+
86
+ Or install from source:
87
+
88
+ ```bash
89
+ git clone https://github.com/fancifulland2718/gswarp.git
90
+ cd gswarp
91
+ pip install .
92
+ ```
93
+
94
+ No compilation steps are needed after installation. The first call to any Warp kernel triggers JIT compilation (a few seconds); subsequent runs use the cache.
95
+
96
+ ---
97
+
98
+ ## Replacing CUDA Backends in a 3DGS Project
99
+
100
+ The examples below follow the [gaussian-splatting](https://github.com/graphdeco-inria/gaussian-splatting) reference implementation.
101
+
102
+ ### Rasterizer
103
+
104
+ Original (`gaussian_renderer/__init__.py`):
105
+
106
+ ```python
107
+ from diff_gaussian_rasterization import (
108
+ GaussianRasterizationSettings,
109
+ GaussianRasterizer,
110
+ )
111
+ ```
112
+
113
+ Replace with:
114
+
115
+ ```python
116
+ from gswarp import (
117
+ GaussianRasterizationSettings,
118
+ GaussianRasterizer,
119
+ )
120
+ ```
121
+
122
+ `GaussianRasterizationSettings` is a `NamedTuple` with the same fields as the original (Warp-specific fields have defaults). `GaussianRasterizer.forward()` returns **additional outputs** compared to the original:
123
+
124
+ ```python
125
+ # Original CUDA:
126
+ color, radii = rasterizer(means3D=..., means2D=..., ...)
127
+
128
+ # gswarp:
129
+ color, radii, depth, alpha, proj_2D, conic_2D, conic_2D_inv, \
130
+ gs_per_pixel, weight_per_gs_pixel, x_mu = rasterizer(...)
131
+ # Extra outputs can be ignored when only color and radii are needed
132
+ ```
133
+
134
+ **Optional runtime configuration** (call once before the training loop):
135
+
136
+ ```python
137
+ from gswarp import initialize_runtime_tuning, set_binning_sort_mode
138
+
139
+ # Detect GPU and select optimal block_dim automatically (recommended)
140
+ initialize_runtime_tuning(device="cuda:0", verbose=True)
141
+
142
+ # Choose a sort mode (default warp_depth_stable_tile is usually best)
143
+ set_binning_sort_mode("warp_depth_stable_tile") # recommended for large scenes
144
+ # set_binning_sort_mode("warp_radix") # alternative
145
+ # set_binning_sort_mode("torch") # fallback
146
+ ```
147
+
148
+ ### SSIM
149
+
150
+ Original (`train.py`):
151
+
152
+ ```python
153
+ from fused_ssim import fused_ssim
154
+ ```
155
+
156
+ Replace with:
157
+
158
+ ```python
159
+ from gswarp.fused_ssim import fused_ssim
160
+ ```
161
+
162
+ The function signature is identical:
163
+
164
+ ```python
165
+ loss_ssim = fused_ssim(img1, img2, padding="same", train=True)
166
+ ```
167
+
168
+ ### KNN
169
+
170
+ Original (`scene/gaussian_model.py`):
171
+
172
+ ```python
173
+ from simple_knn._C import distCUDA2
174
+ ```
175
+
176
+ Replace with:
177
+
178
+ ```python
179
+ from gswarp.knn import distCUDA2
180
+ ```
181
+
182
+ The function signature is identical:
183
+
184
+ ```python
185
+ dist2 = distCUDA2(points) # points: (N, 3) float32 CUDA tensor
186
+ ```
187
+
188
+ ### Recommended: Replace All at Once
189
+
190
+ Add the following near the top of `train.py`:
191
+
192
+ ```python
193
+ try:
194
+ from gswarp import GaussianRasterizationSettings, GaussianRasterizer
195
+ from gswarp.fused_ssim import fused_ssim
196
+ from gswarp.knn import distCUDA2
197
+ GSWARP_AVAILABLE = True
198
+ except ImportError:
199
+ GSWARP_AVAILABLE = False
200
+ ```
201
+
202
+ Then switch backends at each usage site using the `GSWARP_AVAILABLE` flag. A reference integration is available in [gaussian-splatting/train.py](https://github.com/graphdeco-inria/gaussian-splatting/blob/main/train.py).
203
+
204
+ ---
205
+
206
+ ## Performance
207
+
208
+ Results from full 30K-step training on 12 standard 3DGS datasets. Hardware: RTX 5090D V2 (sm_120, 24 GiB), Python 3.14, PyTorch 2.11.0+cu130, Warp 1.12.0. **All three modules use the Warp backend**, with Python-layer overhead optimizations applied.
209
+
210
+ | Dataset | CUDA (it/s) | Warp (it/s) | Speedup |
211
+ |---------|------------|------------|---------|
212
+ | chair | 103.6 | 113.1 | ×1.09 |
213
+ | drums | 103.0 | 115.3 | ×1.12 |
214
+ | ficus | 139.5 | 148.2 | ×1.06 |
215
+ | hotdog | 144.5 | 156.5 | ×1.08 |
216
+ | lego | 117.5 | 126.5 | ×1.08 |
217
+ | materials | 134.0 | 144.9 | ×1.08 |
218
+ | mic | 95.4 | 105.1 | ×1.10 |
219
+ | ship | 107.0 | 113.2 | ×1.06 |
220
+ | train | 55.6 | 58.3 | ×1.05 |
221
+ | truck | 39.4 | 40.1 | ×1.02 |
222
+ | drjohnson | 30.8 | 32.0 | ×1.04 |
223
+ | playroom | 46.9 | 47.5 | ×1.01 |
224
+
225
+ **NeRF Synthetic (8 scenes)**: average ×1.08 speedup. **Tanks & Temples / Deep Blending (4 large scenes)**: average ×1.03 speedup. The smaller gains on large scenes (drjohnson, playroom) are explained by the higher Gaussian counts diluting the rasterizer kernel advantage — see the [rasterizer documentation](docs/rasterizer.md) for a per-phase breakdown.
226
+
227
+ ---
228
+
229
+ ## Quality Metrics
230
+
231
+ Test-set evaluation after 30K training steps:
232
+
233
+ **NeRF Synthetic (8-scene average)**
234
+
235
+ | Metric | CUDA | Warp | Δ |
236
+ |--------|------|------|---|
237
+ | PSNR (dB) | 33.31 | 33.33 | +0.02 |
238
+ | SSIM | 0.9692 | 0.9693 | +0.0001 |
239
+ | LPIPS | 0.0303 | 0.0302 | −0.0001 |
240
+
241
+ **Tanks & Temples (2-scene average)**
242
+
243
+ | Metric | CUDA | Warp | Δ |
244
+ |--------|------|------|---|
245
+ | PSNR (dB) | 23.74 | 23.79 | +0.04 |
246
+ | SSIM | 0.8512 | 0.8515 | +0.0003 |
247
+ | LPIPS | 0.1711 | 0.1707 | −0.0004 |
248
+
249
+ **Deep Blending (2-scene average)**
250
+
251
+ | Metric | CUDA | Warp | Δ |
252
+ |--------|------|------|---|
253
+ | PSNR (dB) | 29.77 | 30.01 | +0.04 |
254
+ | SSIM | 0.9062 | 0.9063 | +0.0001 |
255
+ | LPIPS | 0.2390 | 0.2388 | −0.0002 |
256
+
257
+ Per-scene PSNR differences are within ±0.25 dB; SSIM differences are < 0.001. The Warp backend produces training quality equivalent to the CUDA baseline across all tested scenes.
258
+
259
+ ---
260
+
261
+ ## Detailed Documentation
262
+
263
+ | Document | Contents |
264
+ |----------|----------|
265
+ | [docs/rasterizer.md](docs/rasterizer.md) | Architecture, CUDA implementation differences, micro-benchmarks, correctness, known limitations |
266
+ | [docs/ssim.md](docs/ssim.md) | SSIM kernel optimizations, performance analysis, correctness |
267
+ | [docs/knn.md](docs/knn.md) | KNN algorithm, Morton sorting, performance analysis |
268
+
269
+ ---
270
+
271
+ ## Acknowledgements
272
+
273
+ - [3D Gaussian Splatting](https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/) (INRIA / MPII)
274
+ - [fused-ssim](https://github.com/rahul-goel/fused-ssim) (Rahul Goel et al.)
275
+ - [simple-knn](https://github.com/camenduru/simple-knn) (graphdeco-inria)
276
+ - [Fast Converging 3DGS](https://arxiv.org/abs/2601.19489) (Zhang et al., 2025) — inspiration for compact AABB culling
277
+ - [NVIDIA Warp](https://nvidia.github.io/warp/)
278
+