cutez 0.1.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.
cutez-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ZhangZ
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
cutez-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: cutez
3
+ Version: 0.1.0
4
+ License-File: LICENSE
5
+ Requires-Dist: flash_attn_4==4.0.0b4
6
+ Dynamic: license-file
cutez-0.1.0/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # cutex
2
+
3
+ ## Build
4
+
5
+ Build the source distribution and wheel with:
6
+
7
+ ```bash
8
+ python -m build --sdist --wheel
9
+ ```
@@ -0,0 +1,218 @@
1
+ from typing import List, Type, Union, Tuple
2
+
3
+ import cutlass.cute as cute
4
+
5
+ from cutlass.cute.arch import numeric_conversion
6
+ from cutlass.cute.nvgpu.common import CopyUniversalOp
7
+ from cutlass.cute.nvgpu.warp import StMatrix8x8x16bOp, StMatrix16x8x8bOp
8
+ from cutlass.cute.nvgpu.tcgen05 import (
9
+ MmaF16BF16Op,
10
+ MmaTF32Op,
11
+ MmaI8Op,
12
+ MmaFP8Op,
13
+ MmaMXF8Op,
14
+ MmaMXF4Op,
15
+ MmaMXF4NVF4Op,
16
+ OperandSource as Tcgen05OperandSource,
17
+ OperandMajorMode,
18
+ CtaGroup,
19
+ Ld16x64bOp,
20
+ Ld16x128bOp,
21
+ Ld16x256bOp,
22
+ Ld16x32bx2Op,
23
+ Ld32x32bOp,
24
+ Repetition,
25
+ Pack,
26
+ SmemLayoutAtomKind,
27
+ make_smem_layout_atom,
28
+ tile_to_mma_shape,
29
+ is_tmem_load,
30
+ get_tmem_copy_properties,
31
+ )
32
+ from cutlass.cute.nvgpu.cpasync import (
33
+ CopyBulkTensorTileG2SMulticastOp,
34
+ CopyBulkTensorTileG2SOp,
35
+ )
36
+ from cutlass.utils.layout import LayoutEnum
37
+ from cutlass.cutlass_dsl import (
38
+ Float16,
39
+ BFloat16,
40
+ TFloat32,
41
+ Float32,
42
+ Uint8,
43
+ Int8,
44
+ Float8E4M3FN,
45
+ Float8E5M2,
46
+ Float4E2M1FN,
47
+ Numeric,
48
+ NumericMeta,
49
+ dsl_user_op,
50
+ )
51
+ from torch._prims_common import number_type
52
+
53
+ @dsl_user_op
54
+ def explain_get_smem_store_op(
55
+ layout_d: LayoutEnum,
56
+ elem_ty_d: Type[Numeric],
57
+ elem_ty_acc: Type[Numeric],
58
+ tiled_tmem_load: cute.TiledCopy,
59
+ *,
60
+ loc=None,
61
+ ip=None,
62
+ ) -> cute.CopyAtom:
63
+ """Selects the largest vectorized smem store atom available subject to
64
+ constraint of gmem layout and chosen TMEM_LOAD's thread-value ownership.
65
+
66
+ :param layout_d: The layout enum of the output tensor D.
67
+ :type layout_d: LayoutEnum
68
+ :param elem_ty_d: The element type for output tensor D.
69
+ :type elem_ty_d: Type[Numeric]
70
+ :param elem_ty_acc: The element type for accumulator.
71
+ :type elem_ty_acc: Type[Numeric]
72
+ :param tiled_tmem_load: An instance of TiledCopy that represents the tmem load operation.
73
+ :type tiled_tmem_load: cute.TiledCopy
74
+
75
+ :return: Either SmemStoreMatrix or SimtSyncCopy, based on the input parameters.
76
+ :rtype: cute.CopyAtom
77
+ """
78
+
79
+ def validate_type(ty, ty_name):
80
+ if not isinstance(ty, NumericMeta):
81
+ raise TypeError(f"{ty_name} must be a Numeric, but got {ty}")
82
+
83
+ validate_type(elem_ty_d, "elem_ty_d")
84
+ validate_type(elem_ty_acc, "elem_ty_acc")
85
+
86
+ is_m_major = layout_d.is_m_major_c()
87
+ is_n_major = layout_d.is_n_major_c()
88
+
89
+ if not is_tmem_load(tiled_tmem_load):
90
+ return cute.make_copy_atom(CopyUniversalOp(), elem_ty_d, loc=loc, ip=ip)
91
+
92
+ num_dp, num_bits, num_rep, pack = get_tmem_copy_properties(tiled_tmem_load)
93
+
94
+ use_stmatrix_m8n8_4x = (
95
+ all(
96
+ [
97
+ elem_ty_acc.width == 32,
98
+ elem_ty_d.width == 32,
99
+ is_n_major,
100
+ num_dp == 16,
101
+ num_bits == 128,
102
+ num_rep in (2, 4, 8, 16, 32, 64),
103
+ pack == Pack.NONE,
104
+ ]
105
+ )
106
+ or all(
107
+ [
108
+ elem_ty_acc.width == 32,
109
+ elem_ty_d.width == 16,
110
+ num_dp == 16,
111
+ num_bits == 256,
112
+ num_rep in (2, 4, 8, 16, 32),
113
+ pack == Pack.NONE,
114
+ ]
115
+ )
116
+ or all(
117
+ [
118
+ elem_ty_acc.width == 16,
119
+ elem_ty_d.width == 16,
120
+ num_dp == 16,
121
+ num_bits == 128,
122
+ num_rep in (2, 4, 8, 16, 32, 64),
123
+ pack == Pack.PACK_16b_IN_32b,
124
+ ]
125
+ )
126
+ )
127
+ use_stmatrix_m16n8_4x = all(
128
+ [
129
+ elem_ty_acc.width == 32,
130
+ elem_ty_d.width == 8,
131
+ is_m_major,
132
+ num_dp == 16,
133
+ num_bits == 256,
134
+ num_rep in (4, 8, 16, 32),
135
+ pack == Pack.NONE,
136
+ ]
137
+ )
138
+ use_stmatrix_m8n8_2x = (
139
+ all(
140
+ [
141
+ elem_ty_acc.width == 32,
142
+ elem_ty_d.width == 32,
143
+ is_n_major,
144
+ num_dp == 16,
145
+ num_bits == 128,
146
+ num_rep == 1,
147
+ pack == Pack.NONE,
148
+ ]
149
+ )
150
+ or all(
151
+ [
152
+ elem_ty_acc.width == 32,
153
+ elem_ty_d.width == 16,
154
+ num_dp == 16,
155
+ num_bits == 256,
156
+ num_rep == 1,
157
+ pack == Pack.NONE,
158
+ ]
159
+ )
160
+ or all(
161
+ [
162
+ elem_ty_acc.width == 16,
163
+ elem_ty_d.width == 16,
164
+ num_dp == 16,
165
+ num_bits == 128,
166
+ num_rep == 1,
167
+ pack == Pack.PACK_16b_IN_32b,
168
+ ]
169
+ )
170
+ )
171
+ use_stmatrix_m16n8_2x = all(
172
+ [
173
+ elem_ty_acc.width == 32,
174
+ elem_ty_d.width == 8,
175
+ is_m_major,
176
+ num_dp == 16,
177
+ num_bits == 256,
178
+ num_rep == 2,
179
+ pack == Pack.NONE,
180
+ ]
181
+ )
182
+ use_stmatrix_m16n8_1x = all(
183
+ [
184
+ elem_ty_acc.width == 32,
185
+ elem_ty_d.width == 8,
186
+ is_m_major,
187
+ num_dp == 16,
188
+ num_bits == 256,
189
+ num_rep == 1,
190
+ pack == Pack.NONE,
191
+ ]
192
+ )
193
+ print("===========================================")
194
+ print("explain_get_smem_store_op:")
195
+ if num_dp != 16 or num_bits < 128:
196
+ print("NOTE: to directly use stmatrix, tcgen05.ld must have 16 lanes and 128/256b instruction")
197
+ print(f"elem_ty_acc.width: {elem_ty_acc.width}")
198
+ print(f"elem_ty_d.width: {elem_ty_d.width}")
199
+ print(f"is_n_major: {is_n_major}")
200
+ print(f"num_dp: {num_dp}")
201
+ print(f"num_bits: {num_bits}")
202
+ print(f"num_rep: {num_rep}")
203
+ print(f"pack: {pack}")
204
+
205
+ if use_stmatrix_m8n8_4x:
206
+ op = StMatrix8x8x16bOp(is_m_major, 4)
207
+ elif use_stmatrix_m8n8_2x:
208
+ op = StMatrix8x8x16bOp(is_m_major, 2)
209
+ elif use_stmatrix_m16n8_4x:
210
+ op = StMatrix16x8x8bOp(transpose=True, num_matrices=4)
211
+ elif use_stmatrix_m16n8_2x:
212
+ op = StMatrix16x8x8bOp(transpose=True, num_matrices=2)
213
+ elif use_stmatrix_m16n8_1x:
214
+ op = StMatrix16x8x8bOp(transpose=True, num_matrices=1)
215
+ else:
216
+ op = CopyUniversalOp()
217
+ print(op)
218
+ print("===========================================")
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: cutez
3
+ Version: 0.1.0
4
+ License-File: LICENSE
5
+ Requires-Dist: flash_attn_4==4.0.0b4
6
+ Dynamic: license-file
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ cutez/__init__.py
5
+ cutez.egg-info/PKG-INFO
6
+ cutez.egg-info/SOURCES.txt
7
+ cutez.egg-info/dependency_links.txt
8
+ cutez.egg-info/requires.txt
9
+ cutez.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ flash_attn_4==4.0.0b4
@@ -0,0 +1 @@
1
+ cutez
@@ -0,0 +1,13 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cutez"
7
+ version = "0.1.0"
8
+ dependencies = [
9
+ "flash_attn_4==4.0.0b4",
10
+ ]
11
+
12
+ [tool.setuptools.packages.find]
13
+ include = ["cutez", "cutez.*"]
cutez-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+