spio 0.4.1__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.
- spio-0.4.1/LICENSE +202 -0
- spio-0.4.1/MANIFEST.in +12 -0
- spio-0.4.1/PKG-INFO +297 -0
- spio-0.4.1/README.md +268 -0
- spio-0.4.1/pyproject.toml +41 -0
- spio-0.4.1/setup.cfg +4 -0
- spio-0.4.1/setup.py +62 -0
- spio-0.4.1/spio/__init__.py +20 -0
- spio-0.4.1/spio/compiler/__init__.py +6 -0
- spio-0.4.1/spio/compiler/arch.py +10 -0
- spio-0.4.1/spio/compiler/compile.py +75 -0
- spio-0.4.1/spio/compiler/compile_kernel.py +95 -0
- spio-0.4.1/spio/compiler/compile_nvcc.py +84 -0
- spio-0.4.1/spio/compiler/compiler_pool.py +102 -0
- spio-0.4.1/spio/cuda/__init__.py +9 -0
- spio-0.4.1/spio/cuda/cdriver.pxd +120 -0
- spio-0.4.1/spio/cuda/driver.pyi +60 -0
- spio-0.4.1/spio/cuda/driver.pyx +369 -0
- spio-0.4.1/spio/cuda/nvrtc_ctypes.py +205 -0
- spio-0.4.1/spio/functional/__init__.py +8 -0
- spio-0.4.1/spio/functional/conv2d_gw8_function.py +239 -0
- spio-0.4.1/spio/generators/__init__.py +18 -0
- spio-0.4.1/spio/generators/async_strip_loader.py +52 -0
- spio-0.4.1/spio/generators/checkerboard.py +34 -0
- spio-0.4.1/spio/generators/data_type.py +29 -0
- spio-0.4.1/spio/generators/dim.py +84 -0
- spio-0.4.1/spio/generators/dims.py +92 -0
- spio-0.4.1/spio/generators/fold.py +48 -0
- spio-0.4.1/spio/generators/fragment.py +58 -0
- spio-0.4.1/spio/generators/fragment_index.py +148 -0
- spio-0.4.1/spio/generators/fragment_type.py +23 -0
- spio-0.4.1/spio/generators/gen_specs.py +36 -0
- spio-0.4.1/spio/generators/generators.py +165 -0
- spio-0.4.1/spio/generators/index.py +109 -0
- spio-0.4.1/spio/generators/macros.py +23 -0
- spio-0.4.1/spio/generators/matmul.py +206 -0
- spio-0.4.1/spio/generators/params.py +40 -0
- spio-0.4.1/spio/generators/subindex_protocol.py +29 -0
- spio-0.4.1/spio/generators/tensor.py +135 -0
- spio-0.4.1/spio/include/__init__.py +1 -0
- spio-0.4.1/spio/include/spio/__init__.py +0 -0
- spio-0.4.1/spio/include/spio/allocator.h +80 -0
- spio-0.4.1/spio/include/spio/async_strip_loader.cuh +77 -0
- spio-0.4.1/spio/include/spio/checkerboard_index.h +125 -0
- spio-0.4.1/spio/include/spio/dim.h +309 -0
- spio-0.4.1/spio/include/spio/dim_info.h +156 -0
- spio-0.4.1/spio/include/spio/fifo.cuh +192 -0
- spio-0.4.1/spio/include/spio/fragment.cuh +272 -0
- spio-0.4.1/spio/include/spio/fragment_index.h +246 -0
- spio-0.4.1/spio/include/spio/fragment_load_index.h +279 -0
- spio-0.4.1/spio/include/spio/fragment_mma.cuh +84 -0
- spio-0.4.1/spio/include/spio/index.h +153 -0
- spio-0.4.1/spio/include/spio/index_base.h +20 -0
- spio-0.4.1/spio/include/spio/ldmatrix.cuh +102 -0
- spio-0.4.1/spio/include/spio/macros.h +12 -0
- spio-0.4.1/spio/include/spio/mathutil.h +25 -0
- spio-0.4.1/spio/include/spio/memory.cuh +26 -0
- spio-0.4.1/spio/include/spio/mma.cuh +59 -0
- spio-0.4.1/spio/include/spio/pipeline.h +48 -0
- spio-0.4.1/spio/include/spio/semaphore.cuh +85 -0
- spio-0.4.1/spio/include/spio/strip_loader_params.h +22 -0
- spio-0.4.1/spio/include/spio/tensor.h +497 -0
- spio-0.4.1/spio/include/spio.cuh +16 -0
- spio-0.4.1/spio/kernels/__init__.py +23 -0
- spio-0.4.1/spio/kernels/conv2d_gw8_kernel.py +213 -0
- spio-0.4.1/spio/kernels/conv2d_gw8_params.py +215 -0
- spio-0.4.1/spio/kernels/conv2d_gw8_wgrad_kernel.py +285 -0
- spio-0.4.1/spio/kernels/conv2d_stats.py +126 -0
- spio-0.4.1/spio/kernels/kernel.py +162 -0
- spio-0.4.1/spio/kernels/kernel_cache.py +115 -0
- spio-0.4.1/spio/kernels/kernel_factory.py +218 -0
- spio-0.4.1/spio/kernels/kernel_key.py +34 -0
- spio-0.4.1/spio/kernels/kernel_params_logger.py +113 -0
- spio-0.4.1/spio/kernels/kernel_util.py +14 -0
- spio-0.4.1/spio/kernels/launch_params.py +27 -0
- spio-0.4.1/spio/kernels/params.py +23 -0
- spio-0.4.1/spio/kernels/performance_model_cache.py +489 -0
- spio-0.4.1/spio/kernels/stats.py +74 -0
- spio-0.4.1/spio/layers/__init__.py +4 -0
- spio-0.4.1/spio/layers/conv2d_gw8.py +140 -0
- spio-0.4.1/spio/layers/make.py +15 -0
- spio-0.4.1/spio/reflection/__init__.py +10 -0
- spio-0.4.1/spio/reflection/arg_info.py +154 -0
- spio-0.4.1/spio/reflection/conv2d_gw8_reflection.py +163 -0
- spio-0.4.1/spio/reflection/reflection.py +207 -0
- spio-0.4.1/spio/src/__init__.py +1 -0
- spio-0.4.1/spio/src/conv2d_gw8.cu +271 -0
- spio-0.4.1/spio/src/conv2d_gw8_wgrad.cu +254 -0
- spio-0.4.1/spio/src/layernorm_2d.cu +270 -0
- spio-0.4.1/spio/src_tests/Conv2dGw8Params.dat +81 -0
- spio-0.4.1/spio/src_tests/__init__.py +11 -0
- spio-0.4.1/spio/src_tests/add.cu +9 -0
- spio-0.4.1/spio/src_tests/fifo.cu +51 -0
- spio-0.4.1/spio/src_tests/index.cu +31 -0
- spio-0.4.1/spio/src_tests/ldmatrix.cu +135 -0
- spio-0.4.1/spio/src_tests/memcpy_simple.cu +51 -0
- spio-0.4.1/spio/src_tests/mma.cu +134 -0
- spio-0.4.1/spio/src_tests/mma_checkerboard_16c.cu +171 -0
- spio-0.4.1/spio/src_tests/preprocess_data_file.py +82 -0
- spio-0.4.1/spio/src_tests/row_memcpy.cu +122 -0
- spio-0.4.1/spio/src_tests/run_test.py +318 -0
- spio-0.4.1/spio/src_tests/semaphore.cu +47 -0
- spio-0.4.1/spio/src_tests/utest.h +1700 -0
- spio-0.4.1/spio/transform/__init__.py +8 -0
- spio-0.4.1/spio/transform/_transform.py +110 -0
- spio-0.4.1/spio/util/__init__.py +14 -0
- spio-0.4.1/spio/util/cache_dir.py +8 -0
- spio-0.4.1/spio/util/class_names.py +15 -0
- spio-0.4.1/spio/util/close.py +74 -0
- spio-0.4.1/spio/util/device_info.py +34 -0
- spio-0.4.1/spio/util/interval_timer.py +117 -0
- spio-0.4.1/spio/util/load_parameter_set.py +77 -0
- spio-0.4.1/spio/util/logger.py +17 -0
- spio-0.4.1/spio/util/math.py +21 -0
- spio-0.4.1/spio/util/memory_format.py +29 -0
- spio-0.4.1/spio/util/parse_dataclass.py +38 -0
- spio-0.4.1/spio/util/parse_kwargs.py +24 -0
- spio-0.4.1/spio/util/tensor_format.py +17 -0
- spio-0.4.1/spio/util/test_matrices.py +60 -0
- spio-0.4.1/spio.egg-info/PKG-INFO +297 -0
- spio-0.4.1/spio.egg-info/SOURCES.txt +132 -0
- spio-0.4.1/spio.egg-info/dependency_links.txt +1 -0
- spio-0.4.1/spio.egg-info/requires.txt +10 -0
- spio-0.4.1/spio.egg-info/top_level.txt +1 -0
- spio-0.4.1/tests/test_conv2d_gw8.py +227 -0
- spio-0.4.1/tests/test_cpp.py +545 -0
- spio-0.4.1/tests/test_cuda_driver.py +73 -0
- spio-0.4.1/tests/test_dtype.py +16 -0
- spio-0.4.1/tests/test_kernel.py +210 -0
- spio-0.4.1/tests/test_ldmatrix.py +143 -0
- spio-0.4.1/tests/test_nvcc.py +11 -0
- spio-0.4.1/tests/test_stats.py +52 -0
- spio-0.4.1/tests/test_synchronization.py +80 -0
- spio-0.4.1/tests/test_util.py +50 -0
spio-0.4.1/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
spio-0.4.1/MANIFEST.in
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include LICENSE.txt
|
|
2
|
+
include README.md
|
|
3
|
+
include pyproject.toml
|
|
4
|
+
|
|
5
|
+
recursive-include spio *.py *.pyx *.pxd *.cu *.h *.cuh *.dat
|
|
6
|
+
|
|
7
|
+
# Exclude unnecessary files and directories
|
|
8
|
+
exclude *.pyc
|
|
9
|
+
exclude *.pyo
|
|
10
|
+
exclude .DS_Store
|
|
11
|
+
prune tests/__pycache__
|
|
12
|
+
prune spio/__pycache__
|
spio-0.4.1/PKG-INFO
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spio
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Efficient CUDA kernels for training convolutional neural networks with PyTorch.
|
|
5
|
+
Author-email: Andrew Lavin <alavin@acm.org>
|
|
6
|
+
Project-URL: Homepage, https://github.com/andravin/spio
|
|
7
|
+
Project-URL: Issues, https://github.com/andravin/spio/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: torch>=2.4.0
|
|
19
|
+
Requires-Dist: nvidia-cuda-nvrtc-cu12
|
|
20
|
+
Requires-Dist: nvidia-cuda-runtime-cu12
|
|
21
|
+
Requires-Dist: pytest
|
|
22
|
+
Requires-Dist: xgboost
|
|
23
|
+
Requires-Dist: appdirs
|
|
24
|
+
Requires-Dist: requests
|
|
25
|
+
Requires-Dist: filelock
|
|
26
|
+
Requires-Dist: packaging
|
|
27
|
+
Requires-Dist: importlib_resources>=6.0.0
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Spio
|
|
31
|
+
|
|
32
|
+
Experimental CUDA kernel framework unifying typed dimensions, NVRTC JIT specialization, and ML‑guided tuning.
|
|
33
|
+
|
|
34
|
+
[](https://pypi.org/project/spio/)
|
|
35
|
+
[](LICENSE)
|
|
36
|
+
|
|
37
|
+
## Overview
|
|
38
|
+
|
|
39
|
+
Spio is an experimental CUDA research playground that packages several forward-looking ideas for building next-generation GPU kernels: strongly typed tensor dimensions, pipeline-oriented code generation, and machine-learned performance models that steer NVRTC-compiled kernels at runtime.
|
|
40
|
+
|
|
41
|
+
## Key Features
|
|
42
|
+
|
|
43
|
+
### 🔧 Typed Dimension System
|
|
44
|
+
|
|
45
|
+
Unlike “Named Tensors,” which attach string names to dimensions and validate them at run time, Spio uses Typed Dimensions: each dimension is a distinct C++ type generated at build time and checked at compile time.
|
|
46
|
+
|
|
47
|
+
- Named Tensors (strings, run-time):
|
|
48
|
+
- Dimension identity is a string evaluated at run time
|
|
49
|
+
- Errors surface during execution
|
|
50
|
+
- Requires lookups and checks in hot paths
|
|
51
|
+
|
|
52
|
+
- Typed Dimensions (types, compile-time):
|
|
53
|
+
- Each logical dimension is a unique C++ type (e.g., I, J, K8)
|
|
54
|
+
- Misuses fail to compile (zero run-time overhead)
|
|
55
|
+
- Operator overloading maps types to per-tensor positions/strides
|
|
56
|
+
|
|
57
|
+
When the same dimension type appears in different tensors, it represents the same logical dimension; each tensor still defines its own size and stride for that dimension based on its layout. This enables position-free indexing—users don’t track index positions, sizes, or strides across tensors; the type system ensures correctness at compile time.
|
|
58
|
+
|
|
59
|
+
In practice, the generated tensor classes overload the indexing operator (e.g., `operator[]` and helpers like `get<Dim>()`) to accept dimension types. For each dimension type present in a tensor’s layout, the overload applies that tensor’s stride for that type; if a dimension type not used by the tensor is provided, the expression fails to compile (static_assert), with zero run-time name lookups or checks.
|
|
60
|
+
|
|
61
|
+
### ⚡ Just-in-Time Kernel Generation
|
|
62
|
+
|
|
63
|
+
Spio compiles kernels at runtime with NVIDIA’s NVRTC (libnvrtc) and tunes them for your GPU. No CUDA toolkit install is needed because Spio relies on the CUDA headers and NVRTC shared libraries that NVIDIA distributes as Python packages (the same infrastructure PyTorch depends on). And there’s no host C compiler involved at runtime—Spio invokes kernels directly through the CUDA driver API, so no generated launcher wrappers are required.
|
|
64
|
+
|
|
65
|
+
This contrasts with packages like Triton Language that require a C compiler at runtime.
|
|
66
|
+
|
|
67
|
+
### 🎯 Performance Models
|
|
68
|
+
|
|
69
|
+
Machine learning models predict optimal kernel configurations based on layer parameters and hardware characteristics. This eliminates expensive auto-tuning while achieving better performance than heuristic-based approaches.
|
|
70
|
+
|
|
71
|
+
### 🚀 PyTorch Integration
|
|
72
|
+
|
|
73
|
+
Seamless integration with PyTorch through custom operators and `torch.compile` support. Drop-in replacement for existing operations with significant speedups.
|
|
74
|
+
|
|
75
|
+
## Performance Results
|
|
76
|
+
|
|
77
|
+
### Algorithm Innovation
|
|
78
|
+
|
|
79
|
+
The cuDNN Conv2d kernels use "implicit GEMM" with 1D horizontal tiling, causing excessive memory traffic due to overlapping reads in the convolution halo. Spio uses 2D tiling with a circular-buffer overlap-add algorithm that:
|
|
80
|
+
|
|
81
|
+
- Reduces tile overlap and global memory traffic
|
|
82
|
+
- Maximizes register usage through loop unrolling
|
|
83
|
+
- Increases occupancy by minimizing local memory footprint
|
|
84
|
+
- Leverages Tensor Cores with 8×8 matrix operations for a group width of 8
|
|
85
|
+
|
|
86
|
+
### Benchmark Results
|
|
87
|
+
|
|
88
|
+
On NVIDIA GeForce RTX 3090, Spio approaches theoretical DRAM bandwidth limits for forward pass (FProp), input gradients (DGrad), and weight gradients (WGrad), while PyTorch/cuDNN implementations suffer from excess data transfers.
|
|
89
|
+
|
|
90
|
+
On NVIDIA GeForce RTX 4090, Spio exceeds the effective DRAM bandwidth limit for small batch sizes by effectively utilizing the 72 MB L2 cache:
|
|
91
|
+
|
|
92
|
+

|
|
93
|
+
|
|
94
|
+
Benchmarks use realistic workloads with layers embedded in ConvFirst or MBConv blocks to accurately reflect real-world performance.
|
|
95
|
+
|
|
96
|
+
## Quick Start
|
|
97
|
+
|
|
98
|
+
### Prerequisites
|
|
99
|
+
|
|
100
|
+
- Linux x86_64
|
|
101
|
+
- NVIDIA GPU: Ampere (sm_80/sm_86) or Ada (sm_89)
|
|
102
|
+
- NVIDIA driver (compatible with CUDA 12 runtime)
|
|
103
|
+
- Python 3.9+
|
|
104
|
+
|
|
105
|
+
### Installation
|
|
106
|
+
|
|
107
|
+
Create and activate a virtual environment (recommended):
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
python3 -m venv spio_env
|
|
111
|
+
source spio_env/bin/activate
|
|
112
|
+
|
|
113
|
+
# Upgrade pip.
|
|
114
|
+
python -m pip install --upgrade pip
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Then install Spio from PyPI using pip:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pip install spio
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Notes:
|
|
124
|
+
|
|
125
|
+
- PyTorch (torch>=2.4.0) is an explicit dependency and will be installed automatically when you install Spio; no separate install step is required.
|
|
126
|
+
- CUDA toolkit installation is not required. Spio relies on NVIDIA's CUDA runtime and NVRTC libraries that are pulled in via wheels and are the same libraries PyTorch uses.
|
|
127
|
+
|
|
128
|
+
Alternatively, install Spio from source. For this, you will need a C compiler. On Ubuntu:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
sudo apt update && sudo apt install -y build-essential
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Then clone the Spio repository and install:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
git clone https://github.com/andravin/spio.git
|
|
138
|
+
cd spio
|
|
139
|
+
pip install .
|
|
140
|
+
|
|
141
|
+
# Run tests (optional)
|
|
142
|
+
cd tests
|
|
143
|
+
SPIO_WORKERS=$(nproc) pytest .
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Exit the virtual environment when finished.
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
deactivate
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Usage
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
import torch
|
|
156
|
+
import spio
|
|
157
|
+
|
|
158
|
+
# Replace PyTorch grouped convolution
|
|
159
|
+
x = torch.randn(32, 64, 56, 56, device='cuda', dtype=torch.float16)
|
|
160
|
+
weight = torch.randn(64, 8, 3, 3, device='cuda', dtype=torch.float16)
|
|
161
|
+
|
|
162
|
+
# Automatic kernel selection and compilation
|
|
163
|
+
output = spio.grouped_conv2d(x, weight, groups=8)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Typed Dimensions
|
|
167
|
+
|
|
168
|
+
Spio’s typed dimensions system represents dimensions as distinct C++ types (not run-time strings). The generator emits those types (e.g., I, J, K16, BLOCK_I), and kernels use operator overloading to map them to the correct position and stride per tensor. The same dimension type denotes the same logical axis across tensors, while each tensor provides its own size/stride. Because dimension identity is a type, mistakes are caught at compile time, with no run-time name lookups or checks. This is what enables index-position-free indexing and aggressive compile-time optimization (constexpr indexing, loop unrolling).
|
|
169
|
+
|
|
170
|
+
Operator overloading details:
|
|
171
|
+
|
|
172
|
+
- The generated tensor classes define typed indexing (operator[] chains and get<Dim>() helpers) that accept dimension types in any order and compute offsets using that tensor’s per-dimension strides.
|
|
173
|
+
- If you pass a dimension type that the tensor does not declare, the code fails to compile via static_assert, preventing invalid indexing from reaching run time.
|
|
174
|
+
|
|
175
|
+
Define tensor layouts for a matrix multiply kernel in the Python generator:
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
# Dimension 'i' represents the same logical dimension across all tensors
|
|
179
|
+
# But each tensor defines its own size and stride for 'i' based on its layout
|
|
180
|
+
tensor_a = gen.Tensor(
|
|
181
|
+
"A", gen.dtype.uint4,
|
|
182
|
+
# Dimension 'i' is at position 1 with size m
|
|
183
|
+
gen.Dims(k16=k16, i=m, k8=2),
|
|
184
|
+
constant=True
|
|
185
|
+
)
|
|
186
|
+
smem_tensor_a = gen.Tensor(
|
|
187
|
+
"SmemA", gen.dtype.uint4,
|
|
188
|
+
# Fold dimension 'i' with stride 16 at position 2 with size block_x16
|
|
189
|
+
gen.Dims(ping=2, k16=config.chunk_k16, i16=block_x16, checkers=32)
|
|
190
|
+
)
|
|
191
|
+
tensor_c = gen.Tensor(
|
|
192
|
+
"C", gen.dtype.uint4,
|
|
193
|
+
# Dimension 'i' is at position 0 with size m
|
|
194
|
+
gen.Dims(i=m, j8=n8)
|
|
195
|
+
)
|
|
196
|
+
global_load_index = gen.Index("GlobalLoadIndex", gen.Dims(x16=block_x16, x=16, k8=2))
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
# Define additional tensors for the CUDA kernel...
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Define thread-block tiles in Python:
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
# Dimension 'block_i' folds dimension 'i' with stride block_x.
|
|
206
|
+
gen.Fold("block_i", "i", block_x)
|
|
207
|
+
|
|
208
|
+
# Dimension 'block_j' folds dimension 'j' with stride block_x.
|
|
209
|
+
gen.Fold("block_j", "j", block_x)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
In traditional CUDA code, you manually track array indices and remember that `A[k][i][k8]` corresponds to `C[i][j8]`. With Spio's operator overloading, the same dimension type automatically maps to the correct position and stride in each tensor:
|
|
213
|
+
|
|
214
|
+
```c++
|
|
215
|
+
// Include generated code.
|
|
216
|
+
#include "parameters.h"
|
|
217
|
+
|
|
218
|
+
// Dimension 'i' and folds 'block_i' and 'block_j' generate types I, BLOCK_I, and BLOCK_J
|
|
219
|
+
// that you use in the CUDA kernel.
|
|
220
|
+
|
|
221
|
+
// Map thread-block coordinates to blocks of I and J.
|
|
222
|
+
BLOCK_I block_i(blockIdx.y);
|
|
223
|
+
|
|
224
|
+
// Map the thread index to our tensor's global coordinates X16, X, and K8.
|
|
225
|
+
GlobalLoadIndex global_load_idx(threadIdx.x);
|
|
226
|
+
|
|
227
|
+
// Add the block and thread coordinates to compute this thread's I-coordinate.
|
|
228
|
+
auto global_i = block_i.unfold() + global_load_idx.get<X>().cast<I>();
|
|
229
|
+
|
|
230
|
+
// Same 'i' dimension type works correctly across different tensors
|
|
231
|
+
// - In tensor A: 'i' maps to position 1 with A's stride for dimension 1
|
|
232
|
+
// - In tensor C: 'i' maps to position 0 with C's stride for dimension 0
|
|
233
|
+
auto a_element = A(a_ptr)[global_i][global_load_idx.get<K8>()];
|
|
234
|
+
auto c_element = C(c_ptr)[global_i];
|
|
235
|
+
|
|
236
|
+
// The user doesn't track positions, sizes, or strides - the type system handles it all
|
|
237
|
+
// Type safety prevents dimension misuse at compile time (e.g., using WARP_J with SmemA would fail to compile)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The main computation loop demonstrates how typed dimensions provide compile-time safety by preventing incompatible dimension types from being used with tensors that don't support them. The tensor implementations use `constexpr` with known tile sizes so that tensor indexing arithmetic is greatly simplified at compile-time and loops with constant bounds are unrolled. This produces highly optimized code that runs at near full utilization on NVIDIA GeForce RTX 4090 (Ada) GPUs:
|
|
241
|
+
|
|
242
|
+
```c++
|
|
243
|
+
// Main computation loop with pipelined memory operations
|
|
244
|
+
for (int iter = 0; iter < size.get(); iter += 2 * step_size.get())
|
|
245
|
+
{
|
|
246
|
+
// Double-buffer loads and compute.
|
|
247
|
+
for (auto phase : range(PING(2)))
|
|
248
|
+
{
|
|
249
|
+
// If not the last iteration, load the next tile from global
|
|
250
|
+
// memory to shared memory asynchronously.
|
|
251
|
+
if (iter + (phase.get() + 1) * step_size.get() < size.get())
|
|
252
|
+
{
|
|
253
|
+
// Load into the back-buffer.
|
|
254
|
+
loader_a.load(smem_a_store[(phase + 1) % 2].get(), a.get());
|
|
255
|
+
loader_b.load(smem_b_store[(phase + 1) % 2].get(), b.get());
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Advance the global memory tiles.
|
|
259
|
+
a.step(step_size);
|
|
260
|
+
b.step(step_size);
|
|
261
|
+
|
|
262
|
+
// Synchronize on the previous iteration's global memory load.
|
|
263
|
+
__pipeline_commit();
|
|
264
|
+
__pipeline_wait_prior(1);
|
|
265
|
+
__syncthreads();
|
|
266
|
+
|
|
267
|
+
// Load matrix tiles from shared memory.
|
|
268
|
+
a_tile.load(smem_a_load[phase]);
|
|
269
|
+
b_tile.load(smem_b_load[phase]);
|
|
270
|
+
|
|
271
|
+
// Matrix-multiply the tiles using Tensor Cores.
|
|
272
|
+
// Compile-time type checking ensures the compatibility of the tile dimensions.
|
|
273
|
+
mma(a_tile, b_tile, c_tile, c_tile);
|
|
274
|
+
__syncthreads();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
The output staging loop demonstrates how dimensions can be dynamically refolded with different strides, while the type system ensures compile-time safety by preventing incompatible fold operations:
|
|
280
|
+
|
|
281
|
+
```c++
|
|
282
|
+
// Nested loops using typed dimension iterators - no manual index calculations
|
|
283
|
+
for (auto i16 : range(c_tile.size<I16>())) {
|
|
284
|
+
for (auto j16 : range(c_tile.size<J16>())) {
|
|
285
|
+
*smem_c_cursor[j16.fold<8>()][i16] = c_tile[i16][j16]->to_half2(f);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
The system automatically handles:
|
|
291
|
+
|
|
292
|
+
- **Logical dimension consistency**: Same dimension type represents the same logical dimension across all tensors
|
|
293
|
+
- **Automatic position mapping**: Operator overloading maps dimension types to correct array positions
|
|
294
|
+
- **Per-tensor size and stride**: Each tensor defines its own size and stride for shared dimensions
|
|
295
|
+
- **Index-position-free operations**: No need to track array positions, sizes, or strides manually
|
|
296
|
+
- **Type safety**: Prevents using wrong dimension types at compile time
|
|
297
|
+
- **Memory layout optimization**: Automatic padding and alignment
|