sketchssm 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.
- sketchssm-0.1.0/LICENSE +202 -0
- sketchssm-0.1.0/PKG-INFO +181 -0
- sketchssm-0.1.0/README.md +156 -0
- sketchssm-0.1.0/pyproject.toml +42 -0
- sketchssm-0.1.0/setup.cfg +4 -0
- sketchssm-0.1.0/sketchssm/__init__.py +9 -0
- sketchssm-0.1.0/sketchssm/calibration/__init__.py +2 -0
- sketchssm-0.1.0/sketchssm/calibration/__main__.py +125 -0
- sketchssm-0.1.0/sketchssm/calibration/adapters/__init__.py +39 -0
- sketchssm-0.1.0/sketchssm/calibration/adapters/base.py +66 -0
- sketchssm-0.1.0/sketchssm/calibration/adapters/gdn.py +11 -0
- sketchssm-0.1.0/sketchssm/calibration/adapters/kda.py +12 -0
- sketchssm-0.1.0/sketchssm/calibration/adapters/mamba2.py +13 -0
- sketchssm-0.1.0/sketchssm/calibration/bundles.py +82 -0
- sketchssm-0.1.0/sketchssm/calibration/calibration.py +238 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/__init__.py +1 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/config.py +86 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/data.py +46 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/engine.py +235 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/forced_tokens.py +51 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/hooks/__init__.py +1 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/hooks/gdn.py +418 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/hooks/kda.py +51 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/hooks/kda_statistics.py +135 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/hooks/mamba2.py +555 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/hooks/mamba_scan.py +66 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/models.py +85 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/native/__init__.py +1 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/native/common.py +87 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/native/gdn.py +166 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/native/kda.py +128 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/native/mamba2.py +133 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/observers/__init__.py +1 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/observers/gdn.py +75 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/observers/kda.py +98 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/observers/mamba2.py +59 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/packed/__init__.py +1 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/packed/fp4.py +15 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/packed/glm.py +247 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/packed/qwen.py +237 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/packed/qwen3_5.py +151 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/packed/super.py +213 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/paired.py +220 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/pipeline.py +140 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/storage.py +48 -0
- sketchssm-0.1.0/sketchssm/calibration/collection/worker.py +147 -0
- sketchssm-0.1.0/sketchssm/calibration/core/__init__.py +1 -0
- sketchssm-0.1.0/sketchssm/calibration/core/_solver.py +94 -0
- sketchssm-0.1.0/sketchssm/calibration/core/_statistics.py +77 -0
- sketchssm-0.1.0/sketchssm/calibration/core/allocation.py +71 -0
- sketchssm-0.1.0/sketchssm/calibration/core/basis.py +57 -0
- sketchssm-0.1.0/sketchssm/calibration/core/export.py +33 -0
- sketchssm-0.1.0/sketchssm/calibration/core/frames.py +10 -0
- sketchssm-0.1.0/sketchssm/calibration/core/reuse.py +38 -0
- sketchssm-0.1.0/sketchssm/calibration/core/scoring.py +52 -0
- sketchssm-0.1.0/sketchssm/calibration/core/traffic.py +74 -0
- sketchssm-0.1.0/sketchssm/calibration/run.py +120 -0
- sketchssm-0.1.0/sketchssm/calibration/tools/__init__.py +1 -0
- sketchssm-0.1.0/sketchssm/calibration/tools/check_gdn_hooks.py +50 -0
- sketchssm-0.1.0/sketchssm/calibration/tools/check_kda_collection.py +67 -0
- sketchssm-0.1.0/sketchssm/calibration/tools/check_mamba2_hooks.py +56 -0
- sketchssm-0.1.0/sketchssm/calibration/tools/make_nano_layer_subset.py +71 -0
- sketchssm-0.1.0/sketchssm/calibration/tools/make_toy_data.py +26 -0
- sketchssm-0.1.0/sketchssm/calibration/tools/verify_bundles.py +57 -0
- sketchssm-0.1.0/sketchssm/kernels/README.md +132 -0
- sketchssm-0.1.0/sketchssm/kernels/__init__.py +30 -0
- sketchssm-0.1.0/sketchssm/kernels/_runtime.py +158 -0
- sketchssm-0.1.0/sketchssm/kernels/configs/gdn/num_k_heads=16,num_v_heads=16,device_name=NVIDIA_H100_80GB_HBM3.json +9 -0
- sketchssm-0.1.0/sketchssm/kernels/configs/gdn/num_k_heads=16,num_v_heads=32,device_name=NVIDIA_H100_80GB_HBM3.json +10 -0
- sketchssm-0.1.0/sketchssm/kernels/configs/gdn/num_k_heads=16,num_v_heads=48,device_name=NVIDIA_H100_80GB_HBM3.json +9 -0
- sketchssm-0.1.0/sketchssm/kernels/configs/kda/kda,num_heads=64,device_name=NVIDIA_H100_80GB_HBM3.json +7 -0
- sketchssm-0.1.0/sketchssm/kernels/configs/mamba2/head_dim=128,heads_per_group=16,state_size=256,device_name=NVIDIA_H100_80GB_HBM3.json +10 -0
- sketchssm-0.1.0/sketchssm/kernels/configs/mamba2/head_dim=128,heads_per_group=24,state_size=256,device_name=NVIDIA_H100_80GB_HBM3.json +11 -0
- sketchssm-0.1.0/sketchssm/kernels/configs/mamba2/head_dim=64,heads_per_group=80,state_size=64,device_name=NVIDIA_H100_80GB_HBM3.json +8 -0
- sketchssm-0.1.0/sketchssm/kernels/configs/mamba2/head_dim=80,heads_per_group=16,device_name=NVIDIA_H100_80GB_HBM3.json +11 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/gdn/gdn_sketch_flush.cuh +1002 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/gdn/gdn_sketch_flush_decl.cpp +11 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/gdn/gdn_sketch_flush_launch.cu +47 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/gdn/gdn_sketch_step.cuh +608 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/gdn/gdn_sketch_step_decl.cpp +11 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/gdn/gdn_sketch_step_launch.cu +60 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/kda/kda_sketch_flush.cuh +1136 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/kda/kda_sketch_flush_decl.cpp +12 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/kda/kda_sketch_flush_launch.cu +146 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/kda/kda_sketch_step.cuh +419 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/kda/kda_sketch_step_decl.cpp +11 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/kda/kda_sketch_step_launch.cu +67 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/mamba2/mamba2_sketch_flush.cuh +1217 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/mamba2/mamba2_sketch_flush_decl.cpp +16 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/mamba2/mamba2_sketch_flush_launch.cu +97 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/mamba2/mamba2_sketch_nf.cuh +1327 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/mamba2/mamba2_sketch_nf_decl.cpp +20 -0
- sketchssm-0.1.0/sketchssm/kernels/csrc/mamba2/mamba2_sketch_nf_launch.cu +108 -0
- sketchssm-0.1.0/sketchssm/kernels/docs/PROVENANCE_gdn.md +86 -0
- sketchssm-0.1.0/sketchssm/kernels/docs/PROVENANCE_kda.md +65 -0
- sketchssm-0.1.0/sketchssm/kernels/docs/PROVENANCE_mamba2.md +54 -0
- sketchssm-0.1.0/sketchssm/kernels/gdn.py +348 -0
- sketchssm-0.1.0/sketchssm/kernels/kda.py +337 -0
- sketchssm-0.1.0/sketchssm/kernels/mamba2.py +330 -0
- sketchssm-0.1.0/sketchssm/kernels/tools/__init__.py +0 -0
- sketchssm-0.1.0/sketchssm/kernels/tools/benchmark_gdn.py +111 -0
- sketchssm-0.1.0/sketchssm/kernels/tools/benchmark_kda.py +108 -0
- sketchssm-0.1.0/sketchssm/kernels/tools/benchmark_mamba2.py +159 -0
- sketchssm-0.1.0/sketchssm/kernels/tools/benchmark_utils.py +178 -0
- sketchssm-0.1.0/sketchssm/kernels/tools/tune_gdn.py +72 -0
- sketchssm-0.1.0/sketchssm/kernels/tools/tune_kda.py +74 -0
- sketchssm-0.1.0/sketchssm/kernels/tools/tune_mamba2.py +83 -0
- sketchssm-0.1.0/sketchssm/kernels/types.py +85 -0
- sketchssm-0.1.0/sketchssm.egg-info/PKG-INFO +181 -0
- sketchssm-0.1.0/sketchssm.egg-info/SOURCES.txt +118 -0
- sketchssm-0.1.0/sketchssm.egg-info/dependency_links.txt +1 -0
- sketchssm-0.1.0/sketchssm.egg-info/entry_points.txt +2 -0
- sketchssm-0.1.0/sketchssm.egg-info/requires.txt +16 -0
- sketchssm-0.1.0/sketchssm.egg-info/top_level.txt +1 -0
- sketchssm-0.1.0/tests/test_adapters.py +73 -0
- sketchssm-0.1.0/tests/test_bundles.py +43 -0
- sketchssm-0.1.0/tests/test_calibration.py +162 -0
- sketchssm-0.1.0/tests/test_collection.py +286 -0
- sketchssm-0.1.0/tests/test_portable_calibration.py +255 -0
- sketchssm-0.1.0/tests/test_run.py +65 -0
sketchssm-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
sketchssm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sketchssm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: SketchSSM decode kernels and offline calibration
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/SNU-ARC/SketchSSM
|
|
7
|
+
Project-URL: Repository, https://github.com/SNU-ARC/SketchSSM
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: numpy>=1.26
|
|
12
|
+
Requires-Dist: torch>=2.6
|
|
13
|
+
Requires-Dist: ninja
|
|
14
|
+
Provides-Extra: calibration
|
|
15
|
+
Requires-Dist: PyYAML>=6; extra == "calibration"
|
|
16
|
+
Requires-Dist: transformers; extra == "calibration"
|
|
17
|
+
Requires-Dist: datasets; extra == "calibration"
|
|
18
|
+
Requires-Dist: safetensors; extra == "calibration"
|
|
19
|
+
Requires-Dist: huggingface-hub; extra == "calibration"
|
|
20
|
+
Provides-Extra: collection
|
|
21
|
+
Requires-Dist: sketchssm[calibration]; extra == "collection"
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
Requires-Dist: pytest; extra == "test"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# SketchSSM
|
|
27
|
+
|
|
28
|
+
**SketchSSM: Write to the Full State, Read from a Compact Sketch**
|
|
29
|
+
|
|
30
|
+
SketchSSM speeds up decoding in linear-attention and state-space layers
|
|
31
|
+
(Mamba-2, Gated DeltaNet, KDA). It keeps updating the full recurrent state, but
|
|
32
|
+
between periodic exact flushes it reads a compact low-rank sketch of the state
|
|
33
|
+
instead of the full state, which cuts state-read traffic. The sketch basis and
|
|
34
|
+
per-head ranks come from a one-time offline calibration of each model.
|
|
35
|
+
|
|
36
|
+
[Paper](https://arxiv.org/abs/2609.33051)
|
|
37
|
+
|
|
38
|
+
This repository contains:
|
|
39
|
+
|
|
40
|
+
- [`sketchssm/kernels/`](https://github.com/SNU-ARC/SketchSSM/blob/main/sketchssm/kernels/README.md): the CUDA decode kernels
|
|
41
|
+
(`sketchssm.kernels`), which vLLM uses when this package is installed.
|
|
42
|
+
- [`sketchssm/calibration/`](https://github.com/SNU-ARC/SketchSSM/blob/main/sketchssm/calibration/README.md): calibrates a model
|
|
43
|
+
and packages the result into one portable `calibration.pt`.
|
|
44
|
+
- [`vllm/`](https://github.com/SNU-ARC/SketchSSM/blob/main/vllm/README.md): vLLM v0.30.0 with SketchSSM decode kernels.
|
|
45
|
+
- [`benchmarks/`](https://github.com/SNU-ARC/SketchSSM/blob/main/benchmarks/README.md): per-layer decode latency in vLLM.
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
Python 3.10 or newer with PyTorch. Git LFS is not needed: calibrations for
|
|
50
|
+
serving are downloaded from the Hugging Face Hub when used.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/SNU-ARC/SketchSSM.git
|
|
54
|
+
cd SketchSSM
|
|
55
|
+
python -m pip install ".[calibration]" # kernels + calibration
|
|
56
|
+
(cd vllm && VLLM_USE_PRECOMPILED=1 python -m pip install -e .) # serving
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Quick start: serve with vLLM
|
|
60
|
+
|
|
61
|
+
Pass a calibration (a Hugging Face repo id or a local file) and a rank budget,
|
|
62
|
+
the mean sketch rank per state head:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
vllm serve nvidia/NVIDIA-Nemotron-Nano-9B-v2 --trust-remote-code \
|
|
66
|
+
--sketchssm ominn/SketchSSM-Nemotron-Nano-9B-v2-BF16 --sketchssm-mean-rank 6 \
|
|
67
|
+
--mamba-ssm-cache-dtype float32 --no-enable-prefix-caching
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The SketchSSM CUDA kernels are compiled just in time the first time a layer
|
|
71
|
+
shape is used, which needs the CUDA toolkit's `nvcc` and `ninja`
|
|
72
|
+
(`pip install ninja`) on `PATH`; without them vLLM uses the portable Triton
|
|
73
|
+
kernels. The per-head ranks and frames for the requested budget are derived when the
|
|
74
|
+
model loads. Provided calibrations:
|
|
75
|
+
|
|
76
|
+
| Model | Calibration | Collected with weights | Calibrated budgets |
|
|
77
|
+
| --- | --- | --- | --- |
|
|
78
|
+
| Nemotron Nano 9B v2 | [`ominn/SketchSSM-Nemotron-Nano-9B-v2-BF16`](https://huggingface.co/ominn/SketchSSM-Nemotron-Nano-9B-v2-BF16) | BF16 [`nvidia/NVIDIA-Nemotron-Nano-9B-v2`](https://huggingface.co/nvidia/NVIDIA-Nemotron-Nano-9B-v2) | 4, 6, 10, 21 |
|
|
79
|
+
| Nemotron 3 Super | [`ominn/SketchSSM-Nemotron-3-Super-NVFP4`](https://huggingface.co/ominn/SketchSSM-Nemotron-3-Super-NVFP4) | NVFP4 [`nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4`](https://huggingface.co/nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4) | 2, 3, 5, 9, 20 |
|
|
80
|
+
| Qwen3.8 Flash-Next | [`ominn/SketchSSM-Qwen3.8-Flash-Next-NVFP4`](https://huggingface.co/ominn/SketchSSM-Qwen3.8-Flash-Next-NVFP4) | NVFP4 [`RadixArk/Qwen3.8-Flash-Next-NVFP4`](https://huggingface.co/RadixArk/Qwen3.8-Flash-Next-NVFP4) | 3, 4, 7, 11, 26 |
|
|
81
|
+
| GLM 5.3 Flash | [`ominn/SketchSSM-GLM-5.3-Flash-NVFP4`](https://huggingface.co/ominn/SketchSSM-GLM-5.3-Flash-NVFP4) | NVFP4 [`RedHatAI/GLM-5.3-Flash-NVFP4`](https://huggingface.co/RedHatAI/GLM-5.3-Flash-NVFP4) | 3, 4, 7, 12, 28 |
|
|
82
|
+
| Qwen3.5 9B | [`ominn/SketchSSM-Qwen3.5-9B-BF16`](https://huggingface.co/ominn/SketchSSM-Qwen3.5-9B-BF16) | BF16 [`Qwen/Qwen3.5-9B`](https://huggingface.co/Qwen/Qwen3.5-9B) | 3, 4, 7, 11, 26 |
|
|
83
|
+
|
|
84
|
+
A calibration matches the weights it was collected with. Serve it with those
|
|
85
|
+
weights, or make a new calibration for other weights. The calibrated budgets
|
|
86
|
+
were checked against the stored allocation tables; other budgets use the same
|
|
87
|
+
allocation rule. See [`vllm/README.md`](https://github.com/SNU-ARC/SketchSSM/blob/main/vllm/README.md) for all options and
|
|
88
|
+
constraints.
|
|
89
|
+
|
|
90
|
+
## Make a calibration for your model
|
|
91
|
+
|
|
92
|
+
Write a configuration for your model (start from a nearby
|
|
93
|
+
`sketchssm/calibration/example/<model>/collect.yaml`, following the
|
|
94
|
+
[new-model guide](https://github.com/SNU-ARC/SketchSSM/blob/main/sketchssm/calibration/docs/new_model.md)), then run the
|
|
95
|
+
calibration stages:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
python -m sketchssm.calibration calibrate --config my_model.yaml --out outputs/my_model
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
1. `generate`: generate continuations from WikiText-2 prompts.
|
|
102
|
+
2. `covariance`: replay them and collect state and query covariances.
|
|
103
|
+
3. `basis`: fit one shared sketch basis per head group.
|
|
104
|
+
4. `paired`: score each rank on validation text with output-error and gradient pairs.
|
|
105
|
+
5. `allocate`: assign each head a rank or a dense fallback for every requested budget.
|
|
106
|
+
|
|
107
|
+
Add `--stage <name>` to run one stage or `--resume` to continue. Package the
|
|
108
|
+
result into a single portable file, then serve it locally or share it on the Hub:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
python -m sketchssm.calibration package --bundle outputs/my_model --out outputs/my_model/calibration.pt
|
|
112
|
+
|
|
113
|
+
vllm serve <your-model> --sketchssm outputs/my_model/calibration.pt --sketchssm-mean-rank 6 \
|
|
114
|
+
--mamba-ssm-cache-dtype float32 --no-enable-prefix-caching
|
|
115
|
+
python -m sketchssm.calibration manifest --bundle outputs/my_model \
|
|
116
|
+
--calibration outputs/my_model/calibration.pt --precision bf16 --out outputs/my_model/manifest.json
|
|
117
|
+
hf upload <user>/<repo> outputs/my_model/calibration.pt calibration.pt # then --sketchssm <user>/<repo>
|
|
118
|
+
hf upload <user>/<repo> outputs/my_model/manifest.json manifest.json
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`manifest` records the file hash, the base checkpoint and, for every calibrated
|
|
122
|
+
budget, that the tables and frames derived from `calibration.pt` equal the
|
|
123
|
+
bundle's.
|
|
124
|
+
|
|
125
|
+
The [offline calibration guide](https://github.com/SNU-ARC/SketchSSM/blob/main/sketchssm/calibration/README.md) covers the
|
|
126
|
+
procedure, configuration, file formats and a small CPU-only example.
|
|
127
|
+
|
|
128
|
+
## Reproduce the provided calibrations
|
|
129
|
+
|
|
130
|
+
The provided calibrations were collected with the checkpoints and revisions
|
|
131
|
+
pinned in `sketchssm/calibration/example/<model>/config.yaml`. Running
|
|
132
|
+
`calibrate` with that model's `collect.yaml` regenerates them:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
python -m sketchssm.calibration calibrate \
|
|
136
|
+
--config sketchssm/calibration/example/nemotron_super/collect.yaml --out outputs/nemotron_super
|
|
137
|
+
python -m sketchssm.calibration package --bundle outputs/nemotron_super \
|
|
138
|
+
--out outputs/nemotron_super/calibration.pt
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Recollection is not needed to try other rank budgets. Each Hub
|
|
142
|
+
`calibration.pt` already contains the sketch basis and the allocation scores,
|
|
143
|
+
so the per-head table and frames for any budget are derived from it directly:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
hf download ominn/SketchSSM-Nemotron-3-Super-NVFP4 calibration.pt --local-dir outputs/super
|
|
147
|
+
python -m sketchssm.calibration export --calibration outputs/super/calibration.pt \
|
|
148
|
+
--mean-rank 5 --out outputs/super_g5_frames.pt
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
See the [calibration data guide](https://github.com/SNU-ARC/SketchSSM/blob/main/sketchssm/calibration/example/README.md) for
|
|
152
|
+
the collection recipe and the expected results of each model.
|
|
153
|
+
|
|
154
|
+
## Benchmarks
|
|
155
|
+
|
|
156
|
+
See [`benchmarks/`](https://github.com/SNU-ARC/SketchSSM/blob/main/benchmarks/README.md) to measure the per-layer recurrent
|
|
157
|
+
decode latency of a model in vLLM, and [`vllm/README.md`](https://github.com/SNU-ARC/SketchSSM/blob/main/vllm/README.md) for
|
|
158
|
+
kernel microbenchmarks.
|
|
159
|
+
|
|
160
|
+
## Citation
|
|
161
|
+
|
|
162
|
+
If you use SketchSSM in your research, please cite:
|
|
163
|
+
|
|
164
|
+
```bibtex
|
|
165
|
+
@misc{kwon2026sketchssmwritestateread,
|
|
166
|
+
title={SketchSSM: Write to the Full State, Read from a Compact Sketch},
|
|
167
|
+
author={Omin Kwon and JoongWon Shin and Minseo Kim and Kurt Keutzer and Sehoon Kim and Jae W. Lee},
|
|
168
|
+
year={2026},
|
|
169
|
+
eprint={2609.33051},
|
|
170
|
+
archivePrefix={arXiv},
|
|
171
|
+
primaryClass={cs.LG},
|
|
172
|
+
url={https://arxiv.org/abs/2609.33051},
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
SketchSSM is released under the [Apache License 2.0](https://github.com/SNU-ARC/SketchSSM/blob/main/LICENSE). The
|
|
179
|
+
[`vllm/`](https://github.com/SNU-ARC/SketchSSM/blob/main/vllm/) directory is a fork of vLLM, also under Apache-2.0. Calibration
|
|
180
|
+
files are derived from the base models' weights and are also subject to those
|
|
181
|
+
models' licenses.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# SketchSSM
|
|
2
|
+
|
|
3
|
+
**SketchSSM: Write to the Full State, Read from a Compact Sketch**
|
|
4
|
+
|
|
5
|
+
SketchSSM speeds up decoding in linear-attention and state-space layers
|
|
6
|
+
(Mamba-2, Gated DeltaNet, KDA). It keeps updating the full recurrent state, but
|
|
7
|
+
between periodic exact flushes it reads a compact low-rank sketch of the state
|
|
8
|
+
instead of the full state, which cuts state-read traffic. The sketch basis and
|
|
9
|
+
per-head ranks come from a one-time offline calibration of each model.
|
|
10
|
+
|
|
11
|
+
[Paper](https://arxiv.org/abs/2609.33051)
|
|
12
|
+
|
|
13
|
+
This repository contains:
|
|
14
|
+
|
|
15
|
+
- [`sketchssm/kernels/`](https://github.com/SNU-ARC/SketchSSM/blob/main/sketchssm/kernels/README.md): the CUDA decode kernels
|
|
16
|
+
(`sketchssm.kernels`), which vLLM uses when this package is installed.
|
|
17
|
+
- [`sketchssm/calibration/`](https://github.com/SNU-ARC/SketchSSM/blob/main/sketchssm/calibration/README.md): calibrates a model
|
|
18
|
+
and packages the result into one portable `calibration.pt`.
|
|
19
|
+
- [`vllm/`](https://github.com/SNU-ARC/SketchSSM/blob/main/vllm/README.md): vLLM v0.30.0 with SketchSSM decode kernels.
|
|
20
|
+
- [`benchmarks/`](https://github.com/SNU-ARC/SketchSSM/blob/main/benchmarks/README.md): per-layer decode latency in vLLM.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
Python 3.10 or newer with PyTorch. Git LFS is not needed: calibrations for
|
|
25
|
+
serving are downloaded from the Hugging Face Hub when used.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://github.com/SNU-ARC/SketchSSM.git
|
|
29
|
+
cd SketchSSM
|
|
30
|
+
python -m pip install ".[calibration]" # kernels + calibration
|
|
31
|
+
(cd vllm && VLLM_USE_PRECOMPILED=1 python -m pip install -e .) # serving
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick start: serve with vLLM
|
|
35
|
+
|
|
36
|
+
Pass a calibration (a Hugging Face repo id or a local file) and a rank budget,
|
|
37
|
+
the mean sketch rank per state head:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
vllm serve nvidia/NVIDIA-Nemotron-Nano-9B-v2 --trust-remote-code \
|
|
41
|
+
--sketchssm ominn/SketchSSM-Nemotron-Nano-9B-v2-BF16 --sketchssm-mean-rank 6 \
|
|
42
|
+
--mamba-ssm-cache-dtype float32 --no-enable-prefix-caching
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The SketchSSM CUDA kernels are compiled just in time the first time a layer
|
|
46
|
+
shape is used, which needs the CUDA toolkit's `nvcc` and `ninja`
|
|
47
|
+
(`pip install ninja`) on `PATH`; without them vLLM uses the portable Triton
|
|
48
|
+
kernels. The per-head ranks and frames for the requested budget are derived when the
|
|
49
|
+
model loads. Provided calibrations:
|
|
50
|
+
|
|
51
|
+
| Model | Calibration | Collected with weights | Calibrated budgets |
|
|
52
|
+
| --- | --- | --- | --- |
|
|
53
|
+
| Nemotron Nano 9B v2 | [`ominn/SketchSSM-Nemotron-Nano-9B-v2-BF16`](https://huggingface.co/ominn/SketchSSM-Nemotron-Nano-9B-v2-BF16) | BF16 [`nvidia/NVIDIA-Nemotron-Nano-9B-v2`](https://huggingface.co/nvidia/NVIDIA-Nemotron-Nano-9B-v2) | 4, 6, 10, 21 |
|
|
54
|
+
| Nemotron 3 Super | [`ominn/SketchSSM-Nemotron-3-Super-NVFP4`](https://huggingface.co/ominn/SketchSSM-Nemotron-3-Super-NVFP4) | NVFP4 [`nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4`](https://huggingface.co/nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4) | 2, 3, 5, 9, 20 |
|
|
55
|
+
| Qwen3.8 Flash-Next | [`ominn/SketchSSM-Qwen3.8-Flash-Next-NVFP4`](https://huggingface.co/ominn/SketchSSM-Qwen3.8-Flash-Next-NVFP4) | NVFP4 [`RadixArk/Qwen3.8-Flash-Next-NVFP4`](https://huggingface.co/RadixArk/Qwen3.8-Flash-Next-NVFP4) | 3, 4, 7, 11, 26 |
|
|
56
|
+
| GLM 5.3 Flash | [`ominn/SketchSSM-GLM-5.3-Flash-NVFP4`](https://huggingface.co/ominn/SketchSSM-GLM-5.3-Flash-NVFP4) | NVFP4 [`RedHatAI/GLM-5.3-Flash-NVFP4`](https://huggingface.co/RedHatAI/GLM-5.3-Flash-NVFP4) | 3, 4, 7, 12, 28 |
|
|
57
|
+
| Qwen3.5 9B | [`ominn/SketchSSM-Qwen3.5-9B-BF16`](https://huggingface.co/ominn/SketchSSM-Qwen3.5-9B-BF16) | BF16 [`Qwen/Qwen3.5-9B`](https://huggingface.co/Qwen/Qwen3.5-9B) | 3, 4, 7, 11, 26 |
|
|
58
|
+
|
|
59
|
+
A calibration matches the weights it was collected with. Serve it with those
|
|
60
|
+
weights, or make a new calibration for other weights. The calibrated budgets
|
|
61
|
+
were checked against the stored allocation tables; other budgets use the same
|
|
62
|
+
allocation rule. See [`vllm/README.md`](https://github.com/SNU-ARC/SketchSSM/blob/main/vllm/README.md) for all options and
|
|
63
|
+
constraints.
|
|
64
|
+
|
|
65
|
+
## Make a calibration for your model
|
|
66
|
+
|
|
67
|
+
Write a configuration for your model (start from a nearby
|
|
68
|
+
`sketchssm/calibration/example/<model>/collect.yaml`, following the
|
|
69
|
+
[new-model guide](https://github.com/SNU-ARC/SketchSSM/blob/main/sketchssm/calibration/docs/new_model.md)), then run the
|
|
70
|
+
calibration stages:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
python -m sketchssm.calibration calibrate --config my_model.yaml --out outputs/my_model
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
1. `generate`: generate continuations from WikiText-2 prompts.
|
|
77
|
+
2. `covariance`: replay them and collect state and query covariances.
|
|
78
|
+
3. `basis`: fit one shared sketch basis per head group.
|
|
79
|
+
4. `paired`: score each rank on validation text with output-error and gradient pairs.
|
|
80
|
+
5. `allocate`: assign each head a rank or a dense fallback for every requested budget.
|
|
81
|
+
|
|
82
|
+
Add `--stage <name>` to run one stage or `--resume` to continue. Package the
|
|
83
|
+
result into a single portable file, then serve it locally or share it on the Hub:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
python -m sketchssm.calibration package --bundle outputs/my_model --out outputs/my_model/calibration.pt
|
|
87
|
+
|
|
88
|
+
vllm serve <your-model> --sketchssm outputs/my_model/calibration.pt --sketchssm-mean-rank 6 \
|
|
89
|
+
--mamba-ssm-cache-dtype float32 --no-enable-prefix-caching
|
|
90
|
+
python -m sketchssm.calibration manifest --bundle outputs/my_model \
|
|
91
|
+
--calibration outputs/my_model/calibration.pt --precision bf16 --out outputs/my_model/manifest.json
|
|
92
|
+
hf upload <user>/<repo> outputs/my_model/calibration.pt calibration.pt # then --sketchssm <user>/<repo>
|
|
93
|
+
hf upload <user>/<repo> outputs/my_model/manifest.json manifest.json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`manifest` records the file hash, the base checkpoint and, for every calibrated
|
|
97
|
+
budget, that the tables and frames derived from `calibration.pt` equal the
|
|
98
|
+
bundle's.
|
|
99
|
+
|
|
100
|
+
The [offline calibration guide](https://github.com/SNU-ARC/SketchSSM/blob/main/sketchssm/calibration/README.md) covers the
|
|
101
|
+
procedure, configuration, file formats and a small CPU-only example.
|
|
102
|
+
|
|
103
|
+
## Reproduce the provided calibrations
|
|
104
|
+
|
|
105
|
+
The provided calibrations were collected with the checkpoints and revisions
|
|
106
|
+
pinned in `sketchssm/calibration/example/<model>/config.yaml`. Running
|
|
107
|
+
`calibrate` with that model's `collect.yaml` regenerates them:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
python -m sketchssm.calibration calibrate \
|
|
111
|
+
--config sketchssm/calibration/example/nemotron_super/collect.yaml --out outputs/nemotron_super
|
|
112
|
+
python -m sketchssm.calibration package --bundle outputs/nemotron_super \
|
|
113
|
+
--out outputs/nemotron_super/calibration.pt
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Recollection is not needed to try other rank budgets. Each Hub
|
|
117
|
+
`calibration.pt` already contains the sketch basis and the allocation scores,
|
|
118
|
+
so the per-head table and frames for any budget are derived from it directly:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
hf download ominn/SketchSSM-Nemotron-3-Super-NVFP4 calibration.pt --local-dir outputs/super
|
|
122
|
+
python -m sketchssm.calibration export --calibration outputs/super/calibration.pt \
|
|
123
|
+
--mean-rank 5 --out outputs/super_g5_frames.pt
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
See the [calibration data guide](https://github.com/SNU-ARC/SketchSSM/blob/main/sketchssm/calibration/example/README.md) for
|
|
127
|
+
the collection recipe and the expected results of each model.
|
|
128
|
+
|
|
129
|
+
## Benchmarks
|
|
130
|
+
|
|
131
|
+
See [`benchmarks/`](https://github.com/SNU-ARC/SketchSSM/blob/main/benchmarks/README.md) to measure the per-layer recurrent
|
|
132
|
+
decode latency of a model in vLLM, and [`vllm/README.md`](https://github.com/SNU-ARC/SketchSSM/blob/main/vllm/README.md) for
|
|
133
|
+
kernel microbenchmarks.
|
|
134
|
+
|
|
135
|
+
## Citation
|
|
136
|
+
|
|
137
|
+
If you use SketchSSM in your research, please cite:
|
|
138
|
+
|
|
139
|
+
```bibtex
|
|
140
|
+
@misc{kwon2026sketchssmwritestateread,
|
|
141
|
+
title={SketchSSM: Write to the Full State, Read from a Compact Sketch},
|
|
142
|
+
author={Omin Kwon and JoongWon Shin and Minseo Kim and Kurt Keutzer and Sehoon Kim and Jae W. Lee},
|
|
143
|
+
year={2026},
|
|
144
|
+
eprint={2609.33051},
|
|
145
|
+
archivePrefix={arXiv},
|
|
146
|
+
primaryClass={cs.LG},
|
|
147
|
+
url={https://arxiv.org/abs/2609.33051},
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
SketchSSM is released under the [Apache License 2.0](https://github.com/SNU-ARC/SketchSSM/blob/main/LICENSE). The
|
|
154
|
+
[`vllm/`](https://github.com/SNU-ARC/SketchSSM/blob/main/vllm/) directory is a fork of vLLM, also under Apache-2.0. Calibration
|
|
155
|
+
files are derived from the base models' weights and are also subject to those
|
|
156
|
+
models' licenses.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sketchssm"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "SketchSSM decode kernels and offline calibration"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
# The kernels are built just-in-time, which also needs nvcc.
|
|
14
|
+
dependencies = ["numpy>=1.26", "torch>=2.6", "ninja"]
|
|
15
|
+
|
|
16
|
+
[project.urls]
|
|
17
|
+
Homepage = "https://github.com/SNU-ARC/SketchSSM"
|
|
18
|
+
Repository = "https://github.com/SNU-ARC/SketchSSM"
|
|
19
|
+
|
|
20
|
+
[project.optional-dependencies]
|
|
21
|
+
calibration = ["PyYAML>=6", "transformers", "datasets", "safetensors", "huggingface-hub"]
|
|
22
|
+
# Older name of the calibration extra.
|
|
23
|
+
collection = ["sketchssm[calibration]"]
|
|
24
|
+
test = ["pytest"]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
sketchssm-calibrate = "sketchssm.calibration.__main__:main"
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
include = ["sketchssm*"]
|
|
31
|
+
namespaces = false
|
|
32
|
+
|
|
33
|
+
[tool.setuptools.package-data]
|
|
34
|
+
"sketchssm.kernels" = [
|
|
35
|
+
"csrc/*/*.cuh", "csrc/*/*.cu", "csrc/*/*.cpp", "configs/*/*.json", "docs/*.md",
|
|
36
|
+
"README.md",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[tool.pytest.ini_options]
|
|
40
|
+
markers = [
|
|
41
|
+
"slow: long-window sweeps and other expensive kernel cases (deselect with -m 'not slow')",
|
|
42
|
+
]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright contributors to the SketchSSM project
|
|
3
|
+
"""SketchSSM: write to the full state, read from a compact sketch.
|
|
4
|
+
|
|
5
|
+
``sketchssm.kernels`` holds the CUDA decode kernels and
|
|
6
|
+
``sketchssm.calibration`` the offline calibration (basis and rank allocation).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__version__ = "0.1.0"
|