sglang
mtp
speculative-decoding
draft-head
qwen3_5_moe
Eang commited on
Commit
755da9f
·
0 Parent(s):

Release Occamy 1.0 MTP

Browse files
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
PUBLICATION-GATE.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "ready": true,
3
+ "weight_sha256": "56baea0ef88de178c6c858d81adee9e532983798dce81202f21a7483e59001df",
4
+ "bf16_exact_tokens": 36,
5
+ "bf16_exact_logprobs": 36,
6
+ "nvfp4_exact_tokens": 36,
7
+ "nvfp4_exact_logprobs": 36,
8
+ "requests_per_variant": 36,
9
+ "speed_improvement_established": false,
10
+ "fp8_new_head_validation": null,
11
+ "gguf_new_head_validation": null,
12
+ "scope": "greedy single-request MTP1, supplied runtime hooks, graphs/overlap/prefix cache disabled"
13
+ }
README.md ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Accio-Lab/occamy-1.0
4
+ library_name: sglang
5
+ tags:
6
+ - mtp
7
+ - speculative-decoding
8
+ - draft-head
9
+ - qwen3_5_moe
10
+ datasets:
11
+ - Accio-Lab/occamy-data-1.0
12
+ ---
13
+
14
+ # Occamy 1.0 MTP
15
+
16
+ A BF16 MTP draft head adapted on [Occamy data](https://huggingface.co/datasets/Accio-Lab/occamy-data-1.0) for **512 steps**, using frozen [Occamy 1.0](https://huggingface.co/Accio-Lab/occamy-1.0) predictions as targets. This replaces the earlier 32-step pilot. Download a base checkpoint separately; this is a custom MTP head, not a standalone model or PEFT adapter.
17
+
18
+ This head remains experimental and is separate from the completed quantized-checkpoint release. Native three-step MTP output consistency is still under investigation; it is not covered by the MTP1 results below, and no stable speedup is claimed.
19
+
20
+ ## Training
21
+
22
+ Initialized from `Qwen/Qwen3.6-35B-A3B`. Only 8,392,704 fusion and normalization parameters were trained; the rest of the 844,640,768-parameter head and the Occamy base stayed frozen. Training used 256 text examples over two epochs, with 32 heldout examples and assistant-only loss. Windows contain up to 128 context and 382 assistant tokens. Images and unnormalized tool-call roles were excluded; this is bounded text adaptation, not full-head or full-conversation training.
23
+
24
+ Exported-head target top-1 agreement rose from **73.57% to 74.66%**. Data-answer NLL worsened from **2.2850 to 2.6034**: matching the target model's greedy choices differs from predicting the recorded answers. No external teacher was used. Exact revisions and settings are in [TRAINING.json](TRAINING.json).
25
+
26
+ ## Verified combinations
27
+
28
+ The **same head** was tested on BF16 and [Occamy NVFP4](https://huggingface.co/Accio-Lab/occamy-1.0-NVFP4). Each variant used 10 authored prompts and 8 Occamy heldout prefixes, repeated twice. Comparisons use the matching precision's no-MTP baseline.
29
+
30
+ | Combination | Occamy heldout accepted / proposed | Heldout acceptance | Exact token sequences | Exact token logprobs |
31
+ |---|---:|---:|---:|---:|
32
+ | BF16 + original donor head | 1128 / 1292 | 87.31% | 36/36 | 36/36 |
33
+ | BF16 + released head | 1130 / 1290 | **87.60%** | **36/36** | **36/36** |
34
+ | NVFP4 + released head | 1178 / 1372 | **85.86%** | **36/36** | **36/36** |
35
+
36
+ Across authored and heldout prompts combined, acceptance was 1470/1668 (88.13%) for BF16 and 1506/1756 (85.76%) for NVFP4. The small BF16 acceptance gain does **not establish a meaningful speed improvement**. Timings had concurrent activity and are diagnostic only. NVFP4 has no same-run original-donor-head comparison. Some heldout generations hit the 160-token limit; parity applies to the measured outputs, not unbounded continuations. These checks do not establish broad task accuracy.
37
+
38
+ This release validates **single-request greedy MTP1**, with two verification nodes, context length 2048, deterministic inference, and the supplied hooks. CUDA graphs, overlap and prefix caching were disabled. FP8, GGUF, sampling, concurrency, MTP2, multimodal MTP and other engines are **not validated with this head**. Results for older heads do not apply to it.
39
+
40
+ ## Required runtime
41
+
42
+ Tested with SGLang **0.5.13.post1**, and PyTorch `2.11.0+cu130`. Use `canonical_attention:install` from the included `runtime/` directory. The hooks prevent stale prefill-state initialization during verification and reuse decode kernels for recurrent and full attention. Unsupported batch/tree shapes fail closed. Exact parity is bounded evidence for this configuration, not a universal guarantee or a claim about unmodified SGLang.
43
+
44
+ ## Loading
45
+
46
+ Download this repository and the desired base checkpoint separately. Run the following from this repository's directory. The helper creates a separate assembled directory with links to existing files; it does not modify the base.
47
+
48
+ ```bash
49
+ MTP_BASE_DIR=/path/to/occamy-bf16
50
+ python assemble_head.py \
51
+ --base "$MTP_BASE_DIR" \
52
+ --head ./mtp-trained.safetensors \
53
+ --out ./occamy-with-mtp
54
+
55
+ PYTHONPATH="$PWD/runtime${PYTHONPATH:+:$PYTHONPATH}" python -m sglang.launch_server \
56
+ --model-path ./occamy-with-mtp --tokenizer-path "$MTP_BASE_DIR" \
57
+ --host 127.0.0.1 --port 30000 --dtype bfloat16 \
58
+ --context-length 2048 --max-running-requests 1 --max-total-tokens 2048 \
59
+ --max-mamba-cache-size 4 --mem-fraction-static 0.50 \
60
+ --attention-backend triton --mamba-backend triton --mm-attention-backend sdpa \
61
+ --disable-cuda-graph --disable-overlap-schedule --disable-radix-cache \
62
+ --random-seed 42 --enable-deterministic-inference --moe-runner-backend triton \
63
+ --speculative-algorithm NEXTN --speculative-num-steps 1 \
64
+ --speculative-eagle-topk 1 --speculative-num-draft-tokens 2 \
65
+ --forward-hooks '[{"name":"mtp-strict","target_modules":[""],"hook_factory":"canonical_attention:install","config":{"output":"./mtp-strict-audit.jsonl"}}]'
66
+ ```
67
+
68
+ For [Occamy NVFP4](https://huggingface.co/Accio-Lab/occamy-1.0-NVFP4), assemble a new directory using that base instead. Replace `--moe-runner-backend triton` with:
69
+
70
+ ```text
71
+ --quantization modelopt_fp4 --moe-runner-backend flashinfer_cutlass --speculative-moe-runner-backend triton
72
+ ```
73
+
74
+ The base needs sufficient device memory for the selected memory fraction. The runtime hooks use SGLang internals; different builds or settings require revalidation.
75
+
76
+ ## Files
77
+
78
+ - `mtp-trained.safetensors`: the draft head; download the base model separately.
79
+ - `assemble_head.py`, `mtp_head_config.json`, `runtime/`: loading helpers and required runtime hooks.
80
+ - [Validation results](VALIDATION.json) and [training details](TRAINING.json).
81
+
82
+ Apache 2.0. Full reproduction notes are in [Technical details](TECHNICAL-DETAILS.md).
SHA256SUMS ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 LICENSE
2
+ 52805b38b290ad0169d2e002dda17d45514cd9521cbbcda16b939e07564c9f79 PUBLICATION-GATE.json
3
+ 05c19b21b30dc3ea7258ce2ea4c0b46a2a96564e2b3b9dbe74241fc57c10c4d7 README.md
4
+ 4873ddda961f0f8fd0c879a573327024f91596a3506ba19c75ffd21e116719a3 TRAINING.json
5
+ 32777a13896943ee3340972a705800f61043c3ff6bd9fc34b8d7ae17b51bf376 VALIDATION.json
6
+ bc956144ce92e19271d7d895d3eb2802ce364a2d3fe494bbf74e3a26d8869cfa assemble_head.py
7
+ 195e351e7c56629d110a85cbc517982a959066d516b32a1bc000c48f005b2e15 evaluation_cases.json
8
+ 56baea0ef88de178c6c858d81adee9e532983798dce81202f21a7483e59001df mtp-trained.safetensors
9
+ 7cd00161f50bec7cab657cdb4b8b60d5e6032e9a42d4c162003e4f6cac352b90 mtp_head_config.json
10
+ 8c5bccf910bad935636a9d05be08f49a9a09ce762962652af1301af3aec02718 per-request-results.json
11
+ 1cac008ea8645e618f86fffc737a501f9cbfc779b6dee4525f7f202b5c833432 runtime/canonical_attention.py
12
+ d1d733621cfa4f156ab61a0e861b6f30a4d5e55885d2200c800899bc4ed0dfdd runtime/canonical_gdn.py
13
+ 81459605a7a560b6cfdb92d070584bb44202bf1686caae6a962602054a26a3bd runtime/mtp_state_guard.py
14
+ 324492f91f6042feb3d9d953b1160f3f586d57c392ecdc32f282a98f12ec4bcc runtime/state_commit_audit.py
TECHNICAL-DETAILS.md ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Accio-Lab/occamy-1.0
4
+ library_name: sglang
5
+ tags:
6
+ - mtp
7
+ - speculative-decoding
8
+ - draft-head
9
+ - qwen3_5_moe
10
+ datasets:
11
+ - Accio-Lab/occamy-data-1.0
12
+ ---
13
+
14
+ # Occamy 1.0 MTP
15
+
16
+ A BF16 MTP draft head adapted on [Occamy data](https://huggingface.co/datasets/Accio-Lab/occamy-data-1.0) for **512 steps**, using frozen [Occamy 1.0](https://huggingface.co/Accio-Lab/occamy-1.0) predictions as targets. This replaces the earlier 32-step pilot. Download a base checkpoint separately; this is a custom MTP head, not a standalone model or PEFT adapter.
17
+
18
+ ## Training
19
+
20
+ Initialized from `Qwen/Qwen3.6-35B-A3B`. Only 8,392,704 fusion and normalization parameters were trained; the rest of the 844,640,768-parameter head and the Occamy base stayed frozen. Training used 256 text examples over two epochs, with 32 heldout examples and assistant-only loss. Windows contain up to 128 context and 382 assistant tokens. Images and unnormalized tool-call roles were excluded; this is bounded text adaptation, not full-head or full-conversation training.
21
+
22
+ Exported-head target top-1 agreement rose from **73.57% to 74.66%**. Data-answer NLL worsened from **2.2850 to 2.6034**: matching the target model's greedy choices differs from predicting the recorded answers. No external teacher was used. Exact revisions and settings are in [TRAINING.json](TRAINING.json).
23
+
24
+ ## Verified combinations
25
+
26
+ The **same head** was tested on BF16 and [Occamy NVFP4](https://huggingface.co/Accio-Lab/occamy-1.0-NVFP4). Each variant used 10 authored prompts and 8 Occamy heldout prefixes, repeated twice. Comparisons use the matching precision's no-MTP baseline.
27
+
28
+ | Combination | Occamy heldout accepted / proposed | Heldout acceptance | Exact token sequences | Exact token logprobs |
29
+ |---|---:|---:|---:|---:|
30
+ | BF16 + original donor head | 1128 / 1292 | 87.31% | 36/36 | 36/36 |
31
+ | BF16 + released head | 1130 / 1290 | **87.60%** | **36/36** | **36/36** |
32
+ | NVFP4 + released head | 1178 / 1372 | **85.86%** | **36/36** | **36/36** |
33
+
34
+ Across authored and heldout prompts combined, acceptance was 1470/1668 (88.13%) for BF16 and 1506/1756 (85.76%) for NVFP4. The small BF16 acceptance gain does **not establish a meaningful speed improvement**. Timings had concurrent activity and are diagnostic only. NVFP4 has no same-run original-donor-head comparison. Some heldout generations hit the 160-token limit; parity applies to the measured outputs, not unbounded continuations. These checks do not establish broad task accuracy.
35
+
36
+ This release validates **single-request greedy MTP1**, with two verification nodes, context length 2048, deterministic inference, and the supplied hooks. CUDA graphs, overlap and prefix caching were disabled. FP8, GGUF, sampling, concurrency, MTP2, multimodal MTP and other engines are **not validated with this head**. Results for older heads do not apply to it.
37
+
38
+ ## Required runtime
39
+
40
+ Tested with SGLang **0.5.13.post1**, source revision `85fd90072d1a9f2432842b03588f63b745e524e4`, and PyTorch `2.11.0+cu130`. Use `canonical_attention:install` from the included `runtime/` directory. The hooks prevent stale prefill-state initialization during verification and reuse decode kernels for recurrent and full attention. Unsupported batch/tree shapes fail closed. Exact parity is bounded evidence for this configuration, not a universal guarantee or a claim about unmodified SGLang.
41
+
42
+ ## Loading
43
+
44
+ Download this repository and the desired base checkpoint separately. Run the following from this repository's directory. The helper creates a separate assembled directory with links to existing files; it does not modify the base.
45
+
46
+ ```bash
47
+ MTP_BASE_DIR=/path/to/occamy-bf16
48
+ python assemble_head.py \
49
+ --base "$MTP_BASE_DIR" \
50
+ --head ./mtp-trained.safetensors \
51
+ --out ./occamy-with-mtp
52
+
53
+ PYTHONPATH="$PWD/runtime${PYTHONPATH:+:$PYTHONPATH}" python -m sglang.launch_server \
54
+ --model-path ./occamy-with-mtp --tokenizer-path "$MTP_BASE_DIR" \
55
+ --host 127.0.0.1 --port 30000 --dtype bfloat16 \
56
+ --context-length 2048 --max-running-requests 1 --max-total-tokens 2048 \
57
+ --max-mamba-cache-size 4 --mem-fraction-static 0.50 \
58
+ --attention-backend triton --mamba-backend triton --mm-attention-backend sdpa \
59
+ --disable-cuda-graph --disable-overlap-schedule --disable-radix-cache \
60
+ --random-seed 42 --enable-deterministic-inference --moe-runner-backend triton \
61
+ --speculative-algorithm NEXTN --speculative-num-steps 1 \
62
+ --speculative-eagle-topk 1 --speculative-num-draft-tokens 2 \
63
+ --forward-hooks '[{"name":"mtp-strict","target_modules":[""],"hook_factory":"canonical_attention:install","config":{"output":"./mtp-strict-audit.jsonl"}}]'
64
+ ```
65
+
66
+ For [Occamy NVFP4](https://huggingface.co/Accio-Lab/occamy-1.0-NVFP4), assemble a new directory using that base instead. Replace `--moe-runner-backend triton` with:
67
+
68
+ ```text
69
+ --quantization modelopt_fp4 --moe-runner-backend flashinfer_cutlass --speculative-moe-runner-backend triton
70
+ ```
71
+
72
+ The base needs sufficient device memory for the selected memory fraction. The runtime hooks use SGLang internals; different builds or settings require revalidation.
73
+
74
+ ## Files and evidence
75
+
76
+ - `mtp-trained.safetensors`: 19 BF16 MTP tensors; no base weights.
77
+ - `mtp_head_config.json`, `assemble_head.py`, `runtime/`: assembly configuration and required runtime.
78
+ - [VALIDATION.json](VALIDATION.json): aggregate results, test scope and timing limitations.
79
+ - [per-request-results.json](per-request-results.json): per-request counts, parity and SHA256 fingerprints of inputs, outputs and logprobs; conversation content is not republished.
80
+ - `evaluation_cases.json`, `TRAINING.json`, `SHA256SUMS`: test cases, provenance and file integrity.
81
+
82
+ The base and donor models are Apache-2.0 licensed. Original base weights are unchanged. Training checkpoints and the replaced release are retained separately for recovery.
TRAINING.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "target_model": "Accio-Lab/occamy-1.0",
3
+ "target_revision": "c1ce84770260c4137712cf22115574c4d06b993a",
4
+ "initialization_model": "Qwen/Qwen3.6-35B-A3B",
5
+ "initialization_revision": "995ad96eacd98c81ed38be0c5b274b04031597b0",
6
+ "base_frozen": true,
7
+ "trainable_parameters": 8392704,
8
+ "head_parameters": 844640768,
9
+ "steps": 512,
10
+ "train_samples": 256,
11
+ "heldout_samples": 32,
12
+ "sequence_length": 512,
13
+ "batch_size": 1,
14
+ "optimizer": "AdamW",
15
+ "learning_rate": 1e-05,
16
+ "weight_decay": 0,
17
+ "gradient_clip_norm": 1.0,
18
+ "data": {
19
+ "repo": "Accio-Lab/occamy-data-1.0",
20
+ "revision": "7dd8c12a4382edce172da01b88bd3257ead336cf",
21
+ "file_sha256": "310c0ebcd90d92a4cab3f2f8ba96ee42b8dbaf0261278de1ae1c73b521656202",
22
+ "selection": "Seed 42; one last substantial assistant continuation per text-only session; exact-answer dedup; 256 training and 32 heldout sessions. Up to 128 local-context tokens and 382 assistant tokens. Unnormalized tool_call roles excluded; images excluded. No identical answer or token-window overlap. Heldout excluded from MTP training, not guaranteed unseen by the base."
23
+ },
24
+ "objective": "Cross entropy against frozen Occamy greedy next-token predictions at assistant positions",
25
+ "external_teacher": false,
26
+ "heldout_before_nll": 2.2849533979471612,
27
+ "heldout_after_nll": 2.603421883325693,
28
+ "heldout_target_top1_before": 0.7357322577928339,
29
+ "heldout_target_top1_after": 0.7465660697511188,
30
+ "nll_measurement_note": "Teacher-forced data-answer NLL and target top-1 agreement evaluated after BF16 export. Hard target training is specific to greedy decoding, not a sampling validation.",
31
+ "export_note": "19 BF16 tensors; only fusion and pre-fusion normalization parameters were trainable.",
32
+ "checkpoint_save_restore_verified": true,
33
+ "epochs": 2
34
+ }
VALIDATION.json ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "scope": {
3
+ "prompts": 18,
4
+ "repeats": 2,
5
+ "temperature": 0,
6
+ "max_new_tokens": 160,
7
+ "max_concurrent_requests": 1,
8
+ "context_length": 2048,
9
+ "mtp_steps": 1,
10
+ "draft_tokens": 2,
11
+ "cuda_graphs": false,
12
+ "overlap": false,
13
+ "radix_cache": false,
14
+ "deterministic_inference": true,
15
+ "tool_test": "emitted JSON only; no external tool service",
16
+ "code_test": "bounded Python function execution cases",
17
+ "not_covered": [
18
+ "sampled decoding",
19
+ "concurrency",
20
+ "prefix cache",
21
+ "CUDA graphs",
22
+ "MTP2",
23
+ "multimodal MTP",
24
+ "other engines",
25
+ "other quantizations",
26
+ "FP8 with this head",
27
+ "GGUF Q4/Q8 with this head"
28
+ ],
29
+ "authored_prompts": 10,
30
+ "occamy_heldout_prefixes": 8,
31
+ "heldout_prefix_length": 128
32
+ },
33
+ "runtime": {
34
+ "sglang": "0.5.13.post1",
35
+ "source_revision": "85fd90072d1a9f2432842b03588f63b745e524e4",
36
+ "torch": "2.11.0+cu130",
37
+ "hook": "canonical_attention:install"
38
+ },
39
+ "results": {
40
+ "BF16": {
41
+ "baseline": {
42
+ "requests": 36,
43
+ "quality_pass": 12,
44
+ "quality_total": 16,
45
+ "stopped": 22,
46
+ "length_limited": 14,
47
+ "acceptance": null,
48
+ "accepted": 0,
49
+ "proposed": 0,
50
+ "median_e2e_seconds": 4.305030163610354,
51
+ "repeat_token_parity": 18,
52
+ "exact_tokens": 36,
53
+ "exact_logprobs": 36
54
+ },
55
+ "original-head": {
56
+ "requests": 36,
57
+ "quality_pass": 12,
58
+ "quality_total": 16,
59
+ "stopped": 22,
60
+ "length_limited": 14,
61
+ "acceptance": 0.8767942583732058,
62
+ "accepted": 1466,
63
+ "proposed": 1672,
64
+ "median_e2e_seconds": 6.00265346840024,
65
+ "repeat_token_parity": 18,
66
+ "full_token_matches_baseline": 36,
67
+ "median_matched_output_speed_ratio": 0.7472627789451953,
68
+ "exact_tokens": 36,
69
+ "exact_logprobs": 36
70
+ },
71
+ "trained-head": {
72
+ "requests": 36,
73
+ "quality_pass": 12,
74
+ "quality_total": 16,
75
+ "stopped": 22,
76
+ "length_limited": 14,
77
+ "acceptance": 0.8812949640287769,
78
+ "accepted": 1470,
79
+ "proposed": 1668,
80
+ "median_e2e_seconds": 4.158929664408788,
81
+ "repeat_token_parity": 18,
82
+ "full_token_matches_baseline": 36,
83
+ "median_matched_output_speed_ratio": 1.1084637954727476,
84
+ "exact_tokens": 36,
85
+ "exact_logprobs": 36
86
+ }
87
+ },
88
+ "NVFP4": {
89
+ "baseline": {
90
+ "requests": 36,
91
+ "quality_pass": 12,
92
+ "quality_total": 16,
93
+ "stopped": 20,
94
+ "length_limited": 16,
95
+ "acceptance": null,
96
+ "accepted": 0,
97
+ "proposed": 0,
98
+ "median_e2e_seconds": 3.7523877734784037,
99
+ "repeat_token_parity": 18,
100
+ "exact_tokens": 36,
101
+ "exact_logprobs": 36
102
+ },
103
+ "trained-head": {
104
+ "requests": 36,
105
+ "quality_pass": 12,
106
+ "quality_total": 16,
107
+ "stopped": 20,
108
+ "length_limited": 16,
109
+ "acceptance": 0.857630979498861,
110
+ "accepted": 1506,
111
+ "proposed": 1756,
112
+ "median_e2e_seconds": 4.066564766457304,
113
+ "repeat_token_parity": 18,
114
+ "full_token_matches_baseline": 36,
115
+ "median_matched_output_speed_ratio": 1.0389619272561033,
116
+ "exact_tokens": 36,
117
+ "exact_logprobs": 36
118
+ }
119
+ }
120
+ },
121
+ "head_sha256": "56baea0ef88de178c6c858d81adee9e532983798dce81202f21a7483e59001df",
122
+ "acceptance_by_subset": {
123
+ "bf16": {
124
+ "strict": {
125
+ "tokens": 36,
126
+ "logprobs": 36,
127
+ "total": 36
128
+ },
129
+ "variants": {
130
+ "original-head": {
131
+ "authored": {
132
+ "accepted": 338,
133
+ "proposed": 380,
134
+ "rate": 0.8894736842105263
135
+ },
136
+ "occamy_heldout": {
137
+ "accepted": 1128,
138
+ "proposed": 1292,
139
+ "rate": 0.8730650154798761
140
+ }
141
+ },
142
+ "trained-head": {
143
+ "authored": {
144
+ "accepted": 340,
145
+ "proposed": 378,
146
+ "rate": 0.8994708994708994
147
+ },
148
+ "occamy_heldout": {
149
+ "accepted": 1130,
150
+ "proposed": 1290,
151
+ "rate": 0.875968992248062
152
+ }
153
+ }
154
+ }
155
+ },
156
+ "nvfp4": {
157
+ "strict": {
158
+ "tokens": 36,
159
+ "logprobs": 36,
160
+ "total": 36
161
+ },
162
+ "variants": {
163
+ "trained-head": {
164
+ "authored": {
165
+ "accepted": 328,
166
+ "proposed": 384,
167
+ "rate": 0.8541666666666666
168
+ },
169
+ "occamy_heldout": {
170
+ "accepted": 1178,
171
+ "proposed": 1372,
172
+ "rate": 0.858600583090379
173
+ }
174
+ }
175
+ }
176
+ }
177
+ },
178
+ "timing_caveat": "Diagnostic only. Concurrent activity occurred; BF16 original-head timing included additional requests from an invalid parallel attempt. No controlled training-induced speed improvement established. Invalid NVFP4 attempt excluded in full; replacement NVFP4 run used a separate port and checked served model identity."
179
+ }
assemble_head.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Assemble a separate Qwen3.5-MoE-family checkpoint with an independent MTP head.
2
+ Does not modify base files. Requires safetensors. Runtime support must be tested.
3
+ """
4
+ import argparse, hashlib, json, math
5
+ from pathlib import Path
6
+ from safetensors import safe_open
7
+
8
+ def main():
9
+ p=argparse.ArgumentParser()
10
+ p.add_argument('--base',required=True,type=Path)
11
+ p.add_argument('--head',required=True,type=Path)
12
+ p.add_argument('--out',required=True,type=Path)
13
+ a=p.parse_args();base=a.base.resolve();head=a.head.resolve()
14
+ config=json.loads((base/'config.json').read_text())
15
+ if config.get('text_config',{}).get('model_type')!='qwen3_5_moe_text':
16
+ raise ValueError('Only the tested Qwen3.5 MoE model family is supported')
17
+ index=json.loads((base/'model.safetensors.index.json').read_text())
18
+ if any(k.startswith('mtp.') for k in index['weight_map']):
19
+ raise ValueError('Base already has MTP weights; refusing to replace them')
20
+ with safe_open(head,framework='pt') as f:
21
+ keys=list(f.keys())
22
+ if not keys or not all(k.startswith('mtp.') for k in keys):raise ValueError('Not an MTP-only head')
23
+ if not all(f.get_slice(k).get_dtype()=='BF16' for k in keys):raise ValueError('Expected BF16 MTP head')
24
+ size=sum(math.prod(f.get_slice(k).get_shape())*2 for k in keys)
25
+ a.out.mkdir(parents=True,exist_ok=False)
26
+ skip={'config.json','model.safetensors.index.json','README.md','CANDIDATE_STATUS.json','VALIDATION.json','SHA256SUMS'}
27
+ for f in base.iterdir():
28
+ if f.is_file() and f.name not in skip:(a.out/f.name).symlink_to(f)
29
+ name='mtp-trained.safetensors';(a.out/name).symlink_to(head)
30
+ config['text_config']['mtp_num_hidden_layers']=1
31
+ for k in keys:index['weight_map'][k]=name
32
+ index.setdefault('metadata',{})['total_size']=index.get('metadata',{}).get('total_size',0)+size
33
+ (a.out/'config.json').write_text(json.dumps(config,indent=2))
34
+ (a.out/'model.safetensors.index.json').write_text(json.dumps(index,indent=2))
35
+ digest=hashlib.sha256()
36
+ with head.open('rb') as f:
37
+ for block in iter(lambda:f.read(8*1024*1024),b''):digest.update(block)
38
+ (a.out/'MTP_ASSEMBLY.json').write_text(json.dumps({'head_sha256':digest.hexdigest(),'head_tensors':len(keys),'base_files_modified':False,'assembly_only_not_a_validation_claim':True},indent=2))
39
+
40
+ if __name__=='__main__':main()
evaluation_cases.json ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "id": "extract",
4
+ "prompt": "只输出 JSON,不要解释或代码块。从“林晓于2024年3月8日在成都购买了3本书,总价96元”提取 name、city、count、total,数字使用整数。",
5
+ "expected": {
6
+ "name": "林晓",
7
+ "city": "成都",
8
+ "count": 3,
9
+ "total": 96
10
+ }
11
+ },
12
+ {
13
+ "id": "arithmetic",
14
+ "prompt": "Only output JSON. A box contains 7 rows of 13 bolts. 18 bolts are removed. Return {\"remaining\": integer}.",
15
+ "expected": {
16
+ "remaining": 73
17
+ }
18
+ },
19
+ {
20
+ "id": "sort",
21
+ "prompt": "只输出 JSON 对象,键为 result。把 [9, -2, 9, 0, 4, -2] 去重后从小到大排序。",
22
+ "expected": {
23
+ "result": [
24
+ -2,
25
+ 0,
26
+ 4,
27
+ 9
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ "id": "tool-json",
33
+ "prompt": "只输出一次工具调用的 JSON 对象,格式为 {\"name\":工具名,\"arguments\":参数}。工具 multiply 接受整数 a 和 b。用户要计算 23 乘以 14。",
34
+ "expected": {
35
+ "name": "multiply",
36
+ "arguments": {
37
+ "a": 23,
38
+ "b": 14
39
+ }
40
+ }
41
+ },
42
+ {
43
+ "id": "python-sum",
44
+ "prompt": "Write only Python code defining sum_even(xs), returning the sum of even integers in xs. No imports, examples, or explanation.",
45
+ "code": "sum_even"
46
+ },
47
+ {
48
+ "id": "python-fib",
49
+ "prompt": "Write only Python code defining fib(n), returning the nth Fibonacci number with fib(0)=0 and fib(1)=1. No imports, examples, or explanation.",
50
+ "code": "fib"
51
+ },
52
+ {
53
+ "id": "chinese",
54
+ "prompt": "用三句话解释为什么软件更新前需要备份。不要使用列表。"
55
+ },
56
+ {
57
+ "id": "english",
58
+ "prompt": "In three concise sentences, explain the difference between a cache and a backup."
59
+ },
60
+ {
61
+ "id": "long-context",
62
+ "prompt": "阅读记录,找出最后一条库存变更后的数量。只输出 JSON 对象 {\"quantity\":整数}。初始库存100件。第1次:入库3件,出库2件。第2次:入库3件,出库2件。第3次:入库3件,出库2件。第4次:入库3件,出库2件。第5次:入库3件,出库2件。第6次:入库3件,出库2件。第7次:入库3件,出库2件。第8次:入库3件,出库2件。第9次:入库3件,出库2件。第10次:入库3件,出库2件。第11次:入库3件,出库2件。第12次:入库3件,出库2件。第13次:入库3件,出库2件。第14次:入库3件,出库2件。第15次:入库3件,出库2件。第16次:入库3件,出库2件。第17次:入库3件,出库2件。第18次:入库3件,出库2件。第19次:入库3件,出库2件。第20次:入库3件,出库2件。第21次:入库3件,出库2件。第22次:入库3件,出库2件。第23次:入库3件,出库2件。第24次:入库3件,出库2件。第25次:入库3件,出库2件。第26次:入库3件,出库2件。第27次:入库3件,出库2件。第28次:入库3件,出库2件。第29次:入库3件,出库2件。第30次:入库3件,出库2件。",
63
+ "expected": {
64
+ "quantity": 130
65
+ }
66
+ },
67
+ {
68
+ "id": "unicode",
69
+ "prompt": "只输出 JSON:把字符串“上海🌧️”原样放在键 text 下,把布尔值 false 放在键 sunny 下。",
70
+ "expected": {
71
+ "text": "上海🌧️",
72
+ "sunny": false
73
+ }
74
+ },
75
+ {
76
+ "id": "occamy-heldout-0",
77
+ "prompt": "Heldout token prefix",
78
+ "source_id": "801445f211b9391e092c9586e4e1b25dfa9802288cb86f0e3ede6fc3f6f288e7"
79
+ },
80
+ {
81
+ "id": "occamy-heldout-1",
82
+ "prompt": "Heldout token prefix",
83
+ "source_id": "0db0a632549bd7e3d29dfd407ae8123e0ede84059d6ea49df9132bb33075b9dc"
84
+ },
85
+ {
86
+ "id": "occamy-heldout-2",
87
+ "prompt": "Heldout token prefix",
88
+ "source_id": "57fa0709688ea4ff3dfde622df379176147a0c401b03a94233d01a89910f5445"
89
+ },
90
+ {
91
+ "id": "occamy-heldout-3",
92
+ "prompt": "Heldout token prefix",
93
+ "source_id": "da7d7ae390b8e87df5e4eb1bb4fda97c559a0159e1dc086db107b5b3526c8eb9"
94
+ },
95
+ {
96
+ "id": "occamy-heldout-4",
97
+ "prompt": "Heldout token prefix",
98
+ "source_id": "e74c7792e60050308821da9e596e7c1b41b759783bcf0bc09a33c811817f521b"
99
+ },
100
+ {
101
+ "id": "occamy-heldout-5",
102
+ "prompt": "Heldout token prefix",
103
+ "source_id": "ad2ca4e0dff20b9324b34bb135338b1eb39d143c829b769cfccc7f75b39acd16"
104
+ },
105
+ {
106
+ "id": "occamy-heldout-6",
107
+ "prompt": "Heldout token prefix",
108
+ "source_id": "7851ec2ee49aa4203a56925d4904aab007464176258cb29ccab5c0c70c4968e8"
109
+ },
110
+ {
111
+ "id": "occamy-heldout-7",
112
+ "prompt": "Heldout token prefix",
113
+ "source_id": "70bb0a9253ecd4a035b9920db57defce49daeafb70f8448169fa1cc4439e5b4f"
114
+ }
115
+ ]
mtp-trained.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56baea0ef88de178c6c858d81adee9e532983798dce81202f21a7483e59001df
3
+ size 1689283656
mtp_head_config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "artifact_type": "custom_mtp_draft_head",
3
+ "peft_adapter": false,
4
+ "standalone_model": false,
5
+ "target_model": "Accio-Lab/occamy-1.0",
6
+ "target_revision": "c1ce84770260c4137712cf22115574c4d06b993a",
7
+ "initialization_model": "Qwen/Qwen3.6-35B-A3B",
8
+ "initialization_revision": "995ad96eacd98c81ed38be0c5b274b04031597b0",
9
+ "weight_file": "mtp-trained.safetensors",
10
+ "weight_sha256": "56baea0ef88de178c6c858d81adee9e532983798dce81202f21a7483e59001df",
11
+ "dtype": "bfloat16",
12
+ "tensors": 19,
13
+ "total_parameters": 844640768,
14
+ "trainable_parameters": 8392704,
15
+ "trained_parameters": [
16
+ "mtp.fc.weight",
17
+ "mtp.pre_fc_norm_embedding.weight",
18
+ "mtp.pre_fc_norm_hidden.weight"
19
+ ],
20
+ "logical_training_steps": 512,
21
+ "runtime_hook": "canonical_attention:install",
22
+ "mtp_steps": 1,
23
+ "draft_tokens": 2,
24
+ "max_concurrent_requests": 1,
25
+ "requires_same_decode_kernels_for_verification": true,
26
+ "tested_base_variants": [
27
+ "BF16",
28
+ "ModelOpt NVFP4 experts-only"
29
+ ],
30
+ "training_dataset": "Accio-Lab/occamy-data-1.0"
31
+ }
per-request-results.json ADDED
The diff for this file is too large to render. See raw diff
 
runtime/canonical_attention.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Strict MTP1 attention paths with batched projections/MLP retained."""
2
+ import copy
3
+ import torch
4
+
5
+ def install(config):
6
+ from canonical_gdn import install as gdn
7
+ gdn(config)
8
+ from state_commit_audit import install as audit
9
+ audit(config)
10
+ from sglang.srt.layers.attention.triton_backend import TritonAttnBackend
11
+ from sglang.srt.model_executor.forward_batch_info import ForwardMode
12
+ if getattr(TritonAttnBackend,'_canonical_verify',False):return lambda *a:None
13
+ TritonAttnBackend._canonical_verify=True
14
+ extend=TritonAttnBackend.forward_extend
15
+ def forward(self,q,k,v,layer,batch,save_kv_cache=True,sinks=None):
16
+ if not batch.forward_mode.is_target_verify():
17
+ return extend(self,q,k,v,layer,batch,save_kv_cache,sinks)
18
+ if batch.batch_size!=1 or q.shape[0]!=2 or self.use_mla or self.use_sliding_window_kv_pool:
19
+ raise RuntimeError('Strict attention verifier requires single-request MTP1 without MLA/SWA')
20
+ outputs=[]
21
+ try:
22
+ for step in range(2):
23
+ single=copy.copy(batch)
24
+ single.forward_mode=ForwardMode.DECODE
25
+ single.forward_metadata_ready=False
26
+ single.spec_info=None
27
+ single.input_ids=batch.input_ids[step:step+1]
28
+ single.positions=batch.positions[step:step+1]
29
+ single.out_cache_loc=batch.out_cache_loc[step:step+1]
30
+ single.seq_lens=(single.positions+1).to(batch.seq_lens.dtype)
31
+ single.seq_lens_cpu=single.seq_lens.cpu()
32
+ single.seq_lens_sum=int(single.seq_lens_cpu.sum())
33
+ self.init_forward_metadata(single)
34
+ outputs.append(self.forward_decode(q[step:step+1],k[step:step+1] if k is not None else None,
35
+ v[step:step+1] if v is not None else None,layer,single,save_kv_cache,sinks))
36
+ finally:
37
+ # Rebuild rather than restoring a metadata object whose scratch
38
+ # tensors may have been reused in-place by decode planning.
39
+ self.init_forward_metadata(batch)
40
+ return torch.cat(outputs,dim=0)
41
+ TritonAttnBackend.forward_extend=forward
42
+ return lambda *a:None
runtime/canonical_gdn.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Bounded strict reference for single-request, two-node linear MTP verification.
2
+
3
+ Reuse the exact packed DECODE recurrence for each verification node, retaining
4
+ normal verify intermediate-state commit semantics. Unsupported tree/batch shapes
5
+ fail closed. This is an isolated correctness experiment, not a general backend.
6
+ """
7
+ import torch
8
+
9
+ def install(config):
10
+ from mtp_state_guard import install as state_guard
11
+ state_guard(config)
12
+ from sglang.srt.layers.attention.linear.kernels.gdn_triton import TritonGDNKernel
13
+ def canonical(self,A_log,dt_bias,q,k,v,a,b,*,ssm_states,cache_indices,
14
+ query_start_loc,intermediate_states_buffer,
15
+ intermediate_state_indices,cache_steps,retrieve_parent_token,**kw):
16
+ assert q.shape[0]==1 and q.shape[1]==2, 'Strict reference requires two verification tokens'
17
+ assert query_start_loc.numel()==2, 'Strict reference requires one request'
18
+ # The backend represents a linear (non-tree) sequence with None.
19
+ if retrieve_parent_token is not None:
20
+ assert retrieve_parent_token.shape==(1,2) and int(retrieve_parent_token[0,1])==0, 'Strict reference requires linear MTP1 tree'
21
+ assert cache_steps==2
22
+ # A separate working state prevents speculative/rejected updates from
23
+ # mutating the live target cache before the normal acceptance commit.
24
+ work=ssm_states.index_select(0,cache_indices[:1].long())
25
+ slot=torch.zeros_like(cache_indices[:1])
26
+ mixed=torch.cat([q.reshape(2,-1),k.reshape(2,-1),v.reshape(2,-1)],dim=-1)
27
+ a=a.reshape(2,-1);b=b.reshape(2,-1)
28
+ outputs=[]
29
+ for step in range(2):
30
+ output=self.packed_decode(mixed[step:step+1],a[step:step+1],b[step:step+1],
31
+ A_log=A_log,dt_bias=dt_bias,scale=k.shape[-1]**-.5,
32
+ ssm_states=work,cache_indices=slot,num_v_heads=v.shape[2],head_v_dim=v.shape[3])
33
+ outputs.append(output)
34
+ intermediate_states_buffer[intermediate_state_indices[:1].long(),step]=work
35
+ return torch.cat(outputs,dim=1)
36
+ TritonGDNKernel.target_verify=canonical
37
+ return lambda *a:None
runtime/mtp_state_guard.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Experiment-only guard against replaying prefill state initialization in verify."""
2
+ import json
3
+ from pathlib import Path
4
+
5
+ def install(config):
6
+ from sglang.srt.layers.attention.hybrid_linear_attn_backend import MambaAttnBackendBase
7
+ if getattr(MambaAttnBackendBase, '_occamy_guard', False):
8
+ return lambda *args: None
9
+ MambaAttnBackendBase._occamy_guard = True
10
+ original = MambaAttnBackendBase._execute_deferred_mamba_cow_and_clear
11
+ log_path = Path(config['output'])
12
+ def guarded(self, batch):
13
+ if batch.forward_mode.is_target_verify():
14
+ clear = batch.mamba_clear_indices
15
+ cow = batch.mamba_cow_src_indices
16
+ with log_path.open('a') as f:
17
+ f.write(json.dumps({'mode': 'TARGET_VERIFY', 'skipped_stale_clear_indices': clear.cpu().tolist() if clear is not None else None,
18
+ 'skipped_stale_cow_indices': cow.cpu().tolist() if cow is not None else None}) + '\n')
19
+ return
20
+ return original(self, batch)
21
+ MambaAttnBackendBase._execute_deferred_mamba_cow_and_clear = guarded
22
+ return lambda *args: None
runtime/state_commit_audit.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Validate the native single-request MTP state commit without changing it."""
2
+ import json
3
+ from pathlib import Path
4
+ import torch
5
+
6
+ def install(config):
7
+ from sglang.srt.speculative.eagle_worker_v2 import EAGLEWorkerV2
8
+ if getattr(EAGLEWorkerV2,'_strict_commit_audit',False):return
9
+ EAGLEWorkerV2._strict_commit_audit=True
10
+ original=EAGLEWorkerV2._mamba_verify_update
11
+ path=Path(config['output']+'.commit')
12
+ def checked(self,batch,lens,indices,bs):
13
+ result=original(self,batch,lens,indices,bs)
14
+ if bs==1 and not batch.forward_mode.is_idle():
15
+ backend=self.target_worker.model_runner.attn_backend.linear_attn_backend
16
+ pool=backend.req_to_token_pool.get_speculative_mamba2_params_all_layers()
17
+ slot=int(backend.forward_metadata.mamba_cache_indices[0]);step=int(lens[0])-1
18
+ ok=torch.equal(pool.temporal[:,slot],pool.intermediate_ssm[:,0,step]) and all(torch.equal(live[:,slot],buf[:,0,step]) for live,buf in zip(pool.conv,pool.intermediate_conv_window))
19
+ if not ok:raise RuntimeError('Strict MTP state commit mismatch')
20
+ with path.open('a') as f:f.write(json.dumps({'accepted_nodes':step+1,'state_equal':ok})+'\n')
21
+ return result
22
+ EAGLEWorkerV2._mamba_verify_update=checked