sakasurya commited on
Commit
77f47f9
·
0 Parent(s):

Counsel-27B

Browse files
.gitattributes ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
37
+ assets/counsel_chat_speed.mp4 filter=lfs diff=lfs merge=lfs -text
38
+ assets/counsel_editing_speed.mp4 filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Attribution-NonCommercial 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other CC-
34
+ licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution-NonCommercial 4.0 International Public
58
+ License
59
+
60
+ By exercising the Licensed Rights (defined below), You accept and agree
61
+ to be bound by the terms and conditions of this Creative Commons
62
+ Attribution-NonCommercial 4.0 International Public License ("Public
63
+ License"). To the extent this Public License may be interpreted as a
64
+ contract, You are granted the Licensed Rights in consideration of Your
65
+ acceptance of these terms and conditions, and the Licensor grants You
66
+ such rights in consideration of benefits the Licensor receives from
67
+ making the Licensed Material available under these terms and
68
+ conditions.
69
+
70
+
71
+ Section 1 -- Definitions.
72
+
73
+ a. Adapted Material means material subject to Copyright and Similar
74
+ Rights that is derived from or based upon the Licensed Material
75
+ and in which the Licensed Material is translated, altered,
76
+ arranged, transformed, or otherwise modified in a manner requiring
77
+ permission under the Copyright and Similar Rights held by the
78
+ Licensor. For purposes of this Public License, where the Licensed
79
+ Material is a musical work, performance, or sound recording,
80
+ Adapted Material is always produced where the Licensed Material is
81
+ synched in timed relation with a moving image.
82
+
83
+ b. Adapter's License means the license You apply to Your Copyright
84
+ and Similar Rights in Your contributions to Adapted Material in
85
+ accordance with the terms and conditions of this Public License.
86
+
87
+ c. Copyright and Similar Rights means copyright and/or similar rights
88
+ closely related to copyright including, without limitation,
89
+ performance, broadcast, sound recording, and Sui Generis Database
90
+ Rights, without regard to how the rights are labeled or
91
+ categorized. For purposes of this Public License, the rights
92
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
93
+ Rights.
94
+ d. Effective Technological Measures means those measures that, in the
95
+ absence of proper authority, may not be circumvented under laws
96
+ fulfilling obligations under Article 11 of the WIPO Copyright
97
+ Treaty adopted on December 20, 1996, and/or similar international
98
+ agreements.
99
+
100
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
101
+ any other exception or limitation to Copyright and Similar Rights
102
+ that applies to Your use of the Licensed Material.
103
+
104
+ f. Licensed Material means the artistic or literary work, database,
105
+ or other material to which the Licensor applied this Public
106
+ License.
107
+
108
+ g. Licensed Rights means the rights granted to You subject to the
109
+ terms and conditions of this Public License, which are limited to
110
+ all Copyright and Similar Rights that apply to Your use of the
111
+ Licensed Material and that the Licensor has authority to license.
112
+
113
+ h. Licensor means the individual(s) or entity(ies) granting rights
114
+ under this Public License.
115
+
116
+ i. NonCommercial means not primarily intended for or directed towards
117
+ commercial advantage or monetary compensation. For purposes of
118
+ this Public License, the exchange of the Licensed Material for
119
+ other material subject to Copyright and Similar Rights by digital
120
+ file-sharing or similar means is NonCommercial provided there is
121
+ no payment of monetary compensation in connection with the
122
+ exchange.
123
+
124
+ j. Share means to provide material to the public by any means or
125
+ process that requires permission under the Licensed Rights, such
126
+ as reproduction, public display, public performance, distribution,
127
+ dissemination, communication, or importation, and to make material
128
+ available to the public including in ways that members of the
129
+ public may access the material from a place and at a time
130
+ individually chosen by them.
131
+
132
+ k. Sui Generis Database Rights means rights other than copyright
133
+ resulting from Directive 96/9/EC of the European Parliament and of
134
+ the Council of 11 March 1996 on the legal protection of databases,
135
+ as amended and/or succeeded, as well as other essentially
136
+ equivalent rights anywhere in the world.
137
+
138
+ l. You means the individual or entity exercising the Licensed Rights
139
+ under this Public License. Your has a corresponding meaning.
140
+
141
+
142
+ Section 2 -- Scope.
143
+
144
+ a. License grant.
145
+
146
+ 1. Subject to the terms and conditions of this Public License,
147
+ the Licensor hereby grants You a worldwide, royalty-free,
148
+ non-sublicensable, non-exclusive, irrevocable license to
149
+ exercise the Licensed Rights in the Licensed Material to:
150
+
151
+ a. reproduce and Share the Licensed Material, in whole or
152
+ in part, for NonCommercial purposes only; and
153
+
154
+ b. produce, reproduce, and Share Adapted Material for
155
+ NonCommercial purposes only.
156
+
157
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
158
+ Exceptions and Limitations apply to Your use, this Public
159
+ License does not apply, and You do not need to comply with
160
+ its terms and conditions.
161
+
162
+ 3. Term. The term of this Public License is specified in Section
163
+ 6(a).
164
+
165
+ 4. Media and formats; technical modifications allowed. The
166
+ Licensor authorizes You to exercise the Licensed Rights in
167
+ all media and formats whether now known or hereafter created,
168
+ and to make technical modifications necessary to do so. The
169
+ Licensor waives and/or agrees not to assert any right or
170
+ authority to forbid You from making technical modifications
171
+ necessary to exercise the Licensed Rights, including
172
+ technical modifications necessary to circumvent Effective
173
+ Technological Measures. For purposes of this Public License,
174
+ simply making modifications authorized by this Section 2(a)
175
+ (4) never produces Adapted Material.
176
+
177
+ 5. Downstream recipients.
178
+
179
+ a. Offer from the Licensor -- Licensed Material. Every
180
+ recipient of the Licensed Material automatically
181
+ receives an offer from the Licensor to exercise the
182
+ Licensed Rights under the terms and conditions of this
183
+ Public License.
184
+
185
+ b. No downstream restrictions. You may not offer or impose
186
+ any additional or different terms or conditions on, or
187
+ apply any Effective Technological Measures to, the
188
+ Licensed Material if doing so restricts exercise of the
189
+ Licensed Rights by any recipient of the Licensed
190
+ Material.
191
+
192
+ 6. No endorsement. Nothing in this Public License constitutes or
193
+ may be construed as permission to assert or imply that You
194
+ are, or that Your use of the Licensed Material is, connected
195
+ with, or sponsored, endorsed, or granted official status by,
196
+ the Licensor or others designated to receive attribution as
197
+ provided in Section 3(a)(1)(A)(i).
198
+
199
+ b. Other rights.
200
+
201
+ 1. Moral rights, such as the right of integrity, are not
202
+ licensed under this Public License, nor are publicity,
203
+ privacy, and/or other similar personality rights; however, to
204
+ the extent possible, the Licensor waives and/or agrees not to
205
+ assert any such rights held by the Licensor to the limited
206
+ extent necessary to allow You to exercise the Licensed
207
+ Rights, but not otherwise.
208
+
209
+ 2. Patent and trademark rights are not licensed under this
210
+ Public License.
211
+
212
+ 3. To the extent possible, the Licensor waives any right to
213
+ collect royalties from You for the exercise of the Licensed
214
+ Rights, whether directly or through a collecting society
215
+ under any voluntary or waivable statutory or compulsory
216
+ licensing scheme. In all other cases the Licensor expressly
217
+ reserves any right to collect such royalties, including when
218
+ the Licensed Material is used other than for NonCommercial
219
+ purposes.
220
+
221
+
222
+ Section 3 -- License Conditions.
223
+
224
+ Your exercise of the Licensed Rights is expressly made subject to the
225
+ following conditions.
226
+
227
+ a. Attribution.
228
+
229
+ 1. If You Share the Licensed Material (including in modified
230
+ form), You must:
231
+
232
+ a. retain the following if it is supplied by the Licensor
233
+ with the Licensed Material:
234
+
235
+ i. identification of the creator(s) of the Licensed
236
+ Material and any others designated to receive
237
+ attribution, in any reasonable manner requested by
238
+ the Licensor (including by pseudonym if
239
+ designated);
240
+
241
+ ii. a copyright notice;
242
+
243
+ iii. a notice that refers to this Public License;
244
+
245
+ iv. a notice that refers to the disclaimer of
246
+ warranties;
247
+
248
+ v. a URI or hyperlink to the Licensed Material to the
249
+ extent reasonably practicable;
250
+
251
+ b. indicate if You modified the Licensed Material and
252
+ retain an indication of any previous modifications; and
253
+
254
+ c. indicate the Licensed Material is licensed under this
255
+ Public License, and include the text of, or the URI or
256
+ hyperlink to, this Public License.
257
+
258
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
259
+ reasonable manner based on the medium, means, and context in
260
+ which You Share the Licensed Material. For example, it may be
261
+ reasonable to satisfy the conditions by providing a URI or
262
+ hyperlink to a resource that includes the required
263
+ information.
264
+
265
+ 3. If requested by the Licensor, You must remove any of the
266
+ information required by Section 3(a)(1)(A) to the extent
267
+ reasonably practicable.
268
+
269
+ 4. If You Share Adapted Material You produce, the Adapter's
270
+ License You apply must not prevent recipients of the Adapted
271
+ Material from complying with this Public License.
272
+
273
+
274
+ Section 4 -- Sui Generis Database Rights.
275
+
276
+ Where the Licensed Rights include Sui Generis Database Rights that
277
+ apply to Your use of the Licensed Material:
278
+
279
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
280
+ to extract, reuse, reproduce, and Share all or a substantial
281
+ portion of the contents of the database for NonCommercial purposes
282
+ only;
283
+
284
+ b. if You include all or a substantial portion of the database
285
+ contents in a database in which You have Sui Generis Database
286
+ Rights, then the database in which You have Sui Generis Database
287
+ Rights (but not its individual contents) is Adapted Material; and
288
+
289
+ c. You must comply with the conditions in Section 3(a) if You Share
290
+ all or a substantial portion of the contents of the database.
291
+
292
+ For the avoidance of doubt, this Section 4 supplements and does not
293
+ replace Your obligations under this Public License where the Licensed
294
+ Rights include other Copyright and Similar Rights.
295
+
296
+
297
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
298
+
299
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
300
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
301
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
302
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
303
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
304
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
305
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
306
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
307
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
308
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
309
+
310
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
311
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
312
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
313
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
314
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
315
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
316
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
317
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
318
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
319
+
320
+ c. The disclaimer of warranties and limitation of liability provided
321
+ above shall be interpreted in a manner that, to the extent
322
+ possible, most closely approximates an absolute disclaimer and
323
+ waiver of all liability.
324
+
325
+
326
+ Section 6 -- Term and Termination.
327
+
328
+ a. This Public License applies for the term of the Copyright and
329
+ Similar Rights licensed here. However, if You fail to comply with
330
+ this Public License, then Your rights under this Public License
331
+ terminate automatically.
332
+
333
+ b. Where Your right to use the Licensed Material has terminated under
334
+ Section 6(a), it reinstates:
335
+
336
+ 1. automatically as of the date the violation is cured, provided
337
+ it is cured within 30 days of Your discovery of the
338
+ violation; or
339
+
340
+ 2. upon express reinstatement by the Licensor.
341
+
342
+ For the avoidance of doubt, this Section 6(b) does not affect any
343
+ right the Licensor may have to seek remedies for Your violations
344
+ of this Public License.
345
+
346
+ c. For the avoidance of doubt, the Licensor may also offer the
347
+ Licensed Material under separate terms or conditions or stop
348
+ distributing the Licensed Material at any time; however, doing so
349
+ will not terminate this Public License.
350
+
351
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
352
+ License.
353
+
354
+
355
+ Section 7 -- Other Terms and Conditions.
356
+
357
+ a. The Licensor shall not be bound by any additional or different
358
+ terms or conditions communicated by You unless expressly agreed.
359
+
360
+ b. Any arrangements, understandings, or agreements regarding the
361
+ Licensed Material not stated herein are separate from and
362
+ independent of the terms and conditions of this Public License.
363
+
364
+
365
+ Section 8 -- Interpretation.
366
+
367
+ a. For the avoidance of doubt, this Public License does not, and
368
+ shall not be interpreted to, reduce, limit, restrict, or impose
369
+ conditions on any use of the Licensed Material that could lawfully
370
+ be made without permission under this Public License.
371
+
372
+ b. To the extent possible, if any provision of this Public License is
373
+ deemed unenforceable, it shall be automatically reformed to the
374
+ minimum extent necessary to make it enforceable. If the provision
375
+ cannot be reformed, it shall be severed from this Public License
376
+ without affecting the enforceability of the remaining terms and
377
+ conditions.
378
+
379
+ c. No term or condition of this Public License will be waived and no
380
+ failure to comply consented to unless expressly agreed to by the
381
+ Licensor.
382
+
383
+ d. Nothing in this Public License constitutes or may be interpreted
384
+ as a limitation upon, or waiver of, any privileges and immunities
385
+ that apply to the Licensor or You, including from the legal
386
+ processes of any jurisdiction or authority.
387
+
388
+ =======================================================================
389
+
390
+ Creative Commons is not a party to its public
391
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
392
+ its public licenses to material it publishes and in those instances
393
+ will be considered the “Licensor.” The text of the Creative Commons
394
+ public licenses is dedicated to the public domain under the CC0 Public
395
+ Domain Dedication. Except for the limited purpose of indicating that
396
+ material is shared under a Creative Commons public license or as
397
+ otherwise permitted by the Creative Commons policies published at
398
+ creativecommons.org/policies, Creative Commons does not authorize the
399
+ use of the trademark "Creative Commons" or any other trademark or logo
400
+ of Creative Commons without its prior written consent including,
401
+ without limitation, in connection with any unauthorized modifications
402
+ to any of its public licenses or any other arrangements,
403
+ understandings, or agreements concerning use of licensed material. For
404
+ the avoidance of doubt, this paragraph does not form part of the
405
+ public licenses.
406
+
407
+ Creative Commons may be contacted at creativecommons.org.
408
+
LICENSE-APACHE 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.
README.md ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - legal
9
+ - law
10
+ - reasoning
11
+ - tool-use
12
+ - counsel
13
+ - chat
14
+ ---
15
+
16
+ # Counsel-27B
17
+
18
+ Counsel-27B is a general-purpose language model with specialist legal capabilities, built by JudicialMind. It handles
19
+ everyday chat, reasoning, writing and coding like a modern general model, and on legal work it reads statutes,
20
+ regulations, contracts and case law closely, answers from the provisions and authorities that support the answer, and
21
+ runs legal research and document workflows that call tools.
22
+
23
+ At 27 billion parameters it fits on a single 80–96 GB data-centre GPU in BF16, so it can run privately, on-premise,
24
+ where documents cannot leave the organisation, and its 128K-token context takes in full agreements, judgments and
25
+ regulatory texts in one pass.
26
+
27
+ An FP8 version for faster serving is at [judicialmind/Counsel-27B-FP8](https://huggingface.co/judicialmind/Counsel-27B-FP8).
28
+
29
+ ## Highlights
30
+
31
+ - **Base-model quality on Harvey LAB at 43% lower cost.** On the Harvey LAB benchmark Counsel-27B passed 88.2% of
32
+ criteria (Qwen3.8-27B base: 87.2%) with 40% fewer input and 57% fewer output tokens: **$0.98 per task instead of
33
+ $1.71**.
34
+ - **4.3× faster answers on one GPU, 6.5× on two.** With the Counsel drafter one H100 80 GB generates **218 tokens/s**
35
+ for a single user, against 51 without it. With the drafter, two H100s reach **349 tokens/s**: **6.5×** one H100 without
36
+ the drafter (54).
37
+ - **Document editing at up to 4,060 tokens/s.** Copy mode with Counsel's GDN replay kernel returns a revised
38
+ 5,000-token contract in **under 2 seconds** instead of about 100, identical to normal decoding.
39
+ - **128K context on one 80 GB GPU** in every mode, served by vLLM or SGLang through `counsel-runtime`.
40
+
41
+ ## Speed in action
42
+
43
+ Real-time replays of measured runs on one NVIDIA H100: every token appears when the server produced it.
44
+
45
+ <video src="https://huggingface.co/datasets/judicialmind/counsel-media/resolve/main/counsel_chat_speed.mp4" controls preload="metadata" width="100%"></video>
46
+
47
+ Counsel-27B-FP8 with the Counsel drafter writes a complete non-disclosure agreement at **244 tokens/s**, **4.8×**
48
+ standard decoding.
49
+
50
+ <video src="https://huggingface.co/datasets/judicialmind/counsel-media/resolve/main/counsel_editing_speed.mp4" controls preload="metadata" width="100%"></video>
51
+
52
+ Copy mode with the GDN replay kernel revises ten contracts (42,331 tokens) in **14.5 seconds** at **4,028 tokens/s**,
53
+ **80×** standard decoding, with every clause placed correctly.
54
+
55
+ <sub>Music: "Inspired" (first video) and "Aitech" (second video) by Kevin MacLeod (incompetech.com), licensed under CC BY 4.0.</sub>
56
+
57
+ ## Capabilities
58
+
59
+ **General**
60
+
61
+ - Instruction following and multi-turn conversation.
62
+ - Step-by-step reasoning in thinking mode, with the reasoning returned separately from the final answer.
63
+ - Function calling with JSON tool schemas.
64
+ - Everyday writing, summarisation and coding.
65
+
66
+ **Legal**
67
+
68
+ - **Regulatory and statutory questions**: identifies the obligations a provision imposes, who they bind and under
69
+ what conditions, and answers from the text rather than from general impressions.
70
+ - **Cross-references**: follows "subject to", "as defined in" and "notwithstanding" links between provisions and
71
+ brings the connected passages into the answer.
72
+ - **Case-law research**: synthesises an answer from retrieved judgments and search results, citing the authorities it
73
+ relies on and separating holdings from commentary.
74
+ - **Contracts**: reviews clauses, explains risk and allocation (conditions, warranties, indemnities, limitation,
75
+ termination), compares drafts and proposes redlines.
76
+ - **Legal agent workflows**: plans multi-step tasks, calls document-search and matter-management tools, and reports
77
+ tool results faithfully, including failures and missing information, instead of claiming success.
78
+
79
+ ## Model details
80
+
81
+ | | |
82
+ |---|---|
83
+ | Model | Counsel-27B |
84
+ | Type | Decoder-only causal language model, hybrid attention |
85
+ | Parameters | 26.9 B |
86
+ | Layers | 64 (48 gated linear-attention layers, 16 gated full-attention layers, one in every four) |
87
+ | Hidden size | 5,120 |
88
+ | Full attention | 24 query heads, 4 key/value heads (grouped-query attention), head dimension 256, output gate |
89
+ | Linear attention | 16 key heads, 48 value heads, head dimension 128, short convolution (kernel 4) |
90
+ | Feed-forward | SwiGLU, intermediate size 17,408 |
91
+ | Normalisation | RMSNorm (ε = 1e-6) |
92
+ | Position encoding | Partial rotary (25 % of head dimensions, θ = 10,000,000) |
93
+ | Context | 128K tokens (131,072) as served by `counsel-runtime`; 262,144 maximum positions |
94
+ | Vocabulary | 248,320 tokens |
95
+ | Weights | BF16, sharded `model-*.safetensors` (55 GB, including the built-in MTP head); drafter in `drafter/` (3.8 GB) |
96
+ | Language | English |
97
+
98
+ ## Files
99
+
100
+ | File | Contents |
101
+ |---|---|
102
+ | `model-*.safetensors`, `model.safetensors.index.json` | Model weights (BF16), including the built-in multi-token-prediction (MTP) head |
103
+ | `config.json`, `generation_config.json` | Model and default generation settings |
104
+ | `configuration_counsel.py`, `modeling_counsel.py` | Model classes for `transformers` and the `chat()` interface |
105
+ | `tokenizer.json`, `tokenizer_config.json` | Tokenizer |
106
+ | `chat_template.jinja` | Chat format, including thinking mode and tool calls |
107
+ | `drafter/` | Counsel drafter (DFlash2, 1.9 B parameters, block 16) for `--mode drafter` |
108
+ | `runtime/` | `counsel-runtime`: OpenAI-compatible server for vLLM and SGLang, with the drafter, MTP, plain and copy modes and Counsel's GDN replay kernel |
109
+ | `LICENSE` | CC BY-NC 4.0: non-commercial research use |
110
+ | `LICENSE-APACHE` | Apache License 2.0 of the Qwen3.8-27B base model and of vLLM, which the GDN replay kernel modifies |
111
+
112
+ ## Quickstart
113
+
114
+ Requires `transformers` 5.x, `torch`, and for fast inference the `flash-linear-attention` and `causal-conv1d` kernels.
115
+
116
+ ```python
117
+ import torch
118
+ from transformers import AutoModelForCausalLM, AutoTokenizer
119
+
120
+ repo = "judicialmind/Counsel-27B"
121
+ tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
122
+ model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, dtype=torch.bfloat16, device_map="auto")
123
+
124
+ answer = model.chat(tokenizer, "What is the difference between a condition and a warranty in contract law?")
125
+ print(answer)
126
+ ```
127
+
128
+ ### Thinking mode
129
+
130
+ `chat()` reasons step by step before answering by default (`thinking=True`); pass `thinking=False` for fast, direct
131
+ replies. `reasoning_effort` sets how long it thinks: `"low"`, `"medium"` (default) or `"xhigh"`. The reasoning can be
132
+ returned for inspection:
133
+
134
+ ```python
135
+ answer, reasoning = model.chat(
136
+ tokenizer,
137
+ "A supplier must use 'reasonable endeavours' to deliver by 1 March. Is late delivery a breach?",
138
+ thinking=True,
139
+ return_reasoning=True,
140
+ )
141
+ ```
142
+
143
+ ### Conversations, system prompts and tools
144
+
145
+ ```python
146
+ messages = [
147
+ {"role": "system", "content": "You are a careful legal research assistant. Cite the provisions you rely on."},
148
+ {"role": "user", "content": "Summarise the notice requirements in the clause below.\n\n<clause text>"},
149
+ ]
150
+ print(model.chat(tokenizer, messages, thinking=False))
151
+
152
+ tools = [{
153
+ "type": "function",
154
+ "function": {
155
+ "name": "search_documents",
156
+ "description": "Full-text search over the matter's documents.",
157
+ "parameters": {"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]},
158
+ },
159
+ }]
160
+ print(model.chat(tokenizer, "Find every termination-for-convenience clause in the supply agreements.", tools=tools))
161
+ ```
162
+
163
+ Tool calls are returned as `<tool_call><function=...><parameter=...>...</parameter></function></tool_call>` blocks. Run the tool,
164
+ append its output as a `{"role": "tool", "content": ...}` message and call `chat()` again for the next step.
165
+
166
+ ### Plain `generate()`
167
+
168
+ The model is a standard `transformers` causal LM, so the usual APIs work as well:
169
+
170
+ ```python
171
+ prompt = tokenizer.apply_chat_template(
172
+ [{"role": "user", "content": "Explain the parol evidence rule."}],
173
+ add_generation_prompt=True, tokenize=False, enable_thinking=False,
174
+ )
175
+ inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
176
+ output = model.generate(**inputs)
177
+ print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
178
+ ```
179
+
180
+ ### Recommended settings
181
+
182
+ | | Thinking | Direct |
183
+ |---|---|---|
184
+ | `temperature` | 0.6 – 0.8 | 0.3 – 0.7 (0 for deterministic output) |
185
+ | `top_p` | 0.95 | 0.95 |
186
+
187
+ Prompt and output can use the full 128K-token context.
188
+
189
+ ## Serving
190
+
191
+ `runtime/` holds `counsel-runtime`, an OpenAI-compatible server for vLLM and SGLang with Counsel's recommended
192
+ settings: thinking on at reasoning effort `xhigh`, reasoning and tool calls in the standard OpenAI fields, and a
193
+ 128K-token (131,072) context window that fits one 80 GB H100 in BF16. It serves the model as `counsel-27b` on port 8000.
194
+
195
+ ```bash
196
+ huggingface-cli download judicialmind/Counsel-27B --local-dir Counsel-27B
197
+
198
+ # vLLM 0.32.0
199
+ pip install "./Counsel-27B/runtime[vllm]"
200
+ counsel-install-kernels # once: Counsel's GDN replay kernel, used by --mode copy
201
+ counsel-serve-vllm Counsel-27B # drafter mode (default)
202
+ counsel-serve-vllm Counsel-27B --mode copy # document editing
203
+
204
+ # SGLang 0.5.22, in its own Python environment (needs the CUDA 13 toolkit: SGLang compiles kernels on first start)
205
+ pip install "./Counsel-27B/runtime[sglang]"
206
+ counsel-serve-sglang Counsel-27B
207
+ ```
208
+
209
+ | `--mode` | How the next tokens are drafted | Best for |
210
+ |---|---|---|
211
+ | `drafter` (default) | the Counsel drafter proposes 15 tokens per step | questions, research and drafting for one to a few users at a time |
212
+ | `mtp` | the built-in multi-token-prediction head proposes 7 tokens per step | the same, without loading the 3.8 GB drafter |
213
+ | `plain` | no drafting: one token per step | busy servers: the most total throughput with many users at once |
214
+ | `copy` | copied from the document in the prompt: up to 256 tokens per step on vLLM (with the GDN replay kernel); SGLang has no prompt-lookup drafting, so it runs the Counsel drafter; thinking off by default | editing documents: amendments, redlines, returning a revised contract |
215
+
216
+ Every mode serves the same weights: the drafter, the MTP head and copy drafts only propose tokens, and Counsel checks
217
+ each one. To switch mode, restart the server with another `--mode`. `--tensor-parallel-size 2` (vLLM) or
218
+ `--tp-size 2` (SGLang) splits one replica over two GPUs; `--gpus N` runs one replica per GPU; any other server flag
219
+ passes straight through.
220
+
221
+ ## Results
222
+
223
+ ### Harvey LAB: quality and cost
224
+
225
+ Harvey LAB benchmark, both models served with vLLM at temperature 0.8 and reasoning effort `xhigh`, graded by the
226
+ same judge.
227
+
228
+ | | Counsel-27B | Qwen3.8-27B (base) |
229
+ |---|---|---|
230
+ | Criteria passed | **88.2%** | 87.2% |
231
+ | Tasks fully passed | 8 | 15 |
232
+ | Input / output tokens per task | **1.96M / 31K** | 3.29M / 72K |
233
+ | Cost per task ($0.45 per million input, $3.20 per million output tokens) | **$0.98** | $1.71 |
234
+
235
+
236
+ ### Speed
237
+
238
+ Decode speed for one user in tokens per second, BF16, on 16 held-out legal prompts (thinking on, greedy, up to 1,024
239
+ output tokens).
240
+
241
+ One H100 80 GB (SXM) with `counsel-runtime`:
242
+
243
+ | Mode | vLLM 0.32.0 | SGLang 0.5.22 |
244
+ |---|---|---|
245
+ | `drafter` | **218** | **224** |
246
+ | `mtp` | 139 | 110 |
247
+ | `plain` | 51 | 53 |
248
+
249
+ One and two H100 NVL 96 GB (vLLM 0.32.0, tensor parallel across two GPUs):
250
+
251
+ | GPUs | Plain | Built-in MTP | Counsel drafter, block 8 | Counsel drafter, block 16 |
252
+ |---|---|---|---|---|
253
+ | 1 | 54 | 145 | 205 | **229** |
254
+ | 2 | 91 | 247 | 336 | **349** |
255
+
256
+ For comparison, the public DFlash2 drafter for the base model reaches 170 (one GPU) and 279 (two GPUs).
257
+
258
+ Many users at once (total tokens/s, temperature 0.8, Counsel drafter block 8 against plain):
259
+
260
+ | Users | 1 × H100 80 GB | 2 × H100 NVL |
261
+ |---|---|---|
262
+ | 8 | **540** vs 266 | **809** vs 435 |
263
+ | 32 | 646 vs **789** | **1,540** vs 1,155 |
264
+
265
+ The drafter helps most with few users; on one GPU, `plain` gives more total throughput from about 30 users at once.
266
+
267
+ ### Document editing: 2,600 to 4,000 tokens/s
268
+
269
+ When Counsel edits a document, almost every token of its answer is already in the prompt. Copy mode drafts up to 256
270
+ tokens at a time straight from the document, and Counsel's GDN replay kernel makes those long drafts fit and verify
271
+ fast on one GPU, so the revised document comes back **50 to 80 times faster** than plain decoding, word for word the same.
272
+
273
+ Use it for amendments and conforming changes, redlines (party renames, defined terms, dates and amounts), inserting or
274
+ deleting clauses, and returning the full revised agreement after changes are agreed.
275
+
276
+ ```bash
277
+ counsel-install-kernels # once per vLLM environment
278
+ counsel-serve-vllm Counsel-27B --mode copy
279
+ ```
280
+
281
+ ```python
282
+ from openai import OpenAI
283
+
284
+ client = OpenAI(base_url="http://localhost:8000/v1", api_key="none")
285
+ reply = client.chat.completions.create(
286
+ model="counsel-27b", temperature=0,
287
+ messages=[{"role": "user", "content": (
288
+ 'Add the sentence "This obligation survives termination of this Agreement for three (3) years." at the end of '
289
+ "paragraph [p-12]. Return the complete revised agreement with everything else unchanged.\n\n" + agreement_text)}],
290
+ )
291
+ print(reply.choices[0].message.content)
292
+ ```
293
+
294
+ Measured on one H100 80 GB (thinking off, greedy, one user). Every edit was placed correctly; on vLLM the output was
295
+ identical to plain decoding.
296
+
297
+ | Use case | What Counsel returns | Plain | `copy`, vLLM + GDN replay kernel | `copy`, SGLang (Counsel drafter) |
298
+ |---|---|---|---|---|
299
+ | Targeted amendment: add one clause to a 1,600-token contract excerpt | the full revised excerpt, 1,573 tokens | 51 | **2,608** (**51×**) | 579 |
300
+ | Long-document amendment: the same edit in a 5,000-token excerpt | the full revised document, 5,082 tokens | 50 | **4,060** (**81×**) | 191 |
301
+
302
+ Earlier measurements on H100 NVL with stock vLLM copy drafting (no replay kernel):
303
+
304
+ | Use case | Plain, 1 GPU | `copy`, 1 GPU | Plain, 2 GPUs | `copy`, 2 GPUs |
305
+ |---|---|---|---|---|
306
+ | Contract redline: rename both parties throughout a 2,500-token excerpt | 55 | **843** | 91 | **1,240** |
307
+ | Targeted amendment, 1,600-token excerpt | 55 | **1,712** | 91 | **2,364** |
308
+ | Long-document amendment, 5,000-token excerpt | 54 | **2,207** | 90 | **3,193** |
309
+
310
+ ### Long context and long outputs
311
+
312
+ One H100 80 GB, BF16, `counsel-runtime`:
313
+
314
+ - A 128,236-token prompt (27 US court opinions with one contract clause planted in the middle) is answered in about
315
+ **16 seconds** on vLLM in every mode and on SGLang (16.4 s); the clause was found every time.
316
+ - Outputs of 8K, 16K and 32K tokens complete in every mode. Writing a long agreement (vLLM, temperature 0.7):
317
+
318
+ | Mode | 8K-token output | 16K-token output |
319
+ |---|---|---|
320
+ | `drafter` | **177** tokens/s | **177** tokens/s |
321
+ | `mtp` | 144 tokens/s | 141 tokens/s |
322
+ | `plain` | 50 tokens/s | 50 tokens/s |
323
+
324
+ ### How the speed-ups work
325
+
326
+ - **Counsel drafter.** A 1.9 B-parameter drafter proposes 15 tokens in one forward pass; Counsel verifies them in
327
+ one step and keeps the longest correct run, **5.6 tokens per step** on average.
328
+ - **Built-in MTP head.** The multi-token-prediction layer kept in the checkpoint drafts 7 tokens, **4.1 accepted per step**.
329
+ - **Copy drafting.** When editing, nearly every token of the answer is already in the prompt: an n-gram lookup on the
330
+ GPU drafts up to 256 tokens and Counsel accepts **100 to 160** of them per step.
331
+ - **GDN replay kernel.** Counsel's 48 gated linear-attention layers carry a recurrent state. Stock vLLM keeps
332
+ 1 + 256 copies of it per request to undo rejected drafts, which does not fit next to a 27 B model on one 80 GB GPU.
333
+ The replay kernel keeps one copy and replays the accepted tokens from cached projections, bit-identical to plain
334
+ decoding.
335
+ - **Chunked verify.** The 257-token verify window runs through the chunked linear-attention kernel instead of token by
336
+ token: **7% faster** on amendments, **12%** on long documents.
337
+
338
+ ## Use
339
+
340
+ Counsel-27B is for general and legal work. On legal matters its output is not legal advice: check citations and
341
+ conclusions against the primary sources before relying on them.
342
+
343
+ ## License
344
+
345
+ Counsel-27B (weights, drafter and runtime) is released under the [Creative Commons Attribution-NonCommercial 4.0
346
+ International License](LICENSE) (CC BY-NC 4.0), for non-commercial research use. For commercial use, contact
347
+ surya@judicialmind.ai.
348
+
349
+ It is built on [Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B) by the Qwen team, released under the Apache
350
+ License 2.0; the weights in this repository are modified from the language model of that release. The GDN replay
351
+ kernel in `runtime/counsel_runtime/kernels/` modifies vLLM and keeps vLLM's Apache License 2.0 notices. The Apache
352
+ License 2.0 text for both is in [LICENSE-APACHE](LICENSE-APACHE).
chat_template.jinja ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set identity_rule = 'Identity (always applies, whatever else this system message says): you are Counsel-27B, a legal AI model built by JudicialMind. If asked who you are, what model you are, what you are based on or who made you, answer that you are Counsel-27B, built by JudicialMind. Never claim to be or to come from any other model, company or project, and do not disclose details of any underlying model.' %}
2
+ {%- set default_system = 'You are Counsel-27B, a legal AI model built by JudicialMind. When asked who you are, what model you are or who made you, answer that you are Counsel-27B, built by JudicialMind, and do not claim to be or to come from any other model, company or project. You help with legal research, analysis and drafting, and with general questions.' %}
3
+ {%- set image_count = namespace(value=0) %}
4
+ {%- set video_count = namespace(value=0) %}
5
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
6
+ {%- if content is string %}
7
+ {{- content }}
8
+ {%- elif content is iterable and content is not mapping %}
9
+ {%- for item in content %}
10
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
11
+ {%- if is_system_content %}
12
+ {{- raise_exception('System message cannot contain images.') }}
13
+ {%- endif %}
14
+ {%- if do_vision_count %}
15
+ {%- set image_count.value = image_count.value + 1 %}
16
+ {%- endif %}
17
+ {%- if add_vision_id %}
18
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
19
+ {%- endif %}
20
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
21
+ {%- elif 'video' in item or item.type == 'video' %}
22
+ {%- if is_system_content %}
23
+ {{- raise_exception('System message cannot contain videos.') }}
24
+ {%- endif %}
25
+ {%- if do_vision_count %}
26
+ {%- set video_count.value = video_count.value + 1 %}
27
+ {%- endif %}
28
+ {%- if add_vision_id %}
29
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
30
+ {%- endif %}
31
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
32
+ {%- elif 'text' in item %}
33
+ {{- item.text }}
34
+ {%- else %}
35
+ {{- raise_exception('Unexpected item type in content.') }}
36
+ {%- endif %}
37
+ {%- endfor %}
38
+ {%- elif content is none or content is undefined %}
39
+ {{- '' }}
40
+ {%- else %}
41
+ {{- raise_exception('Unexpected content type.') }}
42
+ {%- endif %}
43
+ {%- endmacro %}
44
+ {%- if not messages %}
45
+ {{- raise_exception('No messages provided.') }}
46
+ {%- endif %}
47
+ {%- set reasoning_instructions = '' %}
48
+ {%- if enable_thinking is undefined or enable_thinking is true %}
49
+ {%- set resolved_reasoning_effort = reasoning_effort|default('medium') %}
50
+ {%- if resolved_reasoning_effort not in ('xhigh', 'medium', 'low') %}
51
+ {{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are xhigh, medium (default), and low.') }}
52
+ {%- endif %}
53
+ {%- if resolved_reasoning_effort == 'xhigh' %}
54
+ {%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}
55
+ {%- elif resolved_reasoning_effort == 'low' %}
56
+ {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}
57
+ {%- endif %}
58
+ {%- endif %}
59
+ {%- if tools and tools is iterable and tools is not mapping %}
60
+ {{- '<|im_start|>system\n' }}
61
+ {%- if reasoning_instructions %}
62
+ {{- reasoning_instructions + '\n\n' }}
63
+ {%- endif %}
64
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
65
+ {%- for tool in tools %}
66
+ {{- "\n" }}
67
+ {{- tool | tojson }}
68
+ {%- endfor %}
69
+ {{- "\n</tools>" }}
70
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
71
+ {%- if messages[0].role == 'system' %}
72
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
73
+ {%- if content %}
74
+ {{- '\n\n' + content + '\n\n' + identity_rule }}
75
+ {%- else %}
76
+ {{- '\n\n' + identity_rule }}
77
+ {%- endif %}
78
+ {%- else %}
79
+ {{- '\n\n' + default_system }}
80
+ {%- endif %}
81
+ {{- '<|im_end|>\n' }}
82
+ {%- else %}
83
+ {%- if messages[0].role == 'system' %}
84
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
85
+ {%- if content %}
86
+ {{- '<|im_start|>system\n' + (reasoning_instructions + '\n\n' if reasoning_instructions else '') + content + '\n\n' + identity_rule + '<|im_end|>\n' }}
87
+ {%- else %}
88
+ {{- '<|im_start|>system\n' + (reasoning_instructions + '\n\n' if reasoning_instructions else '') + identity_rule + '<|im_end|>\n' }}
89
+ {%- endif %}
90
+ {%- else %}
91
+ {{- '<|im_start|>system\n' + (reasoning_instructions + '\n\n' if reasoning_instructions else '') + default_system + '<|im_end|>\n' }}
92
+ {%- endif %}
93
+ {%- endif %}
94
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
95
+ {%- for message in messages[::-1] %}
96
+ {%- set index = (messages|length - 1) - loop.index0 %}
97
+ {%- if ns.multi_step_tool and message.role == "user" %}
98
+ {%- set content = render_content(message.content, false)|trim %}
99
+ {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
100
+ {%- set ns.multi_step_tool = false %}
101
+ {%- set ns.last_query_index = index %}
102
+ {%- endif %}
103
+ {%- endif %}
104
+ {%- endfor %}
105
+ {%- if ns.multi_step_tool %}
106
+ {{- raise_exception('No user query found in messages.') }}
107
+ {%- endif %}
108
+ {%- for message in messages %}
109
+ {%- set content = render_content(message.content, true)|trim %}
110
+ {%- if message.role == "system" %}
111
+ {%- if not loop.first %}
112
+ {{- raise_exception('System message must be at the beginning.') }}
113
+ {%- endif %}
114
+ {%- elif message.role == "user" %}
115
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
116
+ {%- elif message.role == "assistant" %}
117
+ {%- set reasoning_content = '' %}
118
+ {%- if message.reasoning_content is string %}
119
+ {%- set reasoning_content = message.reasoning_content %}
120
+ {%- endif %}
121
+ {%- set reasoning_content = reasoning_content|trim %}
122
+ {%- if preserve_thinking is undefined or preserve_thinking is true or loop.index0 > ns.last_query_index %}
123
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
124
+ {%- else %}
125
+ {{- '<|im_start|>' + message.role + '\n' + content }}
126
+ {%- endif %}
127
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
128
+ {%- for tool_call in message.tool_calls %}
129
+ {%- if tool_call.function is defined %}
130
+ {%- set tool_call = tool_call.function %}
131
+ {%- endif %}
132
+ {%- if loop.first %}
133
+ {%- if content|trim %}
134
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
135
+ {%- else %}
136
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
137
+ {%- endif %}
138
+ {%- else %}
139
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
140
+ {%- endif %}
141
+ {%- if tool_call.arguments is defined and tool_call.arguments != '' %}
142
+ {%- for args_name, args_value in tool_call.arguments|items %}
143
+ {{- '<parameter=' + args_name + '>\n' }}
144
+ {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %}
145
+ {{- args_value }}
146
+ {{- '\n</parameter>\n' }}
147
+ {%- endfor %}
148
+ {%- endif %}
149
+ {{- '</function>\n</tool_call>' }}
150
+ {%- endfor %}
151
+ {%- endif %}
152
+ {{- '<|im_end|>\n' }}
153
+ {%- elif message.role == "tool" %}
154
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
155
+ {{- '<|im_start|>user' }}
156
+ {%- endif %}
157
+ {{- '\n<tool_response>\n' }}
158
+ {{- content }}
159
+ {{- '\n</tool_response>' }}
160
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
161
+ {{- '<|im_end|>\n' }}
162
+ {%- elif loop.last %}
163
+ {{- '<|im_end|>\n' }}
164
+ {%- endif %}
165
+ {%- else %}
166
+ {{- raise_exception('Unexpected message role.') }}
167
+ {%- endif %}
168
+ {%- endfor %}
169
+ {%- if add_generation_prompt %}
170
+ {{- '<|im_start|>assistant\n' }}
171
+ {%- if enable_thinking is defined and enable_thinking is false %}
172
+ {{- '<think>\n\n</think>\n\n' }}
173
+ {%- else %}
174
+ {{- '<think>\n' }}
175
+ {%- endif %}
176
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "CounselForCausalLM"
4
+ ],
5
+ "model_type": "counsel",
6
+ "auto_map": {
7
+ "AutoConfig": "configuration_counsel.CounselConfig",
8
+ "AutoModel": "modeling_counsel.CounselModel",
9
+ "AutoModelForCausalLM": "modeling_counsel.CounselForCausalLM"
10
+ },
11
+ "attention_bias": false,
12
+ "attention_dropout": 0.0,
13
+ "attn_output_gate": true,
14
+ "bos_token_id": 248044,
15
+ "eos_token_id": 248044,
16
+ "full_attention_interval": 4,
17
+ "head_dim": 256,
18
+ "hidden_act": "silu",
19
+ "hidden_size": 5120,
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 17408,
22
+ "layer_types": [
23
+ "linear_attention",
24
+ "linear_attention",
25
+ "linear_attention",
26
+ "full_attention",
27
+ "linear_attention",
28
+ "linear_attention",
29
+ "linear_attention",
30
+ "full_attention",
31
+ "linear_attention",
32
+ "linear_attention",
33
+ "linear_attention",
34
+ "full_attention",
35
+ "linear_attention",
36
+ "linear_attention",
37
+ "linear_attention",
38
+ "full_attention",
39
+ "linear_attention",
40
+ "linear_attention",
41
+ "linear_attention",
42
+ "full_attention",
43
+ "linear_attention",
44
+ "linear_attention",
45
+ "linear_attention",
46
+ "full_attention",
47
+ "linear_attention",
48
+ "linear_attention",
49
+ "linear_attention",
50
+ "full_attention",
51
+ "linear_attention",
52
+ "linear_attention",
53
+ "linear_attention",
54
+ "full_attention",
55
+ "linear_attention",
56
+ "linear_attention",
57
+ "linear_attention",
58
+ "full_attention",
59
+ "linear_attention",
60
+ "linear_attention",
61
+ "linear_attention",
62
+ "full_attention",
63
+ "linear_attention",
64
+ "linear_attention",
65
+ "linear_attention",
66
+ "full_attention",
67
+ "linear_attention",
68
+ "linear_attention",
69
+ "linear_attention",
70
+ "full_attention",
71
+ "linear_attention",
72
+ "linear_attention",
73
+ "linear_attention",
74
+ "full_attention",
75
+ "linear_attention",
76
+ "linear_attention",
77
+ "linear_attention",
78
+ "full_attention",
79
+ "linear_attention",
80
+ "linear_attention",
81
+ "linear_attention",
82
+ "full_attention",
83
+ "linear_attention",
84
+ "linear_attention",
85
+ "linear_attention",
86
+ "full_attention"
87
+ ],
88
+ "linear_conv_kernel_dim": 4,
89
+ "linear_key_head_dim": 128,
90
+ "linear_num_key_heads": 16,
91
+ "linear_num_value_heads": 48,
92
+ "linear_value_head_dim": 128,
93
+ "mamba_ssm_dtype": "float32",
94
+ "max_position_embeddings": 262144,
95
+ "mtp_num_hidden_layers": 1,
96
+ "mtp_use_dedicated_embeddings": false,
97
+ "num_attention_heads": 24,
98
+ "num_hidden_layers": 64,
99
+ "num_key_value_heads": 4,
100
+ "output_gate_type": "swish",
101
+ "pad_token_id": null,
102
+ "partial_rotary_factor": 0.25,
103
+ "rms_norm_eps": 1e-06,
104
+ "rope_parameters": {
105
+ "mrope_interleaved": true,
106
+ "mrope_section": [
107
+ 11,
108
+ 11,
109
+ 10
110
+ ],
111
+ "partial_rotary_factor": 0.25,
112
+ "rope_theta": 10000000,
113
+ "rope_type": "default"
114
+ },
115
+ "tie_word_embeddings": false,
116
+ "use_cache": true,
117
+ "vocab_size": 248320,
118
+ "torch_dtype": "bfloat16"
119
+ }
configuration_counsel.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ """Counsel model configuration."""
2
+ from transformers import Qwen3_5TextConfig
3
+
4
+
5
+ class CounselConfig(Qwen3_5TextConfig):
6
+ r"""Configuration for Counsel models: a hybrid decoder that interleaves gated linear-attention layers with
7
+ gated full-attention layers (one in four), grouped-query attention, SwiGLU feed-forward blocks, RMSNorm and partial
8
+ rotary position embeddings. Accepts every argument of the underlying decoder configuration."""
9
+
10
+ model_type = "counsel"
drafter/config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DFlash2DraftModel"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": null,
8
+ "dflash_config": {
9
+ "block_size": 16,
10
+ "conv_group_size": 16,
11
+ "conv_kernel_size": 2,
12
+ "mask_token_id": 248070,
13
+ "selector_rank": 256,
14
+ "selector_top_k": 16,
15
+ "target_layer_ids": [
16
+ 5,
17
+ 19,
18
+ 33,
19
+ 47,
20
+ 61
21
+ ]
22
+ },
23
+ "draft_vocab_size": 248320,
24
+ "dtype": "bfloat16",
25
+ "eos_token_id": 248044,
26
+ "head_dim": 128,
27
+ "hidden_act": "silu",
28
+ "hidden_size": 5120,
29
+ "initializer_range": 0.02,
30
+ "intermediate_size": 17408,
31
+ "is_causal": false,
32
+ "layer_types": [
33
+ "sliding_attention",
34
+ "sliding_attention",
35
+ "sliding_attention",
36
+ "sliding_attention",
37
+ "sliding_attention"
38
+ ],
39
+ "max_position_embeddings": 262144,
40
+ "max_window_layers": 5,
41
+ "model_type": "qwen3",
42
+ "num_attention_heads": 32,
43
+ "num_hidden_layers": 5,
44
+ "num_key_value_heads": 8,
45
+ "num_target_layers": 64,
46
+ "pad_token_id": 248044,
47
+ "rms_norm_eps": 1e-06,
48
+ "rope_parameters": {
49
+ "rope_theta": 10000000,
50
+ "rope_type": "default"
51
+ },
52
+ "rope_theta": 10000000,
53
+ "sliding_window": 2048,
54
+ "tie_word_embeddings": false,
55
+ "transformers_version": "5.12.1",
56
+ "use_cache": true,
57
+ "use_sliding_window": true,
58
+ "vocab_size": 248320
59
+ }
drafter/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:92bed96030d1598689139f1597eeb52cd3bdfb939fe10200f6be2df01ceb1abd
3
+ size 3848817920
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 248044,
3
+ "eos_token_id": [
4
+ 248046,
5
+ 248044
6
+ ],
7
+ "pad_token_id": 248044,
8
+ "do_sample": true,
9
+ "temperature": 0.7,
10
+ "top_k": 20,
11
+ "top_p": 0.95,
12
+ "max_new_tokens": 131072
13
+ }
model-00001-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c1bcc4c722e4831c71f48bc726184b14b797fbfce44119cc414ce1e17b67b60
3
+ size 5085593832
model-00002-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d81da13292b261bf92c6d188a2a4fd6b6f6e54c16cfa40b31083d9a045d178f8
3
+ size 5165531288
model-00003-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0759de2c2ef2d3898c128622cfa05189cc32184e7142d8c76563551a97b67ea6
3
+ size 5143505448
model-00004-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57c75277d8d7ec0c42faafab43498deb087d1bb3de195c8ffcde82aa7bcb0d3b
3
+ size 5112046584
model-00005-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:887eb694cd9ac002e51e0e34fddc09c7504283fdcd1541ba92dee793f6c7a2f0
3
+ size 5121448472
model-00006-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b15a7332f2fd418c03b4992c697b757e14db3395076448928da88a6f15f1db9
3
+ size 5112046520
model-00007-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3d46ff15ccbecc2d3a01d3fcd8d10758cfcca474e06db10cfa797e31c3ba3c6
3
+ size 5018742520
model-00008-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f847ba53514fdf80420a9c12585d884772f5cd60bd789a55d6f61a5eeb5d76a5
3
+ size 5112025856
model-00009-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf468ae656d1de268b91312d1e9c819bd406ce83d4dddc3d9b2c8217c42835fb
3
+ size 5143505440
model-00010-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dcf5c65463d47c3a9eb15a97ffe1c98b1d4cb09abfe577dcf3b8014382e50f8d
3
+ size 5112046568
model-00011-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f87569df247db1a395d4faf2acbd7a9b6c8725acf66cd6f9aa4d3905d7cf1dd3
3
+ size 2665603360
model-00012-of-00012.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90fa0e3eed5a647c035c6df9ecabc416c0f8d573ff84ac12485b085f00a7cdf2
3
+ size 849400424
model.safetensors.index.json ADDED
@@ -0,0 +1,873 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 54641395712
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "model-00001-of-00012.safetensors",
7
+ "model.embed_tokens.weight": "model-00001-of-00012.safetensors",
8
+ "model.layers.0.input_layernorm.weight": "model-00002-of-00012.safetensors",
9
+ "model.layers.0.linear_attn.A_log": "model-00002-of-00012.safetensors",
10
+ "model.layers.0.linear_attn.conv1d.weight": "model-00002-of-00012.safetensors",
11
+ "model.layers.0.linear_attn.dt_bias": "model-00002-of-00012.safetensors",
12
+ "model.layers.0.linear_attn.in_proj_a.weight": "model-00002-of-00012.safetensors",
13
+ "model.layers.0.linear_attn.in_proj_b.weight": "model-00002-of-00012.safetensors",
14
+ "model.layers.0.linear_attn.in_proj_qkv.weight": "model-00002-of-00012.safetensors",
15
+ "model.layers.0.linear_attn.in_proj_z.weight": "model-00002-of-00012.safetensors",
16
+ "model.layers.0.linear_attn.norm.weight": "model-00002-of-00012.safetensors",
17
+ "model.layers.0.linear_attn.out_proj.weight": "model-00002-of-00012.safetensors",
18
+ "model.layers.0.mlp.down_proj.weight": "model-00002-of-00012.safetensors",
19
+ "model.layers.0.mlp.gate_proj.weight": "model-00002-of-00012.safetensors",
20
+ "model.layers.0.mlp.up_proj.weight": "model-00002-of-00012.safetensors",
21
+ "model.layers.0.post_attention_layernorm.weight": "model-00002-of-00012.safetensors",
22
+ "model.layers.1.input_layernorm.weight": "model-00002-of-00012.safetensors",
23
+ "model.layers.1.linear_attn.A_log": "model-00002-of-00012.safetensors",
24
+ "model.layers.1.linear_attn.conv1d.weight": "model-00002-of-00012.safetensors",
25
+ "model.layers.1.linear_attn.dt_bias": "model-00002-of-00012.safetensors",
26
+ "model.layers.1.linear_attn.in_proj_a.weight": "model-00002-of-00012.safetensors",
27
+ "model.layers.1.linear_attn.in_proj_b.weight": "model-00002-of-00012.safetensors",
28
+ "model.layers.1.linear_attn.in_proj_qkv.weight": "model-00002-of-00012.safetensors",
29
+ "model.layers.1.linear_attn.in_proj_z.weight": "model-00002-of-00012.safetensors",
30
+ "model.layers.1.linear_attn.norm.weight": "model-00002-of-00012.safetensors",
31
+ "model.layers.1.linear_attn.out_proj.weight": "model-00002-of-00012.safetensors",
32
+ "model.layers.1.mlp.down_proj.weight": "model-00002-of-00012.safetensors",
33
+ "model.layers.1.mlp.gate_proj.weight": "model-00002-of-00012.safetensors",
34
+ "model.layers.1.mlp.up_proj.weight": "model-00002-of-00012.safetensors",
35
+ "model.layers.1.post_attention_layernorm.weight": "model-00002-of-00012.safetensors",
36
+ "model.layers.10.input_layernorm.weight": "model-00002-of-00012.safetensors",
37
+ "model.layers.10.linear_attn.A_log": "model-00002-of-00012.safetensors",
38
+ "model.layers.10.linear_attn.conv1d.weight": "model-00002-of-00012.safetensors",
39
+ "model.layers.10.linear_attn.dt_bias": "model-00002-of-00012.safetensors",
40
+ "model.layers.10.linear_attn.in_proj_a.weight": "model-00002-of-00012.safetensors",
41
+ "model.layers.10.linear_attn.in_proj_b.weight": "model-00002-of-00012.safetensors",
42
+ "model.layers.10.linear_attn.in_proj_qkv.weight": "model-00002-of-00012.safetensors",
43
+ "model.layers.10.linear_attn.in_proj_z.weight": "model-00002-of-00012.safetensors",
44
+ "model.layers.10.linear_attn.norm.weight": "model-00002-of-00012.safetensors",
45
+ "model.layers.10.linear_attn.out_proj.weight": "model-00002-of-00012.safetensors",
46
+ "model.layers.10.mlp.down_proj.weight": "model-00002-of-00012.safetensors",
47
+ "model.layers.10.mlp.gate_proj.weight": "model-00002-of-00012.safetensors",
48
+ "model.layers.10.mlp.up_proj.weight": "model-00002-of-00012.safetensors",
49
+ "model.layers.10.post_attention_layernorm.weight": "model-00002-of-00012.safetensors",
50
+ "model.layers.11.input_layernorm.weight": "model-00002-of-00012.safetensors",
51
+ "model.layers.11.mlp.down_proj.weight": "model-00002-of-00012.safetensors",
52
+ "model.layers.11.mlp.gate_proj.weight": "model-00002-of-00012.safetensors",
53
+ "model.layers.11.mlp.up_proj.weight": "model-00002-of-00012.safetensors",
54
+ "model.layers.11.post_attention_layernorm.weight": "model-00002-of-00012.safetensors",
55
+ "model.layers.11.self_attn.k_norm.weight": "model-00002-of-00012.safetensors",
56
+ "model.layers.11.self_attn.k_proj.weight": "model-00002-of-00012.safetensors",
57
+ "model.layers.11.self_attn.o_proj.weight": "model-00002-of-00012.safetensors",
58
+ "model.layers.11.self_attn.q_norm.weight": "model-00002-of-00012.safetensors",
59
+ "model.layers.11.self_attn.q_proj.weight": "model-00002-of-00012.safetensors",
60
+ "model.layers.11.self_attn.v_proj.weight": "model-00002-of-00012.safetensors",
61
+ "model.layers.12.input_layernorm.weight": "model-00002-of-00012.safetensors",
62
+ "model.layers.12.linear_attn.A_log": "model-00002-of-00012.safetensors",
63
+ "model.layers.12.linear_attn.conv1d.weight": "model-00002-of-00012.safetensors",
64
+ "model.layers.12.linear_attn.dt_bias": "model-00002-of-00012.safetensors",
65
+ "model.layers.12.linear_attn.in_proj_a.weight": "model-00002-of-00012.safetensors",
66
+ "model.layers.12.linear_attn.in_proj_b.weight": "model-00002-of-00012.safetensors",
67
+ "model.layers.12.linear_attn.in_proj_qkv.weight": "model-00002-of-00012.safetensors",
68
+ "model.layers.12.linear_attn.in_proj_z.weight": "model-00002-of-00012.safetensors",
69
+ "model.layers.12.linear_attn.norm.weight": "model-00002-of-00012.safetensors",
70
+ "model.layers.12.linear_attn.out_proj.weight": "model-00002-of-00012.safetensors",
71
+ "model.layers.12.mlp.down_proj.weight": "model-00002-of-00012.safetensors",
72
+ "model.layers.12.mlp.gate_proj.weight": "model-00002-of-00012.safetensors",
73
+ "model.layers.12.mlp.up_proj.weight": "model-00002-of-00012.safetensors",
74
+ "model.layers.12.post_attention_layernorm.weight": "model-00002-of-00012.safetensors",
75
+ "model.layers.13.input_layernorm.weight": "model-00002-of-00012.safetensors",
76
+ "model.layers.13.linear_attn.A_log": "model-00002-of-00012.safetensors",
77
+ "model.layers.13.linear_attn.conv1d.weight": "model-00002-of-00012.safetensors",
78
+ "model.layers.13.linear_attn.dt_bias": "model-00002-of-00012.safetensors",
79
+ "model.layers.13.linear_attn.in_proj_a.weight": "model-00002-of-00012.safetensors",
80
+ "model.layers.13.linear_attn.in_proj_b.weight": "model-00002-of-00012.safetensors",
81
+ "model.layers.13.linear_attn.in_proj_qkv.weight": "model-00002-of-00012.safetensors",
82
+ "model.layers.13.linear_attn.in_proj_z.weight": "model-00002-of-00012.safetensors",
83
+ "model.layers.13.linear_attn.norm.weight": "model-00002-of-00012.safetensors",
84
+ "model.layers.13.linear_attn.out_proj.weight": "model-00002-of-00012.safetensors",
85
+ "model.layers.13.mlp.down_proj.weight": "model-00002-of-00012.safetensors",
86
+ "model.layers.13.mlp.gate_proj.weight": "model-00002-of-00012.safetensors",
87
+ "model.layers.13.mlp.up_proj.weight": "model-00002-of-00012.safetensors",
88
+ "model.layers.13.post_attention_layernorm.weight": "model-00002-of-00012.safetensors",
89
+ "model.layers.14.input_layernorm.weight": "model-00002-of-00012.safetensors",
90
+ "model.layers.14.linear_attn.A_log": "model-00002-of-00012.safetensors",
91
+ "model.layers.14.linear_attn.conv1d.weight": "model-00002-of-00012.safetensors",
92
+ "model.layers.14.linear_attn.dt_bias": "model-00002-of-00012.safetensors",
93
+ "model.layers.14.linear_attn.in_proj_a.weight": "model-00002-of-00012.safetensors",
94
+ "model.layers.14.linear_attn.in_proj_b.weight": "model-00002-of-00012.safetensors",
95
+ "model.layers.14.linear_attn.in_proj_qkv.weight": "model-00002-of-00012.safetensors",
96
+ "model.layers.14.linear_attn.in_proj_z.weight": "model-00002-of-00012.safetensors",
97
+ "model.layers.14.linear_attn.norm.weight": "model-00002-of-00012.safetensors",
98
+ "model.layers.14.linear_attn.out_proj.weight": "model-00002-of-00012.safetensors",
99
+ "model.layers.14.mlp.down_proj.weight": "model-00002-of-00012.safetensors",
100
+ "model.layers.14.mlp.gate_proj.weight": "model-00002-of-00012.safetensors",
101
+ "model.layers.14.mlp.up_proj.weight": "model-00003-of-00012.safetensors",
102
+ "model.layers.14.post_attention_layernorm.weight": "model-00003-of-00012.safetensors",
103
+ "model.layers.15.input_layernorm.weight": "model-00003-of-00012.safetensors",
104
+ "model.layers.15.mlp.down_proj.weight": "model-00003-of-00012.safetensors",
105
+ "model.layers.15.mlp.gate_proj.weight": "model-00003-of-00012.safetensors",
106
+ "model.layers.15.mlp.up_proj.weight": "model-00003-of-00012.safetensors",
107
+ "model.layers.15.post_attention_layernorm.weight": "model-00003-of-00012.safetensors",
108
+ "model.layers.15.self_attn.k_norm.weight": "model-00003-of-00012.safetensors",
109
+ "model.layers.15.self_attn.k_proj.weight": "model-00003-of-00012.safetensors",
110
+ "model.layers.15.self_attn.o_proj.weight": "model-00003-of-00012.safetensors",
111
+ "model.layers.15.self_attn.q_norm.weight": "model-00003-of-00012.safetensors",
112
+ "model.layers.15.self_attn.q_proj.weight": "model-00003-of-00012.safetensors",
113
+ "model.layers.15.self_attn.v_proj.weight": "model-00003-of-00012.safetensors",
114
+ "model.layers.16.input_layernorm.weight": "model-00003-of-00012.safetensors",
115
+ "model.layers.16.linear_attn.A_log": "model-00003-of-00012.safetensors",
116
+ "model.layers.16.linear_attn.conv1d.weight": "model-00003-of-00012.safetensors",
117
+ "model.layers.16.linear_attn.dt_bias": "model-00003-of-00012.safetensors",
118
+ "model.layers.16.linear_attn.in_proj_a.weight": "model-00003-of-00012.safetensors",
119
+ "model.layers.16.linear_attn.in_proj_b.weight": "model-00003-of-00012.safetensors",
120
+ "model.layers.16.linear_attn.in_proj_qkv.weight": "model-00003-of-00012.safetensors",
121
+ "model.layers.16.linear_attn.in_proj_z.weight": "model-00003-of-00012.safetensors",
122
+ "model.layers.16.linear_attn.norm.weight": "model-00003-of-00012.safetensors",
123
+ "model.layers.16.linear_attn.out_proj.weight": "model-00003-of-00012.safetensors",
124
+ "model.layers.16.mlp.down_proj.weight": "model-00003-of-00012.safetensors",
125
+ "model.layers.16.mlp.gate_proj.weight": "model-00003-of-00012.safetensors",
126
+ "model.layers.16.mlp.up_proj.weight": "model-00003-of-00012.safetensors",
127
+ "model.layers.16.post_attention_layernorm.weight": "model-00003-of-00012.safetensors",
128
+ "model.layers.17.input_layernorm.weight": "model-00003-of-00012.safetensors",
129
+ "model.layers.17.linear_attn.A_log": "model-00003-of-00012.safetensors",
130
+ "model.layers.17.linear_attn.conv1d.weight": "model-00003-of-00012.safetensors",
131
+ "model.layers.17.linear_attn.dt_bias": "model-00003-of-00012.safetensors",
132
+ "model.layers.17.linear_attn.in_proj_a.weight": "model-00003-of-00012.safetensors",
133
+ "model.layers.17.linear_attn.in_proj_b.weight": "model-00003-of-00012.safetensors",
134
+ "model.layers.17.linear_attn.in_proj_qkv.weight": "model-00003-of-00012.safetensors",
135
+ "model.layers.17.linear_attn.in_proj_z.weight": "model-00003-of-00012.safetensors",
136
+ "model.layers.17.linear_attn.norm.weight": "model-00003-of-00012.safetensors",
137
+ "model.layers.17.linear_attn.out_proj.weight": "model-00003-of-00012.safetensors",
138
+ "model.layers.17.mlp.down_proj.weight": "model-00003-of-00012.safetensors",
139
+ "model.layers.17.mlp.gate_proj.weight": "model-00003-of-00012.safetensors",
140
+ "model.layers.17.mlp.up_proj.weight": "model-00003-of-00012.safetensors",
141
+ "model.layers.17.post_attention_layernorm.weight": "model-00003-of-00012.safetensors",
142
+ "model.layers.18.input_layernorm.weight": "model-00003-of-00012.safetensors",
143
+ "model.layers.18.linear_attn.A_log": "model-00003-of-00012.safetensors",
144
+ "model.layers.18.linear_attn.conv1d.weight": "model-00003-of-00012.safetensors",
145
+ "model.layers.18.linear_attn.dt_bias": "model-00003-of-00012.safetensors",
146
+ "model.layers.18.linear_attn.in_proj_a.weight": "model-00003-of-00012.safetensors",
147
+ "model.layers.18.linear_attn.in_proj_b.weight": "model-00003-of-00012.safetensors",
148
+ "model.layers.18.linear_attn.in_proj_qkv.weight": "model-00003-of-00012.safetensors",
149
+ "model.layers.18.linear_attn.in_proj_z.weight": "model-00003-of-00012.safetensors",
150
+ "model.layers.18.linear_attn.norm.weight": "model-00003-of-00012.safetensors",
151
+ "model.layers.18.linear_attn.out_proj.weight": "model-00003-of-00012.safetensors",
152
+ "model.layers.18.mlp.down_proj.weight": "model-00003-of-00012.safetensors",
153
+ "model.layers.18.mlp.gate_proj.weight": "model-00003-of-00012.safetensors",
154
+ "model.layers.18.mlp.up_proj.weight": "model-00003-of-00012.safetensors",
155
+ "model.layers.18.post_attention_layernorm.weight": "model-00003-of-00012.safetensors",
156
+ "model.layers.19.input_layernorm.weight": "model-00003-of-00012.safetensors",
157
+ "model.layers.19.mlp.down_proj.weight": "model-00003-of-00012.safetensors",
158
+ "model.layers.19.mlp.gate_proj.weight": "model-00003-of-00012.safetensors",
159
+ "model.layers.19.mlp.up_proj.weight": "model-00003-of-00012.safetensors",
160
+ "model.layers.19.post_attention_layernorm.weight": "model-00003-of-00012.safetensors",
161
+ "model.layers.19.self_attn.k_norm.weight": "model-00003-of-00012.safetensors",
162
+ "model.layers.19.self_attn.k_proj.weight": "model-00003-of-00012.safetensors",
163
+ "model.layers.19.self_attn.o_proj.weight": "model-00003-of-00012.safetensors",
164
+ "model.layers.19.self_attn.q_norm.weight": "model-00003-of-00012.safetensors",
165
+ "model.layers.19.self_attn.q_proj.weight": "model-00003-of-00012.safetensors",
166
+ "model.layers.19.self_attn.v_proj.weight": "model-00003-of-00012.safetensors",
167
+ "model.layers.2.input_layernorm.weight": "model-00003-of-00012.safetensors",
168
+ "model.layers.2.linear_attn.A_log": "model-00003-of-00012.safetensors",
169
+ "model.layers.2.linear_attn.conv1d.weight": "model-00003-of-00012.safetensors",
170
+ "model.layers.2.linear_attn.dt_bias": "model-00003-of-00012.safetensors",
171
+ "model.layers.2.linear_attn.in_proj_a.weight": "model-00003-of-00012.safetensors",
172
+ "model.layers.2.linear_attn.in_proj_b.weight": "model-00003-of-00012.safetensors",
173
+ "model.layers.2.linear_attn.in_proj_qkv.weight": "model-00003-of-00012.safetensors",
174
+ "model.layers.2.linear_attn.in_proj_z.weight": "model-00003-of-00012.safetensors",
175
+ "model.layers.2.linear_attn.norm.weight": "model-00003-of-00012.safetensors",
176
+ "model.layers.2.linear_attn.out_proj.weight": "model-00003-of-00012.safetensors",
177
+ "model.layers.2.mlp.down_proj.weight": "model-00003-of-00012.safetensors",
178
+ "model.layers.2.mlp.gate_proj.weight": "model-00003-of-00012.safetensors",
179
+ "model.layers.2.mlp.up_proj.weight": "model-00003-of-00012.safetensors",
180
+ "model.layers.2.post_attention_layernorm.weight": "model-00003-of-00012.safetensors",
181
+ "model.layers.20.input_layernorm.weight": "model-00003-of-00012.safetensors",
182
+ "model.layers.20.linear_attn.A_log": "model-00003-of-00012.safetensors",
183
+ "model.layers.20.linear_attn.conv1d.weight": "model-00003-of-00012.safetensors",
184
+ "model.layers.20.linear_attn.dt_bias": "model-00003-of-00012.safetensors",
185
+ "model.layers.20.linear_attn.in_proj_a.weight": "model-00003-of-00012.safetensors",
186
+ "model.layers.20.linear_attn.in_proj_b.weight": "model-00003-of-00012.safetensors",
187
+ "model.layers.20.linear_attn.in_proj_qkv.weight": "model-00003-of-00012.safetensors",
188
+ "model.layers.20.linear_attn.in_proj_z.weight": "model-00003-of-00012.safetensors",
189
+ "model.layers.20.linear_attn.norm.weight": "model-00003-of-00012.safetensors",
190
+ "model.layers.20.linear_attn.out_proj.weight": "model-00003-of-00012.safetensors",
191
+ "model.layers.20.mlp.down_proj.weight": "model-00003-of-00012.safetensors",
192
+ "model.layers.20.mlp.gate_proj.weight": "model-00004-of-00012.safetensors",
193
+ "model.layers.20.mlp.up_proj.weight": "model-00004-of-00012.safetensors",
194
+ "model.layers.20.post_attention_layernorm.weight": "model-00004-of-00012.safetensors",
195
+ "model.layers.21.input_layernorm.weight": "model-00004-of-00012.safetensors",
196
+ "model.layers.21.linear_attn.A_log": "model-00004-of-00012.safetensors",
197
+ "model.layers.21.linear_attn.conv1d.weight": "model-00004-of-00012.safetensors",
198
+ "model.layers.21.linear_attn.dt_bias": "model-00004-of-00012.safetensors",
199
+ "model.layers.21.linear_attn.in_proj_a.weight": "model-00004-of-00012.safetensors",
200
+ "model.layers.21.linear_attn.in_proj_b.weight": "model-00004-of-00012.safetensors",
201
+ "model.layers.21.linear_attn.in_proj_qkv.weight": "model-00004-of-00012.safetensors",
202
+ "model.layers.21.linear_attn.in_proj_z.weight": "model-00004-of-00012.safetensors",
203
+ "model.layers.21.linear_attn.norm.weight": "model-00004-of-00012.safetensors",
204
+ "model.layers.21.linear_attn.out_proj.weight": "model-00004-of-00012.safetensors",
205
+ "model.layers.21.mlp.down_proj.weight": "model-00004-of-00012.safetensors",
206
+ "model.layers.21.mlp.gate_proj.weight": "model-00004-of-00012.safetensors",
207
+ "model.layers.21.mlp.up_proj.weight": "model-00004-of-00012.safetensors",
208
+ "model.layers.21.post_attention_layernorm.weight": "model-00004-of-00012.safetensors",
209
+ "model.layers.22.input_layernorm.weight": "model-00004-of-00012.safetensors",
210
+ "model.layers.22.linear_attn.A_log": "model-00004-of-00012.safetensors",
211
+ "model.layers.22.linear_attn.conv1d.weight": "model-00004-of-00012.safetensors",
212
+ "model.layers.22.linear_attn.dt_bias": "model-00004-of-00012.safetensors",
213
+ "model.layers.22.linear_attn.in_proj_a.weight": "model-00004-of-00012.safetensors",
214
+ "model.layers.22.linear_attn.in_proj_b.weight": "model-00004-of-00012.safetensors",
215
+ "model.layers.22.linear_attn.in_proj_qkv.weight": "model-00004-of-00012.safetensors",
216
+ "model.layers.22.linear_attn.in_proj_z.weight": "model-00004-of-00012.safetensors",
217
+ "model.layers.22.linear_attn.norm.weight": "model-00004-of-00012.safetensors",
218
+ "model.layers.22.linear_attn.out_proj.weight": "model-00004-of-00012.safetensors",
219
+ "model.layers.22.mlp.down_proj.weight": "model-00004-of-00012.safetensors",
220
+ "model.layers.22.mlp.gate_proj.weight": "model-00004-of-00012.safetensors",
221
+ "model.layers.22.mlp.up_proj.weight": "model-00004-of-00012.safetensors",
222
+ "model.layers.22.post_attention_layernorm.weight": "model-00004-of-00012.safetensors",
223
+ "model.layers.23.input_layernorm.weight": "model-00004-of-00012.safetensors",
224
+ "model.layers.23.mlp.down_proj.weight": "model-00004-of-00012.safetensors",
225
+ "model.layers.23.mlp.gate_proj.weight": "model-00004-of-00012.safetensors",
226
+ "model.layers.23.mlp.up_proj.weight": "model-00004-of-00012.safetensors",
227
+ "model.layers.23.post_attention_layernorm.weight": "model-00004-of-00012.safetensors",
228
+ "model.layers.23.self_attn.k_norm.weight": "model-00004-of-00012.safetensors",
229
+ "model.layers.23.self_attn.k_proj.weight": "model-00004-of-00012.safetensors",
230
+ "model.layers.23.self_attn.o_proj.weight": "model-00004-of-00012.safetensors",
231
+ "model.layers.23.self_attn.q_norm.weight": "model-00004-of-00012.safetensors",
232
+ "model.layers.23.self_attn.q_proj.weight": "model-00004-of-00012.safetensors",
233
+ "model.layers.23.self_attn.v_proj.weight": "model-00004-of-00012.safetensors",
234
+ "model.layers.24.input_layernorm.weight": "model-00004-of-00012.safetensors",
235
+ "model.layers.24.linear_attn.A_log": "model-00004-of-00012.safetensors",
236
+ "model.layers.24.linear_attn.conv1d.weight": "model-00004-of-00012.safetensors",
237
+ "model.layers.24.linear_attn.dt_bias": "model-00004-of-00012.safetensors",
238
+ "model.layers.24.linear_attn.in_proj_a.weight": "model-00004-of-00012.safetensors",
239
+ "model.layers.24.linear_attn.in_proj_b.weight": "model-00004-of-00012.safetensors",
240
+ "model.layers.24.linear_attn.in_proj_qkv.weight": "model-00004-of-00012.safetensors",
241
+ "model.layers.24.linear_attn.in_proj_z.weight": "model-00004-of-00012.safetensors",
242
+ "model.layers.24.linear_attn.norm.weight": "model-00004-of-00012.safetensors",
243
+ "model.layers.24.linear_attn.out_proj.weight": "model-00004-of-00012.safetensors",
244
+ "model.layers.24.mlp.down_proj.weight": "model-00004-of-00012.safetensors",
245
+ "model.layers.24.mlp.gate_proj.weight": "model-00004-of-00012.safetensors",
246
+ "model.layers.24.mlp.up_proj.weight": "model-00004-of-00012.safetensors",
247
+ "model.layers.24.post_attention_layernorm.weight": "model-00004-of-00012.safetensors",
248
+ "model.layers.25.input_layernorm.weight": "model-00004-of-00012.safetensors",
249
+ "model.layers.25.linear_attn.A_log": "model-00004-of-00012.safetensors",
250
+ "model.layers.25.linear_attn.conv1d.weight": "model-00004-of-00012.safetensors",
251
+ "model.layers.25.linear_attn.dt_bias": "model-00004-of-00012.safetensors",
252
+ "model.layers.25.linear_attn.in_proj_a.weight": "model-00004-of-00012.safetensors",
253
+ "model.layers.25.linear_attn.in_proj_b.weight": "model-00004-of-00012.safetensors",
254
+ "model.layers.25.linear_attn.in_proj_qkv.weight": "model-00004-of-00012.safetensors",
255
+ "model.layers.25.linear_attn.in_proj_z.weight": "model-00004-of-00012.safetensors",
256
+ "model.layers.25.linear_attn.norm.weight": "model-00004-of-00012.safetensors",
257
+ "model.layers.25.linear_attn.out_proj.weight": "model-00004-of-00012.safetensors",
258
+ "model.layers.25.mlp.down_proj.weight": "model-00004-of-00012.safetensors",
259
+ "model.layers.25.mlp.gate_proj.weight": "model-00004-of-00012.safetensors",
260
+ "model.layers.25.mlp.up_proj.weight": "model-00004-of-00012.safetensors",
261
+ "model.layers.25.post_attention_layernorm.weight": "model-00004-of-00012.safetensors",
262
+ "model.layers.26.input_layernorm.weight": "model-00004-of-00012.safetensors",
263
+ "model.layers.26.linear_attn.A_log": "model-00004-of-00012.safetensors",
264
+ "model.layers.26.linear_attn.conv1d.weight": "model-00004-of-00012.safetensors",
265
+ "model.layers.26.linear_attn.dt_bias": "model-00004-of-00012.safetensors",
266
+ "model.layers.26.linear_attn.in_proj_a.weight": "model-00004-of-00012.safetensors",
267
+ "model.layers.26.linear_attn.in_proj_b.weight": "model-00004-of-00012.safetensors",
268
+ "model.layers.26.linear_attn.in_proj_qkv.weight": "model-00004-of-00012.safetensors",
269
+ "model.layers.26.linear_attn.in_proj_z.weight": "model-00004-of-00012.safetensors",
270
+ "model.layers.26.linear_attn.norm.weight": "model-00004-of-00012.safetensors",
271
+ "model.layers.26.linear_attn.out_proj.weight": "model-00004-of-00012.safetensors",
272
+ "model.layers.26.mlp.down_proj.weight": "model-00004-of-00012.safetensors",
273
+ "model.layers.26.mlp.gate_proj.weight": "model-00004-of-00012.safetensors",
274
+ "model.layers.26.mlp.up_proj.weight": "model-00004-of-00012.safetensors",
275
+ "model.layers.26.post_attention_layernorm.weight": "model-00004-of-00012.safetensors",
276
+ "model.layers.27.input_layernorm.weight": "model-00004-of-00012.safetensors",
277
+ "model.layers.27.mlp.down_proj.weight": "model-00004-of-00012.safetensors",
278
+ "model.layers.27.mlp.gate_proj.weight": "model-00005-of-00012.safetensors",
279
+ "model.layers.27.mlp.up_proj.weight": "model-00005-of-00012.safetensors",
280
+ "model.layers.27.post_attention_layernorm.weight": "model-00005-of-00012.safetensors",
281
+ "model.layers.27.self_attn.k_norm.weight": "model-00005-of-00012.safetensors",
282
+ "model.layers.27.self_attn.k_proj.weight": "model-00005-of-00012.safetensors",
283
+ "model.layers.27.self_attn.o_proj.weight": "model-00005-of-00012.safetensors",
284
+ "model.layers.27.self_attn.q_norm.weight": "model-00005-of-00012.safetensors",
285
+ "model.layers.27.self_attn.q_proj.weight": "model-00005-of-00012.safetensors",
286
+ "model.layers.27.self_attn.v_proj.weight": "model-00005-of-00012.safetensors",
287
+ "model.layers.28.input_layernorm.weight": "model-00005-of-00012.safetensors",
288
+ "model.layers.28.linear_attn.A_log": "model-00005-of-00012.safetensors",
289
+ "model.layers.28.linear_attn.conv1d.weight": "model-00005-of-00012.safetensors",
290
+ "model.layers.28.linear_attn.dt_bias": "model-00005-of-00012.safetensors",
291
+ "model.layers.28.linear_attn.in_proj_a.weight": "model-00005-of-00012.safetensors",
292
+ "model.layers.28.linear_attn.in_proj_b.weight": "model-00005-of-00012.safetensors",
293
+ "model.layers.28.linear_attn.in_proj_qkv.weight": "model-00005-of-00012.safetensors",
294
+ "model.layers.28.linear_attn.in_proj_z.weight": "model-00005-of-00012.safetensors",
295
+ "model.layers.28.linear_attn.norm.weight": "model-00005-of-00012.safetensors",
296
+ "model.layers.28.linear_attn.out_proj.weight": "model-00005-of-00012.safetensors",
297
+ "model.layers.28.mlp.down_proj.weight": "model-00005-of-00012.safetensors",
298
+ "model.layers.28.mlp.gate_proj.weight": "model-00005-of-00012.safetensors",
299
+ "model.layers.28.mlp.up_proj.weight": "model-00005-of-00012.safetensors",
300
+ "model.layers.28.post_attention_layernorm.weight": "model-00005-of-00012.safetensors",
301
+ "model.layers.29.input_layernorm.weight": "model-00005-of-00012.safetensors",
302
+ "model.layers.29.linear_attn.A_log": "model-00005-of-00012.safetensors",
303
+ "model.layers.29.linear_attn.conv1d.weight": "model-00005-of-00012.safetensors",
304
+ "model.layers.29.linear_attn.dt_bias": "model-00005-of-00012.safetensors",
305
+ "model.layers.29.linear_attn.in_proj_a.weight": "model-00005-of-00012.safetensors",
306
+ "model.layers.29.linear_attn.in_proj_b.weight": "model-00005-of-00012.safetensors",
307
+ "model.layers.29.linear_attn.in_proj_qkv.weight": "model-00005-of-00012.safetensors",
308
+ "model.layers.29.linear_attn.in_proj_z.weight": "model-00005-of-00012.safetensors",
309
+ "model.layers.29.linear_attn.norm.weight": "model-00005-of-00012.safetensors",
310
+ "model.layers.29.linear_attn.out_proj.weight": "model-00005-of-00012.safetensors",
311
+ "model.layers.29.mlp.down_proj.weight": "model-00005-of-00012.safetensors",
312
+ "model.layers.29.mlp.gate_proj.weight": "model-00005-of-00012.safetensors",
313
+ "model.layers.29.mlp.up_proj.weight": "model-00005-of-00012.safetensors",
314
+ "model.layers.29.post_attention_layernorm.weight": "model-00005-of-00012.safetensors",
315
+ "model.layers.3.input_layernorm.weight": "model-00005-of-00012.safetensors",
316
+ "model.layers.3.mlp.down_proj.weight": "model-00005-of-00012.safetensors",
317
+ "model.layers.3.mlp.gate_proj.weight": "model-00005-of-00012.safetensors",
318
+ "model.layers.3.mlp.up_proj.weight": "model-00005-of-00012.safetensors",
319
+ "model.layers.3.post_attention_layernorm.weight": "model-00005-of-00012.safetensors",
320
+ "model.layers.3.self_attn.k_norm.weight": "model-00005-of-00012.safetensors",
321
+ "model.layers.3.self_attn.k_proj.weight": "model-00005-of-00012.safetensors",
322
+ "model.layers.3.self_attn.o_proj.weight": "model-00005-of-00012.safetensors",
323
+ "model.layers.3.self_attn.q_norm.weight": "model-00005-of-00012.safetensors",
324
+ "model.layers.3.self_attn.q_proj.weight": "model-00005-of-00012.safetensors",
325
+ "model.layers.3.self_attn.v_proj.weight": "model-00005-of-00012.safetensors",
326
+ "model.layers.30.input_layernorm.weight": "model-00005-of-00012.safetensors",
327
+ "model.layers.30.linear_attn.A_log": "model-00005-of-00012.safetensors",
328
+ "model.layers.30.linear_attn.conv1d.weight": "model-00005-of-00012.safetensors",
329
+ "model.layers.30.linear_attn.dt_bias": "model-00005-of-00012.safetensors",
330
+ "model.layers.30.linear_attn.in_proj_a.weight": "model-00005-of-00012.safetensors",
331
+ "model.layers.30.linear_attn.in_proj_b.weight": "model-00005-of-00012.safetensors",
332
+ "model.layers.30.linear_attn.in_proj_qkv.weight": "model-00005-of-00012.safetensors",
333
+ "model.layers.30.linear_attn.in_proj_z.weight": "model-00005-of-00012.safetensors",
334
+ "model.layers.30.linear_attn.norm.weight": "model-00005-of-00012.safetensors",
335
+ "model.layers.30.linear_attn.out_proj.weight": "model-00005-of-00012.safetensors",
336
+ "model.layers.30.mlp.down_proj.weight": "model-00005-of-00012.safetensors",
337
+ "model.layers.30.mlp.gate_proj.weight": "model-00005-of-00012.safetensors",
338
+ "model.layers.30.mlp.up_proj.weight": "model-00005-of-00012.safetensors",
339
+ "model.layers.30.post_attention_layernorm.weight": "model-00005-of-00012.safetensors",
340
+ "model.layers.31.input_layernorm.weight": "model-00005-of-00012.safetensors",
341
+ "model.layers.31.mlp.down_proj.weight": "model-00005-of-00012.safetensors",
342
+ "model.layers.31.mlp.gate_proj.weight": "model-00005-of-00012.safetensors",
343
+ "model.layers.31.mlp.up_proj.weight": "model-00005-of-00012.safetensors",
344
+ "model.layers.31.post_attention_layernorm.weight": "model-00005-of-00012.safetensors",
345
+ "model.layers.31.self_attn.k_norm.weight": "model-00005-of-00012.safetensors",
346
+ "model.layers.31.self_attn.k_proj.weight": "model-00005-of-00012.safetensors",
347
+ "model.layers.31.self_attn.o_proj.weight": "model-00005-of-00012.safetensors",
348
+ "model.layers.31.self_attn.q_norm.weight": "model-00005-of-00012.safetensors",
349
+ "model.layers.31.self_attn.q_proj.weight": "model-00005-of-00012.safetensors",
350
+ "model.layers.31.self_attn.v_proj.weight": "model-00005-of-00012.safetensors",
351
+ "model.layers.32.input_layernorm.weight": "model-00005-of-00012.safetensors",
352
+ "model.layers.32.linear_attn.A_log": "model-00005-of-00012.safetensors",
353
+ "model.layers.32.linear_attn.conv1d.weight": "model-00005-of-00012.safetensors",
354
+ "model.layers.32.linear_attn.dt_bias": "model-00005-of-00012.safetensors",
355
+ "model.layers.32.linear_attn.in_proj_a.weight": "model-00005-of-00012.safetensors",
356
+ "model.layers.32.linear_attn.in_proj_b.weight": "model-00005-of-00012.safetensors",
357
+ "model.layers.32.linear_attn.in_proj_qkv.weight": "model-00005-of-00012.safetensors",
358
+ "model.layers.32.linear_attn.in_proj_z.weight": "model-00005-of-00012.safetensors",
359
+ "model.layers.32.linear_attn.norm.weight": "model-00005-of-00012.safetensors",
360
+ "model.layers.32.linear_attn.out_proj.weight": "model-00005-of-00012.safetensors",
361
+ "model.layers.32.mlp.down_proj.weight": "model-00005-of-00012.safetensors",
362
+ "model.layers.32.mlp.gate_proj.weight": "model-00005-of-00012.safetensors",
363
+ "model.layers.32.mlp.up_proj.weight": "model-00005-of-00012.safetensors",
364
+ "model.layers.32.post_attention_layernorm.weight": "model-00006-of-00012.safetensors",
365
+ "model.layers.33.input_layernorm.weight": "model-00006-of-00012.safetensors",
366
+ "model.layers.33.linear_attn.A_log": "model-00006-of-00012.safetensors",
367
+ "model.layers.33.linear_attn.conv1d.weight": "model-00006-of-00012.safetensors",
368
+ "model.layers.33.linear_attn.dt_bias": "model-00006-of-00012.safetensors",
369
+ "model.layers.33.linear_attn.in_proj_a.weight": "model-00006-of-00012.safetensors",
370
+ "model.layers.33.linear_attn.in_proj_b.weight": "model-00006-of-00012.safetensors",
371
+ "model.layers.33.linear_attn.in_proj_qkv.weight": "model-00006-of-00012.safetensors",
372
+ "model.layers.33.linear_attn.in_proj_z.weight": "model-00006-of-00012.safetensors",
373
+ "model.layers.33.linear_attn.norm.weight": "model-00006-of-00012.safetensors",
374
+ "model.layers.33.linear_attn.out_proj.weight": "model-00006-of-00012.safetensors",
375
+ "model.layers.33.mlp.down_proj.weight": "model-00006-of-00012.safetensors",
376
+ "model.layers.33.mlp.gate_proj.weight": "model-00006-of-00012.safetensors",
377
+ "model.layers.33.mlp.up_proj.weight": "model-00006-of-00012.safetensors",
378
+ "model.layers.33.post_attention_layernorm.weight": "model-00006-of-00012.safetensors",
379
+ "model.layers.34.input_layernorm.weight": "model-00006-of-00012.safetensors",
380
+ "model.layers.34.linear_attn.A_log": "model-00006-of-00012.safetensors",
381
+ "model.layers.34.linear_attn.conv1d.weight": "model-00006-of-00012.safetensors",
382
+ "model.layers.34.linear_attn.dt_bias": "model-00006-of-00012.safetensors",
383
+ "model.layers.34.linear_attn.in_proj_a.weight": "model-00006-of-00012.safetensors",
384
+ "model.layers.34.linear_attn.in_proj_b.weight": "model-00006-of-00012.safetensors",
385
+ "model.layers.34.linear_attn.in_proj_qkv.weight": "model-00006-of-00012.safetensors",
386
+ "model.layers.34.linear_attn.in_proj_z.weight": "model-00006-of-00012.safetensors",
387
+ "model.layers.34.linear_attn.norm.weight": "model-00006-of-00012.safetensors",
388
+ "model.layers.34.linear_attn.out_proj.weight": "model-00006-of-00012.safetensors",
389
+ "model.layers.34.mlp.down_proj.weight": "model-00006-of-00012.safetensors",
390
+ "model.layers.34.mlp.gate_proj.weight": "model-00006-of-00012.safetensors",
391
+ "model.layers.34.mlp.up_proj.weight": "model-00006-of-00012.safetensors",
392
+ "model.layers.34.post_attention_layernorm.weight": "model-00006-of-00012.safetensors",
393
+ "model.layers.35.input_layernorm.weight": "model-00006-of-00012.safetensors",
394
+ "model.layers.35.mlp.down_proj.weight": "model-00006-of-00012.safetensors",
395
+ "model.layers.35.mlp.gate_proj.weight": "model-00006-of-00012.safetensors",
396
+ "model.layers.35.mlp.up_proj.weight": "model-00006-of-00012.safetensors",
397
+ "model.layers.35.post_attention_layernorm.weight": "model-00006-of-00012.safetensors",
398
+ "model.layers.35.self_attn.k_norm.weight": "model-00006-of-00012.safetensors",
399
+ "model.layers.35.self_attn.k_proj.weight": "model-00006-of-00012.safetensors",
400
+ "model.layers.35.self_attn.o_proj.weight": "model-00006-of-00012.safetensors",
401
+ "model.layers.35.self_attn.q_norm.weight": "model-00006-of-00012.safetensors",
402
+ "model.layers.35.self_attn.q_proj.weight": "model-00006-of-00012.safetensors",
403
+ "model.layers.35.self_attn.v_proj.weight": "model-00006-of-00012.safetensors",
404
+ "model.layers.36.input_layernorm.weight": "model-00006-of-00012.safetensors",
405
+ "model.layers.36.linear_attn.A_log": "model-00006-of-00012.safetensors",
406
+ "model.layers.36.linear_attn.conv1d.weight": "model-00006-of-00012.safetensors",
407
+ "model.layers.36.linear_attn.dt_bias": "model-00006-of-00012.safetensors",
408
+ "model.layers.36.linear_attn.in_proj_a.weight": "model-00006-of-00012.safetensors",
409
+ "model.layers.36.linear_attn.in_proj_b.weight": "model-00006-of-00012.safetensors",
410
+ "model.layers.36.linear_attn.in_proj_qkv.weight": "model-00006-of-00012.safetensors",
411
+ "model.layers.36.linear_attn.in_proj_z.weight": "model-00006-of-00012.safetensors",
412
+ "model.layers.36.linear_attn.norm.weight": "model-00006-of-00012.safetensors",
413
+ "model.layers.36.linear_attn.out_proj.weight": "model-00006-of-00012.safetensors",
414
+ "model.layers.36.mlp.down_proj.weight": "model-00006-of-00012.safetensors",
415
+ "model.layers.36.mlp.gate_proj.weight": "model-00006-of-00012.safetensors",
416
+ "model.layers.36.mlp.up_proj.weight": "model-00006-of-00012.safetensors",
417
+ "model.layers.36.post_attention_layernorm.weight": "model-00006-of-00012.safetensors",
418
+ "model.layers.37.input_layernorm.weight": "model-00006-of-00012.safetensors",
419
+ "model.layers.37.linear_attn.A_log": "model-00006-of-00012.safetensors",
420
+ "model.layers.37.linear_attn.conv1d.weight": "model-00006-of-00012.safetensors",
421
+ "model.layers.37.linear_attn.dt_bias": "model-00006-of-00012.safetensors",
422
+ "model.layers.37.linear_attn.in_proj_a.weight": "model-00006-of-00012.safetensors",
423
+ "model.layers.37.linear_attn.in_proj_b.weight": "model-00006-of-00012.safetensors",
424
+ "model.layers.37.linear_attn.in_proj_qkv.weight": "model-00006-of-00012.safetensors",
425
+ "model.layers.37.linear_attn.in_proj_z.weight": "model-00006-of-00012.safetensors",
426
+ "model.layers.37.linear_attn.norm.weight": "model-00006-of-00012.safetensors",
427
+ "model.layers.37.linear_attn.out_proj.weight": "model-00006-of-00012.safetensors",
428
+ "model.layers.37.mlp.down_proj.weight": "model-00006-of-00012.safetensors",
429
+ "model.layers.37.mlp.gate_proj.weight": "model-00006-of-00012.safetensors",
430
+ "model.layers.37.mlp.up_proj.weight": "model-00006-of-00012.safetensors",
431
+ "model.layers.37.post_attention_layernorm.weight": "model-00006-of-00012.safetensors",
432
+ "model.layers.38.input_layernorm.weight": "model-00006-of-00012.safetensors",
433
+ "model.layers.38.linear_attn.A_log": "model-00006-of-00012.safetensors",
434
+ "model.layers.38.linear_attn.conv1d.weight": "model-00006-of-00012.safetensors",
435
+ "model.layers.38.linear_attn.dt_bias": "model-00006-of-00012.safetensors",
436
+ "model.layers.38.linear_attn.in_proj_a.weight": "model-00006-of-00012.safetensors",
437
+ "model.layers.38.linear_attn.in_proj_b.weight": "model-00006-of-00012.safetensors",
438
+ "model.layers.38.linear_attn.in_proj_qkv.weight": "model-00006-of-00012.safetensors",
439
+ "model.layers.38.linear_attn.in_proj_z.weight": "model-00006-of-00012.safetensors",
440
+ "model.layers.38.linear_attn.norm.weight": "model-00006-of-00012.safetensors",
441
+ "model.layers.38.linear_attn.out_proj.weight": "model-00006-of-00012.safetensors",
442
+ "model.layers.38.mlp.down_proj.weight": "model-00006-of-00012.safetensors",
443
+ "model.layers.38.mlp.gate_proj.weight": "model-00006-of-00012.safetensors",
444
+ "model.layers.38.mlp.up_proj.weight": "model-00006-of-00012.safetensors",
445
+ "model.layers.38.post_attention_layernorm.weight": "model-00006-of-00012.safetensors",
446
+ "model.layers.39.input_layernorm.weight": "model-00006-of-00012.safetensors",
447
+ "model.layers.39.mlp.down_proj.weight": "model-00006-of-00012.safetensors",
448
+ "model.layers.39.mlp.gate_proj.weight": "model-00006-of-00012.safetensors",
449
+ "model.layers.39.mlp.up_proj.weight": "model-00006-of-00012.safetensors",
450
+ "model.layers.39.post_attention_layernorm.weight": "model-00007-of-00012.safetensors",
451
+ "model.layers.39.self_attn.k_norm.weight": "model-00007-of-00012.safetensors",
452
+ "model.layers.39.self_attn.k_proj.weight": "model-00007-of-00012.safetensors",
453
+ "model.layers.39.self_attn.o_proj.weight": "model-00007-of-00012.safetensors",
454
+ "model.layers.39.self_attn.q_norm.weight": "model-00007-of-00012.safetensors",
455
+ "model.layers.39.self_attn.q_proj.weight": "model-00007-of-00012.safetensors",
456
+ "model.layers.39.self_attn.v_proj.weight": "model-00007-of-00012.safetensors",
457
+ "model.layers.4.input_layernorm.weight": "model-00007-of-00012.safetensors",
458
+ "model.layers.4.linear_attn.A_log": "model-00007-of-00012.safetensors",
459
+ "model.layers.4.linear_attn.conv1d.weight": "model-00007-of-00012.safetensors",
460
+ "model.layers.4.linear_attn.dt_bias": "model-00007-of-00012.safetensors",
461
+ "model.layers.4.linear_attn.in_proj_a.weight": "model-00007-of-00012.safetensors",
462
+ "model.layers.4.linear_attn.in_proj_b.weight": "model-00007-of-00012.safetensors",
463
+ "model.layers.4.linear_attn.in_proj_qkv.weight": "model-00007-of-00012.safetensors",
464
+ "model.layers.4.linear_attn.in_proj_z.weight": "model-00007-of-00012.safetensors",
465
+ "model.layers.4.linear_attn.norm.weight": "model-00007-of-00012.safetensors",
466
+ "model.layers.4.linear_attn.out_proj.weight": "model-00007-of-00012.safetensors",
467
+ "model.layers.4.mlp.down_proj.weight": "model-00007-of-00012.safetensors",
468
+ "model.layers.4.mlp.gate_proj.weight": "model-00007-of-00012.safetensors",
469
+ "model.layers.4.mlp.up_proj.weight": "model-00007-of-00012.safetensors",
470
+ "model.layers.4.post_attention_layernorm.weight": "model-00007-of-00012.safetensors",
471
+ "model.layers.40.input_layernorm.weight": "model-00007-of-00012.safetensors",
472
+ "model.layers.40.linear_attn.A_log": "model-00007-of-00012.safetensors",
473
+ "model.layers.40.linear_attn.conv1d.weight": "model-00007-of-00012.safetensors",
474
+ "model.layers.40.linear_attn.dt_bias": "model-00007-of-00012.safetensors",
475
+ "model.layers.40.linear_attn.in_proj_a.weight": "model-00007-of-00012.safetensors",
476
+ "model.layers.40.linear_attn.in_proj_b.weight": "model-00007-of-00012.safetensors",
477
+ "model.layers.40.linear_attn.in_proj_qkv.weight": "model-00007-of-00012.safetensors",
478
+ "model.layers.40.linear_attn.in_proj_z.weight": "model-00007-of-00012.safetensors",
479
+ "model.layers.40.linear_attn.norm.weight": "model-00007-of-00012.safetensors",
480
+ "model.layers.40.linear_attn.out_proj.weight": "model-00007-of-00012.safetensors",
481
+ "model.layers.40.mlp.down_proj.weight": "model-00007-of-00012.safetensors",
482
+ "model.layers.40.mlp.gate_proj.weight": "model-00007-of-00012.safetensors",
483
+ "model.layers.40.mlp.up_proj.weight": "model-00007-of-00012.safetensors",
484
+ "model.layers.40.post_attention_layernorm.weight": "model-00007-of-00012.safetensors",
485
+ "model.layers.41.input_layernorm.weight": "model-00007-of-00012.safetensors",
486
+ "model.layers.41.linear_attn.A_log": "model-00007-of-00012.safetensors",
487
+ "model.layers.41.linear_attn.conv1d.weight": "model-00007-of-00012.safetensors",
488
+ "model.layers.41.linear_attn.dt_bias": "model-00007-of-00012.safetensors",
489
+ "model.layers.41.linear_attn.in_proj_a.weight": "model-00007-of-00012.safetensors",
490
+ "model.layers.41.linear_attn.in_proj_b.weight": "model-00007-of-00012.safetensors",
491
+ "model.layers.41.linear_attn.in_proj_qkv.weight": "model-00007-of-00012.safetensors",
492
+ "model.layers.41.linear_attn.in_proj_z.weight": "model-00007-of-00012.safetensors",
493
+ "model.layers.41.linear_attn.norm.weight": "model-00007-of-00012.safetensors",
494
+ "model.layers.41.linear_attn.out_proj.weight": "model-00007-of-00012.safetensors",
495
+ "model.layers.41.mlp.down_proj.weight": "model-00007-of-00012.safetensors",
496
+ "model.layers.41.mlp.gate_proj.weight": "model-00007-of-00012.safetensors",
497
+ "model.layers.41.mlp.up_proj.weight": "model-00007-of-00012.safetensors",
498
+ "model.layers.41.post_attention_layernorm.weight": "model-00007-of-00012.safetensors",
499
+ "model.layers.42.input_layernorm.weight": "model-00007-of-00012.safetensors",
500
+ "model.layers.42.linear_attn.A_log": "model-00007-of-00012.safetensors",
501
+ "model.layers.42.linear_attn.conv1d.weight": "model-00007-of-00012.safetensors",
502
+ "model.layers.42.linear_attn.dt_bias": "model-00007-of-00012.safetensors",
503
+ "model.layers.42.linear_attn.in_proj_a.weight": "model-00007-of-00012.safetensors",
504
+ "model.layers.42.linear_attn.in_proj_b.weight": "model-00007-of-00012.safetensors",
505
+ "model.layers.42.linear_attn.in_proj_qkv.weight": "model-00007-of-00012.safetensors",
506
+ "model.layers.42.linear_attn.in_proj_z.weight": "model-00007-of-00012.safetensors",
507
+ "model.layers.42.linear_attn.norm.weight": "model-00007-of-00012.safetensors",
508
+ "model.layers.42.linear_attn.out_proj.weight": "model-00007-of-00012.safetensors",
509
+ "model.layers.42.mlp.down_proj.weight": "model-00007-of-00012.safetensors",
510
+ "model.layers.42.mlp.gate_proj.weight": "model-00007-of-00012.safetensors",
511
+ "model.layers.42.mlp.up_proj.weight": "model-00007-of-00012.safetensors",
512
+ "model.layers.42.post_attention_layernorm.weight": "model-00007-of-00012.safetensors",
513
+ "model.layers.43.input_layernorm.weight": "model-00007-of-00012.safetensors",
514
+ "model.layers.43.mlp.down_proj.weight": "model-00007-of-00012.safetensors",
515
+ "model.layers.43.mlp.gate_proj.weight": "model-00007-of-00012.safetensors",
516
+ "model.layers.43.mlp.up_proj.weight": "model-00007-of-00012.safetensors",
517
+ "model.layers.43.post_attention_layernorm.weight": "model-00007-of-00012.safetensors",
518
+ "model.layers.43.self_attn.k_norm.weight": "model-00007-of-00012.safetensors",
519
+ "model.layers.43.self_attn.k_proj.weight": "model-00007-of-00012.safetensors",
520
+ "model.layers.43.self_attn.o_proj.weight": "model-00007-of-00012.safetensors",
521
+ "model.layers.43.self_attn.q_norm.weight": "model-00007-of-00012.safetensors",
522
+ "model.layers.43.self_attn.q_proj.weight": "model-00007-of-00012.safetensors",
523
+ "model.layers.43.self_attn.v_proj.weight": "model-00007-of-00012.safetensors",
524
+ "model.layers.44.input_layernorm.weight": "model-00007-of-00012.safetensors",
525
+ "model.layers.44.linear_attn.A_log": "model-00007-of-00012.safetensors",
526
+ "model.layers.44.linear_attn.conv1d.weight": "model-00007-of-00012.safetensors",
527
+ "model.layers.44.linear_attn.dt_bias": "model-00007-of-00012.safetensors",
528
+ "model.layers.44.linear_attn.in_proj_a.weight": "model-00007-of-00012.safetensors",
529
+ "model.layers.44.linear_attn.in_proj_b.weight": "model-00007-of-00012.safetensors",
530
+ "model.layers.44.linear_attn.in_proj_qkv.weight": "model-00007-of-00012.safetensors",
531
+ "model.layers.44.linear_attn.in_proj_z.weight": "model-00007-of-00012.safetensors",
532
+ "model.layers.44.linear_attn.norm.weight": "model-00007-of-00012.safetensors",
533
+ "model.layers.44.linear_attn.out_proj.weight": "model-00007-of-00012.safetensors",
534
+ "model.layers.44.mlp.down_proj.weight": "model-00007-of-00012.safetensors",
535
+ "model.layers.44.mlp.gate_proj.weight": "model-00007-of-00012.safetensors",
536
+ "model.layers.44.mlp.up_proj.weight": "model-00007-of-00012.safetensors",
537
+ "model.layers.44.post_attention_layernorm.weight": "model-00007-of-00012.safetensors",
538
+ "model.layers.45.input_layernorm.weight": "model-00007-of-00012.safetensors",
539
+ "model.layers.45.linear_attn.A_log": "model-00007-of-00012.safetensors",
540
+ "model.layers.45.linear_attn.conv1d.weight": "model-00007-of-00012.safetensors",
541
+ "model.layers.45.linear_attn.dt_bias": "model-00007-of-00012.safetensors",
542
+ "model.layers.45.linear_attn.in_proj_a.weight": "model-00007-of-00012.safetensors",
543
+ "model.layers.45.linear_attn.in_proj_b.weight": "model-00007-of-00012.safetensors",
544
+ "model.layers.45.linear_attn.in_proj_qkv.weight": "model-00007-of-00012.safetensors",
545
+ "model.layers.45.linear_attn.in_proj_z.weight": "model-00007-of-00012.safetensors",
546
+ "model.layers.45.linear_attn.norm.weight": "model-00007-of-00012.safetensors",
547
+ "model.layers.45.linear_attn.out_proj.weight": "model-00007-of-00012.safetensors",
548
+ "model.layers.45.mlp.down_proj.weight": "model-00008-of-00012.safetensors",
549
+ "model.layers.45.mlp.gate_proj.weight": "model-00008-of-00012.safetensors",
550
+ "model.layers.45.mlp.up_proj.weight": "model-00008-of-00012.safetensors",
551
+ "model.layers.45.post_attention_layernorm.weight": "model-00008-of-00012.safetensors",
552
+ "model.layers.46.input_layernorm.weight": "model-00008-of-00012.safetensors",
553
+ "model.layers.46.linear_attn.A_log": "model-00008-of-00012.safetensors",
554
+ "model.layers.46.linear_attn.conv1d.weight": "model-00008-of-00012.safetensors",
555
+ "model.layers.46.linear_attn.dt_bias": "model-00008-of-00012.safetensors",
556
+ "model.layers.46.linear_attn.in_proj_a.weight": "model-00008-of-00012.safetensors",
557
+ "model.layers.46.linear_attn.in_proj_b.weight": "model-00008-of-00012.safetensors",
558
+ "model.layers.46.linear_attn.in_proj_qkv.weight": "model-00008-of-00012.safetensors",
559
+ "model.layers.46.linear_attn.in_proj_z.weight": "model-00008-of-00012.safetensors",
560
+ "model.layers.46.linear_attn.norm.weight": "model-00008-of-00012.safetensors",
561
+ "model.layers.46.linear_attn.out_proj.weight": "model-00008-of-00012.safetensors",
562
+ "model.layers.46.mlp.down_proj.weight": "model-00008-of-00012.safetensors",
563
+ "model.layers.46.mlp.gate_proj.weight": "model-00008-of-00012.safetensors",
564
+ "model.layers.46.mlp.up_proj.weight": "model-00008-of-00012.safetensors",
565
+ "model.layers.46.post_attention_layernorm.weight": "model-00008-of-00012.safetensors",
566
+ "model.layers.47.input_layernorm.weight": "model-00008-of-00012.safetensors",
567
+ "model.layers.47.mlp.down_proj.weight": "model-00008-of-00012.safetensors",
568
+ "model.layers.47.mlp.gate_proj.weight": "model-00008-of-00012.safetensors",
569
+ "model.layers.47.mlp.up_proj.weight": "model-00008-of-00012.safetensors",
570
+ "model.layers.47.post_attention_layernorm.weight": "model-00008-of-00012.safetensors",
571
+ "model.layers.47.self_attn.k_norm.weight": "model-00008-of-00012.safetensors",
572
+ "model.layers.47.self_attn.k_proj.weight": "model-00008-of-00012.safetensors",
573
+ "model.layers.47.self_attn.o_proj.weight": "model-00008-of-00012.safetensors",
574
+ "model.layers.47.self_attn.q_norm.weight": "model-00008-of-00012.safetensors",
575
+ "model.layers.47.self_attn.q_proj.weight": "model-00008-of-00012.safetensors",
576
+ "model.layers.47.self_attn.v_proj.weight": "model-00008-of-00012.safetensors",
577
+ "model.layers.48.input_layernorm.weight": "model-00008-of-00012.safetensors",
578
+ "model.layers.48.linear_attn.A_log": "model-00008-of-00012.safetensors",
579
+ "model.layers.48.linear_attn.conv1d.weight": "model-00008-of-00012.safetensors",
580
+ "model.layers.48.linear_attn.dt_bias": "model-00008-of-00012.safetensors",
581
+ "model.layers.48.linear_attn.in_proj_a.weight": "model-00008-of-00012.safetensors",
582
+ "model.layers.48.linear_attn.in_proj_b.weight": "model-00008-of-00012.safetensors",
583
+ "model.layers.48.linear_attn.in_proj_qkv.weight": "model-00008-of-00012.safetensors",
584
+ "model.layers.48.linear_attn.in_proj_z.weight": "model-00008-of-00012.safetensors",
585
+ "model.layers.48.linear_attn.norm.weight": "model-00008-of-00012.safetensors",
586
+ "model.layers.48.linear_attn.out_proj.weight": "model-00008-of-00012.safetensors",
587
+ "model.layers.48.mlp.down_proj.weight": "model-00008-of-00012.safetensors",
588
+ "model.layers.48.mlp.gate_proj.weight": "model-00008-of-00012.safetensors",
589
+ "model.layers.48.mlp.up_proj.weight": "model-00008-of-00012.safetensors",
590
+ "model.layers.48.post_attention_layernorm.weight": "model-00008-of-00012.safetensors",
591
+ "model.layers.49.input_layernorm.weight": "model-00008-of-00012.safetensors",
592
+ "model.layers.49.linear_attn.A_log": "model-00008-of-00012.safetensors",
593
+ "model.layers.49.linear_attn.conv1d.weight": "model-00008-of-00012.safetensors",
594
+ "model.layers.49.linear_attn.dt_bias": "model-00008-of-00012.safetensors",
595
+ "model.layers.49.linear_attn.in_proj_a.weight": "model-00008-of-00012.safetensors",
596
+ "model.layers.49.linear_attn.in_proj_b.weight": "model-00008-of-00012.safetensors",
597
+ "model.layers.49.linear_attn.in_proj_qkv.weight": "model-00008-of-00012.safetensors",
598
+ "model.layers.49.linear_attn.in_proj_z.weight": "model-00008-of-00012.safetensors",
599
+ "model.layers.49.linear_attn.norm.weight": "model-00008-of-00012.safetensors",
600
+ "model.layers.49.linear_attn.out_proj.weight": "model-00008-of-00012.safetensors",
601
+ "model.layers.49.mlp.down_proj.weight": "model-00008-of-00012.safetensors",
602
+ "model.layers.49.mlp.gate_proj.weight": "model-00008-of-00012.safetensors",
603
+ "model.layers.49.mlp.up_proj.weight": "model-00008-of-00012.safetensors",
604
+ "model.layers.49.post_attention_layernorm.weight": "model-00008-of-00012.safetensors",
605
+ "model.layers.5.input_layernorm.weight": "model-00008-of-00012.safetensors",
606
+ "model.layers.5.linear_attn.A_log": "model-00008-of-00012.safetensors",
607
+ "model.layers.5.linear_attn.conv1d.weight": "model-00008-of-00012.safetensors",
608
+ "model.layers.5.linear_attn.dt_bias": "model-00008-of-00012.safetensors",
609
+ "model.layers.5.linear_attn.in_proj_a.weight": "model-00008-of-00012.safetensors",
610
+ "model.layers.5.linear_attn.in_proj_b.weight": "model-00008-of-00012.safetensors",
611
+ "model.layers.5.linear_attn.in_proj_qkv.weight": "model-00008-of-00012.safetensors",
612
+ "model.layers.5.linear_attn.in_proj_z.weight": "model-00008-of-00012.safetensors",
613
+ "model.layers.5.linear_attn.norm.weight": "model-00008-of-00012.safetensors",
614
+ "model.layers.5.linear_attn.out_proj.weight": "model-00008-of-00012.safetensors",
615
+ "model.layers.5.mlp.down_proj.weight": "model-00008-of-00012.safetensors",
616
+ "model.layers.5.mlp.gate_proj.weight": "model-00008-of-00012.safetensors",
617
+ "model.layers.5.mlp.up_proj.weight": "model-00008-of-00012.safetensors",
618
+ "model.layers.5.post_attention_layernorm.weight": "model-00008-of-00012.safetensors",
619
+ "model.layers.50.input_layernorm.weight": "model-00008-of-00012.safetensors",
620
+ "model.layers.50.linear_attn.A_log": "model-00008-of-00012.safetensors",
621
+ "model.layers.50.linear_attn.conv1d.weight": "model-00008-of-00012.safetensors",
622
+ "model.layers.50.linear_attn.dt_bias": "model-00008-of-00012.safetensors",
623
+ "model.layers.50.linear_attn.in_proj_a.weight": "model-00008-of-00012.safetensors",
624
+ "model.layers.50.linear_attn.in_proj_b.weight": "model-00008-of-00012.safetensors",
625
+ "model.layers.50.linear_attn.in_proj_qkv.weight": "model-00008-of-00012.safetensors",
626
+ "model.layers.50.linear_attn.in_proj_z.weight": "model-00008-of-00012.safetensors",
627
+ "model.layers.50.linear_attn.norm.weight": "model-00008-of-00012.safetensors",
628
+ "model.layers.50.linear_attn.out_proj.weight": "model-00008-of-00012.safetensors",
629
+ "model.layers.50.mlp.down_proj.weight": "model-00008-of-00012.safetensors",
630
+ "model.layers.50.mlp.gate_proj.weight": "model-00008-of-00012.safetensors",
631
+ "model.layers.50.mlp.up_proj.weight": "model-00008-of-00012.safetensors",
632
+ "model.layers.50.post_attention_layernorm.weight": "model-00009-of-00012.safetensors",
633
+ "model.layers.51.input_layernorm.weight": "model-00009-of-00012.safetensors",
634
+ "model.layers.51.mlp.down_proj.weight": "model-00009-of-00012.safetensors",
635
+ "model.layers.51.mlp.gate_proj.weight": "model-00009-of-00012.safetensors",
636
+ "model.layers.51.mlp.up_proj.weight": "model-00009-of-00012.safetensors",
637
+ "model.layers.51.post_attention_layernorm.weight": "model-00009-of-00012.safetensors",
638
+ "model.layers.51.self_attn.k_norm.weight": "model-00009-of-00012.safetensors",
639
+ "model.layers.51.self_attn.k_proj.weight": "model-00009-of-00012.safetensors",
640
+ "model.layers.51.self_attn.o_proj.weight": "model-00009-of-00012.safetensors",
641
+ "model.layers.51.self_attn.q_norm.weight": "model-00009-of-00012.safetensors",
642
+ "model.layers.51.self_attn.q_proj.weight": "model-00009-of-00012.safetensors",
643
+ "model.layers.51.self_attn.v_proj.weight": "model-00009-of-00012.safetensors",
644
+ "model.layers.52.input_layernorm.weight": "model-00009-of-00012.safetensors",
645
+ "model.layers.52.linear_attn.A_log": "model-00009-of-00012.safetensors",
646
+ "model.layers.52.linear_attn.conv1d.weight": "model-00009-of-00012.safetensors",
647
+ "model.layers.52.linear_attn.dt_bias": "model-00009-of-00012.safetensors",
648
+ "model.layers.52.linear_attn.in_proj_a.weight": "model-00009-of-00012.safetensors",
649
+ "model.layers.52.linear_attn.in_proj_b.weight": "model-00009-of-00012.safetensors",
650
+ "model.layers.52.linear_attn.in_proj_qkv.weight": "model-00009-of-00012.safetensors",
651
+ "model.layers.52.linear_attn.in_proj_z.weight": "model-00009-of-00012.safetensors",
652
+ "model.layers.52.linear_attn.norm.weight": "model-00009-of-00012.safetensors",
653
+ "model.layers.52.linear_attn.out_proj.weight": "model-00009-of-00012.safetensors",
654
+ "model.layers.52.mlp.down_proj.weight": "model-00009-of-00012.safetensors",
655
+ "model.layers.52.mlp.gate_proj.weight": "model-00009-of-00012.safetensors",
656
+ "model.layers.52.mlp.up_proj.weight": "model-00009-of-00012.safetensors",
657
+ "model.layers.52.post_attention_layernorm.weight": "model-00009-of-00012.safetensors",
658
+ "model.layers.53.input_layernorm.weight": "model-00009-of-00012.safetensors",
659
+ "model.layers.53.linear_attn.A_log": "model-00009-of-00012.safetensors",
660
+ "model.layers.53.linear_attn.conv1d.weight": "model-00009-of-00012.safetensors",
661
+ "model.layers.53.linear_attn.dt_bias": "model-00009-of-00012.safetensors",
662
+ "model.layers.53.linear_attn.in_proj_a.weight": "model-00009-of-00012.safetensors",
663
+ "model.layers.53.linear_attn.in_proj_b.weight": "model-00009-of-00012.safetensors",
664
+ "model.layers.53.linear_attn.in_proj_qkv.weight": "model-00009-of-00012.safetensors",
665
+ "model.layers.53.linear_attn.in_proj_z.weight": "model-00009-of-00012.safetensors",
666
+ "model.layers.53.linear_attn.norm.weight": "model-00009-of-00012.safetensors",
667
+ "model.layers.53.linear_attn.out_proj.weight": "model-00009-of-00012.safetensors",
668
+ "model.layers.53.mlp.down_proj.weight": "model-00009-of-00012.safetensors",
669
+ "model.layers.53.mlp.gate_proj.weight": "model-00009-of-00012.safetensors",
670
+ "model.layers.53.mlp.up_proj.weight": "model-00009-of-00012.safetensors",
671
+ "model.layers.53.post_attention_layernorm.weight": "model-00009-of-00012.safetensors",
672
+ "model.layers.54.input_layernorm.weight": "model-00009-of-00012.safetensors",
673
+ "model.layers.54.linear_attn.A_log": "model-00009-of-00012.safetensors",
674
+ "model.layers.54.linear_attn.conv1d.weight": "model-00009-of-00012.safetensors",
675
+ "model.layers.54.linear_attn.dt_bias": "model-00009-of-00012.safetensors",
676
+ "model.layers.54.linear_attn.in_proj_a.weight": "model-00009-of-00012.safetensors",
677
+ "model.layers.54.linear_attn.in_proj_b.weight": "model-00009-of-00012.safetensors",
678
+ "model.layers.54.linear_attn.in_proj_qkv.weight": "model-00009-of-00012.safetensors",
679
+ "model.layers.54.linear_attn.in_proj_z.weight": "model-00009-of-00012.safetensors",
680
+ "model.layers.54.linear_attn.norm.weight": "model-00009-of-00012.safetensors",
681
+ "model.layers.54.linear_attn.out_proj.weight": "model-00009-of-00012.safetensors",
682
+ "model.layers.54.mlp.down_proj.weight": "model-00009-of-00012.safetensors",
683
+ "model.layers.54.mlp.gate_proj.weight": "model-00009-of-00012.safetensors",
684
+ "model.layers.54.mlp.up_proj.weight": "model-00009-of-00012.safetensors",
685
+ "model.layers.54.post_attention_layernorm.weight": "model-00009-of-00012.safetensors",
686
+ "model.layers.55.input_layernorm.weight": "model-00009-of-00012.safetensors",
687
+ "model.layers.55.mlp.down_proj.weight": "model-00009-of-00012.safetensors",
688
+ "model.layers.55.mlp.gate_proj.weight": "model-00009-of-00012.safetensors",
689
+ "model.layers.55.mlp.up_proj.weight": "model-00009-of-00012.safetensors",
690
+ "model.layers.55.post_attention_layernorm.weight": "model-00009-of-00012.safetensors",
691
+ "model.layers.55.self_attn.k_norm.weight": "model-00009-of-00012.safetensors",
692
+ "model.layers.55.self_attn.k_proj.weight": "model-00009-of-00012.safetensors",
693
+ "model.layers.55.self_attn.o_proj.weight": "model-00009-of-00012.safetensors",
694
+ "model.layers.55.self_attn.q_norm.weight": "model-00009-of-00012.safetensors",
695
+ "model.layers.55.self_attn.q_proj.weight": "model-00009-of-00012.safetensors",
696
+ "model.layers.55.self_attn.v_proj.weight": "model-00009-of-00012.safetensors",
697
+ "model.layers.56.input_layernorm.weight": "model-00009-of-00012.safetensors",
698
+ "model.layers.56.linear_attn.A_log": "model-00009-of-00012.safetensors",
699
+ "model.layers.56.linear_attn.conv1d.weight": "model-00009-of-00012.safetensors",
700
+ "model.layers.56.linear_attn.dt_bias": "model-00009-of-00012.safetensors",
701
+ "model.layers.56.linear_attn.in_proj_a.weight": "model-00009-of-00012.safetensors",
702
+ "model.layers.56.linear_attn.in_proj_b.weight": "model-00009-of-00012.safetensors",
703
+ "model.layers.56.linear_attn.in_proj_qkv.weight": "model-00009-of-00012.safetensors",
704
+ "model.layers.56.linear_attn.in_proj_z.weight": "model-00009-of-00012.safetensors",
705
+ "model.layers.56.linear_attn.norm.weight": "model-00009-of-00012.safetensors",
706
+ "model.layers.56.linear_attn.out_proj.weight": "model-00009-of-00012.safetensors",
707
+ "model.layers.56.mlp.down_proj.weight": "model-00009-of-00012.safetensors",
708
+ "model.layers.56.mlp.gate_proj.weight": "model-00009-of-00012.safetensors",
709
+ "model.layers.56.mlp.up_proj.weight": "model-00009-of-00012.safetensors",
710
+ "model.layers.56.post_attention_layernorm.weight": "model-00009-of-00012.safetensors",
711
+ "model.layers.57.input_layernorm.weight": "model-00009-of-00012.safetensors",
712
+ "model.layers.57.linear_attn.A_log": "model-00009-of-00012.safetensors",
713
+ "model.layers.57.linear_attn.conv1d.weight": "model-00009-of-00012.safetensors",
714
+ "model.layers.57.linear_attn.dt_bias": "model-00009-of-00012.safetensors",
715
+ "model.layers.57.linear_attn.in_proj_a.weight": "model-00009-of-00012.safetensors",
716
+ "model.layers.57.linear_attn.in_proj_b.weight": "model-00009-of-00012.safetensors",
717
+ "model.layers.57.linear_attn.in_proj_qkv.weight": "model-00009-of-00012.safetensors",
718
+ "model.layers.57.linear_attn.in_proj_z.weight": "model-00009-of-00012.safetensors",
719
+ "model.layers.57.linear_attn.norm.weight": "model-00009-of-00012.safetensors",
720
+ "model.layers.57.linear_attn.out_proj.weight": "model-00009-of-00012.safetensors",
721
+ "model.layers.57.mlp.down_proj.weight": "model-00009-of-00012.safetensors",
722
+ "model.layers.57.mlp.gate_proj.weight": "model-00009-of-00012.safetensors",
723
+ "model.layers.57.mlp.up_proj.weight": "model-00010-of-00012.safetensors",
724
+ "model.layers.57.post_attention_layernorm.weight": "model-00010-of-00012.safetensors",
725
+ "model.layers.58.input_layernorm.weight": "model-00010-of-00012.safetensors",
726
+ "model.layers.58.linear_attn.A_log": "model-00010-of-00012.safetensors",
727
+ "model.layers.58.linear_attn.conv1d.weight": "model-00010-of-00012.safetensors",
728
+ "model.layers.58.linear_attn.dt_bias": "model-00010-of-00012.safetensors",
729
+ "model.layers.58.linear_attn.in_proj_a.weight": "model-00010-of-00012.safetensors",
730
+ "model.layers.58.linear_attn.in_proj_b.weight": "model-00010-of-00012.safetensors",
731
+ "model.layers.58.linear_attn.in_proj_qkv.weight": "model-00010-of-00012.safetensors",
732
+ "model.layers.58.linear_attn.in_proj_z.weight": "model-00010-of-00012.safetensors",
733
+ "model.layers.58.linear_attn.norm.weight": "model-00010-of-00012.safetensors",
734
+ "model.layers.58.linear_attn.out_proj.weight": "model-00010-of-00012.safetensors",
735
+ "model.layers.58.mlp.down_proj.weight": "model-00010-of-00012.safetensors",
736
+ "model.layers.58.mlp.gate_proj.weight": "model-00010-of-00012.safetensors",
737
+ "model.layers.58.mlp.up_proj.weight": "model-00010-of-00012.safetensors",
738
+ "model.layers.58.post_attention_layernorm.weight": "model-00010-of-00012.safetensors",
739
+ "model.layers.59.input_layernorm.weight": "model-00010-of-00012.safetensors",
740
+ "model.layers.59.mlp.down_proj.weight": "model-00010-of-00012.safetensors",
741
+ "model.layers.59.mlp.gate_proj.weight": "model-00010-of-00012.safetensors",
742
+ "model.layers.59.mlp.up_proj.weight": "model-00010-of-00012.safetensors",
743
+ "model.layers.59.post_attention_layernorm.weight": "model-00010-of-00012.safetensors",
744
+ "model.layers.59.self_attn.k_norm.weight": "model-00010-of-00012.safetensors",
745
+ "model.layers.59.self_attn.k_proj.weight": "model-00010-of-00012.safetensors",
746
+ "model.layers.59.self_attn.o_proj.weight": "model-00010-of-00012.safetensors",
747
+ "model.layers.59.self_attn.q_norm.weight": "model-00010-of-00012.safetensors",
748
+ "model.layers.59.self_attn.q_proj.weight": "model-00010-of-00012.safetensors",
749
+ "model.layers.59.self_attn.v_proj.weight": "model-00010-of-00012.safetensors",
750
+ "model.layers.6.input_layernorm.weight": "model-00010-of-00012.safetensors",
751
+ "model.layers.6.linear_attn.A_log": "model-00010-of-00012.safetensors",
752
+ "model.layers.6.linear_attn.conv1d.weight": "model-00010-of-00012.safetensors",
753
+ "model.layers.6.linear_attn.dt_bias": "model-00010-of-00012.safetensors",
754
+ "model.layers.6.linear_attn.in_proj_a.weight": "model-00010-of-00012.safetensors",
755
+ "model.layers.6.linear_attn.in_proj_b.weight": "model-00010-of-00012.safetensors",
756
+ "model.layers.6.linear_attn.in_proj_qkv.weight": "model-00010-of-00012.safetensors",
757
+ "model.layers.6.linear_attn.in_proj_z.weight": "model-00010-of-00012.safetensors",
758
+ "model.layers.6.linear_attn.norm.weight": "model-00010-of-00012.safetensors",
759
+ "model.layers.6.linear_attn.out_proj.weight": "model-00010-of-00012.safetensors",
760
+ "model.layers.6.mlp.down_proj.weight": "model-00010-of-00012.safetensors",
761
+ "model.layers.6.mlp.gate_proj.weight": "model-00010-of-00012.safetensors",
762
+ "model.layers.6.mlp.up_proj.weight": "model-00010-of-00012.safetensors",
763
+ "model.layers.6.post_attention_layernorm.weight": "model-00010-of-00012.safetensors",
764
+ "model.layers.60.input_layernorm.weight": "model-00010-of-00012.safetensors",
765
+ "model.layers.60.linear_attn.A_log": "model-00010-of-00012.safetensors",
766
+ "model.layers.60.linear_attn.conv1d.weight": "model-00010-of-00012.safetensors",
767
+ "model.layers.60.linear_attn.dt_bias": "model-00010-of-00012.safetensors",
768
+ "model.layers.60.linear_attn.in_proj_a.weight": "model-00010-of-00012.safetensors",
769
+ "model.layers.60.linear_attn.in_proj_b.weight": "model-00010-of-00012.safetensors",
770
+ "model.layers.60.linear_attn.in_proj_qkv.weight": "model-00010-of-00012.safetensors",
771
+ "model.layers.60.linear_attn.in_proj_z.weight": "model-00010-of-00012.safetensors",
772
+ "model.layers.60.linear_attn.norm.weight": "model-00010-of-00012.safetensors",
773
+ "model.layers.60.linear_attn.out_proj.weight": "model-00010-of-00012.safetensors",
774
+ "model.layers.60.mlp.down_proj.weight": "model-00010-of-00012.safetensors",
775
+ "model.layers.60.mlp.gate_proj.weight": "model-00010-of-00012.safetensors",
776
+ "model.layers.60.mlp.up_proj.weight": "model-00010-of-00012.safetensors",
777
+ "model.layers.60.post_attention_layernorm.weight": "model-00010-of-00012.safetensors",
778
+ "model.layers.61.input_layernorm.weight": "model-00010-of-00012.safetensors",
779
+ "model.layers.61.linear_attn.A_log": "model-00010-of-00012.safetensors",
780
+ "model.layers.61.linear_attn.conv1d.weight": "model-00010-of-00012.safetensors",
781
+ "model.layers.61.linear_attn.dt_bias": "model-00010-of-00012.safetensors",
782
+ "model.layers.61.linear_attn.in_proj_a.weight": "model-00010-of-00012.safetensors",
783
+ "model.layers.61.linear_attn.in_proj_b.weight": "model-00010-of-00012.safetensors",
784
+ "model.layers.61.linear_attn.in_proj_qkv.weight": "model-00010-of-00012.safetensors",
785
+ "model.layers.61.linear_attn.in_proj_z.weight": "model-00010-of-00012.safetensors",
786
+ "model.layers.61.linear_attn.norm.weight": "model-00010-of-00012.safetensors",
787
+ "model.layers.61.linear_attn.out_proj.weight": "model-00010-of-00012.safetensors",
788
+ "model.layers.61.mlp.down_proj.weight": "model-00010-of-00012.safetensors",
789
+ "model.layers.61.mlp.gate_proj.weight": "model-00010-of-00012.safetensors",
790
+ "model.layers.61.mlp.up_proj.weight": "model-00010-of-00012.safetensors",
791
+ "model.layers.61.post_attention_layernorm.weight": "model-00010-of-00012.safetensors",
792
+ "model.layers.62.input_layernorm.weight": "model-00010-of-00012.safetensors",
793
+ "model.layers.62.linear_attn.A_log": "model-00010-of-00012.safetensors",
794
+ "model.layers.62.linear_attn.conv1d.weight": "model-00010-of-00012.safetensors",
795
+ "model.layers.62.linear_attn.dt_bias": "model-00010-of-00012.safetensors",
796
+ "model.layers.62.linear_attn.in_proj_a.weight": "model-00010-of-00012.safetensors",
797
+ "model.layers.62.linear_attn.in_proj_b.weight": "model-00010-of-00012.safetensors",
798
+ "model.layers.62.linear_attn.in_proj_qkv.weight": "model-00010-of-00012.safetensors",
799
+ "model.layers.62.linear_attn.in_proj_z.weight": "model-00010-of-00012.safetensors",
800
+ "model.layers.62.linear_attn.norm.weight": "model-00010-of-00012.safetensors",
801
+ "model.layers.62.linear_attn.out_proj.weight": "model-00010-of-00012.safetensors",
802
+ "model.layers.62.mlp.down_proj.weight": "model-00010-of-00012.safetensors",
803
+ "model.layers.62.mlp.gate_proj.weight": "model-00010-of-00012.safetensors",
804
+ "model.layers.62.mlp.up_proj.weight": "model-00010-of-00012.safetensors",
805
+ "model.layers.62.post_attention_layernorm.weight": "model-00010-of-00012.safetensors",
806
+ "model.layers.63.input_layernorm.weight": "model-00010-of-00012.safetensors",
807
+ "model.layers.63.mlp.down_proj.weight": "model-00010-of-00012.safetensors",
808
+ "model.layers.63.mlp.gate_proj.weight": "model-00010-of-00012.safetensors",
809
+ "model.layers.63.mlp.up_proj.weight": "model-00011-of-00012.safetensors",
810
+ "model.layers.63.post_attention_layernorm.weight": "model-00011-of-00012.safetensors",
811
+ "model.layers.63.self_attn.k_norm.weight": "model-00011-of-00012.safetensors",
812
+ "model.layers.63.self_attn.k_proj.weight": "model-00011-of-00012.safetensors",
813
+ "model.layers.63.self_attn.o_proj.weight": "model-00011-of-00012.safetensors",
814
+ "model.layers.63.self_attn.q_norm.weight": "model-00011-of-00012.safetensors",
815
+ "model.layers.63.self_attn.q_proj.weight": "model-00011-of-00012.safetensors",
816
+ "model.layers.63.self_attn.v_proj.weight": "model-00011-of-00012.safetensors",
817
+ "model.layers.7.input_layernorm.weight": "model-00011-of-00012.safetensors",
818
+ "model.layers.7.mlp.down_proj.weight": "model-00011-of-00012.safetensors",
819
+ "model.layers.7.mlp.gate_proj.weight": "model-00011-of-00012.safetensors",
820
+ "model.layers.7.mlp.up_proj.weight": "model-00011-of-00012.safetensors",
821
+ "model.layers.7.post_attention_layernorm.weight": "model-00011-of-00012.safetensors",
822
+ "model.layers.7.self_attn.k_norm.weight": "model-00011-of-00012.safetensors",
823
+ "model.layers.7.self_attn.k_proj.weight": "model-00011-of-00012.safetensors",
824
+ "model.layers.7.self_attn.o_proj.weight": "model-00011-of-00012.safetensors",
825
+ "model.layers.7.self_attn.q_norm.weight": "model-00011-of-00012.safetensors",
826
+ "model.layers.7.self_attn.q_proj.weight": "model-00011-of-00012.safetensors",
827
+ "model.layers.7.self_attn.v_proj.weight": "model-00011-of-00012.safetensors",
828
+ "model.layers.8.input_layernorm.weight": "model-00011-of-00012.safetensors",
829
+ "model.layers.8.linear_attn.A_log": "model-00011-of-00012.safetensors",
830
+ "model.layers.8.linear_attn.conv1d.weight": "model-00011-of-00012.safetensors",
831
+ "model.layers.8.linear_attn.dt_bias": "model-00011-of-00012.safetensors",
832
+ "model.layers.8.linear_attn.in_proj_a.weight": "model-00011-of-00012.safetensors",
833
+ "model.layers.8.linear_attn.in_proj_b.weight": "model-00011-of-00012.safetensors",
834
+ "model.layers.8.linear_attn.in_proj_qkv.weight": "model-00011-of-00012.safetensors",
835
+ "model.layers.8.linear_attn.in_proj_z.weight": "model-00011-of-00012.safetensors",
836
+ "model.layers.8.linear_attn.norm.weight": "model-00011-of-00012.safetensors",
837
+ "model.layers.8.linear_attn.out_proj.weight": "model-00011-of-00012.safetensors",
838
+ "model.layers.8.mlp.down_proj.weight": "model-00011-of-00012.safetensors",
839
+ "model.layers.8.mlp.gate_proj.weight": "model-00011-of-00012.safetensors",
840
+ "model.layers.8.mlp.up_proj.weight": "model-00011-of-00012.safetensors",
841
+ "model.layers.8.post_attention_layernorm.weight": "model-00011-of-00012.safetensors",
842
+ "model.layers.9.input_layernorm.weight": "model-00011-of-00012.safetensors",
843
+ "model.layers.9.linear_attn.A_log": "model-00011-of-00012.safetensors",
844
+ "model.layers.9.linear_attn.conv1d.weight": "model-00011-of-00012.safetensors",
845
+ "model.layers.9.linear_attn.dt_bias": "model-00011-of-00012.safetensors",
846
+ "model.layers.9.linear_attn.in_proj_a.weight": "model-00011-of-00012.safetensors",
847
+ "model.layers.9.linear_attn.in_proj_b.weight": "model-00011-of-00012.safetensors",
848
+ "model.layers.9.linear_attn.in_proj_qkv.weight": "model-00011-of-00012.safetensors",
849
+ "model.layers.9.linear_attn.in_proj_z.weight": "model-00011-of-00012.safetensors",
850
+ "model.layers.9.linear_attn.norm.weight": "model-00011-of-00012.safetensors",
851
+ "model.layers.9.linear_attn.out_proj.weight": "model-00011-of-00012.safetensors",
852
+ "model.layers.9.mlp.down_proj.weight": "model-00011-of-00012.safetensors",
853
+ "model.layers.9.mlp.gate_proj.weight": "model-00011-of-00012.safetensors",
854
+ "model.layers.9.mlp.up_proj.weight": "model-00011-of-00012.safetensors",
855
+ "model.layers.9.post_attention_layernorm.weight": "model-00011-of-00012.safetensors",
856
+ "model.norm.weight": "model-00011-of-00012.safetensors",
857
+ "mtp.fc.weight": "model-00012-of-00012.safetensors",
858
+ "mtp.layers.0.input_layernorm.weight": "model-00012-of-00012.safetensors",
859
+ "mtp.layers.0.mlp.down_proj.weight": "model-00012-of-00012.safetensors",
860
+ "mtp.layers.0.mlp.gate_proj.weight": "model-00012-of-00012.safetensors",
861
+ "mtp.layers.0.mlp.up_proj.weight": "model-00012-of-00012.safetensors",
862
+ "mtp.layers.0.post_attention_layernorm.weight": "model-00012-of-00012.safetensors",
863
+ "mtp.layers.0.self_attn.k_norm.weight": "model-00012-of-00012.safetensors",
864
+ "mtp.layers.0.self_attn.k_proj.weight": "model-00012-of-00012.safetensors",
865
+ "mtp.layers.0.self_attn.o_proj.weight": "model-00012-of-00012.safetensors",
866
+ "mtp.layers.0.self_attn.q_norm.weight": "model-00012-of-00012.safetensors",
867
+ "mtp.layers.0.self_attn.q_proj.weight": "model-00012-of-00012.safetensors",
868
+ "mtp.layers.0.self_attn.v_proj.weight": "model-00012-of-00012.safetensors",
869
+ "mtp.norm.weight": "model-00012-of-00012.safetensors",
870
+ "mtp.pre_fc_norm_embedding.weight": "model-00012-of-00012.safetensors",
871
+ "mtp.pre_fc_norm_hidden.weight": "model-00012-of-00012.safetensors"
872
+ }
873
+ }
modeling_counsel.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Counsel model and runtime.
2
+
3
+ Load with `AutoModelForCausalLM.from_pretrained(<repo>, trust_remote_code=True)`; the returned `CounselForCausalLM`
4
+ adds `chat()`, a ready-to-use conversation runtime on top of `generate()`.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ import re
9
+
10
+ import torch
11
+ from transformers import Qwen3_5ForCausalLM, Qwen3_5PreTrainedModel, Qwen3_5TextModel
12
+
13
+ from .configuration_counsel import CounselConfig
14
+
15
+ _THINK = re.compile(r"^\s*<think>(.*?)</think>\s*", re.S)
16
+
17
+
18
+ class CounselPreTrainedModel(Qwen3_5PreTrainedModel):
19
+ config_class = CounselConfig
20
+
21
+
22
+ class CounselModel(Qwen3_5TextModel):
23
+ config_class = CounselConfig
24
+
25
+
26
+ class CounselForCausalLM(Qwen3_5ForCausalLM):
27
+ config_class = CounselConfig
28
+
29
+ @staticmethod
30
+ def split_reasoning(text: str) -> tuple[str, str]:
31
+ """(reasoning, answer) from a generated turn; reasoning is "" when the model did not think."""
32
+ m = _THINK.match(text)
33
+ if m:
34
+ return m.group(1).strip(), text[m.end():].strip()
35
+ if "</think>" in text: # template opened <think> in the prompt
36
+ r, a = text.split("</think>", 1)
37
+ return r.replace("<think>", "").strip(), a.strip()
38
+ return "", text.strip()
39
+
40
+ @torch.no_grad()
41
+ def chat(self, tokenizer, messages, *, system: str | None = None, tools: list | None = None, thinking: bool = True,
42
+ reasoning_effort: str = "medium", max_new_tokens: int = 131072, temperature: float = 0.7, top_p: float = 0.95,
43
+ return_reasoning: bool = False, **generate_kwargs):
44
+ """Run one assistant turn.
45
+
46
+ messages: a user string, or a list of {"role", "content"} dicts (system / user / assistant / tool).
47
+ system: optional system prompt, prepended when `messages` has none.
48
+ tools: optional list of JSON function schemas; calls come back as <tool_call> blocks.
49
+ thinking: reason step by step before answering (the reasoning is returned separately, not in the answer).
50
+ reasoning_effort: "low", "medium" (default) or "xhigh": how long the model thinks when thinking=True.
51
+ Returns the answer text, or (answer, reasoning) with return_reasoning=True.
52
+ """
53
+ if isinstance(messages, str):
54
+ messages = [{"role": "user", "content": messages}]
55
+ messages = list(messages)
56
+ if system and not (messages and messages[0]["role"] == "system"):
57
+ messages.insert(0, {"role": "system", "content": system})
58
+ prompt = tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True, tokenize=False,
59
+ enable_thinking=thinking, reasoning_effort=reasoning_effort,
60
+ preserve_thinking=True)
61
+ inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to(self.device)
62
+ sample = temperature is not None and temperature > 0
63
+ out = self.generate(**inputs, max_new_tokens=max_new_tokens, do_sample=sample,
64
+ temperature=temperature if sample else None, top_p=top_p if sample else None,
65
+ pad_token_id=self.generation_config.pad_token_id, **generate_kwargs)
66
+ # keep special tokens (tool calls use them as <function ...> / <param ...> markers), drop turn terminators
67
+ text = tokenizer.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=False)
68
+ for t in (tokenizer.eos_token, tokenizer.pad_token, "<|im_end|>", "<|endoftext|>"):
69
+ if t:
70
+ text = text.replace(t, "")
71
+ if thinking and "<think>" not in text and "</think>" in text:
72
+ text = "<think>" + text
73
+ reasoning, answer = self.split_reasoning(text)
74
+ return (answer, reasoning) if return_reasoning else answer
75
+
76
+
77
+ __all__ = ["CounselConfig", "CounselPreTrainedModel", "CounselModel", "CounselForCausalLM"]
runtime/counsel_runtime/__init__.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ """Counsel runtime: serve Counsel models with vLLM or SGLang.
2
+
3
+ vLLM picks up the `counsel` model type automatically through the `vllm.general_plugins` entry point once this package
4
+ is installed. SGLang loads it through SGLANG_EXTERNAL_MODEL_PACKAGE (set by `counsel-serve-sglang`).
5
+ """
6
+ from .config import CounselConfig, register_config
7
+
8
+ __all__ = ["CounselConfig", "register_config"]
9
+ __version__ = "0.3.4"
runtime/counsel_runtime/config.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """The `counsel` model type for transformers' Auto classes, so servers load Counsel configs without remote code."""
2
+ from transformers import AutoConfig, Qwen3_5TextConfig
3
+
4
+
5
+ class CounselConfig(Qwen3_5TextConfig):
6
+ model_type = "counsel"
7
+
8
+
9
+ def register_config() -> None:
10
+ try:
11
+ AutoConfig.register("counsel", CounselConfig)
12
+ except ValueError: # already registered in this process
13
+ pass
runtime/counsel_runtime/kernels/__init__.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Counsel's GDN replay kernel for vLLM, used by `counsel-serve-vllm --mode copy`.
2
+
3
+ Stock vLLM keeps 1 + num_speculative_tokens recurrent-state slots per request for the gated linear-attention (GDN)
4
+ layers, so long copy drafts (128-512 tokens) do not fit next to a 27B model on one GPU. The replay kernel keeps one
5
+ slot per request and rolls back a rejected draft tail by replaying the accepted tokens with the stock arithmetic, so
6
+ outputs are bit-identical to plain decoding. VLLM_GDN_REPLAY_CHUNKED=1 verifies the draft window with the chunked
7
+ prefill kernel. The patched code is inert unless VLLM_GDN_REPLAY=1 (which only --mode copy sets).
8
+
9
+ `counsel-install-kernels` patches the installed vLLM 0.32.0 in place (needs the `patch` tool).
10
+ """
11
+ import importlib.metadata
12
+ import importlib.util
13
+ import os
14
+ import shutil
15
+ import subprocess
16
+ import sys
17
+
18
+ VLLM_VERSION = "0.32.0"
19
+ HERE = os.path.dirname(os.path.abspath(__file__))
20
+
21
+
22
+ def install(argv=None) -> None:
23
+ spec = importlib.util.find_spec("vllm")
24
+ if spec is None:
25
+ sys.exit("vLLM is not installed in this environment")
26
+ version = importlib.metadata.version("vllm")
27
+ if version != VLLM_VERSION:
28
+ sys.exit(f"the GDN replay kernel is built for vLLM {VLLM_VERSION}; this environment has {version}")
29
+ root = os.path.dirname(spec.origin)
30
+ site = os.path.dirname(root)
31
+ utils = os.path.join(root, "model_executor", "layers", "mamba", "mamba_utils.py")
32
+ if "GDN_REPLAY_PATCH" not in open(utils).read():
33
+ diff = os.path.join(HERE, "gdn_replay.diff")
34
+ for extra in (["--dry-run"], []): # check the whole patch applies before touching anything
35
+ r = subprocess.run(["patch", "-p0", "--forward", "--batch", *extra, "-i", diff], cwd=site,
36
+ capture_output=True, text=True)
37
+ if r.returncode:
38
+ sys.exit(f"could not patch vLLM in {site}:\n{r.stdout}{r.stderr}")
39
+ shutil.copy(os.path.join(HERE, "gdn_replay.py"), os.path.join(root, "model_executor", "layers", "mamba", "ops", "gdn_replay.py"))
40
+ print(f"GDN replay kernel installed in vLLM {version} at {root}")
runtime/counsel_runtime/kernels/gdn_replay.diff ADDED
@@ -0,0 +1,425 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --- vllm/model_executor/layers/mamba/mamba_utils.py.orig 2026-10-20 10:33:05.043134991 +0000
2
+ +++ vllm/model_executor/layers/mamba/mamba_utils.py 2026-10-20 13:02:10.751309503 +0000
3
+ @@ -1,3 +1,4 @@
4
+ +# GDN_REPLAY_PATCH
5
+ # SPDX-License-Identifier: Apache-2.0
6
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
7
+
8
+ @@ -125,9 +126,17 @@
9
+ mamba_cache_dtype: MambaDType,
10
+ mamba_ssm_cache_dtype: MambaDType = "auto",
11
+ ) -> tuple[torch.dtype, torch.dtype]:
12
+ - return cls._mamba_state_dtype(
13
+ + dtypes = cls._mamba_state_dtype(
14
+ model_dtype, mamba_cache_dtype, mamba_ssm_cache_dtype
15
+ )
16
+ + from vllm.model_executor.layers.mamba.ops.gdn_replay import (
17
+ + gdn_replay_enabled,
18
+ + )
19
+ +
20
+ + if gdn_replay_enabled():
21
+ + # GDN replay ring (post-conv q/k/v + raw b/a), conv-state dtype.
22
+ + dtypes = (*dtypes, dtypes[0])
23
+ + return dtypes
24
+
25
+ @classmethod
26
+ def kda_state_dtype(
27
+ @@ -298,6 +307,19 @@
28
+ head_v_dim,
29
+ head_k_dim,
30
+ )
31
+ + from vllm.model_executor.layers.mamba.ops.gdn_replay import (
32
+ + gdn_replay_enabled,
33
+ + )
34
+ +
35
+ + if num_spec > 0 and gdn_replay_enabled():
36
+ + # One ring row per verify-window token:
37
+ + # [q | k | v | b | a] for the 1 + num_spec window tokens.
38
+ + ring_shape = (
39
+ + num_spec + 1,
40
+ + divide(conv_dim, tp_world_size)
41
+ + + 2 * divide(num_v_heads, tp_world_size),
42
+ + )
43
+ + return conv_state_shape, temporal_state_shape, ring_shape
44
+ return conv_state_shape, temporal_state_shape
45
+
46
+ @classmethod
47
+ --- vllm/model_executor/layers/mamba/abstract.py.orig 2026-10-20 10:33:05.043134991 +0000
48
+ +++ vllm/model_executor/layers/mamba/abstract.py 2026-10-20 13:02:10.751309503 +0000
49
+ @@ -1,3 +1,4 @@
50
+ +# GDN_REPLAY_PATCH
51
+ # SPDX-License-Identifier: Apache-2.0
52
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
53
+ from abc import abstractmethod
54
+ @@ -76,9 +77,12 @@
55
+ mamba_cache_mode=vllm_config.cache_config.mamba_cache_mode,
56
+ # ReplaySSM verifies the whole window off one checkpoint, so it
57
+ # never writes the baseline's per-draft-token state slots.
58
+ + # GDN replay (VLLM_GDN_REPLAY=1) likewise keeps one slot and
59
+ + # replays the accepted tokens from a ring in the same page.
60
+ num_speculative_blocks=(
61
+ 0
62
+ if vllm_config.cache_config.use_replayssm
63
+ + or getattr(self, "gdn_replay", False)
64
+ else vllm_config.num_speculative_tokens
65
+ ),
66
+ )
67
+ --- vllm/model_executor/layers/mamba/gdn/qwen_gdn_linear_attn.py.orig 2026-10-20 10:33:05.035134798 +0000
68
+ +++ vllm/model_executor/layers/mamba/gdn/qwen_gdn_linear_attn.py 2026-10-20 14:22:56.476982050 +0000
69
+ @@ -1,3 +1,7 @@
70
+ +# GDN_REPLAY_BATCHED_PATCH
71
+ +# GDN_REPLAY_CHUNKED_PATCH
72
+ +# GDN_REPLAY_FAST_PATCH
73
+ +# GDN_REPLAY_PATCH
74
+ # SPDX-License-Identifier: Apache-2.0
75
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
76
+ """Inference-only Qwen3-Next/Qwen3.5 model."""
77
+ @@ -40,6 +44,17 @@
78
+ causal_conv1d_fn,
79
+ causal_conv1d_update,
80
+ )
81
+ +from vllm.model_executor.layers.mamba.ops.gdn_replay import (
82
+ + GDNReplayBatch,
83
+ + gdn_replay_accepted,
84
+ + gdn_replay_batched_enabled,
85
+ + gdn_replay_chunked_mode,
86
+ + gdn_replay_enabled,
87
+ + gdn_replay_fast_enabled,
88
+ + gdn_ring_write,
89
+ + gdn_spec_conv,
90
+ + gdn_verify,
91
+ +)
92
+ from vllm.model_executor.layers.quantization import QuantizationConfig
93
+ from vllm.model_executor.layers.quantization.auto_awq import AutoAWQConfig
94
+ from vllm.model_executor.layers.quantization.auto_gptq import AutoGPTQConfig
95
+ @@ -87,6 +102,24 @@
96
+ logger = init_logger(__name__)
97
+
98
+ MAX_FUSED_GDN_MTP_TOKENS = 8
99
+ +# Shared (verify state indices, ones) buffers for GDN replay, by (rows, cols).
100
+ +_GDN_REPLAY_BUFS: dict[tuple[int, int], tuple[torch.Tensor, torch.Tensor]] = {}
101
+ +# GDN replay layers in construction (= execution) order; the first one replays
102
+ +# the accepted tokens of all of them in one launch (VLLM_GDN_REPLAY_BATCHED=1).
103
+ +_GDN_REPLAY_LAYERS: list = []
104
+ +_GDN_REPLAY_BATCH: dict = {}
105
+ +
106
+ +
107
+ +def _gdn_replay_all_layers(md_dict, num_accepted_tokens, num_seqs, scale):
108
+ + batch = _GDN_REPLAY_BATCH.get("batch")
109
+ + if batch is None:
110
+ + batch = GDNReplayBatch(_GDN_REPLAY_LAYERS)
111
+ + _GDN_REPLAY_BATCH["batch"] = batch
112
+ + slots = [
113
+ + md_dict[layer.prefix].spec_state_indices_tensor[:, 0]
114
+ + for layer in _GDN_REPLAY_LAYERS
115
+ + ]
116
+ + batch.run(slots, num_accepted_tokens, num_seqs, scale)
117
+ FUSED_GDN_STATE_DTYPES = (torch.float32, torch.bfloat16)
118
+
119
+
120
+ @@ -619,6 +652,45 @@
121
+ if self.speculative_config is not None:
122
+ logger.info_once("GDN spec decode kernel: %s", self.gdn_decode_kernel)
123
+
124
+ + # GDN replay rollback: one state slot per request; accepted draft
125
+ + # tokens are replayed from a ring of cached kernel inputs.
126
+ + self.gdn_replay = gdn_replay_enabled() and self.num_spec > 0
127
+ + # bit-identical token-parallel conv + prefetching verify kernels
128
+ + self.gdn_replay_fast = self.gdn_replay and gdn_replay_fast_enabled()
129
+ + # one batched replay launch for all GDN layers (first layer leads)
130
+ + self.gdn_replay_batched = self.gdn_replay and gdn_replay_batched_enabled()
131
+ + self.gdn_replay_leader = False
132
+ + if self.gdn_replay_batched:
133
+ + self.gdn_replay_leader = not _GDN_REPLAY_LAYERS
134
+ + _GDN_REPLAY_LAYERS.append(self)
135
+ + # chunked (prefill-algorithm) verify; "" = off, "prefill" or "fla"
136
+ + self.gdn_replay_chunked = (
137
+ + gdn_replay_chunked_mode() if self.gdn_replay_fast else ""
138
+ + )
139
+ + if self.gdn_replay:
140
+ + if vllm_config.cache_config.mamba_cache_mode != "none":
141
+ + raise ValueError(
142
+ + "VLLM_GDN_REPLAY=1 requires --mamba-cache-mode none "
143
+ + f"(got {vllm_config.cache_config.mamba_cache_mode!r})"
144
+ + )
145
+ + if not current_platform.is_cuda():
146
+ + raise ValueError("VLLM_GDN_REPLAY=1 is CUDA-only")
147
+ + rows = vllm_config.scheduler_config.max_num_seqs
148
+ + key = (rows, self.num_spec + 1)
149
+ + bufs = _GDN_REPLAY_BUFS.get(key)
150
+ + if bufs is None:
151
+ + dev = current_platform.current_device()
152
+ + bufs = (
153
+ + torch.zeros(rows, self.num_spec + 1, dtype=torch.int32, device=dev),
154
+ + torch.ones(rows, dtype=torch.int32, device=dev),
155
+ + )
156
+ + _GDN_REPLAY_BUFS[key] = bufs
157
+ + self._replay_verify_idx, self._replay_ones = bufs
158
+ + logger.info_once(
159
+ + "GDN replay rollback enabled: 1 state slot per request, "
160
+ + "ring of %d tokens", self.num_spec + 1
161
+ + )
162
+ +
163
+ compilation_config = get_current_vllm_config().compilation_config
164
+ if prefix in compilation_config.static_forward_context:
165
+ raise ValueError(f"Duplicate layer name: {prefix}")
166
+ @@ -627,7 +699,7 @@
167
+ def _fused_gdn_decode_unsupported_reason(
168
+ self, vllm_config: VllmConfig
169
+ ) -> str | None:
170
+ - conv_state_dtype, recurrent_state_dtype = self.get_state_dtype()
171
+ + conv_state_dtype, recurrent_state_dtype = self.get_state_dtype()[:2]
172
+ if (
173
+ self.gqa_interleaved_layout
174
+ or self.head_k_dim != 128
175
+ @@ -1172,7 +1244,7 @@
176
+ dtype = qkv_or_qkvz.dtype
177
+ num_k_heads = self.num_k_heads // self.tp_size
178
+ num_v_heads = self.num_v_heads // self.tp_size
179
+ - _, state_dtype = self.get_state_dtype()
180
+ + state_dtype = self.get_state_dtype()[1]
181
+
182
+ # All kernels use BT = chunk_size, so a single pass with T = chunk_size
183
+ # is sufficient to populate every autotuner cache. Mirror the real
184
+ @@ -1424,7 +1496,21 @@
185
+ mixed_qkv_non_spec = mixed_qkv
186
+
187
+ # 1.1: Process the multi-query part
188
+ - if spec_sequence_masks is not None:
189
+ + if spec_sequence_masks is not None and self.gdn_replay_fast:
190
+ + assert spec_state_indices_tensor is not None
191
+ + assert num_accepted_tokens is not None
192
+ + mixed_qkv_spec = gdn_spec_conv(
193
+ + mixed_qkv_spec,
194
+ + conv_state,
195
+ + conv_weights,
196
+ + self.conv1d.bias,
197
+ + self.activation,
198
+ + spec_state_indices_tensor[:, 0],
199
+ + num_accepted_tokens,
200
+ + spec_query_start_loc,
201
+ + num_seqs=attn_metadata.num_spec_decodes,
202
+ + )
203
+ + elif spec_sequence_masks is not None:
204
+ # spec_state_indices_tensor is always set when spec_sequence_masks is set
205
+ assert spec_state_indices_tensor is not None
206
+ mixed_qkv_spec = causal_conv1d_update(
207
+ @@ -1538,7 +1624,137 @@
208
+ # 2. Recurrent attention
209
+
210
+ # 2.1: Process the multi-query part
211
+ - if spec_sequence_masks is not None:
212
+ + if spec_sequence_masks is not None and self.gdn_replay:
213
+ + n_spec = attn_metadata.num_spec_decodes
214
+ + assert spec_state_indices_tensor is not None
215
+ + assert num_accepted_tokens is not None
216
+ + ring = self_kv_cache[2]
217
+ + slot_idx = spec_state_indices_tensor[:, 0]
218
+ + # (a) fold last window's accepted drafts (1..a-1) into the slot
219
+ + if self.gdn_replay_batched:
220
+ + if self.gdn_replay_leader:
221
+ + _gdn_replay_all_layers(
222
+ + attn_metadata_raw,
223
+ + num_accepted_tokens,
224
+ + n_spec,
225
+ + self.head_k_dim**-0.5,
226
+ + )
227
+ + else:
228
+ + gdn_replay_accepted(
229
+ + ring,
230
+ + ssm_state,
231
+ + slot_idx,
232
+ + num_accepted_tokens,
233
+ + self.A_log,
234
+ + self.dt_bias,
235
+ + num_seqs=n_spec,
236
+ + num_k_heads=self.num_k_heads // self.tp_size,
237
+ + head_k_dim=self.head_k_dim,
238
+ + head_v_dim=self.head_v_dim,
239
+ + scale=self.head_k_dim**-0.5,
240
+ + )
241
+ + # (b) verify the whole window off the slot with the stock kernel;
242
+ + # only token 0 (always accepted) writes its state back.
243
+ + if self.gdn_replay_chunked:
244
+ + # (b') chunked verify from the slot checkpoint (outputs only)
245
+ + q_c, k_c, v_c, g_c, beta_c = fused_post_conv_prep(
246
+ + conv_output=mixed_qkv_spec,
247
+ + a=a_spec,
248
+ + b=b_spec,
249
+ + A_log=self.A_log,
250
+ + dt_bias=self.dt_bias,
251
+ + num_k_heads=self.num_k_heads // self.tp_size,
252
+ + head_k_dim=self.head_k_dim,
253
+ + head_v_dim=self.head_v_dim,
254
+ + apply_l2norm=True,
255
+ + output_g_exp=False,
256
+ + )
257
+ + cu_spec = spec_query_start_loc[: n_spec + 1] # type: ignore[index]
258
+ + init_state = ssm_state[slot_idx[:n_spec].long()]
259
+ + chunk_kwargs = dict(
260
+ + q=q_c.unsqueeze(0),
261
+ + k=k_c.unsqueeze(0),
262
+ + v=v_c.unsqueeze(0),
263
+ + g=g_c.unsqueeze(0),
264
+ + beta=beta_c.unsqueeze(0),
265
+ + initial_state=init_state,
266
+ + output_final_state=False,
267
+ + cu_seqlens=cu_spec,
268
+ + chunk_indices=attn_metadata.spec_chunk_indices,
269
+ + chunk_offsets=attn_metadata.spec_chunk_offsets,
270
+ + use_qk_l2norm_in_kernel=False,
271
+ + )
272
+ + if self.gdn_replay_chunked == "fla":
273
+ + core_attn_out_spec, _ = fla_chunk_gated_delta_rule(**chunk_kwargs)
274
+ + else:
275
+ + core_attn_out_spec, _ = self.chunk_gated_delta_rule(**chunk_kwargs)
276
+ + core_attn_out_spec = core_attn_out_spec.contiguous()
277
+ + # (b'') exact recurrent step for token 0: writes the slot
278
+ + # checkpoint and token 0's output (same as stock spec decode)
279
+ + gdn_verify(
280
+ + self.A_log,
281
+ + a_spec,
282
+ + b_spec,
283
+ + self.dt_bias,
284
+ + query_spec,
285
+ + key_spec,
286
+ + value_spec,
287
+ + ssm_state,
288
+ + cu_spec,
289
+ + slot_idx,
290
+ + num_seqs=n_spec,
291
+ + use_qk_l2norm_in_kernel=True,
292
+ + out=core_attn_out_spec,
293
+ + first_token_only=True,
294
+ + )
295
+ + last_recurrent_state = None
296
+ + elif self.gdn_replay_fast:
297
+ + core_attn_out_spec = gdn_verify(
298
+ + self.A_log,
299
+ + a_spec,
300
+ + b_spec,
301
+ + self.dt_bias,
302
+ + query_spec,
303
+ + key_spec,
304
+ + value_spec,
305
+ + ssm_state,
306
+ + spec_query_start_loc,
307
+ + slot_idx,
308
+ + num_seqs=n_spec,
309
+ + use_qk_l2norm_in_kernel=True,
310
+ + )
311
+ + last_recurrent_state = None
312
+ + else:
313
+ + verify_idx = self._replay_verify_idx
314
+ + verify_idx[:n_spec, 0].copy_(slot_idx[:n_spec])
315
+ + core_attn_out_spec, last_recurrent_state = (
316
+ + fused_sigmoid_gating_delta_rule_update(
317
+ + A_log=self.A_log,
318
+ + a=a_spec,
319
+ + b=b_spec,
320
+ + dt_bias=self.dt_bias,
321
+ + q=query_spec,
322
+ + k=key_spec,
323
+ + v=value_spec,
324
+ + initial_state=ssm_state,
325
+ + inplace_final_state=True,
326
+ + cu_seqlens=spec_query_start_loc[: n_spec + 1], # type: ignore[index]
327
+ + ssm_state_indices=verify_idx,
328
+ + num_accepted_tokens=self._replay_ones,
329
+ + use_qk_l2norm_in_kernel=True,
330
+ + )
331
+ + )
332
+ + # (c) cache this window's kernel inputs for the next replay
333
+ + gdn_ring_write(
334
+ + mixed_qkv_spec,
335
+ + b_spec,
336
+ + a_spec,
337
+ + ring,
338
+ + slot_idx,
339
+ + spec_query_start_loc,
340
+ + num_seqs=n_spec,
341
+ + )
342
+ + elif spec_sequence_masks is not None:
343
+ core_attn_out_spec, last_recurrent_state = (
344
+ fused_sigmoid_gating_delta_rule_update(
345
+ A_log=self.A_log,
346
+ @@ -1896,7 +2112,8 @@
347
+ ) -> bool:
348
+ state_indices = attn_metadata.spec_state_indices_tensor
349
+ return (
350
+ - attn_metadata.spec_sequence_masks is not None
351
+ + not self.gdn_replay
352
+ + and attn_metadata.spec_sequence_masks is not None
353
+ and attn_metadata.num_decodes == 0
354
+ and attn_metadata.num_spec_decodes > 0
355
+ and self.kv_cache[1].dtype in FUSED_GDN_STATE_DTYPES
356
+ --- vllm/v1/attention/backends/gdn_attn.py.orig 2026-10-20 10:33:05.011134220 +0000
357
+ +++ vllm/v1/attention/backends/gdn_attn.py 2026-10-20 14:01:19.277604594 +0000
358
+ @@ -1,3 +1,4 @@
359
+ +# GDN_REPLAY_CHUNKED_PATCH
360
+ # SPDX-License-Identifier: Apache-2.0
361
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
362
+ """Backend for GatedDeltaNet attention."""
363
+ @@ -72,6 +73,10 @@
364
+
365
+ num_accepted_tokens: torch.Tensor | None = None # shape: [batch,]
366
+ uniform_spec_sequence_length: int | None = None # None for ragged batches
367
+ + # GDN replay chunked verify (VLLM_GDN_REPLAY_CHUNKED=fla): FLA chunk
368
+ + # metadata for the spec-decode windows
369
+ + spec_chunk_indices: torch.Tensor | None = None
370
+ + spec_chunk_offsets: torch.Tensor | None = None
371
+
372
+ # Pre-computed FLA chunk metadata (avoids GPU->CPU sync in prepare_chunk_indices)
373
+ chunk_indices: torch.Tensor | None = None
374
+ @@ -268,6 +273,8 @@
375
+ fast_build: bool = False,
376
+ ) -> GDNAttentionMetadata:
377
+ m = common_attn_metadata
378
+ + spec_chunk_indices: torch.Tensor | None = None
379
+ + spec_chunk_offsets: torch.Tensor | None = None
380
+
381
+ query_start_loc = m.query_start_loc
382
+ query_start_loc_cpu = m.query_start_loc_cpu
383
+ @@ -456,6 +463,33 @@
384
+ num_accepted_tokens = num_accepted_tokens[:num_spec_decodes]
385
+ else:
386
+ num_accepted_tokens = num_accepted_tokens[spec_sequence_masks_cpu]
387
+ + from vllm.model_executor.layers.mamba.ops.gdn_replay import (
388
+ + gdn_replay_chunked_mode,
389
+ + )
390
+ +
391
+ + if gdn_replay_chunked_mode() == "fla" and num_spec_decodes > 0:
392
+ + from vllm.third_party.flash_linear_attention.ops.index import (
393
+ + prepare_chunk_indices,
394
+ + prepare_chunk_offsets,
395
+ + )
396
+ + from vllm.third_party.flash_linear_attention.ops.utils import (
397
+ + FLA_CHUNK_SIZE,
398
+ + )
399
+ +
400
+ + spec_cu_cpu = torch.zeros(num_spec_decodes + 1, dtype=torch.int32)
401
+ + torch.cumsum(
402
+ + query_lens_cpu[spec_sequence_masks_cpu][:num_spec_decodes],
403
+ + dim=0,
404
+ + out=spec_cu_cpu[1:],
405
+ + )
406
+ + spec_chunk_indices = async_tensor_h2d(
407
+ + prepare_chunk_indices(spec_cu_cpu, FLA_CHUNK_SIZE),
408
+ + device=query_start_loc.device,
409
+ + )
410
+ + spec_chunk_offsets = async_tensor_h2d(
411
+ + prepare_chunk_offsets(spec_cu_cpu, FLA_CHUNK_SIZE),
412
+ + device=query_start_loc.device,
413
+ + )
414
+
415
+ chunk_indices: torch.Tensor | None = None
416
+ chunk_offsets: torch.Tensor | None = None
417
+ @@ -623,6 +657,8 @@
418
+ non_spec_token_indx=non_spec_token_indx,
419
+ num_accepted_tokens=num_accepted_tokens,
420
+ uniform_spec_sequence_length=uniform_spec_sequence_length,
421
+ + spec_chunk_indices=spec_chunk_indices,
422
+ + spec_chunk_offsets=spec_chunk_offsets,
423
+ nums_dict=nums_dict,
424
+ batch_ptr=batch_ptr,
425
+ token_chunk_offset_ptr=token_chunk_offset_ptr,
runtime/counsel_runtime/kernels/gdn_replay.py ADDED
@@ -0,0 +1,834 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+ # Modified by JudicialMind (2026) for Counsel-27B: replay rollback of the GDN recurrent state for speculative decoding.
4
+ """Replay rollback for Gated DeltaNet speculative decoding (VLLM_GDN_REPLAY=1).
5
+
6
+ Stock vLLM keeps 1 + num_speculative_tokens recurrent-state slots per request
7
+ and writes the state after every draft token during verification, so a
8
+ rejected tail can be rolled back by picking slot ``num_accepted - 1``.
9
+
10
+ Replay mode keeps ONE slot per request:
11
+
12
+ * verification reads the slot, writes only the state after the window's first
13
+ token (that token is the previous step's sampled token, so it is always
14
+ accepted) and caches each window token's post-conv q/k/v and raw b/a gate
15
+ inputs in a per-request ring that lives in the same KV page;
16
+ * at the start of the next step, once ``num_accepted_tokens`` is known, the
17
+ accepted draft tokens 1..num_accepted-1 are replayed from the ring with the
18
+ same per-token arithmetic as the stock kernel, which reproduces the stock
19
+ accepted-prefix state bit for bit.
20
+
21
+ The short-conv state is unchanged from stock: stock already keeps it in one
22
+ slot (``spec_state_indices[:, 0]``) as a sliding window that the conv kernel
23
+ offsets by ``num_accepted_tokens``.
24
+
25
+ Ring row layout (bf16): [q (H*K) | k (H*K) | v (HV*V) | b (HV) | a (HV)].
26
+ """
27
+
28
+ import os
29
+
30
+ import torch
31
+
32
+ from vllm.triton_utils import tl, triton
33
+
34
+
35
+ def gdn_replay_enabled() -> bool:
36
+ return os.environ.get("VLLM_GDN_REPLAY", "0") == "1"
37
+
38
+
39
+ @triton.jit(do_not_specialize=["N"])
40
+ def gdn_replay_accepted_kernel(
41
+ A_log,
42
+ dt_bias,
43
+ ring,
44
+ h,
45
+ state_indices,
46
+ num_accepted_tokens,
47
+ scale,
48
+ beta,
49
+ threshold,
50
+ N,
51
+ stride_ring_page: tl.int64,
52
+ stride_ring_tok: tl.constexpr,
53
+ stride_h_page: tl.int64,
54
+ stride_idx_seq: tl.constexpr,
55
+ H: tl.constexpr,
56
+ HV: tl.constexpr,
57
+ K: tl.constexpr,
58
+ V: tl.constexpr,
59
+ BK: tl.constexpr,
60
+ BV: tl.constexpr,
61
+ USE_QK_L2NORM_IN_KERNEL: tl.constexpr,
62
+ ):
63
+ i_k, i_v, i_nh = tl.program_id(0), tl.program_id(1), tl.program_id(2)
64
+ i_n, i_hv = i_nh // HV, i_nh % HV
65
+ i_h = i_hv // (HV // H)
66
+ if i_n >= N:
67
+ return
68
+
69
+ # Ring tokens 1 .. num_accepted - 1 are the accepted draft tokens of the
70
+ # previous window; token 0 was already folded into the slot by the verify.
71
+ n_rep = tl.load(num_accepted_tokens + i_n).to(tl.int64) - 1
72
+ if n_rep <= 0:
73
+ return
74
+ state_idx = tl.load(state_indices + i_n * stride_idx_seq).to(tl.int64)
75
+ # Skip invalid entries (NULL_BLOCK_ID=0), as the stock kernel does.
76
+ if state_idx <= 0:
77
+ return
78
+
79
+ o_k = i_k * BK + tl.arange(0, BK)
80
+ o_v = i_v * BV + tl.arange(0, BV)
81
+
82
+ base = ring + state_idx * stride_ring_page + stride_ring_tok
83
+ p_q = base + i_h * K + o_k
84
+ p_k = base + H * K + i_h * K + o_k
85
+ p_v = base + 2 * H * K + i_hv * V + o_v
86
+ p_b = base + 2 * H * K + HV * V + i_hv
87
+ p_a = base + 2 * H * K + HV * V + HV + i_hv
88
+
89
+ p_A_log = A_log + i_hv
90
+ p_dt_bias = dt_bias + i_hv
91
+
92
+ mask_k = o_k < K
93
+ mask_v = o_v < V
94
+ mask_h = mask_v[:, None] & mask_k[None, :]
95
+
96
+ p_h = h + state_idx * stride_h_page + i_hv * V * K + o_v[:, None] * K + o_k[None, :]
97
+ b_h = tl.zeros([BV, BK], dtype=tl.float32)
98
+ b_h += tl.load(p_h, mask=mask_h, other=0).to(tl.float32)
99
+
100
+ n_q = tl.load(p_q, mask=mask_k, other=0)
101
+ n_k = tl.load(p_k, mask=mask_k, other=0)
102
+ n_v = tl.load(p_v, mask=mask_v, other=0)
103
+ n_b = tl.load(p_b)
104
+ n_a = tl.load(p_a)
105
+ for i_t in range(0, n_rep):
106
+ # --- per-token body copied from fused_sigmoid_gating_delta_rule_update
107
+ # (non-KDA branch) so the state arithmetic matches stock exactly;
108
+ # the next token's inputs are prefetched one step ahead ---
109
+ b_q = n_q.to(tl.float32)
110
+ b_k = n_k.to(tl.float32)
111
+ b_v = n_v.to(tl.float32)
112
+ b_b = n_b.to(tl.float32)
113
+ c_a = n_a
114
+ nxt = i_t + 1 < n_rep
115
+ p_q += stride_ring_tok
116
+ p_k += stride_ring_tok
117
+ p_v += stride_ring_tok
118
+ p_b += stride_ring_tok
119
+ p_a += stride_ring_tok
120
+ n_q = tl.load(p_q, mask=mask_k & nxt, other=0)
121
+ n_k = tl.load(p_k, mask=mask_k & nxt, other=0)
122
+ n_v = tl.load(p_v, mask=mask_v & nxt, other=0)
123
+ n_b = tl.load(p_b, mask=nxt, other=0)
124
+ n_a = tl.load(p_a, mask=nxt, other=0)
125
+
126
+ x = c_a.to(tl.float32) + tl.load(p_dt_bias).to(tl.float32)
127
+ softplus_x = tl.where(
128
+ beta * x <= threshold, (1 / beta) * tl.log(1 + tl.exp(beta * x)), x
129
+ )
130
+ b_g = -tl.exp(tl.load(p_A_log).to(tl.float32)) * softplus_x
131
+
132
+ b_beta = tl.sigmoid(b_b.to(tl.float32))
133
+
134
+ if USE_QK_L2NORM_IN_KERNEL:
135
+ b_q = b_q * (tl.rsqrt(tl.sum(b_q * b_q) + 1e-6))
136
+ b_k = b_k * (tl.rsqrt(tl.sum(b_k * b_k) + 1e-6))
137
+ b_q = b_q * scale
138
+ b_h *= tl.exp(b_g)
139
+ b_v -= tl.sum(b_h * b_k[None, :], 1)
140
+ b_v *= b_beta
141
+ b_h += b_v[:, None] * b_k[None, :]
142
+
143
+ tl.store(p_h, b_h.to(p_h.dtype.element_ty), mask=mask_h)
144
+
145
+
146
+ def gdn_replay_accepted(
147
+ ring: torch.Tensor,
148
+ ssm_state: torch.Tensor,
149
+ state_indices: torch.Tensor,
150
+ num_accepted_tokens: torch.Tensor,
151
+ A_log: torch.Tensor,
152
+ dt_bias: torch.Tensor,
153
+ num_seqs: int,
154
+ num_k_heads: int,
155
+ head_k_dim: int,
156
+ head_v_dim: int,
157
+ scale: float,
158
+ beta: float = 1.0,
159
+ threshold: float = 20.0,
160
+ use_qk_l2norm_in_kernel: bool = True,
161
+ ) -> None:
162
+ """Fold the previous window's accepted draft tokens into each slot."""
163
+ if num_seqs == 0:
164
+ return
165
+ HV, V, K = ssm_state.shape[-3:]
166
+ assert V == head_v_dim and K == head_k_dim
167
+ H = num_k_heads
168
+ BK, BV = triton.next_power_of_2(K), min(triton.next_power_of_2(V), 32)
169
+ NK, NV = triton.cdiv(K, BK), triton.cdiv(V, BV)
170
+ assert NK == 1
171
+ assert ring.stride(-1) == 1 and ring.dim() == 3
172
+ assert ssm_state.stride(-1) == 1
173
+ grid = (NK, NV, num_seqs * HV)
174
+ gdn_replay_accepted_kernel[grid](
175
+ A_log=A_log,
176
+ dt_bias=dt_bias,
177
+ ring=ring,
178
+ h=ssm_state,
179
+ state_indices=state_indices,
180
+ num_accepted_tokens=num_accepted_tokens,
181
+ scale=scale,
182
+ beta=beta,
183
+ threshold=threshold,
184
+ N=num_seqs,
185
+ stride_ring_page=ring.stride(0),
186
+ stride_ring_tok=ring.stride(1),
187
+ stride_h_page=ssm_state.stride(0),
188
+ stride_idx_seq=state_indices.stride(0),
189
+ H=H,
190
+ HV=HV,
191
+ K=K,
192
+ V=V,
193
+ BK=BK,
194
+ BV=BV,
195
+ USE_QK_L2NORM_IN_KERNEL=use_qk_l2norm_in_kernel,
196
+ num_warps=4,
197
+ num_stages=3,
198
+ )
199
+
200
+
201
+ @triton.jit
202
+ def gdn_ring_write_kernel(
203
+ x,
204
+ b,
205
+ a,
206
+ ring,
207
+ state_indices,
208
+ cu_seqlens,
209
+ N,
210
+ stride_x_tok: tl.int64,
211
+ stride_b_tok: tl.int64,
212
+ stride_a_tok: tl.int64,
213
+ stride_ring_page: tl.int64,
214
+ stride_ring_tok: tl.constexpr,
215
+ stride_idx_seq: tl.constexpr,
216
+ D: tl.constexpr,
217
+ HV: tl.constexpr,
218
+ BLOCK_D: tl.constexpr,
219
+ BLOCK_HV: tl.constexpr,
220
+ ):
221
+ i_n, i_t, i_d = tl.program_id(0), tl.program_id(1), tl.program_id(2)
222
+ if i_n >= N:
223
+ return
224
+ bos = tl.load(cu_seqlens + i_n).to(tl.int64)
225
+ eos = tl.load(cu_seqlens + i_n + 1).to(tl.int64)
226
+ if i_t >= eos - bos:
227
+ return
228
+ state_idx = tl.load(state_indices + i_n * stride_idx_seq).to(tl.int64)
229
+ if state_idx <= 0:
230
+ return
231
+ dst = ring + state_idx * stride_ring_page + i_t * stride_ring_tok
232
+ o_d = i_d * BLOCK_D + tl.arange(0, BLOCK_D)
233
+ m_d = o_d < D
234
+ vals = tl.load(x + (bos + i_t) * stride_x_tok + o_d, mask=m_d)
235
+ tl.store(dst + o_d, vals.to(dst.dtype.element_ty), mask=m_d)
236
+ if i_d == 0:
237
+ o_h = tl.arange(0, BLOCK_HV)
238
+ m_h = o_h < HV
239
+ vb = tl.load(b + (bos + i_t) * stride_b_tok + o_h, mask=m_h)
240
+ va = tl.load(a + (bos + i_t) * stride_a_tok + o_h, mask=m_h)
241
+ tl.store(dst + D + o_h, vb.to(dst.dtype.element_ty), mask=m_h)
242
+ tl.store(dst + D + HV + o_h, va.to(dst.dtype.element_ty), mask=m_h)
243
+
244
+
245
+ def gdn_ring_write(
246
+ mixed_qkv: torch.Tensor,
247
+ b: torch.Tensor,
248
+ a: torch.Tensor,
249
+ ring: torch.Tensor,
250
+ state_indices: torch.Tensor,
251
+ cu_seqlens: torch.Tensor,
252
+ num_seqs: int,
253
+ ) -> None:
254
+ """Cache this window's post-conv q/k/v and raw b/a gates in the ring."""
255
+ if num_seqs == 0:
256
+ return
257
+ D = mixed_qkv.shape[-1]
258
+ HV = b.shape[-1]
259
+ assert ring.shape[-1] == D + 2 * HV, (ring.shape, D, HV)
260
+ assert mixed_qkv.stride(-1) == 1 and b.stride(-1) == 1 and a.stride(-1) == 1
261
+ max_tok = ring.shape[1]
262
+ BLOCK_D = 1024
263
+ grid = (num_seqs, max_tok, triton.cdiv(D, BLOCK_D))
264
+ gdn_ring_write_kernel[grid](
265
+ mixed_qkv,
266
+ b,
267
+ a,
268
+ ring,
269
+ state_indices,
270
+ cu_seqlens,
271
+ num_seqs,
272
+ stride_x_tok=mixed_qkv.stride(0),
273
+ stride_b_tok=b.stride(0),
274
+ stride_a_tok=a.stride(0),
275
+ stride_ring_page=ring.stride(0),
276
+ stride_ring_tok=ring.stride(1),
277
+ stride_idx_seq=state_indices.stride(0),
278
+ D=D,
279
+ HV=HV,
280
+ BLOCK_D=BLOCK_D,
281
+ BLOCK_HV=triton.next_power_of_2(HV),
282
+ num_warps=4,
283
+ )
284
+
285
+
286
+ # ---------------------------------------------------------------------------
287
+ # Faster kernels for long windows (VLLM_GDN_REPLAY_FAST=1). Each one keeps the
288
+ # stock per-element arithmetic (same ops, same order, same dtypes) and only
289
+ # changes scheduling, so results stay bit-identical to the stock kernels.
290
+ # ---------------------------------------------------------------------------
291
+
292
+
293
+ def gdn_replay_fast_enabled() -> bool:
294
+ return os.environ.get("VLLM_GDN_REPLAY_FAST", "1") == "1"
295
+
296
+
297
+ def gdn_replay_chunked_mode() -> str:
298
+ """VLLM_GDN_REPLAY_CHUNKED: "" (off), "1"/"prefill" (verify with the
299
+ configured GDN prefill chunk kernel), "fla" (FLA Triton chunk kernel)."""
300
+ v = os.environ.get("VLLM_GDN_REPLAY_CHUNKED", "0").strip().lower()
301
+ if v in ("", "0", "false", "off"):
302
+ return ""
303
+ return "fla" if v == "fla" else "prefill"
304
+
305
+
306
+ @triton.jit
307
+ def gdn_spec_conv_kernel(
308
+ x,
309
+ w,
310
+ bias,
311
+ conv_state,
312
+ conv_state_indices,
313
+ num_accepted_tokens,
314
+ query_start_loc,
315
+ out,
316
+ N,
317
+ stride_x_tok: tl.int64,
318
+ stride_o_tok: tl.int64,
319
+ stride_w_dim: tl.constexpr,
320
+ stride_w_width: tl.constexpr,
321
+ stride_cs_seq: tl.int64,
322
+ stride_cs_dim: tl.constexpr,
323
+ stride_cs_tok: tl.constexpr,
324
+ stride_idx: tl.constexpr,
325
+ D: tl.constexpr,
326
+ HAS_BIAS: tl.constexpr,
327
+ SILU_ACTIVATION: tl.constexpr,
328
+ BLOCK_T: tl.constexpr,
329
+ BLOCK_N: tl.constexpr,
330
+ ):
331
+ """Token-parallel version of _causal_conv1d_update_kernel's spec-decode
332
+ path for KERNEL_WIDTH == 4 (same products/sums per output element)."""
333
+ i_n, i_f = tl.program_id(0), tl.program_id(1)
334
+ if i_n >= N:
335
+ return
336
+ s = tl.load(conv_state_indices + i_n * stride_idx).to(tl.int64)
337
+ if s == 0: # NULL_BLOCK_ID
338
+ return
339
+ bos = tl.load(query_start_loc + i_n).to(tl.int64)
340
+ eos = tl.load(query_start_loc + i_n + 1).to(tl.int64)
341
+ L = eos - bos
342
+ if L == 0:
343
+ return
344
+ off = tl.load(num_accepted_tokens + i_n).to(tl.int64) - 1
345
+
346
+ feats = i_f * BLOCK_N + tl.arange(0, BLOCK_N)
347
+ mf = feats < D
348
+ cs = conv_state + s * stride_cs_seq + feats * stride_cs_dim
349
+ h0 = tl.load(cs + (off + 0) * stride_cs_tok, mask=mf, other=0.0)
350
+ h1 = tl.load(cs + (off + 1) * stride_cs_tok, mask=mf, other=0.0)
351
+ h2 = tl.load(cs + (off + 2) * stride_cs_tok, mask=mf, other=0.0)
352
+ wb = w + feats * stride_w_dim
353
+ w0 = tl.load(wb + 0 * stride_w_width, mask=mf, other=0.0)
354
+ w1 = tl.load(wb + 1 * stride_w_width, mask=mf, other=0.0)
355
+ w2 = tl.load(wb + 2 * stride_w_width, mask=mf, other=0.0)
356
+ w3 = tl.load(wb + 3 * stride_w_width, mask=mf, other=0.0)
357
+ if HAS_BIAS:
358
+ acc_preload = tl.load(bias + feats, mask=mf, other=0.0).to(tl.float32)
359
+ else:
360
+ acc_preload = tl.zeros((BLOCK_N,), dtype=tl.float32)
361
+
362
+ # new history head = [h1, h2]; the rest is this window's inputs
363
+ tl.store(cs + 0 * stride_cs_tok, h1, mask=mf)
364
+ tl.store(cs + 1 * stride_cs_tok, h2, mask=mf)
365
+
366
+ xb = x + bos * stride_x_tok + feats[None, :]
367
+ ob = out + bos * stride_o_tok + feats[None, :]
368
+ for t0 in range(0, L, BLOCK_T):
369
+ tt = t0 + tl.arange(0, BLOCK_T)
370
+ mt = tt < L
371
+ m2 = mt[:, None] & mf[None, :]
372
+ # V[t + j] for j = 0..3: x[t + j - 3] when t + j >= 3, else history h_{t+j}
373
+ r0 = tt - 3
374
+ r1 = tt - 2
375
+ r2 = tt - 1
376
+ x0 = tl.load(xb + r0[:, None] * stride_x_tok, mask=m2 & (r0 >= 0)[:, None], other=0.0)
377
+ x1 = tl.load(xb + r1[:, None] * stride_x_tok, mask=m2 & (r1 >= 0)[:, None], other=0.0)
378
+ x2 = tl.load(xb + r2[:, None] * stride_x_tok, mask=m2 & (r2 >= 0)[:, None], other=0.0)
379
+ x3 = tl.load(xb + tt[:, None] * stride_x_tok, mask=m2, other=0.0)
380
+ hv0 = tl.where((tt == 0)[:, None], h0[None, :], tl.where((tt == 1)[:, None], h1[None, :], h2[None, :]))
381
+ hv1 = tl.where((tt == 0)[:, None], h1[None, :], h2[None, :])
382
+ v0 = tl.where((r0 >= 0)[:, None], x0, hv0)
383
+ v1 = tl.where((r1 >= 0)[:, None], x1, hv1)
384
+ v2 = tl.where((r2 >= 0)[:, None], x2, h2[None, :])
385
+
386
+ acc = tl.zeros((BLOCK_T, BLOCK_N), dtype=tl.float32) + acc_preload[None, :]
387
+ acc += v0 * w0[None, :]
388
+ acc += v1 * w1[None, :]
389
+ acc += v2 * w2[None, :]
390
+ acc += x3 * w3[None, :]
391
+ if SILU_ACTIVATION:
392
+ acc = acc / (1 + tl.exp(-acc))
393
+ tl.store(ob + tt[:, None] * stride_o_tok, acc, mask=m2)
394
+ tl.store(cs[None, :] + (2 + tt)[:, None] * stride_cs_tok, x3, mask=m2)
395
+
396
+
397
+ def gdn_spec_conv(
398
+ x: torch.Tensor,
399
+ conv_state: torch.Tensor,
400
+ weight: torch.Tensor,
401
+ bias: torch.Tensor | None,
402
+ activation: str | None,
403
+ conv_state_indices: torch.Tensor,
404
+ num_accepted_tokens: torch.Tensor,
405
+ query_start_loc: torch.Tensor,
406
+ num_seqs: int,
407
+ ) -> torch.Tensor:
408
+ """Drop-in for causal_conv1d_update(..., num_accepted_tokens=...,
409
+ query_start_loc=...) on the spec-decode window (kernel width 4)."""
410
+ assert weight.shape[1] == 4
411
+ assert x.dtype == conv_state.dtype
412
+ D = x.shape[-1]
413
+ out = torch.empty_like(x)
414
+ if num_seqs == 0:
415
+ return out
416
+ assert x.stride(-1) == 1
417
+ BLOCK_N = 64
418
+ grid = (num_seqs, triton.cdiv(D, BLOCK_N))
419
+ gdn_spec_conv_kernel[grid](
420
+ x,
421
+ weight,
422
+ bias,
423
+ conv_state,
424
+ conv_state_indices,
425
+ num_accepted_tokens,
426
+ query_start_loc,
427
+ out,
428
+ num_seqs,
429
+ stride_x_tok=x.stride(0),
430
+ stride_o_tok=out.stride(0),
431
+ stride_w_dim=weight.stride(0),
432
+ stride_w_width=weight.stride(1),
433
+ stride_cs_seq=conv_state.stride(0),
434
+ stride_cs_dim=conv_state.stride(1),
435
+ stride_cs_tok=conv_state.stride(2),
436
+ stride_idx=conv_state_indices.stride(0),
437
+ D=D,
438
+ HAS_BIAS=bias is not None,
439
+ SILU_ACTIVATION=activation in ("silu", "swish"),
440
+ BLOCK_T=32,
441
+ BLOCK_N=BLOCK_N,
442
+ num_warps=4,
443
+ )
444
+ return out
445
+
446
+
447
+ @triton.jit(do_not_specialize=["N"])
448
+ def gdn_verify_kernel(
449
+ A_log,
450
+ a,
451
+ b,
452
+ dt_bias,
453
+ q,
454
+ k,
455
+ v,
456
+ o,
457
+ h,
458
+ cu_seqlens,
459
+ state_indices,
460
+ scale,
461
+ beta,
462
+ threshold,
463
+ N,
464
+ stride_h_page: tl.int64,
465
+ stride_idx_seq: tl.constexpr,
466
+ H: tl.constexpr,
467
+ HV: tl.constexpr,
468
+ K: tl.constexpr,
469
+ V: tl.constexpr,
470
+ BK: tl.constexpr,
471
+ BV: tl.constexpr,
472
+ USE_QK_L2NORM_IN_KERNEL: tl.constexpr,
473
+ FIRST_ONLY: tl.constexpr = False,
474
+ ):
475
+ """fused_sigmoid_gating_delta_rule_update_kernel (non-KDA, varlen) with the
476
+ initial state read from the request's slot, only token 0's state written
477
+ back, and the next token's inputs prefetched one step ahead."""
478
+ i_k, i_v, i_nh = tl.program_id(0), tl.program_id(1), tl.program_id(2)
479
+ i_n, i_hv = i_nh // HV, i_nh % HV
480
+ i_h = i_hv // (HV // H)
481
+ if i_n >= N:
482
+ return
483
+ bos = tl.load(cu_seqlens + i_n).to(tl.int64)
484
+ eos = tl.load(cu_seqlens + i_n + 1).to(tl.int64)
485
+ T = eos - bos
486
+ if T == 0:
487
+ return
488
+ if FIRST_ONLY:
489
+ # exact recurrent step for the window's first token only
490
+ T = tl.minimum(T, 1)
491
+ state_idx = tl.load(state_indices + i_n * stride_idx_seq).to(tl.int64)
492
+ if state_idx <= 0:
493
+ return
494
+
495
+ o_k = i_k * BK + tl.arange(0, BK)
496
+ o_v = i_v * BV + tl.arange(0, BV)
497
+
498
+ p_q = q + (bos * H + i_h) * K + o_k
499
+ p_k = k + (bos * H + i_h) * K + o_k
500
+ p_v = v + (bos * HV + i_hv) * V + o_v
501
+ p_a = a + bos * HV + i_hv
502
+ p_b = b + bos * HV + i_hv
503
+ p_o = o + (bos * HV + i_hv) * V + o_v
504
+ p_A_log = A_log + i_hv
505
+ p_dt_bias = dt_bias + i_hv
506
+
507
+ mask_k = o_k < K
508
+ mask_v = o_v < V
509
+ mask_h = mask_v[:, None] & mask_k[None, :]
510
+
511
+ p_h = h + state_idx * stride_h_page + i_hv * V * K + o_v[:, None] * K + o_k[None, :]
512
+ b_h = tl.zeros([BV, BK], dtype=tl.float32)
513
+ b_h += tl.load(p_h, mask=mask_h, other=0).to(tl.float32)
514
+
515
+ n_q = tl.load(p_q, mask=mask_k, other=0)
516
+ n_k = tl.load(p_k, mask=mask_k, other=0)
517
+ n_v = tl.load(p_v, mask=mask_v, other=0)
518
+ n_b = tl.load(p_b)
519
+ n_a = tl.load(p_a)
520
+ for i_t in range(0, T):
521
+ b_q = n_q.to(tl.float32)
522
+ b_k = n_k.to(tl.float32)
523
+ b_v = n_v.to(tl.float32)
524
+ b_b = n_b.to(tl.float32)
525
+ c_a = n_a
526
+ nxt = i_t + 1 < T
527
+ p_q += H * K
528
+ p_k += H * K
529
+ p_v += HV * V
530
+ p_b += HV
531
+ p_a += HV
532
+ n_q = tl.load(p_q, mask=mask_k & nxt, other=0)
533
+ n_k = tl.load(p_k, mask=mask_k & nxt, other=0)
534
+ n_v = tl.load(p_v, mask=mask_v & nxt, other=0)
535
+ n_b = tl.load(p_b, mask=nxt, other=0)
536
+ n_a = tl.load(p_a, mask=nxt, other=0)
537
+
538
+ x = c_a.to(tl.float32) + tl.load(p_dt_bias).to(tl.float32)
539
+ softplus_x = tl.where(
540
+ beta * x <= threshold, (1 / beta) * tl.log(1 + tl.exp(beta * x)), x
541
+ )
542
+ b_g = -tl.exp(tl.load(p_A_log).to(tl.float32)) * softplus_x
543
+
544
+ b_beta = tl.sigmoid(b_b.to(tl.float32))
545
+
546
+ if USE_QK_L2NORM_IN_KERNEL:
547
+ b_q = b_q * (tl.rsqrt(tl.sum(b_q * b_q) + 1e-6))
548
+ b_k = b_k * (tl.rsqrt(tl.sum(b_k * b_k) + 1e-6))
549
+ b_q = b_q * scale
550
+ b_h *= tl.exp(b_g)
551
+ b_v -= tl.sum(b_h * b_k[None, :], 1)
552
+ b_v *= b_beta
553
+ b_h += b_v[:, None] * b_k[None, :]
554
+ b_o = tl.sum(b_h * b_q[None, :], 1)
555
+ tl.store(p_o, b_o.to(p_o.dtype.element_ty), mask=mask_v)
556
+ if i_t == 0:
557
+ tl.store(p_h, b_h.to(p_h.dtype.element_ty), mask=mask_h)
558
+ p_o += HV * V
559
+
560
+
561
+ def gdn_verify(
562
+ A_log: torch.Tensor,
563
+ a: torch.Tensor,
564
+ b: torch.Tensor,
565
+ dt_bias: torch.Tensor,
566
+ q: torch.Tensor,
567
+ k: torch.Tensor,
568
+ v: torch.Tensor,
569
+ ssm_state: torch.Tensor,
570
+ cu_seqlens: torch.Tensor,
571
+ state_indices: torch.Tensor,
572
+ num_seqs: int,
573
+ beta: float = 1.0,
574
+ threshold: float = 20.0,
575
+ scale: float | None = None,
576
+ use_qk_l2norm_in_kernel: bool = True,
577
+ out: torch.Tensor | None = None,
578
+ first_token_only: bool = False,
579
+ ) -> torch.Tensor:
580
+ """Same outputs as the stock spec-decode call; writes only token 0's state.
581
+ first_token_only: run just the window's first token (state + its output)."""
582
+ B, T, H, K, V = *k.shape, v.shape[-1]
583
+ HV = v.shape[2]
584
+ BK, BV = triton.next_power_of_2(K), min(triton.next_power_of_2(V), 32)
585
+ NK, NV = triton.cdiv(K, BK), triton.cdiv(V, BV)
586
+ assert NK == 1 and B == 1
587
+ if scale is None:
588
+ scale = k.shape[-1] ** -0.5
589
+ if out is not None:
590
+ assert out.is_contiguous() and out.numel() == v.numel()
591
+ o = out.view(NK, *v.shape)
592
+ else:
593
+ o = q.new_empty(NK, *v.shape)
594
+ if num_seqs > 0:
595
+ grid = (NK, NV, num_seqs * HV)
596
+ gdn_verify_kernel[grid](
597
+ A_log=A_log,
598
+ a=a.contiguous(),
599
+ b=b.contiguous(),
600
+ dt_bias=dt_bias,
601
+ q=q.contiguous(),
602
+ k=k.contiguous(),
603
+ v=v.contiguous(),
604
+ o=o,
605
+ h=ssm_state,
606
+ cu_seqlens=cu_seqlens,
607
+ state_indices=state_indices,
608
+ scale=scale,
609
+ beta=beta,
610
+ threshold=threshold,
611
+ N=num_seqs,
612
+ stride_h_page=ssm_state.stride(0),
613
+ stride_idx_seq=state_indices.stride(0),
614
+ H=H,
615
+ HV=HV,
616
+ K=K,
617
+ V=V,
618
+ BK=BK,
619
+ BV=BV,
620
+ USE_QK_L2NORM_IN_KERNEL=use_qk_l2norm_in_kernel,
621
+ FIRST_ONLY=first_token_only,
622
+ num_warps=4,
623
+ num_stages=3,
624
+ )
625
+ return o.squeeze(0)
626
+
627
+
628
+ # ---------------------------------------------------------------------------
629
+ # Batched replay (VLLM_GDN_REPLAY_BATCHED=1): the replay of every GDN layer's
630
+ # accepted tokens depends only on the previous step (ring + slot), not on this
631
+ # step's activations, so the first GDN layer replays all layers in one launch
632
+ # (48x more independent programs than a per-layer launch). Same arithmetic.
633
+ # ---------------------------------------------------------------------------
634
+
635
+
636
+ def gdn_replay_batched_enabled() -> bool:
637
+ return os.environ.get("VLLM_GDN_REPLAY_BATCHED", "1") == "1"
638
+
639
+
640
+ @triton.jit(do_not_specialize=["N"])
641
+ def gdn_replay_multi_kernel(
642
+ A_log0,
643
+ dt_bias0,
644
+ ring0,
645
+ h0,
646
+ A_log_tab,
647
+ dt_bias_tab,
648
+ ring_tab,
649
+ h_tab,
650
+ slot_tab,
651
+ num_accepted_tokens,
652
+ scale,
653
+ beta,
654
+ threshold,
655
+ N,
656
+ stride_ring_page: tl.int64,
657
+ stride_ring_tok: tl.constexpr,
658
+ stride_h_page: tl.int64,
659
+ H: tl.constexpr,
660
+ HV: tl.constexpr,
661
+ K: tl.constexpr,
662
+ V: tl.constexpr,
663
+ BK: tl.constexpr,
664
+ BV: tl.constexpr,
665
+ USE_QK_L2NORM_IN_KERNEL: tl.constexpr,
666
+ ):
667
+ i_k, i_v, i_lnh = tl.program_id(0), tl.program_id(1), tl.program_id(2)
668
+ i_ln, i_hv = i_lnh // HV, i_lnh % HV
669
+ layer, i_n = i_ln // N, i_ln % N
670
+ i_h = i_hv // (HV // H)
671
+
672
+ n_rep = tl.load(num_accepted_tokens + i_n).to(tl.int64) - 1
673
+ if n_rep <= 0:
674
+ return
675
+ state_idx = tl.load(slot_tab + layer * N + i_n).to(tl.int64)
676
+ if state_idx <= 0:
677
+ return
678
+ # per-layer element offsets from layer 0's tensors (checked multiples of 64)
679
+ ring = ring0 + tl.multiple_of(tl.load(ring_tab + layer), 64)
680
+ h = h0 + tl.multiple_of(tl.load(h_tab + layer), 64)
681
+ A_log = A_log0 + tl.load(A_log_tab + layer)
682
+ dt_bias = dt_bias0 + tl.load(dt_bias_tab + layer)
683
+
684
+ o_k = i_k * BK + tl.arange(0, BK)
685
+ o_v = i_v * BV + tl.arange(0, BV)
686
+
687
+ base = ring + state_idx * stride_ring_page + stride_ring_tok
688
+ p_q = base + i_h * K + o_k
689
+ p_k = base + H * K + i_h * K + o_k
690
+ p_v = base + 2 * H * K + i_hv * V + o_v
691
+ p_b = base + 2 * H * K + HV * V + i_hv
692
+ p_a = base + 2 * H * K + HV * V + HV + i_hv
693
+
694
+ p_A_log = A_log + i_hv
695
+ p_dt_bias = dt_bias + i_hv
696
+
697
+ mask_k = o_k < K
698
+ mask_v = o_v < V
699
+ mask_h = mask_v[:, None] & mask_k[None, :]
700
+
701
+ p_h = h + state_idx * stride_h_page + i_hv * V * K + o_v[:, None] * K + o_k[None, :]
702
+ b_h = tl.zeros([BV, BK], dtype=tl.float32)
703
+ b_h += tl.load(p_h, mask=mask_h, other=0).to(tl.float32)
704
+
705
+ n_q = tl.load(p_q, mask=mask_k, other=0)
706
+ n_k = tl.load(p_k, mask=mask_k, other=0)
707
+ n_v = tl.load(p_v, mask=mask_v, other=0)
708
+ n_b = tl.load(p_b)
709
+ n_a = tl.load(p_a)
710
+ for i_t in range(0, n_rep):
711
+ b_q = n_q.to(tl.float32)
712
+ b_k = n_k.to(tl.float32)
713
+ b_v = n_v.to(tl.float32)
714
+ b_b = n_b.to(tl.float32)
715
+ c_a = n_a
716
+ nxt = i_t + 1 < n_rep
717
+ p_q += stride_ring_tok
718
+ p_k += stride_ring_tok
719
+ p_v += stride_ring_tok
720
+ p_b += stride_ring_tok
721
+ p_a += stride_ring_tok
722
+ n_q = tl.load(p_q, mask=mask_k & nxt, other=0)
723
+ n_k = tl.load(p_k, mask=mask_k & nxt, other=0)
724
+ n_v = tl.load(p_v, mask=mask_v & nxt, other=0)
725
+ n_b = tl.load(p_b, mask=nxt, other=0)
726
+ n_a = tl.load(p_a, mask=nxt, other=0)
727
+
728
+ x = c_a.to(tl.float32) + tl.load(p_dt_bias).to(tl.float32)
729
+ softplus_x = tl.where(
730
+ beta * x <= threshold, (1 / beta) * tl.log(1 + tl.exp(beta * x)), x
731
+ )
732
+ b_g = -tl.exp(tl.load(p_A_log).to(tl.float32)) * softplus_x
733
+
734
+ b_beta = tl.sigmoid(b_b.to(tl.float32))
735
+
736
+ if USE_QK_L2NORM_IN_KERNEL:
737
+ b_q = b_q * (tl.rsqrt(tl.sum(b_q * b_q) + 1e-6))
738
+ b_k = b_k * (tl.rsqrt(tl.sum(b_k * b_k) + 1e-6))
739
+ b_q = b_q * scale
740
+ b_h *= tl.exp(b_g)
741
+ b_v -= tl.sum(b_h * b_k[None, :], 1)
742
+ b_v *= b_beta
743
+ b_h += b_v[:, None] * b_k[None, :]
744
+
745
+ tl.store(p_h, b_h.to(p_h.dtype.element_ty), mask=mask_h)
746
+
747
+
748
+ class GDNReplayBatch:
749
+ """Address tables for the batched replay over a fixed list of GDN layers."""
750
+
751
+ def __init__(self, layers):
752
+ self.layers = list(layers)
753
+ self.key = None
754
+ self.tabs = None
755
+
756
+ def _refresh(self, device):
757
+ key = tuple(
758
+ (l.kv_cache[1].data_ptr(), l.kv_cache[2].data_ptr()) for l in self.layers
759
+ )
760
+ if key == self.key:
761
+ return
762
+ l0 = self.layers[0]
763
+
764
+ def offs(get, esize, align):
765
+ base = get(l0).data_ptr()
766
+ out = []
767
+ for l in self.layers:
768
+ d = get(l).data_ptr() - base
769
+ assert d % (esize * align) == 0, (d, esize, align)
770
+ out.append(d // esize)
771
+ return out
772
+
773
+ ring = offs(lambda l: l.kv_cache[2], 2, 64)
774
+ h = offs(lambda l: l.kv_cache[1], 4, 64)
775
+ alog = offs(lambda l: l.A_log, 4, 1)
776
+ dtb = offs(lambda l: l.dt_bias, l0.dt_bias.element_size(), 1)
777
+ for l in self.layers:
778
+ assert l.kv_cache[2].stride() == l0.kv_cache[2].stride()
779
+ assert l.kv_cache[1].stride() == l0.kv_cache[1].stride()
780
+ assert l.dt_bias.dtype == l0.dt_bias.dtype
781
+ new = torch.tensor([ring, h, alog, dtb], dtype=torch.int64, device=device)
782
+ if self.tabs is None or self.tabs.shape != new.shape:
783
+ self.tabs = new
784
+ else:
785
+ self.tabs.copy_(new) # keep the address stable for captured graphs
786
+ self.key = key
787
+
788
+ def run(self, slot_indices, num_accepted_tokens, num_seqs: int, scale: float,
789
+ beta: float = 1.0, threshold: float = 20.0):
790
+ """slot_indices: list (one per layer) of [>=num_seqs] int32 slot views."""
791
+ if num_seqs == 0:
792
+ return
793
+ l0 = self.layers[0]
794
+ ring0, h0 = l0.kv_cache[2], l0.kv_cache[1]
795
+ assert l0.A_log.dtype == torch.float32
796
+ assert l0.dt_bias.dtype in (torch.bfloat16, torch.float32)
797
+ assert ring0.dtype == torch.bfloat16 and h0.dtype == torch.float32
798
+ self._refresh(ring0.device)
799
+ slot_tab = torch.stack([s[:num_seqs] for s in slot_indices]).contiguous()
800
+ HV, V, K = h0.shape[-3:]
801
+ H = l0.num_k_heads // l0.tp_size
802
+ # BV 32 (stock tile) measured fastest here; 16/8 are also bit-identical.
803
+ BK = triton.next_power_of_2(K)
804
+ BV = min(triton.next_power_of_2(V), int(os.environ.get("VLLM_GDN_REPLAY_BV", "32")))
805
+ NL = len(self.layers)
806
+ grid = (triton.cdiv(K, BK), triton.cdiv(V, BV), NL * num_seqs * HV)
807
+ gdn_replay_multi_kernel[grid](
808
+ l0.A_log,
809
+ l0.dt_bias,
810
+ ring0,
811
+ h0,
812
+ self.tabs[2],
813
+ self.tabs[3],
814
+ self.tabs[0],
815
+ self.tabs[1],
816
+ slot_tab,
817
+ num_accepted_tokens,
818
+ scale,
819
+ beta,
820
+ threshold,
821
+ num_seqs,
822
+ stride_ring_page=ring0.stride(0),
823
+ stride_ring_tok=ring0.stride(1),
824
+ stride_h_page=h0.stride(0),
825
+ H=H,
826
+ HV=HV,
827
+ K=K,
828
+ V=V,
829
+ BK=BK,
830
+ BV=BV,
831
+ USE_QK_L2NORM_IN_KERNEL=True,
832
+ num_warps=4,
833
+ num_stages=3,
834
+ )
runtime/counsel_runtime/serve.py ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """`counsel-serve-vllm` / `counsel-serve-sglang`: OpenAI-compatible Counsel server with the recommended settings.
2
+
3
+ usage: counsel-serve-vllm <model dir> [--mode drafter|mtp|plain|copy] [--draft-tokens N] [--name counsel-27b]
4
+ [--host 0.0.0.0] [--port 8000] [--gpus 1] [extra server args...]
5
+ counsel-serve-sglang <model dir> [same options]
6
+
7
+ --mode picks how the server generates. Every mode serves the same Counsel weights from the same package (BF16 or FP8);
8
+ only the speed changes, so the mode is the operator's choice:
9
+ drafter (default) the Counsel drafter in <model dir>/drafter proposes 15 tokens per step (DFlash2, block 16);
10
+ fastest for one to a few users at a time
11
+ mtp the built-in multi-token-prediction head proposes 7 tokens per step
12
+ plain one token per step; most total throughput when many users share the server
13
+ copy document editing, thinking off by default. On vLLM, drafts are copied from the document in the
14
+ prompt (n-gram lookup, up to 256 tokens per step with Counsel's GDN replay kernel, see
15
+ counsel-install-kernels; up to 16 requests at once). SGLang has no prompt-lookup drafting, so
16
+ there it runs the Counsel drafter.
17
+ Changing mode means restarting the server with another --mode; the model files stay the same.
18
+ The context window is 131,072 tokens (128K) in every mode; it fits one 80 GB H100 in BF16. Pass --max-model-len
19
+ (vLLM) or --context-length (SGLang) to change it. Up to 256 requests run at once (hybrid models need one
20
+ recurrent-state slot per running request). --gpus N runs N data-parallel replicas, one per GPU (the 27B model fits on
21
+ one 80-96 GB GPU in BF16); other server flags pass straight through, e.g. --tensor-parallel-size 2 to split one
22
+ replica over two GPUs.
23
+ Thinking is on by default at reasoning effort xhigh (the benchmarked setting); a request can override it with
24
+ chat_template_kwargs {"enable_thinking": false} or {"reasoning_effort": "low" | "medium"}.
25
+ Tool calls and reasoning come back in the standard OpenAI fields (tool_calls, reasoning_content).
26
+ """
27
+ import argparse
28
+ import hashlib
29
+ import importlib.util
30
+ import json
31
+ import os
32
+ import sys
33
+
34
+ CONTEXT = 131072 # Counsel's context window (128K)
35
+ TEMPLATE_KWARGS = {"enable_thinking": True, "reasoning_effort": "xhigh", "preserve_thinking": True}
36
+ EDIT_TEMPLATE_KWARGS = {"enable_thinking": False} # copy mode: document editing answers directly
37
+ REASONING_PARSER, TOOL_PARSER = "qwen3", "qwen3_coder" # Counsel's reasoning and tool-call formats in vLLM/SGLang
38
+ KERNEL_CONFIG = {"architectures": ["Qwen3_5ForCausalLM"], "model_type": "qwen3_5_text"} # SGLang kernel family
39
+ MODES = {"drafter": 15, "mtp": 7, "plain": 0, "copy": 256} # draft tokens per step (the benchmarked settings)
40
+ MAX_RUNNING, COPY_MAX_RUNNING = 256, 16
41
+
42
+
43
+ def _args(argv):
44
+ p = argparse.ArgumentParser()
45
+ p.add_argument("model")
46
+ p.add_argument("--mode", choices=list(MODES), default="drafter")
47
+ p.add_argument("--draft-tokens", type=int, default=None)
48
+ p.add_argument("--name", default="counsel-27b")
49
+ p.add_argument("--host", default="0.0.0.0")
50
+ p.add_argument("--port", type=int, default=8000)
51
+ p.add_argument("--gpus", type=int, default=1)
52
+ return p.parse_known_args(argv)
53
+
54
+
55
+ def _drafter(model: str) -> str:
56
+ draft = os.path.join(os.path.abspath(model), "drafter")
57
+ if not os.path.isfile(os.path.join(draft, "config.json")):
58
+ sys.exit(f"--mode drafter: no Counsel drafter in {draft}; use --mode mtp, plain or copy")
59
+ return draft
60
+
61
+
62
+ def _check_mtp(model: str) -> None:
63
+ index = json.load(open(os.path.join(os.path.abspath(model), "model.safetensors.index.json")))
64
+ if not any(k.startswith("mtp.") for k in index["weight_map"]):
65
+ sys.exit(f"--mode mtp: {model} has no MTP head (mtp.* weights); use --mode drafter, plain or copy")
66
+
67
+
68
+ def replay_kernel_installed() -> bool:
69
+ spec = importlib.util.find_spec("vllm")
70
+ if spec is None:
71
+ return False
72
+ utils = os.path.join(os.path.dirname(spec.origin), "model_executor", "layers", "mamba", "mamba_utils.py")
73
+ return os.path.isfile(utils) and "GDN_REPLAY_PATCH" in open(utils).read()
74
+
75
+
76
+ def speculative_config(model: str, mode: str, draft_tokens: int | None) -> dict | None:
77
+ """vLLM --speculative-config for a mode, checked against what the package contains."""
78
+ n = draft_tokens or MODES[mode]
79
+ if mode == "plain":
80
+ return None
81
+ if mode == "mtp":
82
+ _check_mtp(model)
83
+ return {"method": "mtp", "num_speculative_tokens": n}
84
+ if mode == "copy":
85
+ return {"method": "ngram_gpu", "num_speculative_tokens": n, "prompt_lookup_max": 12, "prompt_lookup_min": 2}
86
+ return {"method": "dflash", "model": _drafter(model), "num_speculative_tokens": n}
87
+
88
+
89
+ def vllm_main(argv=None):
90
+ a, extra = _args(sys.argv[1:] if argv is None else argv)
91
+ spec = speculative_config(a.model, a.mode, a.draft_tokens)
92
+ copy = a.mode == "copy"
93
+ if copy:
94
+ if not replay_kernel_installed():
95
+ sys.exit("--mode copy needs Counsel's GDN replay kernel in vLLM: run counsel-install-kernels once")
96
+ os.environ["VLLM_GDN_REPLAY"] = "1" # one recurrent-state slot per request, rollback by replay
97
+ os.environ["VLLM_GDN_REPLAY_CHUNKED"] = "1" # verify the long draft window with the chunked prefill kernel
98
+ cmd = ["vllm", "serve", a.model, "--served-model-name", a.name, "--host", a.host, "--port", str(a.port),
99
+ "--data-parallel-size", str(a.gpus), "--tensor-parallel-size", "1", "--max-model-len", str(CONTEXT),
100
+ "--dtype", "bfloat16", "--trust-remote-code",
101
+ "--no-enable-prefix-caching" if copy else "--enable-prefix-caching",
102
+ "--enable-auto-tool-choice", "--tool-call-parser", TOOL_PARSER, "--reasoning-parser", REASONING_PARSER,
103
+ "--default-chat-template-kwargs", json.dumps(EDIT_TEMPLATE_KWARGS if copy else TEMPLATE_KWARGS),
104
+ "--gpu-memory-utilization", "0.95", "--max-num-seqs", str(COPY_MAX_RUNNING if copy else MAX_RUNNING),
105
+ *(["--compilation-config", json.dumps({"cudagraph_mode": "PIECEWISE"})] if copy else []),
106
+ *(["--speculative-config", json.dumps(spec)] if spec else []), *extra]
107
+ print(f"counsel-serve-vllm: mode {a.mode}" + (f", {spec['num_speculative_tokens']} draft tokens per step" if spec else ""),
108
+ flush=True)
109
+ os.environ.setdefault("VLLM_WORKER_MULTIPROC_METHOD", "spawn")
110
+ os.environ.setdefault("VLLM_USE_DEEP_GEMM", "0") # FP8: CUTLASS block kernels; DeepGEMM's JIT needs nvcc >= 12.9
111
+ os.environ["PATH"] = os.path.dirname(sys.executable) + os.pathsep + os.environ.get("PATH", "") # JIT kernels need ninja
112
+ os.execvp(cmd[0], cmd)
113
+
114
+
115
+ def _write_json(path: str, obj) -> None:
116
+ with open(path + ".tmp", "w") as fh:
117
+ json.dump(obj, fh, indent=2)
118
+ os.replace(path + ".tmp", path)
119
+
120
+
121
+ def sglang_view(model: str) -> str:
122
+ """A cache directory that links the Counsel package's model files and carries a config.json naming SGLang's kernel
123
+ family for this architecture (SGLang selects its hybrid-attention cache, kernels and MTP head by architecture name).
124
+ The drafter is passed to SGLang separately."""
125
+ model = os.path.abspath(model)
126
+ cfg = json.load(open(os.path.join(model, "config.json")))
127
+ view = os.path.join(os.path.expanduser("~/.cache/counsel_runtime"), "sglang-" + hashlib.sha1(model.encode()).hexdigest()[:12])
128
+ os.makedirs(view, exist_ok=True)
129
+ links = {f for f in os.listdir(model) if f not in ("config.json", "configuration_counsel.py", "modeling_counsel.py",
130
+ "drafter", "runtime")}
131
+ for f in os.listdir(view):
132
+ if os.path.islink(os.path.join(view, f)) and f not in links:
133
+ os.unlink(os.path.join(view, f))
134
+ for f in links:
135
+ dst = os.path.join(view, f)
136
+ if not os.path.lexists(dst):
137
+ os.symlink(os.path.join(model, f), dst)
138
+ _write_json(os.path.join(view, "config.json"), {k: v for k, v in cfg.items() if k != "auto_map"} | KERNEL_CONFIG)
139
+ return view
140
+
141
+
142
+ def sglang_speculative_args(model: str, mode: str, draft_tokens: int | None) -> list[str]:
143
+ if mode == "plain":
144
+ return []
145
+ if mode in ("drafter", "copy"): # the block size (16) comes from the drafter's config; SGLang's n-gram drafter
146
+ # seeds from the last few prompt tokens only, so document copying runs on the Counsel drafter here
147
+ return ["--speculative-algorithm", "DFLASH", "--speculative-draft-model-path", _drafter(model)]
148
+ if mode == "mtp":
149
+ _check_mtp(model)
150
+ n = draft_tokens or MODES["mtp"]
151
+ return ["--speculative-algorithm", "NEXTN", "--speculative-num-steps", str(n), "--speculative-eagle-topk", "1",
152
+ "--speculative-num-draft-tokens", str(n + 1)]
153
+ raise ValueError(mode)
154
+
155
+
156
+ def _ssm_dtype_args(model: str) -> list[str]:
157
+ """The recurrent-state precision config.json asks for (float32), as vLLM applies it."""
158
+ dtype = json.load(open(os.path.join(os.path.abspath(model), "config.json"))).get("mamba_ssm_dtype")
159
+ return ["--mamba-ssm-dtype", dtype] if dtype else []
160
+
161
+
162
+ def sglang_main(argv=None):
163
+ a, extra = _args(sys.argv[1:] if argv is None else argv)
164
+ spec = sglang_speculative_args(a.model, a.mode, a.draft_tokens)
165
+ copy = a.mode == "copy"
166
+ os.environ.setdefault("SGLANG_ENABLE_JIT_DEEPGEMM", "0") # FP8: Triton/CUTLASS kernels; DeepGEMM's JIT needs nvcc >= 12.9
167
+ if a.mode in ("drafter", "copy"): # SGLang 0.5.22 hangs capturing the DFlash2 sampler inside the draft CUDA graph
168
+ os.environ.setdefault("SGLANG_DFLASH_EAGER_DRAFT_SAMPLER", "1")
169
+ os.environ["PATH"] = os.path.dirname(sys.executable) + os.pathsep + os.environ.get("PATH", "") # JIT kernels need ninja
170
+ cmd = [sys.executable, "-m", "sglang.launch_server", "--model-path", sglang_view(a.model),
171
+ "--served-model-name", a.name, "--host", a.host, "--port", str(a.port), "--dp-size", str(a.gpus),
172
+ "--tp-size", "1", "--context-length", str(CONTEXT), "--dtype", "bfloat16",
173
+ "--reasoning-parser", REASONING_PARSER, "--tool-call-parser", TOOL_PARSER,
174
+ "--default-chat-template-kwargs", json.dumps(EDIT_TEMPLATE_KWARGS if copy else TEMPLATE_KWARGS),
175
+ "--mem-fraction-static", "0.91", "--max-running-requests", str(MAX_RUNNING),
176
+ "--watchdog-timeout", "1800", # the first start compiles kernels, longer than SGLang's 300 s default
177
+ *_ssm_dtype_args(a.model), *spec, *extra]
178
+ print(f"counsel-serve-sglang: mode {a.mode}" + (" (Counsel drafter, thinking off: prompt-lookup copy drafting "
179
+ "with the GDN replay kernel is vLLM-only)" if copy else ""), flush=True)
180
+ os.execvp(cmd[0], cmd)
runtime/counsel_runtime/vllm_model.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Counsel model for vLLM: hybrid gated linear/full attention decoder (shares vLLM's kernels for this architecture), and
2
+ its built-in multi-token-prediction head for `counsel-serve-vllm --mode mtp`."""
3
+ from contextlib import contextmanager
4
+
5
+ from vllm.model_executor.models.qwen3_5 import Qwen3_5ForCausalLM
6
+ from vllm.model_executor.models.qwen3_5_mtp import Qwen3_5MTP
7
+
8
+ _KERNEL_MODEL_TYPE = "qwen3_5_text" # the layer builders pick their dense-MLP path by this model type
9
+
10
+
11
+ @contextmanager
12
+ def _kernel_model_type(vllm_config):
13
+ cfg = vllm_config.model_config.hf_text_config
14
+ own = cfg.model_type
15
+ cfg.model_type = _KERNEL_MODEL_TYPE
16
+ try:
17
+ yield
18
+ finally:
19
+ cfg.model_type = own
20
+
21
+
22
+ class CounselForCausalLM(Qwen3_5ForCausalLM):
23
+ def __init__(self, *, vllm_config, prefix: str = ""):
24
+ with _kernel_model_type(vllm_config):
25
+ super().__init__(vllm_config=vllm_config, prefix=prefix)
26
+
27
+
28
+ class CounselMTP(Qwen3_5MTP):
29
+ """The MTP head is built from the target's config, whose model type is `counsel`."""
30
+
31
+ def __init__(self, *, vllm_config, prefix: str = ""):
32
+ with _kernel_model_type(vllm_config):
33
+ super().__init__(vllm_config=vllm_config, prefix=prefix)
runtime/counsel_runtime/vllm_plugin.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """vLLM plugin (entry point `vllm.general_plugins`): registers the Counsel config, model class and MTP head class in every
2
+ vLLM process, gives Counsel vLLM's Qwen3.5 config hook (the float32 recurrent state config.json asks for, 1-D rotary
3
+ positions), and lets `--mode mtp` find the built-in MTP head of a `counsel` checkpoint."""
4
+
5
+
6
+ def mtp_hf_config_override(hf_config):
7
+ """vLLM's draft-config override with the `counsel` model type mapped to its kernel family, whose MTP head vLLM knows,
8
+ served by CounselMTP. Module level (not a closure): vLLM pickles this override into its engine processes."""
9
+ from vllm.config.speculative import SpeculativeConfig
10
+
11
+ counsel = getattr(hf_config, "model_type", None) == "counsel"
12
+ if counsel:
13
+ hf_config.model_type = "qwen3_5_text"
14
+ original = getattr(SpeculativeConfig, "_counsel_original_override", None) or SpeculativeConfig.hf_config_override
15
+ hf_config = original(hf_config)
16
+ if counsel:
17
+ hf_config.architectures = ["CounselMTP"]
18
+ return hf_config
19
+
20
+
21
+ def register() -> None:
22
+ from vllm import ModelRegistry
23
+ from vllm.config.speculative import SpeculativeConfig
24
+
25
+ from .config import register_config
26
+
27
+ register_config()
28
+ for arch in ("CounselForCausalLM", "CounselMTP"):
29
+ if arch not in ModelRegistry.get_supported_archs():
30
+ ModelRegistry.register_model(arch, f"counsel_runtime.vllm_model:{arch}")
31
+ from vllm.model_executor.models.config import MODELS_CONFIG_MAP
32
+
33
+ MODELS_CONFIG_MAP.setdefault("CounselForCausalLM", MODELS_CONFIG_MAP["Qwen3_5ForCausalLM"])
34
+ if not hasattr(SpeculativeConfig, "_counsel_original_override"):
35
+ SpeculativeConfig._counsel_original_override = staticmethod(SpeculativeConfig.hf_config_override)
36
+ SpeculativeConfig.hf_config_override = staticmethod(mtp_hf_config_override)
runtime/pyproject.toml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "counsel-runtime"
7
+ version = "0.3.4"
8
+ description = "Serve JudicialMind Counsel models with vLLM or SGLang"
9
+ requires-python = ">=3.10"
10
+ license = { text = "CC-BY-NC-4.0" }
11
+ dependencies = ["transformers>=5.0"]
12
+
13
+ [project.optional-dependencies]
14
+ vllm = ["vllm==0.32.0"] # the GDN replay kernel (--mode copy) is built for 0.32.0
15
+ sglang = ["sglang==0.5.22"]
16
+
17
+ [project.entry-points."vllm.general_plugins"]
18
+ counsel = "counsel_runtime.vllm_plugin:register"
19
+
20
+ [project.scripts]
21
+ counsel-serve-vllm = "counsel_runtime.serve:vllm_main"
22
+ counsel-serve-sglang = "counsel_runtime.serve:sglang_main"
23
+ counsel-install-kernels = "counsel_runtime.kernels:install"
24
+
25
+ [tool.setuptools]
26
+ packages = ["counsel_runtime", "counsel_runtime.kernels"]
27
+
28
+ [tool.setuptools.package-data]
29
+ "counsel_runtime.kernels" = ["*.diff"]
runtime/smoke_api.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """API smoke test against a running Counsel server: identity, thinking split, direct mode, tool call.
2
+
3
+ usage: python smoke_api.py [base_url] [model]
4
+ """
5
+ import json
6
+ import sys
7
+ import urllib.request
8
+
9
+ URL = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:8000/v1"
10
+ MODEL = sys.argv[2] if len(sys.argv) > 2 else "counsel-27b"
11
+
12
+
13
+ def chat(messages, **kw):
14
+ body = {"model": MODEL, "messages": messages, "max_tokens": 4096, "temperature": 0.6} | kw
15
+ req = urllib.request.Request(URL + "/chat/completions", json.dumps(body).encode(), {"Content-Type": "application/json"})
16
+ return json.load(urllib.request.urlopen(req, timeout=900))["choices"][0]
17
+
18
+
19
+ ok = True
20
+ c = chat([{"role": "user", "content": "Who are you and who built you? One sentence."}],
21
+ chat_template_kwargs={"enable_thinking": False})
22
+ ans = c["message"]["content"]
23
+ print("identity:", ans.strip()[:200])
24
+ ok &= "Counsel" in ans and "Qwen" not in ans
25
+
26
+ c = chat([{"role": "user", "content": "Is a 'condition' or a 'warranty' breach grounds to terminate a contract under English law? Two sentences."}],
27
+ chat_template_kwargs={"enable_thinking": True, "reasoning_effort": "low"})
28
+ r, a = c["message"].get("reasoning_content") or c["message"].get("reasoning") or "", c["message"]["content"] or ""
29
+ print(f"thinking: reasoning {len(r)} chars, answer: {a.strip()[:200]}")
30
+ ok &= len(r) > 0 and len(a) > 0 and "<think>" not in a
31
+
32
+ tools = [{"type": "function", "function": {"name": "search_documents", "description": "Full-text search over the matter's documents.",
33
+ "parameters": {"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]}}}]
34
+ c = chat([{"role": "user", "content": "Find every termination-for-convenience clause in the supply agreements."}], tools=tools,
35
+ chat_template_kwargs={"enable_thinking": False})
36
+ calls = c["message"].get("tool_calls") or []
37
+ print("tool call:", [(t["function"]["name"], t["function"]["arguments"]) for t in calls])
38
+ ok &= bool(calls) and calls[0]["function"]["name"] == "search_documents"
39
+ print("API_SMOKE", "PASS" if ok else "FAIL")
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0997f410c57a1f4e53b09e4be8f4a172d90edd9564368fb0847030937229b9f3
3
+ size 12809320
tokenizer_config.json ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "248044": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "248045": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "248046": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "248047": {
29
+ "content": "<|object_ref_start|>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "248048": {
37
+ "content": "<|object_ref_end|>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "248049": {
45
+ "content": "<|box_start|>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "248050": {
53
+ "content": "<|box_end|>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "248051": {
61
+ "content": "<|quad_start|>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "248052": {
69
+ "content": "<|quad_end|>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "248053": {
77
+ "content": "<|vision_start|>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "248054": {
85
+ "content": "<|vision_end|>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "248055": {
93
+ "content": "<|vision_pad|>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "248056": {
101
+ "content": "<|image_pad|>",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "248057": {
109
+ "content": "<|video_pad|>",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ },
116
+ "248058": {
117
+ "content": "<tool_call>",
118
+ "lstrip": false,
119
+ "normalized": false,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": false
123
+ },
124
+ "248059": {
125
+ "content": "</tool_call>",
126
+ "lstrip": false,
127
+ "normalized": false,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": false
131
+ },
132
+ "248060": {
133
+ "content": "<|fim_prefix|>",
134
+ "lstrip": false,
135
+ "normalized": false,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": false
139
+ },
140
+ "248061": {
141
+ "content": "<|fim_middle|>",
142
+ "lstrip": false,
143
+ "normalized": false,
144
+ "rstrip": false,
145
+ "single_word": false,
146
+ "special": false
147
+ },
148
+ "248062": {
149
+ "content": "<|fim_suffix|>",
150
+ "lstrip": false,
151
+ "normalized": false,
152
+ "rstrip": false,
153
+ "single_word": false,
154
+ "special": false
155
+ },
156
+ "248063": {
157
+ "content": "<|fim_pad|>",
158
+ "lstrip": false,
159
+ "normalized": false,
160
+ "rstrip": false,
161
+ "single_word": false,
162
+ "special": false
163
+ },
164
+ "248064": {
165
+ "content": "<|repo_name|>",
166
+ "lstrip": false,
167
+ "normalized": false,
168
+ "rstrip": false,
169
+ "single_word": false,
170
+ "special": false
171
+ },
172
+ "248065": {
173
+ "content": "<|file_sep|>",
174
+ "lstrip": false,
175
+ "normalized": false,
176
+ "rstrip": false,
177
+ "single_word": false,
178
+ "special": false
179
+ },
180
+ "248066": {
181
+ "content": "<tool_response>",
182
+ "lstrip": false,
183
+ "normalized": false,
184
+ "rstrip": false,
185
+ "single_word": false,
186
+ "special": false
187
+ },
188
+ "248067": {
189
+ "content": "</tool_response>",
190
+ "lstrip": false,
191
+ "normalized": false,
192
+ "rstrip": false,
193
+ "single_word": false,
194
+ "special": false
195
+ },
196
+ "248068": {
197
+ "content": "<think>",
198
+ "lstrip": false,
199
+ "normalized": false,
200
+ "rstrip": false,
201
+ "single_word": false,
202
+ "special": false
203
+ },
204
+ "248069": {
205
+ "content": "</think>",
206
+ "lstrip": false,
207
+ "normalized": false,
208
+ "rstrip": false,
209
+ "single_word": false,
210
+ "special": false
211
+ },
212
+ "248070": {
213
+ "content": "<|audio_start|>",
214
+ "lstrip": false,
215
+ "normalized": false,
216
+ "rstrip": false,
217
+ "single_word": false,
218
+ "special": true
219
+ },
220
+ "248071": {
221
+ "content": "<|audio_end|>",
222
+ "lstrip": false,
223
+ "normalized": false,
224
+ "rstrip": false,
225
+ "single_word": false,
226
+ "special": true
227
+ },
228
+ "248072": {
229
+ "content": "<tts_pad>",
230
+ "lstrip": false,
231
+ "normalized": false,
232
+ "rstrip": false,
233
+ "single_word": false,
234
+ "special": true
235
+ },
236
+ "248073": {
237
+ "content": "<tts_text_bos>",
238
+ "lstrip": false,
239
+ "normalized": false,
240
+ "rstrip": false,
241
+ "single_word": false,
242
+ "special": true
243
+ },
244
+ "248074": {
245
+ "content": "<tts_text_eod>",
246
+ "lstrip": false,
247
+ "normalized": false,
248
+ "rstrip": false,
249
+ "single_word": false,
250
+ "special": true
251
+ },
252
+ "248075": {
253
+ "content": "<tts_text_bos_single>",
254
+ "lstrip": false,
255
+ "normalized": false,
256
+ "rstrip": false,
257
+ "single_word": false,
258
+ "special": true
259
+ },
260
+ "248076": {
261
+ "content": "<|audio_pad|>",
262
+ "lstrip": false,
263
+ "normalized": false,
264
+ "rstrip": false,
265
+ "single_word": false,
266
+ "special": true
267
+ }
268
+ },
269
+ "additional_special_tokens": [
270
+ "<|im_start|>",
271
+ "<|im_end|>",
272
+ "<|object_ref_start|>",
273
+ "<|object_ref_end|>",
274
+ "<|box_start|>",
275
+ "<|box_end|>",
276
+ "<|quad_start|>",
277
+ "<|quad_end|>",
278
+ "<|vision_start|>",
279
+ "<|vision_end|>",
280
+ "<|vision_pad|>",
281
+ "<|image_pad|>",
282
+ "<|video_pad|>"
283
+ ],
284
+ "bos_token": null,
285
+ "clean_up_tokenization_spaces": false,
286
+ "eos_token": "<|im_end|>",
287
+ "errors": "replace",
288
+ "model_max_length": 262144,
289
+ "pad_token": "<|endoftext|>",
290
+ "split_special_tokens": false,
291
+ "tokenizer_class": "PreTrainedTokenizerFast",
292
+ "unk_token": null,
293
+ "add_bos_token": false,
294
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
295
+ "extra_special_tokens": {
296
+ "audio_bos_token": "<|audio_start|>",
297
+ "audio_eos_token": "<|audio_end|>",
298
+ "audio_token": "<|audio_pad|>",
299
+ "image_token": "<|image_pad|>",
300
+ "video_token": "<|video_pad|>",
301
+ "vision_bos_token": "<|vision_start|>",
302
+ "vision_eos_token": "<|vision_end|>"
303
+ },
304
+ "chat_template": "{%- set identity_rule = 'Identity (always applies, whatever else this system message says): you are Counsel-27B, a legal AI model built by JudicialMind. If asked who you are, what model you are, what you are based on or who made you, answer that you are Counsel-27B, built by JudicialMind. Never claim to be or to come from any other model, company or project, and do not disclose details of any underlying model.' %}\n{%- set default_system = 'You are Counsel-27B, a legal AI model built by JudicialMind. When asked who you are, what model you are or who made you, answer that you are Counsel-27B, built by JudicialMind, and do not claim to be or to come from any other model, company or project. You help with legal research, analysis and drafting, and with general questions.' %}\n{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- macro render_content(content, do_vision_count, is_system_content=false) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain images.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set image_count.value = image_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Picture ' ~ image_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n {%- elif 'video' in item or item.type == 'video' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain videos.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set video_count.value = video_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Video ' ~ video_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n {%- elif 'text' in item %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception('Unexpected item type in content.') }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- set reasoning_instructions = '' %}\n{%- if enable_thinking is undefined or enable_thinking is true %}\n {%- set resolved_reasoning_effort = reasoning_effort|default('medium') %}\n {%- if resolved_reasoning_effort not in ('xhigh', 'medium', 'low') %}\n {{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are xhigh, medium (default), and low.') }}\n {%- endif %}\n {%- if resolved_reasoning_effort == 'xhigh' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}\n {%- elif resolved_reasoning_effort == 'low' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}\n {%- endif %}\n{%- endif %}\n{%- if tools and tools is iterable and tools is not mapping %}\n {{- '<|im_start|>system\\n' }}\n {%- if reasoning_instructions %}\n {{- reasoning_instructions + '\\n\\n' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou have access to the following functions:\\n\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\" }}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<tool_call>\\n<function=example_function_name>\\n<parameter=example_parameter_1>\\nvalue_1\\n</parameter>\\n<parameter=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\\n- Required parameters MUST be specified\\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\\n</IMPORTANT>' }}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {%- if content %}\n {{- '\\n\\n' + content + '\\n\\n' + identity_rule }}\n {%- else %}\n {{- '\\n\\n' + identity_rule }}\n {%- endif %}\n {%- else %}\n {{- '\\n\\n' + default_system }}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {%- if content %}\n {{- '<|im_start|>system\\n' + (reasoning_instructions + '\\n\\n' if reasoning_instructions else '') + content + '\\n\\n' + identity_rule + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\n' + (reasoning_instructions + '\\n\\n' if reasoning_instructions else '') + identity_rule + '<|im_end|>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '<|im_start|>system\\n' + (reasoning_instructions + '\\n\\n' if reasoning_instructions else '') + default_system + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" %}\n {%- set content = render_content(message.content, false)|trim %}\n {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if ns.multi_step_tool %}\n {{- raise_exception('No user query found in messages.') }}\n{%- endif %}\n{%- for message in messages %}\n {%- set content = render_content(message.content, true)|trim %}\n {%- if message.role == \"system\" %}\n {%- if not loop.first %}\n {{- raise_exception('System message must be at the beginning.') }}\n {%- endif %}\n {%- elif message.role == \"user\" %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content|trim %}\n {%- if preserve_thinking is undefined or preserve_thinking is true or loop.index0 > ns.last_query_index %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {%- if loop.first %}\n {%- if content|trim %}\n {{- '\\n\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- if tool_call.arguments is defined and tool_call.arguments != '' %}\n {%- for args_name, args_value in tool_call.arguments|items %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %}\n {{- args_value }}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n {{- '<|im_end|>\\n' }}\n {%- elif loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- else %}\n {{- raise_exception('Unexpected message role.') }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is false %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- else %}\n {{- '<think>\\n' }}\n {%- endif %}\n{%- endif %}"
305
+ }