spio 0.0.6.post12__tar.gz → 0.3.0__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.
Potentially problematic release.
This version of spio might be problematic. Click here for more details.
- spio-0.3.0/LICENSE +202 -0
- spio-0.3.0/MANIFEST.in +12 -0
- spio-0.3.0/PKG-INFO +162 -0
- spio-0.3.0/README.md +148 -0
- spio-0.3.0/pyproject.toml +22 -0
- spio-0.3.0/setup.cfg +4 -0
- spio-0.3.0/setup.py +46 -0
- spio-0.3.0/spio/__init__.py +20 -0
- spio-0.3.0/spio/compiler/__init__.py +6 -0
- spio-0.3.0/spio/compiler/arch.py +10 -0
- spio-0.3.0/spio/compiler/compile.py +64 -0
- spio-0.3.0/spio/compiler/compile_kernel.py +90 -0
- spio-0.3.0/spio/compiler/compile_nvcc.py +84 -0
- spio-0.3.0/spio/compiler/compiler_pool.py +98 -0
- spio-0.3.0/spio/cuda/__init__.py +9 -0
- spio-0.3.0/spio/cuda/cdriver.pxd +96 -0
- spio-0.3.0/spio/cuda/driver.c +13060 -0
- spio-0.3.0/spio/cuda/driver.pyx +141 -0
- spio-0.3.0/spio/cuda/nvrtc_ctypes.py +205 -0
- spio-0.3.0/spio/functional/__init__.py +8 -0
- spio-0.3.0/spio/functional/conv2d_gw8_function.py +249 -0
- spio-0.3.0/spio/generators/__init__.py +8 -0
- spio-0.3.0/spio/generators/fragment.py +65 -0
- spio-0.3.0/spio/generators/gen_specs.py +17 -0
- spio-0.3.0/spio/generators/generators.py +51 -0
- spio-0.3.0/spio/generators/index.py +97 -0
- spio-0.3.0/spio/generators/macros.py +23 -0
- spio-0.3.0/spio/generators/params.py +40 -0
- spio-0.3.0/spio/generators/tensor.py +141 -0
- spio-0.3.0/spio/include/__init__.py +1 -0
- spio-0.3.0/spio/include/spio/fragment.cuh +199 -0
- spio-0.3.0/spio/include/spio/index.h +93 -0
- spio-0.3.0/spio/include/spio/ldmatrix.cuh +102 -0
- spio-0.3.0/spio/include/spio/mma.cuh +60 -0
- spio-0.3.0/spio/include/spio/pipeline.h +32 -0
- spio-0.3.0/spio/include/spio/tensor.h +109 -0
- spio-0.3.0/spio/kernels/__init__.py +20 -0
- spio-0.3.0/spio/kernels/conv2d_gw8_kernel.py +186 -0
- spio-0.3.0/spio/kernels/conv2d_gw8_params.py +215 -0
- spio-0.3.0/spio/kernels/conv2d_gw8_wgrad_kernel.py +251 -0
- spio-0.3.0/spio/kernels/conv2d_stats.py +126 -0
- spio-0.3.0/spio/kernels/kernel.py +143 -0
- spio-0.3.0/spio/kernels/kernel_cache.py +108 -0
- spio-0.3.0/spio/kernels/kernel_factory.py +193 -0
- spio-0.3.0/spio/kernels/kernel_key.py +34 -0
- spio-0.3.0/spio/kernels/kernel_params_logger.py +113 -0
- spio-0.3.0/spio/kernels/kernel_util.py +14 -0
- spio-0.3.0/spio/kernels/launch_params.py +25 -0
- spio-0.3.0/spio/kernels/params.py +23 -0
- spio-0.3.0/spio/kernels/performance_model_cache.py +473 -0
- spio-0.3.0/spio/kernels/stats.py +74 -0
- spio-0.3.0/spio/layers/__init__.py +4 -0
- spio-0.3.0/spio/layers/conv2d_gw8.py +140 -0
- spio-0.3.0/spio/layers/make.py +15 -0
- spio-0.3.0/spio/reflection/__init__.py +10 -0
- spio-0.3.0/spio/reflection/arg_info.py +146 -0
- spio-0.3.0/spio/reflection/conv2d_gw8_reflection.py +163 -0
- spio-0.3.0/spio/reflection/reflection.py +203 -0
- spio-0.3.0/spio/src/__init__.py +1 -0
- spio-0.3.0/spio/src/conv2d_gw8.cu +386 -0
- spio-0.3.0/spio/src/conv2d_gw8_wgrad.cu +279 -0
- spio-0.3.0/spio/src_tests/Conv2dGw8Params.dat +81 -0
- spio-0.3.0/spio/src_tests/__init__.py +11 -0
- spio-0.3.0/spio/src_tests/add.cu +9 -0
- spio-0.3.0/spio/src_tests/ldmatrix.cu +135 -0
- spio-0.3.0/spio/src_tests/memcpy_simple.cu +51 -0
- spio-0.3.0/spio/src_tests/mma.cu +63 -0
- spio-0.3.0/spio/src_tests/preprocess_data_file.py +82 -0
- spio-0.3.0/spio/src_tests/row_memcpy.cu +126 -0
- spio-0.3.0/spio/src_tests/run_test.py +221 -0
- spio-0.3.0/spio/src_tests/utest.h +1700 -0
- spio-0.3.0/spio/transform/__init__.py +8 -0
- spio-0.3.0/spio/transform/_transform.py +110 -0
- spio-0.3.0/spio/util/__init__.py +12 -0
- spio-0.3.0/spio/util/cache_dir.py +8 -0
- spio-0.3.0/spio/util/class_names.py +15 -0
- spio-0.3.0/spio/util/close.py +69 -0
- spio-0.3.0/spio/util/device_info.py +16 -0
- spio-0.3.0/spio/util/interval_timer.py +117 -0
- spio-0.3.0/spio/util/load_parameter_set.py +77 -0
- spio-0.3.0/spio/util/logger.py +17 -0
- spio-0.3.0/spio/util/math.py +6 -0
- spio-0.3.0/spio/util/parse_dataclass.py +38 -0
- spio-0.3.0/spio/util/parse_kwargs.py +24 -0
- spio-0.3.0/spio.egg-info/PKG-INFO +162 -0
- spio-0.3.0/spio.egg-info/SOURCES.txt +93 -0
- spio-0.3.0/spio.egg-info/dependency_links.txt +1 -0
- spio-0.3.0/spio.egg-info/top_level.txt +1 -0
- spio-0.3.0/tests/test_conv2d_gw8.py +175 -0
- spio-0.3.0/tests/test_index.py +128 -0
- spio-0.3.0/tests/test_kernel.py +223 -0
- spio-0.3.0/tests/test_ldmatrix.py +143 -0
- spio-0.3.0/tests/test_nvcc.py +11 -0
- spio-0.3.0/tests/test_stats.py +49 -0
- spio-0.0.6.post12/LICENSE.md +0 -19
- spio-0.0.6.post12/PKG-INFO +0 -157
- spio-0.0.6.post12/README.md +0 -137
- spio-0.0.6.post12/pyproject.toml +0 -26
- spio-0.0.6.post12/src/marvin/tools/default_config.ini +0 -11
- spio-0.0.6.post12/src/marvin/tools/spio.py +0 -1316
- {spio-0.0.6.post12/src/marvin → spio-0.3.0/spio/include/spio}/__init__.py +0 -0
spio-0.3.0/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.3.0/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.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: spio
|
|
3
|
+
Version: 0.3.0
|
|
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
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
|
|
15
|
+
# Spio
|
|
16
|
+
|
|
17
|
+
Efficient CUDA kernels for training convolutional neural networks with PyTorch.
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
## Introduction
|
|
22
|
+
|
|
23
|
+
The goal of the Spio project is to improve training efficiency for convolutional neural networks (ConvNets). While there has been a lot of progress in the design of ConvNet models, the performance of ConvNet kernels has languished. Today, the performance of a ConvNet is often limited by the efficiency of its implementation.
|
|
24
|
+
|
|
25
|
+
Our [paper](https://arxiv.org/abs/2404.03617) implemented efficient GPU kernels for ConvNet inference. Spio implements kernels for training.
|
|
26
|
+
|
|
27
|
+
The first Spio kernel is for grouped convolution, a promising layer that has fallen into disuse because of the inefficiency of the current implementation. We focus on group width equal to eight and stride 1, as used in our ConvFirst model, and support NVIDIA Ampere ([sm_80](https://images.nvidia.com/aem-dam/en-zz/Solutions/data-center/nvidia-ampere-architecture-whitepaper.pdf) and [sm_86](https://www.nvidia.com/content/PDF/nvidia-ampere-ga-102-gpu-architecture-whitepaper-v2.pdf)) and Ada ([sm_89](https://images.nvidia.com/aem-dam/Solutions/Data-Center/l4/nvidia-ada-gpu-architecture-whitepaper-v2.1.pdf)) GPUs.
|
|
28
|
+
|
|
29
|
+
### Audience
|
|
30
|
+
|
|
31
|
+
At this early stage of development, Spio is for performance engineers and other heroes. As we add more kernels, Spio will guide model researchers to safety, like the Nereid Spio guiding sailors through treacherous waters.
|
|
32
|
+
|
|
33
|
+
## Benchmarks
|
|
34
|
+
|
|
35
|
+
The cuDNN Conv2d kernels use an "implicit GEMM" algorithm that tiles the input tensor with horizontal strips. The support halo for the convolution kernel causes overlapping reads of the input tensor, and when the tile is a 1D strip, the overlap is larger than the tile. This results in excess global memory traffic.
|
|
36
|
+
|
|
37
|
+
The Spio Conv2d kernel uses 2D tiles. This reduces the overlap between tiles and reduces global memory traffic. It processes the 2D tile one row at a time, convolving each input row with every filter row while updating a circular buffer of output rows. The circular buffer is implemented in registers by unrolling the input-row loop by the number of filter rows. This overlap-add style algorithm minimizes the kernel's local memory footprint, which increases occupancy and maximizes utilization of the global memory bandwidth.
|
|
38
|
+
|
|
39
|
+
Group width 8 matches the accumulation depth of the Float16 tensor core (through AD102, sm_89). Therefore, the grouped convolution is implemented just like regular planar convolution, but with scalar input elements
|
|
40
|
+
replaced by 8-element vectors, scalar filter elements replaced by 8x8 matrices, and scalar multiplication replaced by matrix-vector multiplication. Processing 16 columns of the input row at once turns the input vectors into input matrices, so that the algorithm can use the [mma.sync.aligned.m16n8k8.row.col.f32.f16.f16.f32](https://docs.nvidia.com/cuda/parallel-thread-execution/#warp-level-matrix-instructions-mma) instruction.
|
|
41
|
+
|
|
42
|
+
On the NVIDIA RTX 3090 GPU (above), Spio approaches the DRAM memory bandwidth limit for the FProp, DGrad (gradient with respect to inputs), and WGrad (gradient with respect to weights) kernels, while the PyTorch / cuDNN kernels struggle with excess data transfers.
|
|
43
|
+
|
|
44
|
+
On the NVIDIA RTX 4090 GPU, Spio exceeds the DRAM memory bandwidth limit for small batch sizes by exploiting the fact that the activation tensors fit in the GPU's large (72 MB) L2 cache:
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
### Benchmarking Methodology
|
|
49
|
+
|
|
50
|
+
Our benchmarks use [torch.profile](https://pytorch.org/docs/stable/profiler.html), which uses NVIDIA's [libcupti](https://developer.nvidia.com/cupti-ctk12_0) internally for precise
|
|
51
|
+
kernel timing. We benchmark layers *in situ*, placing a grouped convolution layer inside a
|
|
52
|
+
ConvFirst or MBConv building block and constructing a stack of several blocks. This creates a realistic environment for the target kernel, where the memory hierarchy is exercised similarly to a real-world use case.
|
|
53
|
+
|
|
54
|
+
## Implementation Notes
|
|
55
|
+
|
|
56
|
+
Spio uses several strategies to simplify the development of high-performance CUDA kernels that
|
|
57
|
+
integrate with PyTorch.
|
|
58
|
+
|
|
59
|
+
### Named Tensors
|
|
60
|
+
|
|
61
|
+
Spio uses named tensors to simplify tensor indexing in CUDA source code. In Python, you specify the tensor
|
|
62
|
+
and indexing dimensions like this:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
TensorSpec("Output", "uint4", {"n": n, "p": p, "q": q, "k8": c8}),
|
|
66
|
+
TensorSpec(
|
|
67
|
+
"ConstSmemOutput",
|
|
68
|
+
"const uint4",
|
|
69
|
+
{"q": block_q, "n": block_n, "k8": block_c8 + 1},
|
|
70
|
+
),
|
|
71
|
+
IndexSpec("OutputStoreIdx", {"n": block_n, "q": block_q, "k8": block_c8}),
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
which generates CUDA/C++ classes that you use in your kernel like this:
|
|
75
|
+
|
|
76
|
+
```c++
|
|
77
|
+
// Output-smem to output.
|
|
78
|
+
ConstSmemOutput smem_output_load(smem_output_buf);
|
|
79
|
+
Output output(dst);
|
|
80
|
+
bool thread_stores_output;
|
|
81
|
+
{
|
|
82
|
+
OutputStoreIdx idx(threadIdx.x);
|
|
83
|
+
auto q = block_q + idx.q();
|
|
84
|
+
auto n = block_n + idx.n();
|
|
85
|
+
auto k8 = block_c8 + idx.k8();
|
|
86
|
+
smem_output_load = smem_output_load.n(idx.n()).q(idx.q()).k8(idx.k8());
|
|
87
|
+
output = output.n(n).p(block_p).q(q).k8(k8);
|
|
88
|
+
thread_stores_output = n < Output::N && q < Output::Q && k8 < Output::K8 &&
|
|
89
|
+
threadIdx.x < OutputStoreIdx::size;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# ...
|
|
93
|
+
|
|
94
|
+
if (thread_stores_output)
|
|
95
|
+
{
|
|
96
|
+
*output = *smem_output_load;
|
|
97
|
+
}
|
|
98
|
+
output = output.p(1);
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Run Time Compilation
|
|
103
|
+
|
|
104
|
+
Spio compiles kernels at runtime using [libnvrtc](https://docs.nvidia.com/cuda/nvrtc/index.html) and launches them with [libcuda](https://docs.nvidia.com/cuda/cuda-driver-api/index.html). Unlike other packages that offer runtime compilation, Spio does not depend on the CUDA toolkit. We simply use the same NVIDIA [libnvrtc](https://pypi.org/project/nvidia-cuda-nvrtc-cu12/) and [cuda-runtime](https://pypi.org/project/nvidia-cuda-runtime-cu12/) Python packages on which PyTorch already [depends](https://github.com/pytorch/pytorch/blob/bae3426af77be643af83f1527fb430e9ca09b058/.github/scripts/generate_binary_build_matrix.py#L71). This minimizes software dependencies and simplifies installation.
|
|
105
|
+
|
|
106
|
+
### Kernel Performance Models
|
|
107
|
+
|
|
108
|
+
Spio predicts the best kernel configuration for each layer with a performance model trained on thousands of offline benchmarking samples. Prediction takes just a few milliseconds, so startup is much faster than other frameworks that use a time consuming auto-tuning step.
|
|
109
|
+
|
|
110
|
+
### Integration with torch.compile
|
|
111
|
+
|
|
112
|
+
We integrate with `torch.compile` using the [Python Custom Operators](https://pytorch.org/tutorials/advanced/python_custom_ops.html) interface from PyTorch 2.4. This functionality passes basic tests but is still experimental. See this [PyTorch issue](https://github.com/pytorch/pytorch/issues/137033).
|
|
113
|
+
|
|
114
|
+
## Installation from Source
|
|
115
|
+
|
|
116
|
+
First, ensure you have a C compiler installed. On Ubuntu:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
sudo apt update
|
|
120
|
+
sudo apt install build-essential
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Clone the repository:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
git clone https://github.com/andravin/spio.git
|
|
127
|
+
cd spio
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Optionally, create a virtual environment and activate it:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
python3 -m venv .venv
|
|
134
|
+
source .venv/bin/activate
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Install the package from source using pip:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
pip install --upgrade pip
|
|
141
|
+
pip install .
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Optionally, run the unit tests. This can take a while,
|
|
145
|
+
because Spio tests every configuration of each kernel. It goes a bit faster
|
|
146
|
+
if we set the SPIO_WORKERS environment variable to use all CPU cores for compiling kernels:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
cd tests
|
|
150
|
+
SPIO_WORKERS=$(nproc) pytest .
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Note: the tests and scripts cannot be run from the top-level spio directory because
|
|
154
|
+
that would cause Python to find the local spio package instead of the installed package.
|
|
155
|
+
Only the installed package includes the compiled spio.cuda.driver Cython extension, so using
|
|
156
|
+
the local package would result in an import error. Therefore, running `cd tests` before `pytest .` is essential.
|
|
157
|
+
|
|
158
|
+
## Using Spio with Timm
|
|
159
|
+
|
|
160
|
+
Spio is integrated with [our fork](https://github.com/andravin/pytorch-image-models.git) of pytorch-image-models (timm) on the `spio_dev` branch. Add the `--spio` option to the command line of `benchmark.py`, `validate.py`, or `train.py`, and timm will use the Spio implementation for any supported operations.
|
|
161
|
+
|
|
162
|
+
Set the environment variable `export SPIO_LOGGER=1` to cause Spio to print diagnostic info to the console.
|
spio-0.3.0/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Spio
|
|
2
|
+
|
|
3
|
+
Efficient CUDA kernels for training convolutional neural networks with PyTorch.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Introduction
|
|
8
|
+
|
|
9
|
+
The goal of the Spio project is to improve training efficiency for convolutional neural networks (ConvNets). While there has been a lot of progress in the design of ConvNet models, the performance of ConvNet kernels has languished. Today, the performance of a ConvNet is often limited by the efficiency of its implementation.
|
|
10
|
+
|
|
11
|
+
Our [paper](https://arxiv.org/abs/2404.03617) implemented efficient GPU kernels for ConvNet inference. Spio implements kernels for training.
|
|
12
|
+
|
|
13
|
+
The first Spio kernel is for grouped convolution, a promising layer that has fallen into disuse because of the inefficiency of the current implementation. We focus on group width equal to eight and stride 1, as used in our ConvFirst model, and support NVIDIA Ampere ([sm_80](https://images.nvidia.com/aem-dam/en-zz/Solutions/data-center/nvidia-ampere-architecture-whitepaper.pdf) and [sm_86](https://www.nvidia.com/content/PDF/nvidia-ampere-ga-102-gpu-architecture-whitepaper-v2.pdf)) and Ada ([sm_89](https://images.nvidia.com/aem-dam/Solutions/Data-Center/l4/nvidia-ada-gpu-architecture-whitepaper-v2.1.pdf)) GPUs.
|
|
14
|
+
|
|
15
|
+
### Audience
|
|
16
|
+
|
|
17
|
+
At this early stage of development, Spio is for performance engineers and other heroes. As we add more kernels, Spio will guide model researchers to safety, like the Nereid Spio guiding sailors through treacherous waters.
|
|
18
|
+
|
|
19
|
+
## Benchmarks
|
|
20
|
+
|
|
21
|
+
The cuDNN Conv2d kernels use an "implicit GEMM" algorithm that tiles the input tensor with horizontal strips. The support halo for the convolution kernel causes overlapping reads of the input tensor, and when the tile is a 1D strip, the overlap is larger than the tile. This results in excess global memory traffic.
|
|
22
|
+
|
|
23
|
+
The Spio Conv2d kernel uses 2D tiles. This reduces the overlap between tiles and reduces global memory traffic. It processes the 2D tile one row at a time, convolving each input row with every filter row while updating a circular buffer of output rows. The circular buffer is implemented in registers by unrolling the input-row loop by the number of filter rows. This overlap-add style algorithm minimizes the kernel's local memory footprint, which increases occupancy and maximizes utilization of the global memory bandwidth.
|
|
24
|
+
|
|
25
|
+
Group width 8 matches the accumulation depth of the Float16 tensor core (through AD102, sm_89). Therefore, the grouped convolution is implemented just like regular planar convolution, but with scalar input elements
|
|
26
|
+
replaced by 8-element vectors, scalar filter elements replaced by 8x8 matrices, and scalar multiplication replaced by matrix-vector multiplication. Processing 16 columns of the input row at once turns the input vectors into input matrices, so that the algorithm can use the [mma.sync.aligned.m16n8k8.row.col.f32.f16.f16.f32](https://docs.nvidia.com/cuda/parallel-thread-execution/#warp-level-matrix-instructions-mma) instruction.
|
|
27
|
+
|
|
28
|
+
On the NVIDIA RTX 3090 GPU (above), Spio approaches the DRAM memory bandwidth limit for the FProp, DGrad (gradient with respect to inputs), and WGrad (gradient with respect to weights) kernels, while the PyTorch / cuDNN kernels struggle with excess data transfers.
|
|
29
|
+
|
|
30
|
+
On the NVIDIA RTX 4090 GPU, Spio exceeds the DRAM memory bandwidth limit for small batch sizes by exploiting the fact that the activation tensors fit in the GPU's large (72 MB) L2 cache:
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
### Benchmarking Methodology
|
|
35
|
+
|
|
36
|
+
Our benchmarks use [torch.profile](https://pytorch.org/docs/stable/profiler.html), which uses NVIDIA's [libcupti](https://developer.nvidia.com/cupti-ctk12_0) internally for precise
|
|
37
|
+
kernel timing. We benchmark layers *in situ*, placing a grouped convolution layer inside a
|
|
38
|
+
ConvFirst or MBConv building block and constructing a stack of several blocks. This creates a realistic environment for the target kernel, where the memory hierarchy is exercised similarly to a real-world use case.
|
|
39
|
+
|
|
40
|
+
## Implementation Notes
|
|
41
|
+
|
|
42
|
+
Spio uses several strategies to simplify the development of high-performance CUDA kernels that
|
|
43
|
+
integrate with PyTorch.
|
|
44
|
+
|
|
45
|
+
### Named Tensors
|
|
46
|
+
|
|
47
|
+
Spio uses named tensors to simplify tensor indexing in CUDA source code. In Python, you specify the tensor
|
|
48
|
+
and indexing dimensions like this:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
TensorSpec("Output", "uint4", {"n": n, "p": p, "q": q, "k8": c8}),
|
|
52
|
+
TensorSpec(
|
|
53
|
+
"ConstSmemOutput",
|
|
54
|
+
"const uint4",
|
|
55
|
+
{"q": block_q, "n": block_n, "k8": block_c8 + 1},
|
|
56
|
+
),
|
|
57
|
+
IndexSpec("OutputStoreIdx", {"n": block_n, "q": block_q, "k8": block_c8}),
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
which generates CUDA/C++ classes that you use in your kernel like this:
|
|
61
|
+
|
|
62
|
+
```c++
|
|
63
|
+
// Output-smem to output.
|
|
64
|
+
ConstSmemOutput smem_output_load(smem_output_buf);
|
|
65
|
+
Output output(dst);
|
|
66
|
+
bool thread_stores_output;
|
|
67
|
+
{
|
|
68
|
+
OutputStoreIdx idx(threadIdx.x);
|
|
69
|
+
auto q = block_q + idx.q();
|
|
70
|
+
auto n = block_n + idx.n();
|
|
71
|
+
auto k8 = block_c8 + idx.k8();
|
|
72
|
+
smem_output_load = smem_output_load.n(idx.n()).q(idx.q()).k8(idx.k8());
|
|
73
|
+
output = output.n(n).p(block_p).q(q).k8(k8);
|
|
74
|
+
thread_stores_output = n < Output::N && q < Output::Q && k8 < Output::K8 &&
|
|
75
|
+
threadIdx.x < OutputStoreIdx::size;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# ...
|
|
79
|
+
|
|
80
|
+
if (thread_stores_output)
|
|
81
|
+
{
|
|
82
|
+
*output = *smem_output_load;
|
|
83
|
+
}
|
|
84
|
+
output = output.p(1);
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Run Time Compilation
|
|
89
|
+
|
|
90
|
+
Spio compiles kernels at runtime using [libnvrtc](https://docs.nvidia.com/cuda/nvrtc/index.html) and launches them with [libcuda](https://docs.nvidia.com/cuda/cuda-driver-api/index.html). Unlike other packages that offer runtime compilation, Spio does not depend on the CUDA toolkit. We simply use the same NVIDIA [libnvrtc](https://pypi.org/project/nvidia-cuda-nvrtc-cu12/) and [cuda-runtime](https://pypi.org/project/nvidia-cuda-runtime-cu12/) Python packages on which PyTorch already [depends](https://github.com/pytorch/pytorch/blob/bae3426af77be643af83f1527fb430e9ca09b058/.github/scripts/generate_binary_build_matrix.py#L71). This minimizes software dependencies and simplifies installation.
|
|
91
|
+
|
|
92
|
+
### Kernel Performance Models
|
|
93
|
+
|
|
94
|
+
Spio predicts the best kernel configuration for each layer with a performance model trained on thousands of offline benchmarking samples. Prediction takes just a few milliseconds, so startup is much faster than other frameworks that use a time consuming auto-tuning step.
|
|
95
|
+
|
|
96
|
+
### Integration with torch.compile
|
|
97
|
+
|
|
98
|
+
We integrate with `torch.compile` using the [Python Custom Operators](https://pytorch.org/tutorials/advanced/python_custom_ops.html) interface from PyTorch 2.4. This functionality passes basic tests but is still experimental. See this [PyTorch issue](https://github.com/pytorch/pytorch/issues/137033).
|
|
99
|
+
|
|
100
|
+
## Installation from Source
|
|
101
|
+
|
|
102
|
+
First, ensure you have a C compiler installed. On Ubuntu:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
sudo apt update
|
|
106
|
+
sudo apt install build-essential
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Clone the repository:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
git clone https://github.com/andravin/spio.git
|
|
113
|
+
cd spio
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Optionally, create a virtual environment and activate it:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
python3 -m venv .venv
|
|
120
|
+
source .venv/bin/activate
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Install the package from source using pip:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pip install --upgrade pip
|
|
127
|
+
pip install .
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Optionally, run the unit tests. This can take a while,
|
|
131
|
+
because Spio tests every configuration of each kernel. It goes a bit faster
|
|
132
|
+
if we set the SPIO_WORKERS environment variable to use all CPU cores for compiling kernels:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
cd tests
|
|
136
|
+
SPIO_WORKERS=$(nproc) pytest .
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Note: the tests and scripts cannot be run from the top-level spio directory because
|
|
140
|
+
that would cause Python to find the local spio package instead of the installed package.
|
|
141
|
+
Only the installed package includes the compiled spio.cuda.driver Cython extension, so using
|
|
142
|
+
the local package would result in an import error. Therefore, running `cd tests` before `pytest .` is essential.
|
|
143
|
+
|
|
144
|
+
## Using Spio with Timm
|
|
145
|
+
|
|
146
|
+
Spio is integrated with [our fork](https://github.com/andravin/pytorch-image-models.git) of pytorch-image-models (timm) on the `spio_dev` branch. Add the `--spio` option to the command line of `benchmark.py`, `validate.py`, or `train.py`, and timm will use the Spio implementation for any supported operations.
|
|
147
|
+
|
|
148
|
+
Set the environment variable `export SPIO_LOGGER=1` to cause Spio to print diagnostic info to the console.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=42", "wheel", "Cython", "nvidia-cuda-runtime-cu12", "importlib_resources"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "spio"
|
|
7
|
+
version = "0.3.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Andrew Lavin", email = "alavin@acm.org" },
|
|
10
|
+
]
|
|
11
|
+
description = "Efficient CUDA kernels for training convolutional neural networks with PyTorch."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: Apache Software License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com/andravin/spio"
|
|
22
|
+
Issues = "https://github.com/andravin/spio/issues"
|
spio-0.3.0/setup.cfg
ADDED
spio-0.3.0/setup.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Setup script for the spio package."""
|
|
2
|
+
|
|
3
|
+
from setuptools import setup, find_packages, Extension
|
|
4
|
+
from Cython.Build import cythonize
|
|
5
|
+
|
|
6
|
+
from importlib_resources import files as importlib_resources_files
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _get_cuda_rt_include_path() -> str:
|
|
10
|
+
"""Get the CUDA runtime include path from the nvidia.cuda_runtime package."""
|
|
11
|
+
try:
|
|
12
|
+
with importlib_resources_files("nvidia.cuda_runtime.include") as path:
|
|
13
|
+
return str(path)
|
|
14
|
+
except FileNotFoundError as e:
|
|
15
|
+
raise RuntimeError("Could not find CUDA runtime include directory.") from e
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
extensions = [
|
|
19
|
+
Extension(
|
|
20
|
+
name="spio.cuda.driver",
|
|
21
|
+
sources=["spio/cuda/driver.pyx"],
|
|
22
|
+
libraries=["cuda"],
|
|
23
|
+
include_dirs=[_get_cuda_rt_include_path()],
|
|
24
|
+
),
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
setup(
|
|
29
|
+
name="spio",
|
|
30
|
+
version="0.3.0",
|
|
31
|
+
packages=find_packages(),
|
|
32
|
+
ext_modules=cythonize(extensions),
|
|
33
|
+
install_requires=[
|
|
34
|
+
"torch>=2.4.0",
|
|
35
|
+
"nvidia-cuda-nvrtc-cu12",
|
|
36
|
+
"nvidia-cuda-runtime-cu12",
|
|
37
|
+
"pytest",
|
|
38
|
+
"xgboost",
|
|
39
|
+
"appdirs",
|
|
40
|
+
"requests",
|
|
41
|
+
"filelock",
|
|
42
|
+
"packaging",
|
|
43
|
+
"importlib_resources",
|
|
44
|
+
],
|
|
45
|
+
include_package_data=True,
|
|
46
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""spio: A Python package with efficient GPU kernels for training convolutional neural networks."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.3.0"
|
|
4
|
+
# Import the CUDA and driver modules to ensure they are initialized
|
|
5
|
+
# before accessing their contents.
|
|
6
|
+
from .cuda.driver import init, PrimaryContextGuard
|
|
7
|
+
|
|
8
|
+
# Initialize CUDA driver API
|
|
9
|
+
init()
|
|
10
|
+
|
|
11
|
+
# Retain the primary CUDA context.
|
|
12
|
+
primary_context_guard = PrimaryContextGuard()
|
|
13
|
+
|
|
14
|
+
# Supported GPU architectures
|
|
15
|
+
# sm_80: A100
|
|
16
|
+
# sm_86: RTX 30 series
|
|
17
|
+
# sm_89: RTX 40 series
|
|
18
|
+
supported_arch = ["sm_80", "sm_86", "sm_89"]
|
|
19
|
+
|
|
20
|
+
# sm_90: H100 (not yet supported)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Functions for compiling CUDA kernels."""
|
|
2
|
+
|
|
3
|
+
from .compile import compile_cuda
|
|
4
|
+
from .compile_nvcc import nvcc_full_path, compile_with_nvcc
|
|
5
|
+
from .compile_kernel import compile_kernel, load_kernel, compile_and_load_kernel
|
|
6
|
+
from .compiler_pool import lineinfo, debug, compile_kernel_configs, compile_kernels
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Helper functions for dealing with CUDA architectures."""
|
|
2
|
+
|
|
3
|
+
from typing import Tuple
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def sm_from_arch(arch: Tuple[int, int]) -> str:
|
|
7
|
+
"""Return a sm_xx string for an arch tuple."""
|
|
8
|
+
if isinstance(arch, tuple):
|
|
9
|
+
return f"sm_{arch[0]}{arch[1]}"
|
|
10
|
+
return arch
|