HCHs commited on
Commit
cd55fe8
·
verified ·
1 Parent(s): 1eaf5d3

Upload RivetCoder-9B-A4B-FP8 TorchAO checkpoint

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* 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
 
 
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
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ __pycache__/
2
+ *.pyc
3
+ *.tmp
4
+ .cache/
LICENSE ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ LFM Open License v1.0
2
+
3
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
4
+
5
+ 1. Definitions.
6
+
7
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
8
+
9
+ "Licensor" shall mean Liquid AI, Inc.
10
+
11
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
12
+
13
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
14
+
15
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
16
+
17
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
18
+
19
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
20
+
21
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
22
+
23
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
24
+
25
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
26
+
27
+ "Commercial Use" shall mean any use of the Work for direct or indirect commercial advantage or monetary compensation.
28
+
29
+ "Qualified Non-Profit Organization" shall mean a Legal Entity that is organized and operated exclusively for religious, charitable, scientific, testing for public safety, literary, or educational purposes, and which is exempt from federal income tax under Section 501(c)(3) of the United States Internal Revenue Code of 1986, as amended, or any equivalent non-profit or charitable organization in a foreign jurisdiction.
30
+
31
+ "Non-Commercial or Research Purposes" shall mean purposes that do not involve any use of the Work or a Derivative Work for Commercial Use.
32
+
33
+ "Threshold" shall mean annual revenue of 10 million United States dollars ($10,000,000) or more.
34
+
35
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, including the Commercial Use limitation set forth in Section 5, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
36
+
37
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, including the Commercial Use limitation set forth in Section 5, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
38
+
39
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
40
+
41
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
42
+
43
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
44
+
45
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
46
+
47
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
48
+
49
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
50
+
51
+ 5. Commercial Use Limitation.
52
+
53
+ (a) The rights granted under this License for Commercial Use are conditioned upon You or Your Legal Entity not exceeding the Threshold.
54
+
55
+ (b) Any Commercial Use of the Work or a Derivative Work by a Legal Entity that exceeds the Threshold is not licensed under this Agreement.
56
+
57
+ (c) The Threshold shall not apply to a Qualified Non-Profit Organization's use of the Work or a Derivative Work for Non-Commercial or Research Purposes.
58
+
59
+ 6. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
60
+
61
+ 7. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except for the reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
62
+
63
+ 8. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
64
+
65
+ 9. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
66
+
67
+ 10. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
68
+
69
+ 11. Termination. This License will terminate automatically and immediately if You fail to comply with any of its terms and conditions. Upon termination, You must cease all use of the Work and any Derivative Works and delete all copies in Your possession.
70
+
71
+ END OF TERMS AND CONDITIONS
NOTICE.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Attribution notice
2
+
3
+ RivetCoder-9B-A4B combines the following sources:
4
+
5
+ - Host model: `LiquidAI/LFM2.5-2.6B`, revision
6
+ `654f9463ce32b05d0429d76fe1f580b27d4c1ac0`, under the LFM Open License v1.0.
7
+ - Expert donor: `zai-org/GLM-5.3-Flash`, revision
8
+ `3f1971b7b5f7a528c9c4ef6212c8785298a8c24a`, under the MIT License.
9
+ - Router sequence teacher: `qwen/qwen3.8-27b`, accessed through a local LM Studio
10
+ endpoint. No Qwen weights are included.
11
+ - Architectural reference: `Akahsizrr/fuse-1-Lite`, revision
12
+ `430c959e47556ae53fed18a9d97f7cf30876e6ff`.
13
+
14
+ Modifications and new work include GLM expert selection, a fixed tied
15
+ identity-Hadamard bridge, expert/router weight folding, per-layer Top-4 routing,
16
+ token gating, bounded residual scaling, Qwen-supervised routing-control training,
17
+ and the custom `fuse_glm` Transformers implementation shipped in this repository.
18
+
19
+ See `provenance/` for the complete local build record with personal filesystem
20
+ paths removed.
README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: lfm-open-license-v1.0
4
+ license_link: LICENSE
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
+ base_model: HCHs/RivetCoder-9B-A4B
8
+ base_model_relation: quantized
9
+ language:
10
+ - en
11
+ - ko
12
+ - code
13
+ tags:
14
+ - custom_code
15
+ - lfm2
16
+ - glm
17
+ - mixture-of-experts
18
+ - routed-experts
19
+ - coding
20
+ - code-generation
21
+ - fp8
22
+ - torchao
23
+ - top-k-routing
24
+ - trust-remote-code
25
+ ---
26
+
27
+ # RivetCoder-9B-A4B-FP8
28
+
29
+ RivetCoder-9B-A4B-FP8 is the TorchAO FP8 deployment build of
30
+ [`HCHs/RivetCoder-9B-A4B`](https://huggingface.co/HCHs/RivetCoder-9B-A4B).
31
+ It keeps the same experimental coding-oriented architecture: a frozen
32
+ `LiquidAI/LFM2.5-2.6B` host plus 16 layer-qualified GLM-derived FFN candidates
33
+ at each of 30 layers, with Top-4 routing per token.
34
+
35
+ This repository contains custom Transformers code and must be loaded with
36
+ `trust_remote_code=True`.
37
+
38
+ ## FP8 format
39
+
40
+ The checkpoint was quantized with TorchAO
41
+ `Float8DynamicActivationFloat8WeightConfig` using E4M3 FP8 weights and dynamic
42
+ FP8 activations for compatible `nn.Linear` modules.
43
+
44
+ | Item | Value |
45
+ |---|---:|
46
+ | Source revision | `9a90b1917d9b5438e4d2fe1a4f6aea884db59a60` |
47
+ | Approx. total parameters | 8.74B |
48
+ | Approx. active parameters | 4.21B |
49
+ | FP8 tensor-subclass parameters | 1,636 |
50
+ | FP8-quantized parameter elements | 8,475,574,272 |
51
+ | Stored tensor bytes | 9,000,638,976 |
52
+ | Safetensors shards | 5 |
53
+ | Tested resident CUDA allocation | about 8.4 GiB |
54
+
55
+ Embeddings, convolution parameters, token gates, correction biases, residual
56
+ scales, and other small or precision-sensitive tensors remain BF16 or FP32.
57
+ Router projection matrices are FP8, while the custom router still computes its
58
+ logits in FP32. “FP8” therefore describes compatible Linear matrices, not every
59
+ scalar in the checkpoint.
60
+
61
+ ## Installation
62
+
63
+ The exact local stack used to create and validate this build was PyTorch
64
+ `2.12.0+cu130`, Transformers `5.16.1`, Accelerate `1.13.0`, Safetensors `0.8.0`,
65
+ and TorchAO `0.15.0` on an NVIDIA GeForce RTX 5070 Ti (SM 12.0).
66
+
67
+ ```bash
68
+ pip install "torch>=2.12,<2.13" "transformers>=5.16.1,<5.17" "accelerate>=1.13" \
69
+ "safetensors>=0.8" "torchao==0.15.0"
70
+ ```
71
+
72
+ ## Usage
73
+
74
+ ```python
75
+ import torch
76
+ from transformers import AutoModelForCausalLM, AutoTokenizer
77
+
78
+ model_id = "HCHs/RivetCoder-9B-A4B-FP8"
79
+
80
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
81
+ model = AutoModelForCausalLM.from_pretrained(
82
+ model_id,
83
+ trust_remote_code=True,
84
+ device_map=0,
85
+ dtype=torch.bfloat16,
86
+ ).eval()
87
+
88
+ messages = [{
89
+ "role": "user",
90
+ "content": "Implement merge_intervals in Python and include concise tests.",
91
+ }]
92
+ inputs = tokenizer.apply_chat_template(
93
+ messages,
94
+ add_generation_prompt=True,
95
+ return_tensors="pt",
96
+ return_dict=True,
97
+ ).to("cuda")
98
+
99
+ # Use no_grad with the tested TorchAO/PyTorch stack.
100
+ with torch.no_grad():
101
+ output = model.generate(
102
+ **inputs,
103
+ max_new_tokens=1024,
104
+ temperature=0.2,
105
+ do_sample=True,
106
+ )
107
+
108
+ print(tokenizer.decode(
109
+ output[0, inputs["input_ids"].shape[-1]:],
110
+ skip_special_tokens=True,
111
+ ))
112
+ ```
113
+
114
+ The bundled chat template opens a reasoning segment before the final answer.
115
+ Allocate enough output tokens for both reasoning and code.
116
+
117
+ ## Validation
118
+
119
+ The saved FP8 tensors were independently reloaded entirely on one RTX 5070 Ti.
120
+ The clean reload took about 338 seconds, found no CPU or `meta` parameters, and
121
+ restored all 1,636 FP8 parameters. A separate six-token forward pass produced
122
+ finite logits with shape `(1, 6, 128000)`.
123
+
124
+ On the tested Windows stack, `torch.inference_mode()` is incompatible with the
125
+ TorchAO FP8 tensor subclass and raises a version-counter error. Use
126
+ `torch.no_grad()` as shown above.
127
+
128
+ TorchAO 0.15.0 also reports that its optional C++ extensions are skipped with
129
+ the tested PyTorch 2.12 build. The native CUDA FP8 path used by this checkpoint
130
+ still passed quantization, serialization, clean reload, and forward validation.
131
+
132
+ ## Limitations
133
+
134
+ - This is an experimental fusion with only 60 routing-control optimizer steps.
135
+ - HumanEval, MBPP, SWE-bench, and broad regression results have not been reported.
136
+ - The fixed GLM-to-LFM bridge is deterministic and was not learned.
137
+ - This TorchAO checkpoint is not a GGUF file and is not directly compatible
138
+ with llama.cpp, LM Studio, or Ollama.
139
+ - Hardware and software combinations other than the tested stack may need
140
+ additional compatibility work.
141
+
142
+ See `provenance/quantization.json` for the local quantization and placement
143
+ report. Architecture, source-model, expert-selection, and router-training
144
+ provenance are retained from the BF16 repository.
145
+
146
+ ## License and attribution
147
+
148
+ The LFM host remains subject to the included LFM Open License v1.0. GLM-derived
149
+ expert tensors retain the included MIT license and attribution. Review
150
+ `LICENSE`, `NOTICE.md`, and `licenses/` before redistribution or deployment.
chat_template.jinja ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- bos_token -}}
2
+ {%- set preserve_thinking = preserve_thinking | default(false) -%}
3
+
4
+ {%- macro format_arg_value(arg_value) -%}
5
+ {%- if arg_value is string -%}
6
+ {{- "'" + (arg_value | replace("\\", "\\\\") | replace("'", "\\'") | replace("\n", "\\n") | replace("\r", "\\r")) + "'" -}}
7
+ {%- elif arg_value is mapping or arg_value is iterable -%}
8
+ {{- arg_value | tojson -}}
9
+ {%- else -%}
10
+ {{- arg_value | string -}}
11
+ {%- endif -%}
12
+ {%- endmacro -%}
13
+
14
+ {%- macro parse_content(content) -%}
15
+ {%- if content is string -%}
16
+ {{- content -}}
17
+ {%- elif content is mapping -%}
18
+ {{- content | tojson -}}
19
+ {%- elif content is iterable -%}
20
+ {%- set _ns = namespace(result="") -%}
21
+ {%- for item in content -%}
22
+ {%- if item is string -%}
23
+ {%- set _ns.result = _ns.result + item -%}
24
+ {%- elif item is mapping and item.get("type") == "image" -%}
25
+ {%- set _ns.result = _ns.result + "<image>" -%}
26
+ {%- elif item is mapping and item.get("type") == "text" -%}
27
+ {%- set _ns.result = _ns.result + ((item.get("text") or "") | string) -%}
28
+ {%- else -%}
29
+ {%- set _ns.result = _ns.result + (item | tojson) -%}
30
+ {%- endif -%}
31
+ {%- endfor -%}
32
+ {{- _ns.result -}}
33
+ {%- endif -%}
34
+ {%- endmacro -%}
35
+
36
+ {%- macro render_tool_calls(tool_calls) -%}
37
+ {%- set tool_calls_ns = namespace(tool_calls=[]) -%}
38
+ {%- for tool_call in tool_calls -%}
39
+ {%- set func = tool_call["function"] if "function" in tool_call else tool_call -%}
40
+ {%- set func_name = func["name"] -%}
41
+ {%- set func_args = func.get("arguments") -%}
42
+ {%- set args_ns = namespace(arg_strings=[]) -%}
43
+ {%- if func_args is mapping -%}
44
+ {%- for arg_name, arg_value in func_args.items() -%}
45
+ {%- set args_ns.arg_strings = args_ns.arg_strings + [arg_name + "=" + format_arg_value(arg_value)] -%}
46
+ {%- endfor -%}
47
+ {%- elif func_args is string and (func_args | trim) not in ["", "{}", "null"] -%}
48
+ {{- raise_exception("Tool call arguments must be a mapping, got a JSON-encoded string: parse arguments with json.loads() before applying the chat template") -}}
49
+ {%- endif -%}
50
+ {%- set tool_calls_ns.tool_calls = tool_calls_ns.tool_calls + [func_name + "(" + (args_ns.arg_strings | join(", ")) + ")"] -%}
51
+ {%- endfor -%}
52
+ {{- "<|tool_call_start|>[" + (tool_calls_ns.tool_calls | join(", ")) + "]<|tool_call_end|>" -}}
53
+ {%- endmacro -%}
54
+
55
+ {%- set ns = namespace(system_prompt="", last_user_index=-1) -%}
56
+ {%- if messages and messages[0]["role"] == "system" -%}
57
+ {%- if messages[0].get("content") -%}
58
+ {%- set ns.system_prompt = parse_content(messages[0]["content"]) -%}
59
+ {%- endif -%}
60
+ {%- set messages = messages[1:] -%}
61
+ {%- endif -%}
62
+ {%- if tools -%}
63
+ {%- set ns.system_prompt = ns.system_prompt + ("\n" if ns.system_prompt else "") + "List of tools: [" -%}
64
+ {%- for tool in tools -%}
65
+ {%- if tool is not string -%}
66
+ {%- set tool = tool | tojson -%}
67
+ {%- endif -%}
68
+ {%- set ns.system_prompt = ns.system_prompt + tool -%}
69
+ {%- if not loop.last -%}
70
+ {%- set ns.system_prompt = ns.system_prompt + ", " -%}
71
+ {%- endif -%}
72
+ {%- endfor -%}
73
+ {%- set ns.system_prompt = ns.system_prompt + "]" -%}
74
+ {%- endif -%}
75
+ {%- if ns.system_prompt -%}
76
+ {{- "<|im_start|>system\n" + ns.system_prompt + "<|im_end|>\n" -}}
77
+ {%- endif -%}
78
+ {%- for message in messages -%}
79
+ {%- if message["role"] == "user" -%}
80
+ {%- set ns.last_user_index = loop.index0 -%}
81
+ {%- endif -%}
82
+ {%- endfor -%}
83
+ {%- for message in messages -%}
84
+ {{- "<|im_start|>" + message.role + "\n" -}}
85
+ {%- if message.role == "assistant" -%}
86
+ {%- generation -%}
87
+ {%- set keep_thinking = preserve_thinking or loop.index0 > ns.last_user_index -%}
88
+ {%- set thinking = message.thinking or message.reasoning or message.reasoning_content -%}
89
+ {%- set thinking = thinking if thinking is string else "" -%}
90
+ {%- if thinking and keep_thinking -%}
91
+ {{- "<think>" + thinking + "</think>" -}}
92
+ {%- endif -%}
93
+ {%- set _cfm_tag = "CONTINUE_FINAL_MESSAGE_TAG " -%}
94
+ {%- set _has_cfm = false -%}
95
+ {%- set content = "" -%}
96
+ {%- if message.get("content") -%}
97
+ {%- set content = parse_content(message.content) -%}
98
+ {%- endif -%}
99
+ {%- if not keep_thinking and "</think>" in content -%}
100
+ {%- set content = content.split("</think>")[-1] | trim -%}
101
+ {%- endif -%}
102
+ {%- if content.endswith(_cfm_tag) -%}
103
+ {%- set _has_cfm = true -%}
104
+ {%- set _trunc_len = (content | length) - (_cfm_tag | length) -%}
105
+ {%- set content = content[:_trunc_len] -%}
106
+ {%- endif -%}
107
+ {{- content -}}
108
+ {%- if message.tool_calls -%}
109
+ {{- render_tool_calls(message.tool_calls) -}}
110
+ {%- endif -%}
111
+ {%- if _has_cfm -%}
112
+ {{- _cfm_tag -}}
113
+ {%- endif -%}
114
+ {{- "<|im_end|>\n" -}}
115
+ {%- endgeneration -%}
116
+ {%- else %}
117
+ {%- if message.get("content") -%}
118
+ {{- parse_content(message["content"]) -}}
119
+ {%- endif -%}
120
+ {{- "<|im_end|>\n" -}}
121
+ {%- endif %}
122
+ {%- endfor -%}
123
+ {%- if add_generation_prompt -%}
124
+ {{- "<|im_start|>assistant\n<think>" -}}
125
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "FuseGlmForCausalLM"
4
+ ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_fuse_glm.FuseGlmConfig",
7
+ "AutoModelForCausalLM": "modeling_fuse_glm.FuseGlmForCausalLM"
8
+ },
9
+ "block_auto_adjust_ff_dim": false,
10
+ "block_dim": 2048,
11
+ "block_ffn_dim_multiplier": 1.0,
12
+ "block_mlp_init_scale": 1.0,
13
+ "block_multiple_of": 256,
14
+ "block_norm_eps": 1e-05,
15
+ "block_out_init_scale": 1.0,
16
+ "block_use_swiglu": true,
17
+ "block_use_xavier_init": true,
18
+ "bos_token_id": 124894,
19
+ "conv_L_cache": 3,
20
+ "conv_bias": false,
21
+ "conv_dim": 2048,
22
+ "conv_use_xavier_init": true,
23
+ "dtype": "bfloat16",
24
+ "eos_token_id": 124900,
25
+ "full_attn_idxs": null,
26
+ "fuse_glm_coding_enabled": true,
27
+ "fuse_glm_expert_intermediate_size": 2048,
28
+ "fuse_glm_gate_clamp_max": 10.0,
29
+ "fuse_glm_hard_token_gate_at_eval": false,
30
+ "fuse_glm_layer_indices": [
31
+ 0,
32
+ 1,
33
+ 2,
34
+ 3,
35
+ 4,
36
+ 5,
37
+ 6,
38
+ 7,
39
+ 8,
40
+ 9,
41
+ 10,
42
+ 11,
43
+ 12,
44
+ 13,
45
+ 14,
46
+ 15,
47
+ 16,
48
+ 17,
49
+ 18,
50
+ 19,
51
+ 20,
52
+ 21,
53
+ 22,
54
+ 23,
55
+ 24,
56
+ 25,
57
+ 26,
58
+ 27,
59
+ 28,
60
+ 29
61
+ ],
62
+ "fuse_glm_num_experts": 16,
63
+ "fuse_glm_output_router_diagnostics": false,
64
+ "fuse_glm_residual_scale_max": 0.1,
65
+ "fuse_glm_router_aux_loss_coef": 0.0,
66
+ "fuse_glm_token_gate_bias": -4.0,
67
+ "fuse_glm_token_gate_threshold": 0.5,
68
+ "fuse_glm_top_k": 4,
69
+ "fuse_glm_up_clamp_max": 10.0,
70
+ "fuse_glm_up_clamp_min": -10.0,
71
+ "hidden_size": 2048,
72
+ "initializer_range": 0.02,
73
+ "intermediate_size": 10752,
74
+ "layer_types": [
75
+ "linear_attention",
76
+ "linear_attention",
77
+ "full_attention",
78
+ "linear_attention",
79
+ "linear_attention",
80
+ "full_attention",
81
+ "linear_attention",
82
+ "linear_attention",
83
+ "linear_attention",
84
+ "full_attention",
85
+ "linear_attention",
86
+ "linear_attention",
87
+ "linear_attention",
88
+ "full_attention",
89
+ "linear_attention",
90
+ "linear_attention",
91
+ "linear_attention",
92
+ "full_attention",
93
+ "linear_attention",
94
+ "linear_attention",
95
+ "linear_attention",
96
+ "full_attention",
97
+ "linear_attention",
98
+ "linear_attention",
99
+ "full_attention",
100
+ "linear_attention",
101
+ "linear_attention",
102
+ "full_attention",
103
+ "linear_attention",
104
+ "linear_attention"
105
+ ],
106
+ "max_position_embeddings": 131072,
107
+ "model_type": "fuse_glm",
108
+ "norm_eps": 1e-05,
109
+ "num_attention_heads": 32,
110
+ "num_heads": 32,
111
+ "num_hidden_layers": 30,
112
+ "num_key_value_heads": 8,
113
+ "pad_token_id": 124893,
114
+ "quantization_config": {
115
+ "include_input_output_embeddings": false,
116
+ "modules_to_not_convert": null,
117
+ "quant_method": "torchao",
118
+ "quant_type": {
119
+ "default": {
120
+ "_data": {
121
+ "activation_dtype": {
122
+ "_data": "float8_e4m3fn",
123
+ "_type": "torch.dtype"
124
+ },
125
+ "activation_value_lb": null,
126
+ "activation_value_ub": null,
127
+ "granularity": [
128
+ {
129
+ "_data": {},
130
+ "_type": "PerTensor",
131
+ "_version": 1
132
+ },
133
+ {
134
+ "_data": {},
135
+ "_type": "PerTensor",
136
+ "_version": 1
137
+ }
138
+ ],
139
+ "kernel_preference": {
140
+ "_data": "AUTO",
141
+ "_type": "KernelPreference"
142
+ },
143
+ "mm_config": {
144
+ "_data": {
145
+ "emulate": false,
146
+ "pad_inner_dim": false,
147
+ "use_fast_accum": true
148
+ },
149
+ "_type": "Float8MMConfig",
150
+ "_version": 1
151
+ },
152
+ "set_inductor_config": true,
153
+ "weight_dtype": {
154
+ "_data": "float8_e4m3fn",
155
+ "_type": "torch.dtype"
156
+ }
157
+ },
158
+ "_type": "Float8DynamicActivationFloat8WeightConfig",
159
+ "_version": 2
160
+ }
161
+ },
162
+ "untie_embedding_weights": false
163
+ },
164
+ "rivet_coder": {
165
+ "active_parameters_approx": 4210000000,
166
+ "base_repo_id": "HCHs/RivetCoder-9B-A4B",
167
+ "donor": "zai-org/GLM-5.3-Flash",
168
+ "experts_per_layer": 16,
169
+ "experts_per_token": 4,
170
+ "host": "LiquidAI/LFM2.5-2.6B",
171
+ "name": "RivetCoder-9B-A4B-FP8",
172
+ "quantization": "TorchAO Float8DynamicActivationFloat8WeightConfig",
173
+ "repo_id": "HCHs/RivetCoder-9B-A4B-FP8",
174
+ "router_teacher": "qwen/qwen3.8-27b",
175
+ "total_parameters_approx": 8740000000,
176
+ "training_steps": 60
177
+ },
178
+ "rope_parameters": {
179
+ "rope_theta": 10000000.0,
180
+ "rope_type": "default"
181
+ },
182
+ "tie_word_embeddings": true,
183
+ "transformers_version": "5.16.1",
184
+ "use_cache": true,
185
+ "use_pos_enc": true,
186
+ "vocab_size": 128000
187
+ }
configuration_fuse_glm.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Configuration for the LFM2 + folded GLM expert model.
2
+
3
+ The defaults describe the intended production architecture: sixteen folded
4
+ GLM experts in every LFM2 layer, with four experts selected per token.
5
+ All dimensions remain configurable so the implementation can be exercised
6
+ with very small, synthetic models without downloading either checkpoint.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from collections.abc import Mapping
12
+ from typing import Any
13
+
14
+ from transformers import Lfm2Config
15
+
16
+
17
+ class FuseGlmConfig(Lfm2Config):
18
+ """Extend :class:`~transformers.Lfm2Config` with sparse GLM sidecars.
19
+
20
+ Parameters prefixed with ``fuse_glm_`` only control the added expert
21
+ branch. All ordinary LFM2 configuration arguments are forwarded to
22
+ ``Lfm2Config`` unchanged.
23
+
24
+ ``fuse_glm_layer_indices=None`` means that every decoder layer receives a
25
+ sidecar. A concrete list can be supplied for ablations or staged builds.
26
+ The production model uses hidden/intermediate size 2048; tests may select
27
+ smaller values.
28
+ """
29
+
30
+ model_type = "fuse_glm"
31
+
32
+ def __init__(
33
+ self,
34
+ *,
35
+ fuse_glm_num_experts: int = 16,
36
+ fuse_glm_top_k: int = 4,
37
+ fuse_glm_expert_intermediate_size: int = 2048,
38
+ fuse_glm_layer_indices: list[int] | tuple[int, ...] | None = None,
39
+ fuse_glm_gate_clamp_max: float = 10.0,
40
+ fuse_glm_up_clamp_min: float = -10.0,
41
+ fuse_glm_up_clamp_max: float = 10.0,
42
+ fuse_glm_residual_scale_max: float = 0.1,
43
+ fuse_glm_router_aux_loss_coef: float = 0.01,
44
+ fuse_glm_token_gate_bias: float = -4.0,
45
+ fuse_glm_token_gate_threshold: float = 0.5,
46
+ fuse_glm_hard_token_gate_at_eval: bool = False,
47
+ fuse_glm_coding_enabled: bool = True,
48
+ fuse_glm_output_router_diagnostics: bool = False,
49
+ **kwargs: Any,
50
+ ) -> None:
51
+ super().__init__(**kwargs)
52
+
53
+ # Transformers 5.16 remaps legacy attention names for configurations
54
+ # it classifies as custom code. LFM2's implementation still indexes
55
+ # masks with the literal key ``conv``, however, so a FuseGlmConfig
56
+ # must retain the host model's native spelling. Without this reversal
57
+ # a real LFM checkpoint fails in Lfm2Model.forward with
58
+ # ``KeyError: 'linear_attention'`` even though an Lfm2Config loaded
59
+ # from the same file works correctly.
60
+ self.layer_types = [
61
+ "conv" if layer_type == "linear_attention" else layer_type
62
+ for layer_type in self.layer_types
63
+ ]
64
+
65
+ self.fuse_glm_num_experts = int(fuse_glm_num_experts)
66
+ self.fuse_glm_top_k = int(fuse_glm_top_k)
67
+ self.fuse_glm_expert_intermediate_size = int(fuse_glm_expert_intermediate_size)
68
+ self.fuse_glm_layer_indices = (
69
+ None if fuse_glm_layer_indices is None else [int(index) for index in fuse_glm_layer_indices]
70
+ )
71
+ self.fuse_glm_gate_clamp_max = float(fuse_glm_gate_clamp_max)
72
+ self.fuse_glm_up_clamp_min = float(fuse_glm_up_clamp_min)
73
+ self.fuse_glm_up_clamp_max = float(fuse_glm_up_clamp_max)
74
+ self.fuse_glm_residual_scale_max = float(fuse_glm_residual_scale_max)
75
+ self.fuse_glm_router_aux_loss_coef = float(fuse_glm_router_aux_loss_coef)
76
+ self.fuse_glm_token_gate_bias = float(fuse_glm_token_gate_bias)
77
+ self.fuse_glm_token_gate_threshold = float(fuse_glm_token_gate_threshold)
78
+ self.fuse_glm_hard_token_gate_at_eval = bool(fuse_glm_hard_token_gate_at_eval)
79
+ self.fuse_glm_coding_enabled = bool(fuse_glm_coding_enabled)
80
+ self.fuse_glm_output_router_diagnostics = bool(fuse_glm_output_router_diagnostics)
81
+
82
+ self._validate_fuse_glm_fields()
83
+
84
+ # Saved checkpoints should resolve to the fused class rather than the
85
+ # base LFM2 class. This does not affect loading an ordinary LFM config
86
+ # through ``from_lfm_config`` below.
87
+ self.architectures = ["FuseGlmForCausalLM"]
88
+
89
+ @property
90
+ def resolved_fuse_glm_layer_indices(self) -> tuple[int, ...]:
91
+ """Return the validated decoder layer indices receiving experts."""
92
+
93
+ if self.fuse_glm_layer_indices is None:
94
+ return tuple(range(self.num_hidden_layers))
95
+ return tuple(self.fuse_glm_layer_indices)
96
+
97
+ def _validate_fuse_glm_fields(self) -> None:
98
+ if self.fuse_glm_num_experts < 1:
99
+ raise ValueError("fuse_glm_num_experts must be at least 1")
100
+ if not 1 <= self.fuse_glm_top_k <= self.fuse_glm_num_experts:
101
+ raise ValueError("fuse_glm_top_k must be between 1 and fuse_glm_num_experts")
102
+ if self.fuse_glm_expert_intermediate_size < 1:
103
+ raise ValueError("fuse_glm_expert_intermediate_size must be at least 1")
104
+ if self.fuse_glm_up_clamp_min >= self.fuse_glm_up_clamp_max:
105
+ raise ValueError("fuse_glm_up_clamp_min must be smaller than fuse_glm_up_clamp_max")
106
+ if self.fuse_glm_residual_scale_max <= 0:
107
+ raise ValueError("fuse_glm_residual_scale_max must be positive")
108
+ if self.fuse_glm_router_aux_loss_coef < 0:
109
+ raise ValueError("fuse_glm_router_aux_loss_coef cannot be negative")
110
+ if not 0.0 <= self.fuse_glm_token_gate_threshold <= 1.0:
111
+ raise ValueError("fuse_glm_token_gate_threshold must be in [0, 1]")
112
+
113
+ indices = self.resolved_fuse_glm_layer_indices
114
+ if len(set(indices)) != len(indices):
115
+ raise ValueError("fuse_glm_layer_indices cannot contain duplicates")
116
+ invalid = [index for index in indices if index < 0 or index >= self.num_hidden_layers]
117
+ if invalid:
118
+ raise ValueError(
119
+ "fuse_glm_layer_indices contains indices outside the LFM2 decoder: "
120
+ f"{invalid} (num_hidden_layers={self.num_hidden_layers})"
121
+ )
122
+
123
+ @classmethod
124
+ def from_lfm_config(
125
+ cls,
126
+ config: Lfm2Config | Mapping[str, Any],
127
+ **fuse_overrides: Any,
128
+ ) -> "FuseGlmConfig":
129
+ """Create a fused config from an existing LFM2 config.
130
+
131
+ This method is purely local and never resolves or downloads a model.
132
+ ``config`` may be an instantiated ``Lfm2Config`` or its dictionary.
133
+ """
134
+
135
+ if isinstance(config, Lfm2Config):
136
+ config_dict = config.to_dict()
137
+ elif isinstance(config, Mapping):
138
+ config_dict = dict(config)
139
+ else:
140
+ raise TypeError("config must be an Lfm2Config or a mapping")
141
+
142
+ # These values describe the source class/revision, not constructor
143
+ # fields of the new local class.
144
+ for key in ("model_type", "_commit_hash"):
145
+ config_dict.pop(key, None)
146
+ config_dict.pop("architectures", None)
147
+ config_dict.update(fuse_overrides)
148
+ return cls(**config_dict)
149
+
150
+
151
+ __all__ = ["FuseGlmConfig"]
generation_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 124894,
4
+ "do_sample": true,
5
+ "eos_token_id": [
6
+ 124900
7
+ ],
8
+ "output_attentions": false,
9
+ "output_hidden_states": false,
10
+ "pad_token_id": 124893,
11
+ "repetition_penalty": 1.1,
12
+ "temperature": 0.1,
13
+ "top_k": 50,
14
+ "transformers_version": "5.16.1",
15
+ "use_cache": true
16
+ }
licenses/GLM-MIT.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Z.AI Co., Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
licenses/LFM-OPEN-LICENSE-v1.0.txt ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ LFM Open License v1.0
2
+
3
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
4
+
5
+ 1. Definitions.
6
+
7
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
8
+
9
+ "Licensor" shall mean Liquid AI, Inc.
10
+
11
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
12
+
13
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
14
+
15
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
16
+
17
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
18
+
19
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
20
+
21
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
22
+
23
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
24
+
25
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
26
+
27
+ "Commercial Use" shall mean any use of the Work for direct or indirect commercial advantage or monetary compensation.
28
+
29
+ "Qualified Non-Profit Organization" shall mean a Legal Entity that is organized and operated exclusively for religious, charitable, scientific, testing for public safety, literary, or educational purposes, and which is exempt from federal income tax under Section 501(c)(3) of the United States Internal Revenue Code of 1986, as amended, or any equivalent non-profit or charitable organization in a foreign jurisdiction.
30
+
31
+ "Non-Commercial or Research Purposes" shall mean purposes that do not involve any use of the Work or a Derivative Work for Commercial Use.
32
+
33
+ "Threshold" shall mean annual revenue of 10 million United States dollars ($10,000,000) or more.
34
+
35
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, including the Commercial Use limitation set forth in Section 5, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
36
+
37
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, including the Commercial Use limitation set forth in Section 5, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
38
+
39
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
40
+
41
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
42
+
43
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
44
+
45
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
46
+
47
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
48
+
49
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
50
+
51
+ 5. Commercial Use Limitation.
52
+
53
+ (a) The rights granted under this License for Commercial Use are conditioned upon You or Your Legal Entity not exceeding the Threshold.
54
+
55
+ (b) Any Commercial Use of the Work or a Derivative Work by a Legal Entity that exceeds the Threshold is not licensed under this Agreement.
56
+
57
+ (c) The Threshold shall not apply to a Qualified Non-Profit Organization's use of the Work or a Derivative Work for Non-Commercial or Research Purposes.
58
+
59
+ 6. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
60
+
61
+ 7. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except for the reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
62
+
63
+ 8. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
64
+
65
+ 9. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
66
+
67
+ 10. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
68
+
69
+ 11. Termination. This License will terminate automatically and immediately if You fail to comply with any of its terms and conditions. Upon termination, You must cease all use of the Work and any Derivative Works and delete all copies in Your possession.
70
+
71
+ END OF TERMS AND CONDITIONS
model-00001-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a3c863c63fb2c52b7f881b483ffc7d1f4b352b2de932b718f62b2b2134de1e8
3
+ size 1999384120
model-00002-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e1668117e8a2ad1c7d4ff9a12c1687c9e907a39738dcafd1a48647d38a6efed3
3
+ size 1999530876
model-00003-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f7266ae364fb4bb0c3f30da7deca8133d7501fb415840861de747716ed483ca
3
+ size 1999519716
model-00004-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ebb55bc7f9cd7139d3e21c0677f2b2b7f99ec25925837729b0c07a6efa2b0074
3
+ size 1999519740
model-00005-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5aec98e4957c1263db1e79f2014f468620ec1b512831256329d8091f762fc61a
3
+ size 1010472884
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
modeling_fuse_glm.py ADDED
@@ -0,0 +1,757 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """LFM2 with sparse, folded GLM-5.3-Flash coding experts.
2
+
3
+ The implementation intentionally depends only on upstream ``transformers``
4
+ LFM2 classes. It does not import GLM modeling code and it never downloads a
5
+ checkpoint at import or construction time. Folded expert tensors can be
6
+ copied into the exposed ``gate_proj``, ``up_proj`` and ``down_proj`` modules
7
+ after a separate extraction/folding step.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from contextlib import contextmanager
13
+ from dataclasses import dataclass
14
+ from typing import Any, Iterator, Literal
15
+
16
+ import torch
17
+ import torch.nn.functional as F
18
+ from torch import nn
19
+ from transformers import Lfm2Config, Lfm2ForCausalLM
20
+ from transformers.modeling_outputs import CausalLMOutputWithPast
21
+
22
+ from .configuration_fuse_glm import FuseGlmConfig
23
+
24
+
25
+ class _AddAuxiliaryLoss(torch.autograd.Function):
26
+ """Attach an auxiliary scalar gradient without changing forward values.
27
+
28
+ This is useful here because LFM2 decoder layers return only hidden states.
29
+ Returning the router loss through that API would require replacing the
30
+ entire decoder stack and would also interfere with generation caches. The
31
+ identity operation keeps the native forward contract and remains valid
32
+ when gradient checkpointing recomputes a decoder layer.
33
+ """
34
+
35
+ @staticmethod
36
+ def forward(ctx: Any, hidden_states: torch.Tensor, auxiliary_loss: torch.Tensor) -> torch.Tensor:
37
+ ctx.auxiliary_dtype = auxiliary_loss.dtype
38
+ ctx.auxiliary_device = auxiliary_loss.device
39
+ return hidden_states
40
+
41
+ @staticmethod
42
+ def backward(ctx: Any, grad_output: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
43
+ auxiliary_grad = torch.ones((), dtype=ctx.auxiliary_dtype, device=ctx.auxiliary_device)
44
+ return grad_output, auxiliary_grad
45
+
46
+
47
+ @dataclass(frozen=True)
48
+ class RouterState:
49
+ """Differentiable routing state from one fused decoder layer."""
50
+
51
+ layer_index: int
52
+ token_indices: torch.Tensor
53
+ router_logits: torch.Tensor
54
+ topk_indices: torch.Tensor
55
+ topk_weights: torch.Tensor
56
+ token_gate: torch.Tensor
57
+ auxiliary_loss: torch.Tensor
58
+
59
+ def detached(self) -> "RouterState":
60
+ return RouterState(
61
+ layer_index=self.layer_index,
62
+ token_indices=self.token_indices.detach(),
63
+ router_logits=self.router_logits.detach(),
64
+ topk_indices=self.topk_indices.detach(),
65
+ topk_weights=self.topk_weights.detach(),
66
+ token_gate=self.token_gate.detach(),
67
+ auxiliary_loss=self.auxiliary_loss.detach(),
68
+ )
69
+
70
+
71
+ @dataclass(frozen=True)
72
+ class RouterDiagnostics:
73
+ """Compact, detached-by-default statistics for monitoring routing."""
74
+
75
+ layer_index: int
76
+ token_count: int
77
+ active_token_count: int
78
+ expert_counts: torch.Tensor
79
+ mean_selected_weights: torch.Tensor
80
+ router_entropy: torch.Tensor
81
+ token_gate_mean: torch.Tensor
82
+ token_gate_active_fraction: torch.Tensor
83
+ residual_scale: torch.Tensor
84
+ auxiliary_loss: torch.Tensor
85
+ coding_enabled: bool
86
+
87
+ def detached(self) -> "RouterDiagnostics":
88
+ return RouterDiagnostics(
89
+ layer_index=self.layer_index,
90
+ token_count=self.token_count,
91
+ active_token_count=self.active_token_count,
92
+ expert_counts=self.expert_counts.detach(),
93
+ mean_selected_weights=self.mean_selected_weights.detach(),
94
+ router_entropy=self.router_entropy.detach(),
95
+ token_gate_mean=self.token_gate_mean.detach(),
96
+ token_gate_active_fraction=self.token_gate_active_fraction.detach(),
97
+ residual_scale=self.residual_scale.detach(),
98
+ auxiliary_loss=self.auxiliary_loss.detach(),
99
+ coding_enabled=self.coding_enabled,
100
+ )
101
+
102
+
103
+ @dataclass
104
+ class FuseGlmCausalLMOutputWithPast(CausalLMOutputWithPast):
105
+ """Causal LM output augmented with sparse-router training information."""
106
+
107
+ router_aux_loss: torch.FloatTensor | None = None
108
+ router_diagnostics: tuple[RouterDiagnostics, ...] | None = None
109
+
110
+
111
+ class FoldedGlmExpert(nn.Module):
112
+ """A folded GLM-clamped SwiGLU expert in the LFM hidden space.
113
+
114
+ For the production configuration all three dimensions are 2048. The
115
+ separate ``intermediate_size`` argument exists to enable inexpensive unit
116
+ tests and later structured compression experiments.
117
+ """
118
+
119
+ def __init__(
120
+ self,
121
+ hidden_size: int,
122
+ intermediate_size: int,
123
+ *,
124
+ gate_clamp_max: float = 10.0,
125
+ up_clamp_min: float = -10.0,
126
+ up_clamp_max: float = 10.0,
127
+ initializer_range: float = 0.02,
128
+ ) -> None:
129
+ super().__init__()
130
+ self.hidden_size = int(hidden_size)
131
+ self.intermediate_size = int(intermediate_size)
132
+ self.gate_clamp_max = float(gate_clamp_max)
133
+ self.up_clamp_min = float(up_clamp_min)
134
+ self.up_clamp_max = float(up_clamp_max)
135
+
136
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
137
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
138
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
139
+ self.reset_parameters(initializer_range)
140
+
141
+ def reset_parameters(self, initializer_range: float) -> None:
142
+ for projection in (self.gate_proj, self.up_proj, self.down_proj):
143
+ nn.init.normal_(projection.weight, mean=0.0, std=initializer_range)
144
+
145
+ def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
146
+ gate = self.gate_proj(hidden_states).clamp(max=self.gate_clamp_max)
147
+ up = self.up_proj(hidden_states).clamp(min=self.up_clamp_min, max=self.up_clamp_max)
148
+ return self.down_proj(F.silu(gate) * up)
149
+
150
+ @torch.no_grad()
151
+ def load_folded_weights(
152
+ self,
153
+ *,
154
+ gate_proj: torch.Tensor,
155
+ up_proj: torch.Tensor,
156
+ down_proj: torch.Tensor,
157
+ ) -> None:
158
+ """Validate and copy three already-folded expert matrices."""
159
+
160
+ supplied = {
161
+ "gate_proj": gate_proj,
162
+ "up_proj": up_proj,
163
+ "down_proj": down_proj,
164
+ }
165
+ modules = {
166
+ "gate_proj": self.gate_proj,
167
+ "up_proj": self.up_proj,
168
+ "down_proj": self.down_proj,
169
+ }
170
+ for name, tensor in supplied.items():
171
+ expected_shape = tuple(modules[name].weight.shape)
172
+ if tuple(tensor.shape) != expected_shape:
173
+ raise ValueError(f"{name} has shape {tuple(tensor.shape)}; expected {expected_shape}")
174
+ modules[name].weight.copy_(tensor.to(device=modules[name].weight.device, dtype=modules[name].weight.dtype))
175
+
176
+
177
+ class TopKFoldedExpertRouter(nn.Module):
178
+ """GLM-style sigmoid top-k router with post-sigmoid choice correction."""
179
+
180
+ def __init__(self, hidden_size: int, num_experts: int, top_k: int, initializer_range: float) -> None:
181
+ super().__init__()
182
+ self.num_experts = int(num_experts)
183
+ self.top_k = int(top_k)
184
+ self.proj = nn.Linear(hidden_size, num_experts, bias=False)
185
+ nn.init.normal_(self.proj.weight, mean=0.0, std=initializer_range)
186
+ # GLM adds this value only while choosing experts. The routed mixture
187
+ # weights are gathered from the uncorrected sigmoid scores, so this
188
+ # must not be represented as a Linear bias.
189
+ self.register_buffer(
190
+ "e_score_correction_bias",
191
+ torch.zeros(self.num_experts, dtype=torch.float32),
192
+ )
193
+
194
+ def forward(
195
+ self,
196
+ hidden_states: torch.Tensor,
197
+ ) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
198
+ # GLM computes router logits in FP32 even when expert weights are FP8
199
+ # or BF16. Keeping that behavior also stabilizes small synthetic tests.
200
+ logits = F.linear(hidden_states.float(), self.proj.weight.float())
201
+ scores = torch.sigmoid(logits)
202
+ choice_scores = scores + self.e_score_correction_bias.float()
203
+ selected_indices = torch.topk(choice_scores, self.top_k, dim=-1).indices
204
+ selected_scores = scores.gather(-1, selected_indices)
205
+ selected_weights = selected_scores / selected_scores.sum(dim=-1, keepdim=True).clamp_min(1e-12)
206
+
207
+ # Switch-style balancing objective. The top-k assignment fraction is
208
+ # normalized by k, making a perfectly balanced value equal to 1.
209
+ probabilities = torch.softmax(logits, dim=-1)
210
+ assignment = F.one_hot(selected_indices, num_classes=self.num_experts).float().sum(dim=-2)
211
+ assignment = assignment / float(self.top_k)
212
+ probability_fraction = probabilities.mean(dim=0)
213
+ token_fraction = assignment.mean(dim=0)
214
+ auxiliary_loss = self.num_experts * torch.sum(probability_fraction * token_fraction)
215
+ return logits, selected_indices, selected_weights, auxiliary_loss
216
+
217
+
218
+ class FuseGlmFeedForward(nn.Module):
219
+ """Preserve the native LFM FFN and add a sparse expert sidecar in parallel.
220
+
221
+ The native projections remain registered directly as ``w1``, ``w2`` and
222
+ ``w3``. Consequently their state-dict keys are identical to an ordinary
223
+ ``Lfm2ForCausalLM`` checkpoint even after this wrapper is installed.
224
+ """
225
+
226
+ def __init__(
227
+ self,
228
+ base_ffn: nn.Module,
229
+ config: FuseGlmConfig,
230
+ layer_index: int,
231
+ *,
232
+ auxiliary_loss_scale: float,
233
+ ) -> None:
234
+ super().__init__()
235
+ for name in ("w1", "w2", "w3"):
236
+ if not hasattr(base_ffn, name):
237
+ raise TypeError(f"Unsupported LFM2 feed_forward module: missing {name}")
238
+
239
+ # Preserve original checkpoint paths: feed_forward.w1/w2/w3.
240
+ self.w1 = base_ffn.w1
241
+ self.w2 = base_ffn.w2
242
+ self.w3 = base_ffn.w3
243
+
244
+ self.layer_index = int(layer_index)
245
+ self.num_experts = config.fuse_glm_num_experts
246
+ self.top_k = config.fuse_glm_top_k
247
+ self.residual_scale_max = config.fuse_glm_residual_scale_max
248
+ self.token_gate_threshold = config.fuse_glm_token_gate_threshold
249
+ self.hard_token_gate_at_eval = config.fuse_glm_hard_token_gate_at_eval
250
+ self.coding_enabled = config.fuse_glm_coding_enabled
251
+ self.auxiliary_loss_scale = float(auxiliary_loss_scale)
252
+
253
+ self.experts = nn.ModuleList(
254
+ [
255
+ FoldedGlmExpert(
256
+ config.hidden_size,
257
+ config.fuse_glm_expert_intermediate_size,
258
+ gate_clamp_max=config.fuse_glm_gate_clamp_max,
259
+ up_clamp_min=config.fuse_glm_up_clamp_min,
260
+ up_clamp_max=config.fuse_glm_up_clamp_max,
261
+ initializer_range=config.initializer_range,
262
+ )
263
+ for _ in range(self.num_experts)
264
+ ]
265
+ )
266
+ self.router = TopKFoldedExpertRouter(
267
+ config.hidden_size,
268
+ self.num_experts,
269
+ self.top_k,
270
+ config.initializer_range,
271
+ )
272
+ self.token_gate = nn.Linear(config.hidden_size, 1, bias=True)
273
+ nn.init.zeros_(self.token_gate.weight)
274
+ nn.init.constant_(self.token_gate.bias, config.fuse_glm_token_gate_bias)
275
+
276
+ # tanh(0) is exactly zero, so a newly constructed fused model computes
277
+ # the same function as its LFM host while retaining nonzero expert
278
+ # activations from which this scale can learn.
279
+ self.raw_residual_scale = nn.Parameter(torch.zeros(()))
280
+ self.last_router_state: RouterState | None = None
281
+ self.last_router_diagnostics: RouterDiagnostics | None = None
282
+
283
+ @property
284
+ def residual_scale(self) -> torch.Tensor:
285
+ return self.residual_scale_max * torch.tanh(self.raw_residual_scale)
286
+
287
+ def base_forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
288
+ return self.w2(F.silu(self.w1(hidden_states)) * self.w3(hidden_states))
289
+
290
+ def _disabled_diagnostics(self, hidden_states: torch.Tensor) -> RouterDiagnostics:
291
+ scalar_zero = hidden_states.new_zeros(())
292
+ return RouterDiagnostics(
293
+ layer_index=self.layer_index,
294
+ token_count=hidden_states.numel() // hidden_states.shape[-1],
295
+ active_token_count=0,
296
+ expert_counts=torch.zeros(self.num_experts, dtype=torch.long, device=hidden_states.device),
297
+ mean_selected_weights=hidden_states.new_zeros(self.num_experts),
298
+ router_entropy=scalar_zero,
299
+ token_gate_mean=scalar_zero,
300
+ token_gate_active_fraction=scalar_zero,
301
+ residual_scale=self.residual_scale,
302
+ auxiliary_loss=scalar_zero,
303
+ coding_enabled=False,
304
+ )
305
+
306
+ def _dispatch(
307
+ self,
308
+ hidden_states: torch.Tensor,
309
+ selected_indices: torch.Tensor,
310
+ selected_weights: torch.Tensor,
311
+ ) -> torch.Tensor:
312
+ output = torch.zeros_like(hidden_states)
313
+ for expert_index, expert in enumerate(self.experts):
314
+ token_positions, route_slots = torch.where(selected_indices == expert_index)
315
+ if token_positions.numel() == 0:
316
+ continue
317
+ expert_input = hidden_states.index_select(0, token_positions)
318
+ expert_output = expert(expert_input)
319
+ route_weight = selected_weights[token_positions, route_slots].to(expert_output.dtype).unsqueeze(-1)
320
+ output = output.index_add(0, token_positions, expert_output * route_weight)
321
+ return output
322
+
323
+ def _make_diagnostics(
324
+ self,
325
+ state: RouterState,
326
+ token_count: int,
327
+ active_mask: torch.Tensor,
328
+ ) -> RouterDiagnostics:
329
+ expert_counts = F.one_hot(state.topk_indices, num_classes=self.num_experts).sum(dim=(0, 1))
330
+ selected_weight_sums = torch.zeros(
331
+ self.num_experts,
332
+ device=state.topk_weights.device,
333
+ dtype=state.topk_weights.dtype,
334
+ )
335
+ selected_weight_sums.scatter_add_(0, state.topk_indices.reshape(-1), state.topk_weights.reshape(-1))
336
+ mean_selected_weights = selected_weight_sums / expert_counts.clamp_min(1).to(selected_weight_sums.dtype)
337
+
338
+ if state.router_logits.shape[0] == 0:
339
+ entropy = state.router_logits.new_zeros(())
340
+ else:
341
+ probabilities = torch.softmax(state.router_logits, dim=-1)
342
+ entropy = -(probabilities * probabilities.clamp_min(1e-12).log()).sum(dim=-1).mean()
343
+ gate = state.token_gate
344
+ return RouterDiagnostics(
345
+ layer_index=self.layer_index,
346
+ token_count=token_count,
347
+ active_token_count=int(state.token_indices.numel()),
348
+ expert_counts=expert_counts,
349
+ mean_selected_weights=mean_selected_weights,
350
+ router_entropy=entropy,
351
+ token_gate_mean=gate.mean(),
352
+ token_gate_active_fraction=active_mask.float().mean(),
353
+ residual_scale=self.residual_scale,
354
+ auxiliary_loss=state.auxiliary_loss,
355
+ coding_enabled=True,
356
+ )
357
+
358
+ def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
359
+ base_output = self.base_forward(hidden_states)
360
+ if not self.coding_enabled:
361
+ self.last_router_state = None
362
+ self.last_router_diagnostics = self._disabled_diagnostics(hidden_states)
363
+ return base_output
364
+
365
+ original_shape = hidden_states.shape
366
+ flat_hidden = hidden_states.reshape(-1, original_shape[-1])
367
+ token_gate = torch.sigmoid(F.linear(flat_hidden.float(), self.token_gate.weight.float(), self.token_gate.bias.float()))
368
+ token_gate = token_gate.squeeze(-1)
369
+ active_mask = token_gate >= self.token_gate_threshold
370
+
371
+ # Soft gating is used while training so the token gate itself receives
372
+ # dense gradients. Optional hard gating at evaluation actually skips
373
+ # expert computation for low-confidence non-coding tokens.
374
+ if self.hard_token_gate_at_eval and not self.training:
375
+ token_indices = torch.where(active_mask)[0]
376
+ else:
377
+ token_indices = torch.arange(flat_hidden.shape[0], device=flat_hidden.device)
378
+
379
+ if token_indices.numel() == 0:
380
+ expert_delta = torch.zeros_like(flat_hidden)
381
+ auxiliary_loss = flat_hidden.sum() * 0.0
382
+ state = RouterState(
383
+ layer_index=self.layer_index,
384
+ token_indices=token_indices,
385
+ router_logits=flat_hidden.new_empty((0, self.num_experts), dtype=torch.float32),
386
+ topk_indices=torch.empty((0, self.top_k), dtype=torch.long, device=flat_hidden.device),
387
+ topk_weights=flat_hidden.new_empty((0, self.top_k), dtype=torch.float32),
388
+ token_gate=token_gate,
389
+ auxiliary_loss=auxiliary_loss,
390
+ )
391
+ else:
392
+ active_hidden = flat_hidden.index_select(0, token_indices)
393
+ logits, selected_indices, selected_weights, auxiliary_loss = self.router(active_hidden)
394
+ active_delta = self._dispatch(active_hidden, selected_indices, selected_weights)
395
+ active_gate = token_gate.index_select(0, token_indices).to(active_delta.dtype).unsqueeze(-1)
396
+ expert_delta = torch.zeros_like(flat_hidden).index_add(
397
+ 0,
398
+ token_indices,
399
+ active_delta * active_gate,
400
+ )
401
+ state = RouterState(
402
+ layer_index=self.layer_index,
403
+ token_indices=token_indices,
404
+ router_logits=logits,
405
+ topk_indices=selected_indices,
406
+ topk_weights=selected_weights,
407
+ token_gate=token_gate,
408
+ auxiliary_loss=auxiliary_loss,
409
+ )
410
+
411
+ self.last_router_state = state
412
+ self.last_router_diagnostics = self._make_diagnostics(state, flat_hidden.shape[0], active_mask)
413
+
414
+ output = base_output + self.residual_scale.to(expert_delta.dtype) * expert_delta.reshape(original_shape)
415
+ if self.training and self.auxiliary_loss_scale > 0.0:
416
+ output = _AddAuxiliaryLoss.apply(output, auxiliary_loss * self.auxiliary_loss_scale)
417
+ return output
418
+
419
+
420
+ class FuseGlmForCausalLM(Lfm2ForCausalLM):
421
+ """LFM2 causal LM augmented with folded GLM coding experts."""
422
+
423
+ config_class = FuseGlmConfig
424
+ _no_split_modules = ["Lfm2DecoderLayer", "FuseGlmFeedForward", "FoldedGlmExpert"]
425
+ _keep_in_fp32_modules_strict = [
426
+ "router.proj.weight",
427
+ "e_score_correction_bias",
428
+ "token_gate.weight",
429
+ "token_gate.bias",
430
+ "raw_residual_scale",
431
+ ]
432
+
433
+ def __init__(self, config: FuseGlmConfig) -> None:
434
+ if not isinstance(config, FuseGlmConfig):
435
+ if isinstance(config, Lfm2Config):
436
+ config = FuseGlmConfig.from_lfm_config(config)
437
+ else:
438
+ raise TypeError("config must be FuseGlmConfig or Lfm2Config")
439
+ super().__init__(config)
440
+ self._install_fusion_wrappers()
441
+
442
+ @torch.no_grad()
443
+ def _initialize_missing_keys(self, is_quantized: bool) -> None:
444
+ """Initialize fusion-only keys correctly when loading a base LFM.
445
+
446
+ ``from_pretrained`` constructs models under an empty/meta-parameter
447
+ context. The generic Transformers initializer handles Linear weights
448
+ but does not know that our scalar scale must be zero, nor that the
449
+ token gate needs a zero weight and negative bias. Capture the names
450
+ that were absent from the checkpoint, let upstream initialize all
451
+ ordinary parameters, then repair only those absent fusion parameters.
452
+ Existing values from a fused checkpoint are never overwritten.
453
+ """
454
+
455
+ missing_names = {
456
+ name
457
+ for name, parameter in self.named_parameters()
458
+ if not getattr(parameter, "_is_hf_initialized", False)
459
+ }
460
+ super()._initialize_missing_keys(is_quantized)
461
+
462
+ parameters = dict(self.named_parameters())
463
+ for name in missing_names:
464
+ parameter = parameters.get(name)
465
+ if parameter is None:
466
+ continue
467
+ if name.endswith("feed_forward.raw_residual_scale"):
468
+ nn.init.zeros_(parameter)
469
+ elif name.endswith("feed_forward.token_gate.weight"):
470
+ nn.init.zeros_(parameter)
471
+ elif name.endswith("feed_forward.token_gate.bias"):
472
+ nn.init.constant_(parameter, self.config.fuse_glm_token_gate_bias)
473
+
474
+ def _install_fusion_wrappers(self) -> None:
475
+ layer_indices = self.config.resolved_fuse_glm_layer_indices
476
+ auxiliary_scale = (
477
+ self.config.fuse_glm_router_aux_loss_coef / len(layer_indices) if layer_indices else 0.0
478
+ )
479
+ selected = set(layer_indices)
480
+ for layer_index, decoder_layer in enumerate(self.model.layers):
481
+ if layer_index not in selected:
482
+ continue
483
+ if isinstance(decoder_layer.feed_forward, FuseGlmFeedForward):
484
+ continue
485
+ decoder_layer.feed_forward = FuseGlmFeedForward(
486
+ decoder_layer.feed_forward,
487
+ self.config,
488
+ layer_index,
489
+ auxiliary_loss_scale=auxiliary_scale,
490
+ )
491
+
492
+ def fusion_layers(self) -> tuple[FuseGlmFeedForward, ...]:
493
+ return tuple(
494
+ layer.feed_forward
495
+ for layer in self.model.layers
496
+ if isinstance(layer.feed_forward, FuseGlmFeedForward)
497
+ )
498
+
499
+ def iter_folded_experts(self) -> Iterator[tuple[int, int, FoldedGlmExpert]]:
500
+ for wrapper in self.fusion_layers():
501
+ for expert_index, expert in enumerate(wrapper.experts):
502
+ yield wrapper.layer_index, expert_index, expert
503
+
504
+ def get_router_states(self, *, detach: bool = False) -> tuple[RouterState, ...]:
505
+ states = tuple(
506
+ wrapper.last_router_state
507
+ for wrapper in self.fusion_layers()
508
+ if wrapper.last_router_state is not None
509
+ )
510
+ if detach:
511
+ return tuple(state.detached() for state in states)
512
+ return states
513
+
514
+ def get_router_diagnostics(self, *, detach: bool = True) -> tuple[RouterDiagnostics, ...]:
515
+ diagnostics = tuple(
516
+ wrapper.last_router_diagnostics
517
+ for wrapper in self.fusion_layers()
518
+ if wrapper.last_router_diagnostics is not None
519
+ )
520
+ if detach:
521
+ return tuple(item.detached() for item in diagnostics)
522
+ return diagnostics
523
+
524
+ def get_router_aux_loss(
525
+ self,
526
+ reduction: Literal["mean", "sum", "none"] = "mean",
527
+ *,
528
+ detach: bool = False,
529
+ ) -> torch.Tensor:
530
+ losses = [state.auxiliary_loss for state in self.get_router_states(detach=detach)]
531
+ if not losses:
532
+ return next(self.parameters()).new_zeros(())
533
+ stacked = torch.stack(losses)
534
+ if reduction == "none":
535
+ return stacked
536
+ if reduction == "sum":
537
+ return stacked.sum()
538
+ if reduction == "mean":
539
+ return stacked.mean()
540
+ raise ValueError("reduction must be 'mean', 'sum', or 'none'")
541
+
542
+ def clear_router_state(self) -> None:
543
+ for wrapper in self.fusion_layers():
544
+ wrapper.last_router_state = None
545
+ wrapper.last_router_diagnostics = None
546
+
547
+ def set_coding_enabled(self, enabled: bool = True) -> "FuseGlmForCausalLM":
548
+ """Enable or bypass every coding-expert branch."""
549
+
550
+ for wrapper in self.fusion_layers():
551
+ wrapper.coding_enabled = bool(enabled)
552
+ return self
553
+
554
+ @property
555
+ def coding_enabled(self) -> bool:
556
+ layers = self.fusion_layers()
557
+ return bool(layers) and all(wrapper.coding_enabled for wrapper in layers)
558
+
559
+ @contextmanager
560
+ def coding_experts(self, enabled: bool = True) -> Iterator["FuseGlmForCausalLM"]:
561
+ """Temporarily enable/disable coding experts for one local operation."""
562
+
563
+ wrappers = self.fusion_layers()
564
+ previous = tuple(wrapper.coding_enabled for wrapper in wrappers)
565
+ self.set_coding_enabled(enabled)
566
+ try:
567
+ yield self
568
+ finally:
569
+ for wrapper, old_value in zip(wrappers, previous):
570
+ wrapper.coding_enabled = old_value
571
+
572
+ @torch.no_grad()
573
+ def load_folded_expert(
574
+ self,
575
+ layer_index: int,
576
+ expert_index: int,
577
+ *,
578
+ gate_proj: torch.Tensor,
579
+ up_proj: torch.Tensor,
580
+ down_proj: torch.Tensor,
581
+ ) -> None:
582
+ """Copy one folded expert into a concrete decoder/expert slot."""
583
+
584
+ if layer_index < 0 or layer_index >= len(self.model.layers):
585
+ raise IndexError(f"layer_index {layer_index} is outside the decoder")
586
+ wrapper = self.model.layers[layer_index].feed_forward
587
+ if not isinstance(wrapper, FuseGlmFeedForward):
588
+ raise ValueError(f"decoder layer {layer_index} has no fused expert branch")
589
+ if expert_index < 0 or expert_index >= len(wrapper.experts):
590
+ raise IndexError(f"expert_index {expert_index} is outside layer {layer_index}")
591
+ wrapper.experts[expert_index].load_folded_weights(
592
+ gate_proj=gate_proj,
593
+ up_proj=up_proj,
594
+ down_proj=down_proj,
595
+ )
596
+
597
+ @torch.no_grad()
598
+ def load_router_initializer(
599
+ self,
600
+ layer_index: int,
601
+ *,
602
+ proj_weight: torch.Tensor,
603
+ e_score_correction_bias: torch.Tensor,
604
+ ) -> None:
605
+ """Load one folded GLM router while preserving post-sigmoid bias semantics."""
606
+
607
+ wrappers = {wrapper.layer_index: wrapper for wrapper in self.fusion_layers()}
608
+ if layer_index not in wrappers:
609
+ raise KeyError(f"decoder layer {layer_index} has no fused expert branch")
610
+ router = wrappers[layer_index].router
611
+ expected_weight_shape = tuple(router.proj.weight.shape)
612
+ expected_bias_shape = tuple(router.e_score_correction_bias.shape)
613
+ if tuple(proj_weight.shape) != expected_weight_shape:
614
+ raise ValueError(
615
+ f"router proj_weight has shape {tuple(proj_weight.shape)}; "
616
+ f"expected {expected_weight_shape}"
617
+ )
618
+ if tuple(e_score_correction_bias.shape) != expected_bias_shape:
619
+ raise ValueError(
620
+ "router e_score_correction_bias has shape "
621
+ f"{tuple(e_score_correction_bias.shape)}; expected {expected_bias_shape}"
622
+ )
623
+ if not bool(torch.isfinite(proj_weight).all()):
624
+ raise ValueError("router proj_weight contains NaN or infinity")
625
+ if not bool(torch.isfinite(e_score_correction_bias).all()):
626
+ raise ValueError("router e_score_correction_bias contains NaN or infinity")
627
+ router.proj.weight.copy_(
628
+ proj_weight.to(device=router.proj.weight.device, dtype=router.proj.weight.dtype)
629
+ )
630
+ router.e_score_correction_bias.copy_(
631
+ e_score_correction_bias.to(
632
+ device=router.e_score_correction_bias.device,
633
+ dtype=router.e_score_correction_bias.dtype,
634
+ )
635
+ )
636
+
637
+ @classmethod
638
+ def from_lfm_pretrained(
639
+ cls,
640
+ pretrained_model_name_or_path: str,
641
+ *model_args: Any,
642
+ config: Lfm2Config | FuseGlmConfig | None = None,
643
+ fuse_overrides: dict[str, Any] | None = None,
644
+ **kwargs: Any,
645
+ ) -> "FuseGlmForCausalLM":
646
+ """Load native LFM weights and initialize only the fusion branch.
647
+
648
+ The method accepts local directories and normal Hugging Face loading
649
+ arguments. It does not set ``trust_remote_code`` or force a network
650
+ lookup. Use ``local_files_only=True`` when an offline-only guarantee is
651
+ desired.
652
+ """
653
+
654
+ overrides = dict(fuse_overrides or {})
655
+ if config is None:
656
+ config_keys = (
657
+ "cache_dir",
658
+ "force_download",
659
+ "local_files_only",
660
+ "revision",
661
+ "subfolder",
662
+ "token",
663
+ )
664
+ config_kwargs = {key: kwargs[key] for key in config_keys if key in kwargs}
665
+ config = Lfm2Config.from_pretrained(pretrained_model_name_or_path, **config_kwargs)
666
+ if not isinstance(config, FuseGlmConfig):
667
+ config = FuseGlmConfig.from_lfm_config(config, **overrides)
668
+ elif overrides:
669
+ config = FuseGlmConfig.from_lfm_config(config, **overrides)
670
+ return cls.from_pretrained(
671
+ pretrained_model_name_or_path,
672
+ *model_args,
673
+ config=config,
674
+ **kwargs,
675
+ )
676
+
677
+ def forward(
678
+ self,
679
+ input_ids: torch.LongTensor | None = None,
680
+ attention_mask: torch.Tensor | None = None,
681
+ position_ids: torch.LongTensor | None = None,
682
+ past_key_values: Any | None = None,
683
+ inputs_embeds: torch.FloatTensor | None = None,
684
+ labels: torch.LongTensor | None = None,
685
+ use_cache: bool | None = None,
686
+ logits_to_keep: int | torch.Tensor = 0,
687
+ output_router_diagnostics: bool | None = None,
688
+ coding_enabled: bool | None = None,
689
+ **kwargs: Any,
690
+ ) -> FuseGlmCausalLMOutputWithPast | tuple[torch.Tensor, ...]:
691
+ """Run the native LFM forward plus the configured coding sidecars.
692
+
693
+ Passing ``coding_enabled`` provides a convenient per-call override.
694
+ For concurrent callers, prefer separate model instances because this
695
+ override temporarily changes local module flags.
696
+ """
697
+
698
+ wrappers = self.fusion_layers()
699
+ previous = tuple(wrapper.coding_enabled for wrapper in wrappers)
700
+ if coding_enabled is not None:
701
+ self.set_coding_enabled(coding_enabled)
702
+ try:
703
+ outputs = super().forward(
704
+ input_ids=input_ids,
705
+ attention_mask=attention_mask,
706
+ position_ids=position_ids,
707
+ past_key_values=past_key_values,
708
+ inputs_embeds=inputs_embeds,
709
+ labels=labels,
710
+ use_cache=use_cache,
711
+ logits_to_keep=logits_to_keep,
712
+ **kwargs,
713
+ )
714
+ finally:
715
+ if coding_enabled is not None:
716
+ for wrapper, old_value in zip(wrappers, previous):
717
+ wrapper.coding_enabled = old_value
718
+
719
+ # ``return_dict=False`` is retained for compatibility with upstream.
720
+ # Router information remains accessible through the getter methods.
721
+ if not isinstance(outputs, CausalLMOutputWithPast):
722
+ return outputs
723
+
724
+ router_aux_loss = self.get_router_aux_loss(reduction="mean")
725
+ loss = outputs.loss
726
+ if loss is not None and self.training and self.config.fuse_glm_router_aux_loss_coef > 0:
727
+ # Gradients are attached inside each wrapper (checkpoint-safe).
728
+ # This detached term makes the scalar reported to users equal to
729
+ # CE + coefficient * mean(auxiliary loss) without double-counting.
730
+ loss = loss + self.config.fuse_glm_router_aux_loss_coef * router_aux_loss.detach()
731
+
732
+ include_diagnostics = (
733
+ self.config.fuse_glm_output_router_diagnostics
734
+ if output_router_diagnostics is None
735
+ else bool(output_router_diagnostics)
736
+ )
737
+ diagnostics = self.get_router_diagnostics() if include_diagnostics else None
738
+ return FuseGlmCausalLMOutputWithPast(
739
+ loss=loss,
740
+ logits=outputs.logits,
741
+ past_key_values=outputs.past_key_values,
742
+ hidden_states=outputs.hidden_states,
743
+ attentions=outputs.attentions,
744
+ router_aux_loss=router_aux_loss,
745
+ router_diagnostics=diagnostics,
746
+ )
747
+
748
+
749
+ __all__ = [
750
+ "FoldedGlmExpert",
751
+ "FuseGlmCausalLMOutputWithPast",
752
+ "FuseGlmFeedForward",
753
+ "FuseGlmForCausalLM",
754
+ "RouterDiagnostics",
755
+ "RouterState",
756
+ "TopKFoldedExpertRouter",
757
+ ]
provenance/assembly.json ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "created_at": "2026-08-27T13:15:51.908322+00:00",
3
+ "output": {
4
+ "config_sha256": "8582a503ded278e710a929f31848356b8ca95ea76a957b0842d6d5871ad16e1a",
5
+ "configuration_code_sha256": "922dfb636b84d09d2f92ba0c5bc226d00d7b41999c7e9aef1939ccb022192427",
6
+ "directory": "<workspace>\\RivetCoder-9B-A4B",
7
+ "index_sha256": "939b9f2bf0c48523d6a1a2ef93d987876a3e20613b33fe3715bf6b78bbc2a1bb",
8
+ "linked_weight_files": [
9
+ {
10
+ "method": "hardlink",
11
+ "name": "host-model-00001-of-00002.safetensors",
12
+ "role": "host_weight",
13
+ "size": 5329406264,
14
+ "source": "<workspace>\\models\\LiquidAI\\LFM2.5-2.6B\\model-00001-of-00002.safetensors"
15
+ },
16
+ {
17
+ "method": "hardlink",
18
+ "name": "host-model-00002-of-00002.safetensors",
19
+ "role": "host_weight",
20
+ "size": 65021192,
21
+ "source": "<workspace>\\models\\LiquidAI\\LFM2.5-2.6B\\model-00002-of-00002.safetensors"
22
+ },
23
+ {
24
+ "method": "hardlink",
25
+ "name": "expert-model-00001-of-00012.safetensors",
26
+ "role": "expert_weight",
27
+ "size": 1065764144,
28
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00001.safetensors"
29
+ },
30
+ {
31
+ "method": "hardlink",
32
+ "name": "expert-model-00002-of-00012.safetensors",
33
+ "role": "expert_weight",
34
+ "size": 1065764160,
35
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00002.safetensors"
36
+ },
37
+ {
38
+ "method": "hardlink",
39
+ "name": "expert-model-00003-of-00012.safetensors",
40
+ "role": "expert_weight",
41
+ "size": 1065632784,
42
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00003.safetensors"
43
+ },
44
+ {
45
+ "method": "hardlink",
46
+ "name": "expert-model-00004-of-00012.safetensors",
47
+ "role": "expert_weight",
48
+ "size": 1065764176,
49
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00004.safetensors"
50
+ },
51
+ {
52
+ "method": "hardlink",
53
+ "name": "expert-model-00005-of-00012.safetensors",
54
+ "role": "expert_weight",
55
+ "size": 1065764296,
56
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00005.safetensors"
57
+ },
58
+ {
59
+ "method": "hardlink",
60
+ "name": "expert-model-00006-of-00012.safetensors",
61
+ "role": "expert_weight",
62
+ "size": 1065632912,
63
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00006.safetensors"
64
+ },
65
+ {
66
+ "method": "hardlink",
67
+ "name": "expert-model-00007-of-00012.safetensors",
68
+ "role": "expert_weight",
69
+ "size": 1065764280,
70
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00007.safetensors"
71
+ },
72
+ {
73
+ "method": "hardlink",
74
+ "name": "expert-model-00008-of-00012.safetensors",
75
+ "role": "expert_weight",
76
+ "size": 1065764296,
77
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00008.safetensors"
78
+ },
79
+ {
80
+ "method": "hardlink",
81
+ "name": "expert-model-00009-of-00012.safetensors",
82
+ "role": "expert_weight",
83
+ "size": 1065632912,
84
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00009.safetensors"
85
+ },
86
+ {
87
+ "method": "hardlink",
88
+ "name": "expert-model-00010-of-00012.safetensors",
89
+ "role": "expert_weight",
90
+ "size": 1065764288,
91
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00010.safetensors"
92
+ },
93
+ {
94
+ "method": "hardlink",
95
+ "name": "expert-model-00011-of-00012.safetensors",
96
+ "role": "expert_weight",
97
+ "size": 1065764296,
98
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00011.safetensors"
99
+ },
100
+ {
101
+ "method": "hardlink",
102
+ "name": "expert-model-00012-of-00012.safetensors",
103
+ "role": "expert_weight",
104
+ "size": 360716032,
105
+ "source": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\folded-experts-00012.safetensors"
106
+ },
107
+ {
108
+ "method": "hardlink",
109
+ "name": "routing-controls.safetensors",
110
+ "role": "routing_controls",
111
+ "size": 4191720,
112
+ "source": "<workspace>\\artifacts\\router-training-qwen-all30-fixed16-top4\\checkpoint-00000060\\trainable.safetensors"
113
+ }
114
+ ],
115
+ "max_shard_bytes": 2139130024,
116
+ "model_card_sha256": "ec7558e18405570c051065b40d0811fe5635fca0b057825b0c9be3490846f676",
117
+ "modeling_code_sha256": "2fe578e98265fa3704aa6971d1234784c4e1ef6ebf9a6df6661c831e340d3f33",
118
+ "physical_duplicate_keys": 0,
119
+ "physical_tensor_count": 1856,
120
+ "removed_precedence_sources": [
121
+ "expert-model-00001-of-00012.safetensors",
122
+ "expert-model-00002-of-00012.safetensors",
123
+ "expert-model-00003-of-00012.safetensors",
124
+ "expert-model-00004-of-00012.safetensors",
125
+ "expert-model-00005-of-00012.safetensors",
126
+ "expert-model-00006-of-00012.safetensors",
127
+ "expert-model-00007-of-00012.safetensors",
128
+ "expert-model-00008-of-00012.safetensors",
129
+ "expert-model-00009-of-00012.safetensors",
130
+ "expert-model-00010-of-00012.safetensors",
131
+ "expert-model-00011-of-00012.safetensors",
132
+ "expert-model-00012-of-00012.safetensors",
133
+ "host-model-00001-of-00002.safetensors",
134
+ "host-model-00002-of-00002.safetensors",
135
+ "routing-controls.safetensors"
136
+ ],
137
+ "shards": [
138
+ {
139
+ "name": "model-00001-of-00009.safetensors",
140
+ "sha256": "65eb65a6001739bee7959aebe2d6ff564065db69658b768e05ee085f2dbceac4",
141
+ "size": 2139129752,
142
+ "tensor_count": 261
143
+ },
144
+ {
145
+ "name": "model-00002-of-00009.safetensors",
146
+ "sha256": "b689619b9816a94218227afd89ce1c29580b6ec27307c971fabf450e27c6586f",
147
+ "size": 2139129608,
148
+ "tensor_count": 260
149
+ },
150
+ {
151
+ "name": "model-00003-of-00009.safetensors",
152
+ "sha256": "8603121c0ae3e5062526deea09a67f6f17964d8d4018772050aeb368e6767e3d",
153
+ "size": 2139129848,
154
+ "tensor_count": 260
155
+ },
156
+ {
157
+ "name": "model-00004-of-00009.safetensors",
158
+ "sha256": "427ed53be708fbc114263b296a1800cde40ae590b47ac5c65a3afbda5f449fe3",
159
+ "size": 2139130024,
160
+ "tensor_count": 261
161
+ },
162
+ {
163
+ "name": "model-00005-of-00009.safetensors",
164
+ "sha256": "e6d934e3c3709e322cf0b9cba7f5962c31aa50f83fab768b49d2677c08c0dacd",
165
+ "size": 2139129840,
166
+ "tensor_count": 260
167
+ },
168
+ {
169
+ "name": "model-00006-of-00009.safetensors",
170
+ "sha256": "3c2bfeae45226c395ee5a80fc5bb40dcdab0564901746e1e204b2ed1f986097c",
171
+ "size": 2107698648,
172
+ "tensor_count": 181
173
+ },
174
+ {
175
+ "name": "model-00007-of-00009.safetensors",
176
+ "sha256": "1fd608240effcf5db7819f0ec066d938b7f6bbd8a13d48f9bdd8639c217d7069",
177
+ "size": 2126742608,
178
+ "tensor_count": 111
179
+ },
180
+ {
181
+ "name": "model-00008-of-00009.safetensors",
182
+ "sha256": "1b15e4727b4b81c5e9d99ba2537d7cf72c6954c6cb235a5821723b48e4fa0701",
183
+ "size": 2137241792,
184
+ "tensor_count": 119
185
+ },
186
+ {
187
+ "name": "model-00009-of-00009.safetensors",
188
+ "sha256": "dbc94cfe4bca880602ca8bc58283d2e2147501e731cb69ae639bb557d3f315a7",
189
+ "size": 411078784,
190
+ "tensor_count": 143
191
+ }
192
+ ]
193
+ },
194
+ "repo_id": "HCHs/RivetCoder-9B-A4B",
195
+ "schema": "rivetcoder-hf-package",
196
+ "schema_version": 1,
197
+ "sources": {
198
+ "expert_index_sha256": "c156f43793b0cee11290e32619c767d86eaaf4ca1a6ec268ece9eb8d62b6880c",
199
+ "host_index_sha256": "1be35d0d99dc56f68e6c5b306f7d4d99b6da97d1ab41ee753832bf1495655c4a",
200
+ "routing_controls_sha256": "740f15e9bcf68efcb4d9c0f4b2bcfebff66ba199aead9cd2666156dffc60b1ad",
201
+ "training_summary_sha256": "6cef5c9b40ce3f184f8ab32a58cc2a795dedb220b6dc324c6eb5a1c429613c68"
202
+ },
203
+ "weights": {
204
+ "combined_tensor_count": 1856,
205
+ "combined_total_size": 17478172784,
206
+ "expert_shards": 12,
207
+ "final_shards": 9,
208
+ "folded_total_size": 12083529600,
209
+ "host_shards": 2,
210
+ "host_total_size": 5394397184,
211
+ "physical_duplicate_keys": 0,
212
+ "repacked": true,
213
+ "replaced_warmstart_router_bytes": 3932160,
214
+ "routing_control_files": 1,
215
+ "trained_control_bytes": 4178160
216
+ }
217
+ }
provenance/base-bf16-checksums.sha256 ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 34448b82c17d60fec9b65b1f093c115ddbaadc04beb1b0140b6bfed2e012a930 .gitattributes
2
+ 032227c2d1dd0a5e8b337834a2959d2bd62893b21b92ee9829df7600caf18e0b .gitignore
3
+ ea663864491de7ade391839479860ca95541f892f72665c73251fbd4643b1bef chat_template.jinja
4
+ 8582a503ded278e710a929f31848356b8ca95ea76a957b0842d6d5871ad16e1a config.json
5
+ 922dfb636b84d09d2f92ba0c5bc226d00d7b41999c7e9aef1939ccb022192427 configuration_fuse_glm.py
6
+ 7366b93f26f8830e7a94441a3d2b9f344ceb9e1e31a808e0656df40720075874 generation_config.json
7
+ 4d28ca14dedc0b3d0fcc2b3339f0e79931faa33874f3d24f522183a8fc70068c LICENSE
8
+ 30b85b6b9659f2e78aa259f8faf5d920a68dee7c9ced3fa6dba1f19f2bc4fca1 licenses/GLM-MIT.txt
9
+ 4d28ca14dedc0b3d0fcc2b3339f0e79931faa33874f3d24f522183a8fc70068c licenses/LFM-OPEN-LICENSE-v1.0.txt
10
+ 65eb65a6001739bee7959aebe2d6ff564065db69658b768e05ee085f2dbceac4 model-00001-of-00009.safetensors
11
+ b689619b9816a94218227afd89ce1c29580b6ec27307c971fabf450e27c6586f model-00002-of-00009.safetensors
12
+ 8603121c0ae3e5062526deea09a67f6f17964d8d4018772050aeb368e6767e3d model-00003-of-00009.safetensors
13
+ 427ed53be708fbc114263b296a1800cde40ae590b47ac5c65a3afbda5f449fe3 model-00004-of-00009.safetensors
14
+ e6d934e3c3709e322cf0b9cba7f5962c31aa50f83fab768b49d2677c08c0dacd model-00005-of-00009.safetensors
15
+ 3c2bfeae45226c395ee5a80fc5bb40dcdab0564901746e1e204b2ed1f986097c model-00006-of-00009.safetensors
16
+ 1fd608240effcf5db7819f0ec066d938b7f6bbd8a13d48f9bdd8639c217d7069 model-00007-of-00009.safetensors
17
+ 1b15e4727b4b81c5e9d99ba2537d7cf72c6954c6cb235a5821723b48e4fa0701 model-00008-of-00009.safetensors
18
+ dbc94cfe4bca880602ca8bc58283d2e2147501e731cb69ae639bb557d3f315a7 model-00009-of-00009.safetensors
19
+ 939b9f2bf0c48523d6a1a2ef93d987876a3e20613b33fe3715bf6b78bbc2a1bb model.safetensors.index.json
20
+ 2fe578e98265fa3704aa6971d1234784c4e1ef6ebf9a6df6661c831e340d3f33 modeling_fuse_glm.py
21
+ a1829a85639489b9b4cef7dbb520e34c914bdc4bc1a726f68de5714083fe59b0 NOTICE.md
22
+ b7d698b9414c814a1d78dce6a414c3340f3cd0cd949fc2c6b192bd2e35688710 provenance/assembly.json
23
+ 92eda133f175fa573b88b92fca5995518965117e534f3b732c63e64862488ff0 provenance/bridge.json
24
+ 69ae72f0e5add90269c5e949366c10e87d1de64fc815d14d0f330010f0fd1400 provenance/expert-selection.json
25
+ 036c4343e5d62e72613b3bb0ad1238d9f8000088d1118439798ac7ade13d7a2f provenance/folding.json
26
+ 2ba3ae47063c1b4a957b8c5983c48d08c0dacb01c5624f856b8414ac7ccfc2c8 provenance/fusion-plan.json
27
+ a0ab71b19384546ea62e09d0c55eee623f59b92fff5140f1baa883d2386ff12f provenance/pre-repack-index.json
28
+ f6c13f0c8a28f1029132af53138b91352db35791b5da4eb0748cde4a42c59e51 provenance/router-training.json
29
+ b8bf61e3cd2abfe2ad4b9b59e71ee48c7b680485963f3bc4e3b19df7849a3016 provenance/selected-expert-tensors.json
30
+ ac437e75d524dd58e1c6934ad0838c62e11c9d0954d24873cb17862f958f64a5 provenance/source-models.json
31
+ 88fd032686145809f3dee3e8082a7a3b1cffe2874661289b59472a56ed5fcc1c provenance/training-data-manifest.json
32
+ f426ea62b798bb2340b8d9cfdea2f53f309044dbe9caa061c208e358ddc39ea9 provenance/training-summary.json
33
+ 19f75f7117ca582e393d9f79452af231f93339c55dfcc6bebd2b953f87ed3152 provenance/validation-metrics.json
34
+ ec7558e18405570c051065b40d0811fe5635fca0b057825b0c9be3490846f676 README.md
35
+ ee1fa8fc1ed52ab1944fc4b65db3e5eae74e98a92bf0ee6f54dbd5f86daeb4b4 requirements.txt
36
+ 695be7802a0e4b8a81048f0ff5ebb7fc811a0ba5a6be63dbb24deb5a81096f41 tokenizer.json
37
+ 11f1de897317b489dd09199284528382eeb17f566398b16e2039bb2266d26b09 tokenizer_config.json
38
+ 2adc48a1d558261d69de8f43f35d8b3dc19bf122b604038cc8c56e5eadaf972c UPLOAD_INSTRUCTIONS.md
provenance/bridge.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "contract": {
3
+ "bias": null,
4
+ "constraint": "P_out @ P_in = I",
5
+ "forward": "P_in: host hidden -> donor hidden",
6
+ "reverse": "P_out = P_in.T: donor hidden -> host hidden",
7
+ "trainable": false
8
+ },
9
+ "method": "identity_hadamard",
10
+ "output": {
11
+ "path": "<workspace>\\artifacts\\fixed-bridges\\lfm2048-glm4096-identity-hadamard.safetensors",
12
+ "sha256": "497cae6c91cc46fe16d4c78a95746eb4bac83d140a5daca5658a053b7b0db729",
13
+ "size": 67109144,
14
+ "tensors": {
15
+ "P_in": {
16
+ "dtype": "torch.float32",
17
+ "sha256": "477152e3bcca9a407c222443c0f1e832a21cc44ae500ab35d86a4580293a3cbd",
18
+ "shape": [
19
+ 4096,
20
+ 2048
21
+ ],
22
+ "storage_bytes": 33554432
23
+ },
24
+ "P_out": {
25
+ "dtype": "torch.float32",
26
+ "sha256": "26c5f05e8f90d54f5d5b2e8fa91d7a846aaf3cde92c66eac79da6e351e27b408",
27
+ "shape": [
28
+ 2048,
29
+ 4096
30
+ ],
31
+ "storage_bytes": 33554432
32
+ }
33
+ }
34
+ },
35
+ "schema": "lfm-glm-fixed-tied-bridge",
36
+ "schema_version": 1,
37
+ "seed": 53042016,
38
+ "validation": {
39
+ "column_norm_max": 0.9999999403953552,
40
+ "column_norm_min": 0.9999999403953552,
41
+ "compute_device": "cuda",
42
+ "donor_size": 4096,
43
+ "gram_atol": 1e-05,
44
+ "gram_max_absolute_error": 5.960464477539063e-08,
45
+ "host_size": 2048,
46
+ "transpose_exact": true
47
+ }
48
+ }
provenance/checksums.sha256 ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 34448b82c17d60fec9b65b1f093c115ddbaadc04beb1b0140b6bfed2e012a930 .gitattributes
2
+ 032227c2d1dd0a5e8b337834a2959d2bd62893b21b92ee9829df7600caf18e0b .gitignore
3
+ f3e412383b66fc807c3d0fbe9e6f8a4a58b2638df55d8380e9cab64af30e8675 chat_template.jinja
4
+ 1b441cb88813e8c01f8a9ae98452adfe655ba680e1964c787583634ecb8cb473 config.json
5
+ 922dfb636b84d09d2f92ba0c5bc226d00d7b41999c7e9aef1939ccb022192427 configuration_fuse_glm.py
6
+ e34e51ccf5a169f0d9cecf8119e9f719132fa0cf5fae7f8b650893821348e62a generation_config.json
7
+ 4d28ca14dedc0b3d0fcc2b3339f0e79931faa33874f3d24f522183a8fc70068c LICENSE
8
+ 30b85b6b9659f2e78aa259f8faf5d920a68dee7c9ced3fa6dba1f19f2bc4fca1 licenses/GLM-MIT.txt
9
+ 4d28ca14dedc0b3d0fcc2b3339f0e79931faa33874f3d24f522183a8fc70068c licenses/LFM-OPEN-LICENSE-v1.0.txt
10
+ 7a3c863c63fb2c52b7f881b483ffc7d1f4b352b2de932b718f62b2b2134de1e8 model-00001-of-00005.safetensors
11
+ e1668117e8a2ad1c7d4ff9a12c1687c9e907a39738dcafd1a48647d38a6efed3 model-00002-of-00005.safetensors
12
+ 2f7266ae364fb4bb0c3f30da7deca8133d7501fb415840861de747716ed483ca model-00003-of-00005.safetensors
13
+ ebb55bc7f9cd7139d3e21c0677f2b2b7f99ec25925837729b0c07a6efa2b0074 model-00004-of-00005.safetensors
14
+ 5aec98e4957c1263db1e79f2014f468620ec1b512831256329d8091f762fc61a model-00005-of-00005.safetensors
15
+ 95b79151fed3d2716210fb3046282a47bf73e2016c0ae59f413b59e221e50fc5 model.safetensors.index.json
16
+ 2fe578e98265fa3704aa6971d1234784c4e1ef6ebf9a6df6661c831e340d3f33 modeling_fuse_glm.py
17
+ a1829a85639489b9b4cef7dbb520e34c914bdc4bc1a726f68de5714083fe59b0 NOTICE.md
18
+ b7d698b9414c814a1d78dce6a414c3340f3cd0cd949fc2c6b192bd2e35688710 provenance/assembly.json
19
+ 4dbb9025d648edd432e0fcbd6cc1f6dafa96e4aa0e0222171923feb17965aa25 provenance/base-bf16-checksums.sha256
20
+ 92eda133f175fa573b88b92fca5995518965117e534f3b732c63e64862488ff0 provenance/bridge.json
21
+ 69ae72f0e5add90269c5e949366c10e87d1de64fc815d14d0f330010f0fd1400 provenance/expert-selection.json
22
+ 036c4343e5d62e72613b3bb0ad1238d9f8000088d1118439798ac7ade13d7a2f provenance/folding.json
23
+ 2ba3ae47063c1b4a957b8c5983c48d08c0dacb01c5624f856b8414ac7ccfc2c8 provenance/fusion-plan.json
24
+ a0ab71b19384546ea62e09d0c55eee623f59b92fff5140f1baa883d2386ff12f provenance/pre-repack-index.json
25
+ 15d69ac2fd857a1749578273f84f1385b004cd1e3fb9204e5d7684cc6c534e8c provenance/quantization.json
26
+ f6c13f0c8a28f1029132af53138b91352db35791b5da4eb0748cde4a42c59e51 provenance/router-training.json
27
+ b8bf61e3cd2abfe2ad4b9b59e71ee48c7b680485963f3bc4e3b19df7849a3016 provenance/selected-expert-tensors.json
28
+ ac437e75d524dd58e1c6934ad0838c62e11c9d0954d24873cb17862f958f64a5 provenance/source-models.json
29
+ 88fd032686145809f3dee3e8082a7a3b1cffe2874661289b59472a56ed5fcc1c provenance/training-data-manifest.json
30
+ f426ea62b798bb2340b8d9cfdea2f53f309044dbe9caa061c208e358ddc39ea9 provenance/training-summary.json
31
+ 19f75f7117ca582e393d9f79452af231f93339c55dfcc6bebd2b953f87ed3152 provenance/validation-metrics.json
32
+ 3cc74de6c69b37d403f553e376348e1c1addcbae099f90054a4f95640c6a93e3 README.md
33
+ ce31a666514d30d302472da9387348b4958872f7e307a7ee443ae09f8d1b19b5 requirements.txt
34
+ 14c60d6814b7f64c69711d5c5d5561d3de9cc3896feebf9613ae8a8523a3497d tokenizer_config.json
35
+ 695be7802a0e4b8a81048f0ff5ebb7fc811a0ba5a6be63dbb24deb5a81096f41 tokenizer.json
provenance/expert-selection.json ADDED
The diff for this file is too large to render. See raw diff
 
provenance/folding.json ADDED
The diff for this file is too large to render. See raw diff
 
provenance/fusion-plan.json ADDED
@@ -0,0 +1,738 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architecture": {
3
+ "bridge": {
4
+ "constraint": "P^T P = I",
5
+ "fold_down": "W_down_folded = P^T @ W_down_glm",
6
+ "fold_gate_up": "W_folded = W_glm @ P",
7
+ "fold_router_init": "R_lfm_init = R_glm[selected_experts] @ P",
8
+ "forward": "2048->4096",
9
+ "kind": "tied frozen linear projection",
10
+ "reverse": "4096->2048"
11
+ },
12
+ "candidate_expert_count": 480,
13
+ "donor": "zai-org/GLM-5.3-Flash",
14
+ "donor_hidden_size": 4096,
15
+ "expert_intermediate_size": 2048,
16
+ "experts_per_layer": 16,
17
+ "folded_expert_parameter_count": 6039797760,
18
+ "folded_parameter_count_per_expert": 12582912,
19
+ "frozen": [
20
+ "LFM host",
21
+ "GLM experts",
22
+ "bridge"
23
+ ],
24
+ "host": "LiquidAI/LFM2.5-2.6B",
25
+ "host_hidden_size": 2048,
26
+ "maximum_active_experts_per_token": 120,
27
+ "runtime_top_k": 4,
28
+ "target_layer_count": 30,
29
+ "trainable": [
30
+ "per-layer router",
31
+ "token gate",
32
+ "bounded residual scale"
33
+ ]
34
+ },
35
+ "canonical_mapping_projection_sha256": "f02ef1f5152697e814f2fb41fedad3f7ea6738ac29eed1587f1d9948ed7360ac",
36
+ "mapping_status": "provisional",
37
+ "mappings": [
38
+ {
39
+ "expert_count": 16,
40
+ "expert_ids": [
41
+ 149,
42
+ 171,
43
+ 186,
44
+ 98,
45
+ 286,
46
+ 189,
47
+ 12,
48
+ 10,
49
+ 202,
50
+ 177,
51
+ 66,
52
+ 24,
53
+ 118,
54
+ 107,
55
+ 220,
56
+ 47
57
+ ],
58
+ "source_layer": 3,
59
+ "target_layer": 0
60
+ },
61
+ {
62
+ "expert_count": 16,
63
+ "expert_ids": [
64
+ 241,
65
+ 243,
66
+ 173,
67
+ 268,
68
+ 39,
69
+ 45,
70
+ 216,
71
+ 197,
72
+ 205,
73
+ 223,
74
+ 89,
75
+ 178,
76
+ 248,
77
+ 93,
78
+ 142,
79
+ 74
80
+ ],
81
+ "source_layer": 4,
82
+ "target_layer": 1
83
+ },
84
+ {
85
+ "expert_count": 16,
86
+ "expert_ids": [
87
+ 160,
88
+ 276,
89
+ 104,
90
+ 234,
91
+ 16,
92
+ 83,
93
+ 209,
94
+ 260,
95
+ 270,
96
+ 282,
97
+ 55,
98
+ 174,
99
+ 236,
100
+ 256,
101
+ 137,
102
+ 206
103
+ ],
104
+ "source_layer": 6,
105
+ "target_layer": 2
106
+ },
107
+ {
108
+ "expert_count": 16,
109
+ "expert_ids": [
110
+ 81,
111
+ 57,
112
+ 131,
113
+ 233,
114
+ 68,
115
+ 129,
116
+ 94,
117
+ 145,
118
+ 208,
119
+ 262,
120
+ 184,
121
+ 48,
122
+ 211,
123
+ 51,
124
+ 44,
125
+ 72
126
+ ],
127
+ "source_layer": 7,
128
+ "target_layer": 3
129
+ },
130
+ {
131
+ "expert_count": 16,
132
+ "expert_ids": [
133
+ 129,
134
+ 142,
135
+ 181,
136
+ 82,
137
+ 74,
138
+ 95,
139
+ 177,
140
+ 88,
141
+ 202,
142
+ 150,
143
+ 6,
144
+ 239,
145
+ 98,
146
+ 271,
147
+ 221,
148
+ 219
149
+ ],
150
+ "source_layer": 9,
151
+ "target_layer": 4
152
+ },
153
+ {
154
+ "expert_count": 16,
155
+ "expert_ids": [
156
+ 96,
157
+ 98,
158
+ 285,
159
+ 75,
160
+ 81,
161
+ 284,
162
+ 111,
163
+ 9,
164
+ 177,
165
+ 268,
166
+ 0,
167
+ 159,
168
+ 70,
169
+ 28,
170
+ 65,
171
+ 144
172
+ ],
173
+ "source_layer": 10,
174
+ "target_layer": 5
175
+ },
176
+ {
177
+ "expert_count": 16,
178
+ "expert_ids": [
179
+ 246,
180
+ 103,
181
+ 109,
182
+ 138,
183
+ 128,
184
+ 69,
185
+ 178,
186
+ 219,
187
+ 28,
188
+ 159,
189
+ 220,
190
+ 66,
191
+ 81,
192
+ 91,
193
+ 166,
194
+ 47
195
+ ],
196
+ "source_layer": 11,
197
+ "target_layer": 6
198
+ },
199
+ {
200
+ "expert_count": 16,
201
+ "expert_ids": [
202
+ 178,
203
+ 145,
204
+ 13,
205
+ 25,
206
+ 75,
207
+ 187,
208
+ 70,
209
+ 169,
210
+ 235,
211
+ 20,
212
+ 142,
213
+ 209,
214
+ 156,
215
+ 52,
216
+ 99,
217
+ 177
218
+ ],
219
+ "source_layer": 13,
220
+ "target_layer": 7
221
+ },
222
+ {
223
+ "expert_count": 16,
224
+ "expert_ids": [
225
+ 143,
226
+ 121,
227
+ 277,
228
+ 228,
229
+ 46,
230
+ 72,
231
+ 285,
232
+ 243,
233
+ 70,
234
+ 180,
235
+ 86,
236
+ 23,
237
+ 150,
238
+ 205,
239
+ 28,
240
+ 275
241
+ ],
242
+ "source_layer": 14,
243
+ "target_layer": 8
244
+ },
245
+ {
246
+ "expert_count": 16,
247
+ "expert_ids": [
248
+ 229,
249
+ 219,
250
+ 23,
251
+ 224,
252
+ 64,
253
+ 244,
254
+ 273,
255
+ 90,
256
+ 66,
257
+ 185,
258
+ 77,
259
+ 237,
260
+ 96,
261
+ 136,
262
+ 226,
263
+ 109
264
+ ],
265
+ "source_layer": 16,
266
+ "target_layer": 9
267
+ },
268
+ {
269
+ "expert_count": 16,
270
+ "expert_ids": [
271
+ 279,
272
+ 172,
273
+ 114,
274
+ 217,
275
+ 9,
276
+ 66,
277
+ 157,
278
+ 180,
279
+ 210,
280
+ 102,
281
+ 150,
282
+ 283,
283
+ 175,
284
+ 89,
285
+ 32,
286
+ 186
287
+ ],
288
+ "source_layer": 17,
289
+ "target_layer": 10
290
+ },
291
+ {
292
+ "expert_count": 16,
293
+ "expert_ids": [
294
+ 157,
295
+ 281,
296
+ 111,
297
+ 228,
298
+ 27,
299
+ 5,
300
+ 23,
301
+ 21,
302
+ 282,
303
+ 261,
304
+ 92,
305
+ 81,
306
+ 271,
307
+ 85,
308
+ 80,
309
+ 136
310
+ ],
311
+ "source_layer": 19,
312
+ "target_layer": 11
313
+ },
314
+ {
315
+ "expert_count": 16,
316
+ "expert_ids": [
317
+ 269,
318
+ 92,
319
+ 42,
320
+ 15,
321
+ 173,
322
+ 216,
323
+ 141,
324
+ 282,
325
+ 29,
326
+ 210,
327
+ 35,
328
+ 110,
329
+ 260,
330
+ 64,
331
+ 245,
332
+ 247
333
+ ],
334
+ "source_layer": 20,
335
+ "target_layer": 12
336
+ },
337
+ {
338
+ "expert_count": 16,
339
+ "expert_ids": [
340
+ 123,
341
+ 165,
342
+ 166,
343
+ 178,
344
+ 5,
345
+ 182,
346
+ 33,
347
+ 37,
348
+ 110,
349
+ 211,
350
+ 186,
351
+ 158,
352
+ 63,
353
+ 106,
354
+ 159,
355
+ 267
356
+ ],
357
+ "source_layer": 21,
358
+ "target_layer": 13
359
+ },
360
+ {
361
+ "expert_count": 16,
362
+ "expert_ids": [
363
+ 269,
364
+ 234,
365
+ 202,
366
+ 229,
367
+ 106,
368
+ 90,
369
+ 67,
370
+ 11,
371
+ 133,
372
+ 152,
373
+ 254,
374
+ 70,
375
+ 219,
376
+ 13,
377
+ 57,
378
+ 10
379
+ ],
380
+ "source_layer": 23,
381
+ "target_layer": 14
382
+ },
383
+ {
384
+ "expert_count": 16,
385
+ "expert_ids": [
386
+ 135,
387
+ 49,
388
+ 193,
389
+ 207,
390
+ 272,
391
+ 25,
392
+ 45,
393
+ 101,
394
+ 177,
395
+ 56,
396
+ 29,
397
+ 23,
398
+ 119,
399
+ 198,
400
+ 35,
401
+ 159
402
+ ],
403
+ "source_layer": 24,
404
+ "target_layer": 15
405
+ },
406
+ {
407
+ "expert_count": 16,
408
+ "expert_ids": [
409
+ 227,
410
+ 49,
411
+ 43,
412
+ 214,
413
+ 245,
414
+ 127,
415
+ 248,
416
+ 150,
417
+ 25,
418
+ 223,
419
+ 246,
420
+ 203,
421
+ 145,
422
+ 57,
423
+ 89,
424
+ 208
425
+ ],
426
+ "source_layer": 26,
427
+ "target_layer": 16
428
+ },
429
+ {
430
+ "expert_count": 16,
431
+ "expert_ids": [
432
+ 134,
433
+ 196,
434
+ 89,
435
+ 66,
436
+ 106,
437
+ 205,
438
+ 60,
439
+ 121,
440
+ 209,
441
+ 224,
442
+ 286,
443
+ 114,
444
+ 26,
445
+ 248,
446
+ 188,
447
+ 194
448
+ ],
449
+ "source_layer": 27,
450
+ "target_layer": 17
451
+ },
452
+ {
453
+ "expert_count": 16,
454
+ "expert_ids": [
455
+ 69,
456
+ 214,
457
+ 198,
458
+ 283,
459
+ 272,
460
+ 56,
461
+ 89,
462
+ 107,
463
+ 60,
464
+ 50,
465
+ 245,
466
+ 61,
467
+ 185,
468
+ 67,
469
+ 97,
470
+ 99
471
+ ],
472
+ "source_layer": 28,
473
+ "target_layer": 18
474
+ },
475
+ {
476
+ "expert_count": 16,
477
+ "expert_ids": [
478
+ 93,
479
+ 139,
480
+ 36,
481
+ 279,
482
+ 29,
483
+ 97,
484
+ 111,
485
+ 64,
486
+ 0,
487
+ 195,
488
+ 242,
489
+ 24,
490
+ 140,
491
+ 101,
492
+ 8,
493
+ 136
494
+ ],
495
+ "source_layer": 30,
496
+ "target_layer": 19
497
+ },
498
+ {
499
+ "expert_count": 16,
500
+ "expert_ids": [
501
+ 147,
502
+ 241,
503
+ 11,
504
+ 251,
505
+ 178,
506
+ 268,
507
+ 118,
508
+ 154,
509
+ 103,
510
+ 248,
511
+ 25,
512
+ 157,
513
+ 197,
514
+ 66,
515
+ 210,
516
+ 98
517
+ ],
518
+ "source_layer": 31,
519
+ "target_layer": 20
520
+ },
521
+ {
522
+ "expert_count": 16,
523
+ "expert_ids": [
524
+ 206,
525
+ 72,
526
+ 170,
527
+ 171,
528
+ 237,
529
+ 8,
530
+ 168,
531
+ 61,
532
+ 172,
533
+ 202,
534
+ 130,
535
+ 222,
536
+ 256,
537
+ 128,
538
+ 226,
539
+ 252
540
+ ],
541
+ "source_layer": 33,
542
+ "target_layer": 21
543
+ },
544
+ {
545
+ "expert_count": 16,
546
+ "expert_ids": [
547
+ 52,
548
+ 258,
549
+ 18,
550
+ 59,
551
+ 80,
552
+ 172,
553
+ 137,
554
+ 40,
555
+ 197,
556
+ 89,
557
+ 35,
558
+ 154,
559
+ 84,
560
+ 19,
561
+ 255,
562
+ 38
563
+ ],
564
+ "source_layer": 34,
565
+ "target_layer": 22
566
+ },
567
+ {
568
+ "expert_count": 16,
569
+ "expert_ids": [
570
+ 220,
571
+ 31,
572
+ 280,
573
+ 106,
574
+ 10,
575
+ 178,
576
+ 234,
577
+ 36,
578
+ 7,
579
+ 212,
580
+ 187,
581
+ 199,
582
+ 221,
583
+ 47,
584
+ 186,
585
+ 147
586
+ ],
587
+ "source_layer": 36,
588
+ "target_layer": 23
589
+ },
590
+ {
591
+ "expert_count": 16,
592
+ "expert_ids": [
593
+ 36,
594
+ 197,
595
+ 33,
596
+ 93,
597
+ 181,
598
+ 134,
599
+ 84,
600
+ 244,
601
+ 264,
602
+ 164,
603
+ 207,
604
+ 202,
605
+ 71,
606
+ 59,
607
+ 214,
608
+ 284
609
+ ],
610
+ "source_layer": 37,
611
+ "target_layer": 24
612
+ },
613
+ {
614
+ "expert_count": 16,
615
+ "expert_ids": [
616
+ 54,
617
+ 143,
618
+ 130,
619
+ 15,
620
+ 14,
621
+ 107,
622
+ 76,
623
+ 225,
624
+ 8,
625
+ 195,
626
+ 281,
627
+ 212,
628
+ 161,
629
+ 177,
630
+ 258,
631
+ 259
632
+ ],
633
+ "source_layer": 38,
634
+ "target_layer": 25
635
+ },
636
+ {
637
+ "expert_count": 16,
638
+ "expert_ids": [
639
+ 5,
640
+ 187,
641
+ 78,
642
+ 105,
643
+ 165,
644
+ 9,
645
+ 156,
646
+ 139,
647
+ 235,
648
+ 121,
649
+ 62,
650
+ 256,
651
+ 14,
652
+ 201,
653
+ 180,
654
+ 277
655
+ ],
656
+ "source_layer": 40,
657
+ "target_layer": 26
658
+ },
659
+ {
660
+ "expert_count": 16,
661
+ "expert_ids": [
662
+ 144,
663
+ 154,
664
+ 125,
665
+ 98,
666
+ 92,
667
+ 123,
668
+ 196,
669
+ 80,
670
+ 141,
671
+ 83,
672
+ 249,
673
+ 250,
674
+ 20,
675
+ 34,
676
+ 134,
677
+ 184
678
+ ],
679
+ "source_layer": 41,
680
+ "target_layer": 27
681
+ },
682
+ {
683
+ "expert_count": 16,
684
+ "expert_ids": [
685
+ 249,
686
+ 148,
687
+ 151,
688
+ 221,
689
+ 18,
690
+ 87,
691
+ 239,
692
+ 105,
693
+ 207,
694
+ 35,
695
+ 147,
696
+ 20,
697
+ 84,
698
+ 130,
699
+ 52,
700
+ 17
701
+ ],
702
+ "source_layer": 43,
703
+ "target_layer": 28
704
+ },
705
+ {
706
+ "expert_count": 16,
707
+ "expert_ids": [
708
+ 44,
709
+ 212,
710
+ 152,
711
+ 127,
712
+ 244,
713
+ 138,
714
+ 156,
715
+ 266,
716
+ 24,
717
+ 135,
718
+ 113,
719
+ 185,
720
+ 147,
721
+ 186,
722
+ 17,
723
+ 184
724
+ ],
725
+ "source_layer": 44,
726
+ "target_layer": 29
727
+ }
728
+ ],
729
+ "schema": "lfm-glm-fixed16-top4-fusion-plan",
730
+ "schema_version": 1,
731
+ "source": {
732
+ "layer_map": "<workspace>\\manifests\\lfm_to_glm_layer_map.json",
733
+ "layer_map_method": "monotonic normalized depth over GLM main sparse layers 3..44; replace with CKA/CCA mapping after paired activation collection",
734
+ "layer_map_sha256": "bd7e4efc18148ff1ebd66f58adfc994b1383a4d56d166cc2b576a973b9c4f4d4",
735
+ "selection_profile": "<workspace>\\artifacts\\glm-code-expert-ranking\\selection_profile_fixed16_hybrid.json",
736
+ "selection_profile_sha256": "48ee7d8528836935ceffb256050c647b087c31a801a76de3d9169235c8efc58c"
737
+ }
738
+ }
provenance/pre-repack-index.json ADDED
The diff for this file is too large to render. See raw diff
 
provenance/quantization.json ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema": "rivetcoder-fp8-quantization",
3
+ "schema_version": 1,
4
+ "created_at": "2026-08-27T23:01:09+09:00",
5
+ "source": {
6
+ "repo_id": "HCHs/RivetCoder-9B-A4B",
7
+ "revision": "9a90b1917d9b5438e4d2fe1a4f6aea884db59a60"
8
+ },
9
+ "target": {
10
+ "repo_id": "HCHs/RivetCoder-9B-A4B-FP8",
11
+ "local_directory": "RivetCoder-9B-A4B-FP8"
12
+ },
13
+ "method": {
14
+ "framework": "TorchAO",
15
+ "config": "Float8DynamicActivationFloat8WeightConfig",
16
+ "weight_dtype": "float8_e4m3fn",
17
+ "activation_dtype": "float8_e4m3fn",
18
+ "activation_scheme": "dynamic",
19
+ "granularity": "per-tensor",
20
+ "compatible_linear_modules_only": true
21
+ },
22
+ "runtime": {
23
+ "platform": "Windows 11",
24
+ "python": "3.12.10",
25
+ "torch": "2.12.0+cu130",
26
+ "transformers": "5.16.1",
27
+ "accelerate": "1.13.0",
28
+ "safetensors": "0.8.0",
29
+ "torchao": "0.15.0",
30
+ "gpu": "NVIDIA GeForce RTX 5070 Ti",
31
+ "compute_capability": [12, 0]
32
+ },
33
+ "results": {
34
+ "parameter_tensors": 1826,
35
+ "fp8_tensor_subclass_parameters": 1636,
36
+ "fp8_parameter_elements": 8475574272,
37
+ "stored_tensor_bytes": 9000638976,
38
+ "safetensors_shards": 5,
39
+ "all_parameters_materialized": true,
40
+ "all_parameters_on_cuda": true,
41
+ "clean_reload_success": true,
42
+ "clean_reload_seconds": 338.0,
43
+ "clean_reload_fp8_parameters": 1636,
44
+ "clean_reload_non_cuda_parameters": 0,
45
+ "resident_cuda_allocated_bytes": 9039455232,
46
+ "forward_finite": true,
47
+ "forward_logits_shape": [1, 6, 128000]
48
+ },
49
+ "compatibility": {
50
+ "required_context": "torch.no_grad",
51
+ "known_incompatible_context": "torch.inference_mode",
52
+ "known_error": "Cannot set version_counter for inference tensor"
53
+ }
54
+ }
provenance/router-training.json ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "created_at": "2026-08-27T12:25:03Z",
3
+ "completion": {
4
+ "actual_global_step": 60,
5
+ "final_checkpoint": "checkpoint-00000060",
6
+ "note": "The initial run targeted 20 steps and was resumed with identical semantics to step 60; max_steps is excluded from the run fingerprint."
7
+ },
8
+ "data": {
9
+ "assistant_only_coding_loss": true,
10
+ "balanced_batching": "equal coding and generic microbatch sizes at every accumulation step",
11
+ "chat_template_sha256": "ea663864491de7ade391839479860ca95541f892f72665c73251fbd4643b1bef",
12
+ "coding_jsonl": "<workspace>\\data\\router_training_qwen\\coding_train.jsonl",
13
+ "coding_label_scope": "LFM chat-template assistant tokens only",
14
+ "coding_sha256": "a70575ac0c1e2977054bc3ba7035c63c4432882c983ab9033fac96884e3164ff",
15
+ "generic_jsonl": "<workspace>\\data\\router_training_qwen\\generic_control.jsonl",
16
+ "generic_sha256": "e0dca59cf6419f958711ce6dfe6aef06ca00a2526abaf700e3bf1f1f87d8921b",
17
+ "tokenizer": "same local LFM tokenizer for coding, generic teacher, and generic student",
18
+ "tokenizer_json_sha256": "695be7802a0e4b8a81048f0ff5ebb7fc811a0ba5a6be63dbb24deb5a81096f41",
19
+ "validation_jsonl": "<workspace>\\data\\router_training_qwen\\coding_validation.jsonl",
20
+ "validation_sha256": "7cdd0ab2c64eab93c3d61f47b0aa6868b6b7448ae341bb6d5cc916de60d98d44"
21
+ },
22
+ "donor": {
23
+ "raw_glm_logit_kl": false,
24
+ "reason": "GLM and LFM vocabularies/tokenizers differ",
25
+ "repo_id": "zai-org/GLM-5.3-Flash",
26
+ "revision": "3f1971b7b5f7a528c9c4ef6212c8785298a8c24a"
27
+ },
28
+ "folded_experts": {
29
+ "directory": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard",
30
+ "frozen": true,
31
+ "hidden_size": 2048,
32
+ "index": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard\\model.safetensors.index.json",
33
+ "index_sha256": "c156f43793b0cee11290e32619c767d86eaaf4ca1a6ec268ece9eb8d62b6880c",
34
+ "intermediate_size": 2048,
35
+ "layers": [
36
+ 0,
37
+ 1,
38
+ 2,
39
+ 3,
40
+ 4,
41
+ 5,
42
+ 6,
43
+ 7,
44
+ 8,
45
+ 9,
46
+ 10,
47
+ 11,
48
+ 12,
49
+ 13,
50
+ 14,
51
+ 15,
52
+ 16,
53
+ 17,
54
+ 18,
55
+ 19,
56
+ 20,
57
+ 21,
58
+ 22,
59
+ 23,
60
+ 24,
61
+ 25,
62
+ 26,
63
+ 27,
64
+ 28,
65
+ 29
66
+ ],
67
+ "loaded_expert_tensor_count": 1440,
68
+ "loaded_tensor_count": 1500,
69
+ "num_experts_per_layer": 16,
70
+ "provenance_sha256": "6dbfc15a45f773b515a1aa0b2fb2f0b3174697a3873d62865a6dfafcc54c586a",
71
+ "selected_tensor_storage_bytes": 12079595520,
72
+ "top_k": 4
73
+ },
74
+ "host": {
75
+ "config_sha256": "480f63fa8e1efa534ae8b92774b3b53b8d6812d62a726e9ecfc866933662f273",
76
+ "frozen": true,
77
+ "local_path": "<workspace>\\models\\LiquidAI\\LFM2.5-2.6B",
78
+ "repo_id": "LiquidAI/LFM2.5-2.6B",
79
+ "revision": "654f9463ce32b05d0429d76fe1f580b27d4c1ac0"
80
+ },
81
+ "initial_expert_off_exactness": {
82
+ "atol": 0.0,
83
+ "exact_equal": true,
84
+ "max_abs_diff": 0.0,
85
+ "within_tolerance": true
86
+ },
87
+ "losses": {
88
+ "coding": "causal CE on fused LFM logits",
89
+ "coding_gate": "MSE to coding_gate_target",
90
+ "generic": "teacher||student KL; teacher is the same frozen LFM with coding_enabled=False",
91
+ "generic_gate": "mean sigmoid token gate (L1-like sparsity)",
92
+ "router": "valid-token Switch-style top-k load balance"
93
+ },
94
+ "router_initialization": {
95
+ "correction_semantics": "post-sigmoid correction used for top-k choice only; mixture weights use uncorrected sigmoid scores",
96
+ "correction_trainable": false,
97
+ "layers": [
98
+ 0,
99
+ 1,
100
+ 2,
101
+ 3,
102
+ 4,
103
+ 5,
104
+ 6,
105
+ 7,
106
+ 8,
107
+ 9,
108
+ 10,
109
+ 11,
110
+ 12,
111
+ 13,
112
+ 14,
113
+ 15,
114
+ 16,
115
+ 17,
116
+ 18,
117
+ 19,
118
+ 20,
119
+ 21,
120
+ 22,
121
+ 23,
122
+ 24,
123
+ 25,
124
+ 26,
125
+ 27,
126
+ 28,
127
+ 29
128
+ ],
129
+ "loaded_before_optimizer": true,
130
+ "loaded_tensor_count": 60,
131
+ "mode": "folded GLM router warm-start",
132
+ "storage_bytes": 3934080,
133
+ "weight_equation": "R_glm[selected expert rows] @ P_in",
134
+ "weight_trainable": true
135
+ },
136
+ "run_fingerprint": "68f9fa90e18e180f7037dea5e057aa296c95b59267aa09f38285363b5e517c2a",
137
+ "runtime": {
138
+ "arguments": {
139
+ "adam_beta1": 0.9,
140
+ "adam_beta2": 0.95,
141
+ "adam_epsilon": 1e-08,
142
+ "allow_vram_oversubscription": false,
143
+ "assistant_only_coding_loss": true,
144
+ "attn_implementation": "sdpa",
145
+ "batch_size": 1,
146
+ "coding_ce_weight": 1.0,
147
+ "coding_gate_target": 0.8,
148
+ "coding_gate_target_weight": 0.25,
149
+ "coding_jsonl": "<workspace>\\data\\router_training_qwen\\coding_train.jsonl",
150
+ "deterministic": true,
151
+ "device": "cuda",
152
+ "donor_repo_id": "zai-org/GLM-5.3-Flash",
153
+ "donor_revision": "3f1971b7b5f7a528c9c4ef6212c8785298a8c24a",
154
+ "exactness_atol": 0.0,
155
+ "exactness_every": 5,
156
+ "expert_cpu_offload": true,
157
+ "expert_cpu_offload_dtype": "bfloat16",
158
+ "fail_on_exactness_drift": true,
159
+ "folded_experts": "<workspace>\\artifacts\\folded-glm-experts-fixed16-top4-identity-hadamard",
160
+ "fusion_layers": "0-29",
161
+ "generic_gate_sparsity_weight": 0.1,
162
+ "generic_jsonl": "<workspace>\\data\\router_training_qwen\\generic_control.jsonl",
163
+ "generic_kl_weight": 1.0,
164
+ "gradient_accumulation_steps": 1,
165
+ "host_model": "<workspace>\\models\\LiquidAI\\LFM2.5-2.6B",
166
+ "host_repo_id": "LiquidAI/LFM2.5-2.6B",
167
+ "host_revision": "654f9463ce32b05d0429d76fe1f580b27d4c1ac0",
168
+ "kl_temperature": 1.0,
169
+ "kl_vocab_chunk_size": 8192,
170
+ "learning_rate": 0.0005,
171
+ "log_every": 1,
172
+ "max_grad_norm": 1.0,
173
+ "max_length": 768,
174
+ "max_steps": 20,
175
+ "num_experts": 16,
176
+ "output_dir": "<workspace>\\artifacts\\router-training-qwen-all30-fixed16-top4",
177
+ "precision": "bfloat16",
178
+ "residual_scale_learning_rate": 0.05,
179
+ "resume": null,
180
+ "router_learning_rate": 0.0005,
181
+ "router_load_balance_weight": 0.005,
182
+ "save_every": 5,
183
+ "seed": 1234,
184
+ "text_field": "text",
185
+ "token_gate_learning_rate": 0.001,
186
+ "top_k": 4,
187
+ "validation_jsonl": "<workspace>\\data\\router_training_qwen\\coding_validation.jsonl",
188
+ "vram_max_fraction": 0.85,
189
+ "warmup_steps": 2,
190
+ "weight_decay": 0.0
191
+ },
192
+ "cuda_available": true,
193
+ "cuda_device": "NVIDIA GeForce RTX 5070 Ti",
194
+ "platform": "Windows-11-10.0.26200-SP0",
195
+ "python": "3.12.10",
196
+ "versions": {
197
+ "accelerate": "1.13.0",
198
+ "huggingface_hub": "1.18.0",
199
+ "numpy": "2.3.3",
200
+ "safetensors": "0.8.0",
201
+ "torch": "2.12.0+cu130",
202
+ "transformers": "5.16.1"
203
+ },
204
+ "vram_preflight": {
205
+ "configured_limit_bytes": 13402321715,
206
+ "cuda_free_bytes_before_move": 15767437312,
207
+ "cuda_total_bytes": 17066033152,
208
+ "device": "cuda",
209
+ "estimated_resident_parameter_bytes": 5396486264,
210
+ "expert_cpu_offload": true,
211
+ "model_parameter_bytes": 17476081784
212
+ }
213
+ },
214
+ "schema": "fuse-glm-router-training",
215
+ "schema_version": 1,
216
+ "trainable": {
217
+ "allowed_modules": [
218
+ "router",
219
+ "token_gate",
220
+ "raw_residual_scale"
221
+ ],
222
+ "parameter_count": 1044540,
223
+ "parameter_names": [
224
+ "model.layers.0.feed_forward.raw_residual_scale",
225
+ "model.layers.0.feed_forward.router.proj.weight",
226
+ "model.layers.0.feed_forward.token_gate.weight",
227
+ "model.layers.0.feed_forward.token_gate.bias",
228
+ "model.layers.1.feed_forward.raw_residual_scale",
229
+ "model.layers.1.feed_forward.router.proj.weight",
230
+ "model.layers.1.feed_forward.token_gate.weight",
231
+ "model.layers.1.feed_forward.token_gate.bias",
232
+ "model.layers.2.feed_forward.raw_residual_scale",
233
+ "model.layers.2.feed_forward.router.proj.weight",
234
+ "model.layers.2.feed_forward.token_gate.weight",
235
+ "model.layers.2.feed_forward.token_gate.bias",
236
+ "model.layers.3.feed_forward.raw_residual_scale",
237
+ "model.layers.3.feed_forward.router.proj.weight",
238
+ "model.layers.3.feed_forward.token_gate.weight",
239
+ "model.layers.3.feed_forward.token_gate.bias",
240
+ "model.layers.4.feed_forward.raw_residual_scale",
241
+ "model.layers.4.feed_forward.router.proj.weight",
242
+ "model.layers.4.feed_forward.token_gate.weight",
243
+ "model.layers.4.feed_forward.token_gate.bias",
244
+ "model.layers.5.feed_forward.raw_residual_scale",
245
+ "model.layers.5.feed_forward.router.proj.weight",
246
+ "model.layers.5.feed_forward.token_gate.weight",
247
+ "model.layers.5.feed_forward.token_gate.bias",
248
+ "model.layers.6.feed_forward.raw_residual_scale",
249
+ "model.layers.6.feed_forward.router.proj.weight",
250
+ "model.layers.6.feed_forward.token_gate.weight",
251
+ "model.layers.6.feed_forward.token_gate.bias",
252
+ "model.layers.7.feed_forward.raw_residual_scale",
253
+ "model.layers.7.feed_forward.router.proj.weight",
254
+ "model.layers.7.feed_forward.token_gate.weight",
255
+ "model.layers.7.feed_forward.token_gate.bias",
256
+ "model.layers.8.feed_forward.raw_residual_scale",
257
+ "model.layers.8.feed_forward.router.proj.weight",
258
+ "model.layers.8.feed_forward.token_gate.weight",
259
+ "model.layers.8.feed_forward.token_gate.bias",
260
+ "model.layers.9.feed_forward.raw_residual_scale",
261
+ "model.layers.9.feed_forward.router.proj.weight",
262
+ "model.layers.9.feed_forward.token_gate.weight",
263
+ "model.layers.9.feed_forward.token_gate.bias",
264
+ "model.layers.10.feed_forward.raw_residual_scale",
265
+ "model.layers.10.feed_forward.router.proj.weight",
266
+ "model.layers.10.feed_forward.token_gate.weight",
267
+ "model.layers.10.feed_forward.token_gate.bias",
268
+ "model.layers.11.feed_forward.raw_residual_scale",
269
+ "model.layers.11.feed_forward.router.proj.weight",
270
+ "model.layers.11.feed_forward.token_gate.weight",
271
+ "model.layers.11.feed_forward.token_gate.bias",
272
+ "model.layers.12.feed_forward.raw_residual_scale",
273
+ "model.layers.12.feed_forward.router.proj.weight",
274
+ "model.layers.12.feed_forward.token_gate.weight",
275
+ "model.layers.12.feed_forward.token_gate.bias",
276
+ "model.layers.13.feed_forward.raw_residual_scale",
277
+ "model.layers.13.feed_forward.router.proj.weight",
278
+ "model.layers.13.feed_forward.token_gate.weight",
279
+ "model.layers.13.feed_forward.token_gate.bias",
280
+ "model.layers.14.feed_forward.raw_residual_scale",
281
+ "model.layers.14.feed_forward.router.proj.weight",
282
+ "model.layers.14.feed_forward.token_gate.weight",
283
+ "model.layers.14.feed_forward.token_gate.bias",
284
+ "model.layers.15.feed_forward.raw_residual_scale",
285
+ "model.layers.15.feed_forward.router.proj.weight",
286
+ "model.layers.15.feed_forward.token_gate.weight",
287
+ "model.layers.15.feed_forward.token_gate.bias",
288
+ "model.layers.16.feed_forward.raw_residual_scale",
289
+ "model.layers.16.feed_forward.router.proj.weight",
290
+ "model.layers.16.feed_forward.token_gate.weight",
291
+ "model.layers.16.feed_forward.token_gate.bias",
292
+ "model.layers.17.feed_forward.raw_residual_scale",
293
+ "model.layers.17.feed_forward.router.proj.weight",
294
+ "model.layers.17.feed_forward.token_gate.weight",
295
+ "model.layers.17.feed_forward.token_gate.bias",
296
+ "model.layers.18.feed_forward.raw_residual_scale",
297
+ "model.layers.18.feed_forward.router.proj.weight",
298
+ "model.layers.18.feed_forward.token_gate.weight",
299
+ "model.layers.18.feed_forward.token_gate.bias",
300
+ "model.layers.19.feed_forward.raw_residual_scale",
301
+ "model.layers.19.feed_forward.router.proj.weight",
302
+ "model.layers.19.feed_forward.token_gate.weight",
303
+ "model.layers.19.feed_forward.token_gate.bias",
304
+ "model.layers.20.feed_forward.raw_residual_scale",
305
+ "model.layers.20.feed_forward.router.proj.weight",
306
+ "model.layers.20.feed_forward.token_gate.weight",
307
+ "model.layers.20.feed_forward.token_gate.bias",
308
+ "model.layers.21.feed_forward.raw_residual_scale",
309
+ "model.layers.21.feed_forward.router.proj.weight",
310
+ "model.layers.21.feed_forward.token_gate.weight",
311
+ "model.layers.21.feed_forward.token_gate.bias",
312
+ "model.layers.22.feed_forward.raw_residual_scale",
313
+ "model.layers.22.feed_forward.router.proj.weight",
314
+ "model.layers.22.feed_forward.token_gate.weight",
315
+ "model.layers.22.feed_forward.token_gate.bias",
316
+ "model.layers.23.feed_forward.raw_residual_scale",
317
+ "model.layers.23.feed_forward.router.proj.weight",
318
+ "model.layers.23.feed_forward.token_gate.weight",
319
+ "model.layers.23.feed_forward.token_gate.bias",
320
+ "model.layers.24.feed_forward.raw_residual_scale",
321
+ "model.layers.24.feed_forward.router.proj.weight",
322
+ "model.layers.24.feed_forward.token_gate.weight",
323
+ "model.layers.24.feed_forward.token_gate.bias",
324
+ "model.layers.25.feed_forward.raw_residual_scale",
325
+ "model.layers.25.feed_forward.router.proj.weight",
326
+ "model.layers.25.feed_forward.token_gate.weight",
327
+ "model.layers.25.feed_forward.token_gate.bias",
328
+ "model.layers.26.feed_forward.raw_residual_scale",
329
+ "model.layers.26.feed_forward.router.proj.weight",
330
+ "model.layers.26.feed_forward.token_gate.weight",
331
+ "model.layers.26.feed_forward.token_gate.bias",
332
+ "model.layers.27.feed_forward.raw_residual_scale",
333
+ "model.layers.27.feed_forward.router.proj.weight",
334
+ "model.layers.27.feed_forward.token_gate.weight",
335
+ "model.layers.27.feed_forward.token_gate.bias",
336
+ "model.layers.28.feed_forward.raw_residual_scale",
337
+ "model.layers.28.feed_forward.router.proj.weight",
338
+ "model.layers.28.feed_forward.token_gate.weight",
339
+ "model.layers.28.feed_forward.token_gate.bias",
340
+ "model.layers.29.feed_forward.raw_residual_scale",
341
+ "model.layers.29.feed_forward.router.proj.weight",
342
+ "model.layers.29.feed_forward.token_gate.weight",
343
+ "model.layers.29.feed_forward.token_gate.bias"
344
+ ]
345
+ }
346
+ }
provenance/selected-expert-tensors.json ADDED
The diff for this file is too large to render. See raw diff
 
provenance/source-models.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "donor": {
3
+ "license": "MIT",
4
+ "local_path": "models/zai-org/GLM-5.3-Flash",
5
+ "repo_id": "zai-org/GLM-5.3-Flash",
6
+ "revision": "3f1971b7b5f7a528c9c4ef6212c8785298a8c24a",
7
+ "role": "coding-expert donor and profiling teacher",
8
+ "snapshot_bytes": 328366171529
9
+ },
10
+ "host": {
11
+ "license": "LFM Open License v1.0",
12
+ "local_path": "models/LiquidAI/LFM2.5-2.6B",
13
+ "repo_id": "LiquidAI/LFM2.5-2.6B",
14
+ "revision": "654f9463ce32b05d0429d76fe1f580b27d4c1ac0",
15
+ "role": "frozen host model and tokenizer",
16
+ "snapshot_bytes": 5412392560
17
+ },
18
+ "reference": {
19
+ "repo_id": "Akahsizrr/fuse-1-Lite",
20
+ "revision": "430c959e47556ae53fed18a9d97f7cf30876e6ff",
21
+ "role": "architecture reference only"
22
+ },
23
+ "schema_version": 1
24
+ }
provenance/training-data-manifest.json ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "created_at": "2026-08-27T12:12:57.894412+00:00",
3
+ "generation": {
4
+ "base_seed": 20261027,
5
+ "max_tokens": 640,
6
+ "model": "qwen/qwen3.8-27b",
7
+ "reasoning_effort": "none",
8
+ "repaired_ids": [
9
+ "qwen-coding-001",
10
+ "qwen-coding-002",
11
+ "qwen-coding-003",
12
+ "qwen-coding-004",
13
+ "qwen-coding-005",
14
+ "qwen-coding-020"
15
+ ],
16
+ "temperature": 0.3,
17
+ "top_p": 0.9
18
+ },
19
+ "output": {
20
+ "coding_train": {
21
+ "path": "data\\router_training_qwen\\coding_train.jsonl",
22
+ "records": 20,
23
+ "sha256": "a70575ac0c1e2977054bc3ba7035c63c4432882c983ab9033fac96884e3164ff"
24
+ },
25
+ "coding_validation": {
26
+ "path": "data\\router_training_qwen\\coding_validation.jsonl",
27
+ "records": 4,
28
+ "sha256": "7cdd0ab2c64eab93c3d61f47b0aa6868b6b7448ae341bb6d5cc916de60d98d44"
29
+ },
30
+ "generic_control": {
31
+ "path": "data\\router_training_qwen\\generic_control.jsonl",
32
+ "records": 8,
33
+ "sha256": "e0dca59cf6419f958711ce6dfe6aef06ca00a2526abaf700e3bf1f1f87d8921b"
34
+ }
35
+ },
36
+ "schema": "qwen-router-training-corpus",
37
+ "schema_version": 1,
38
+ "source": {
39
+ "coding": "data\\teacher_qwen3.8_27b\\coding_calibration.jsonl",
40
+ "coding_sha256": "4b9cb9bdf18a4abe0c8e08fb45b67d94d77dc432c4a56e6e84daeb5e08290ba8",
41
+ "generic": "data\\teacher_qwen3.8_27b\\generic_control.jsonl",
42
+ "generic_sha256": "2ebc8f764048e2fe9a8a3b3528c898f31a3bc622a88c0b97388be26c82129f65"
43
+ },
44
+ "split": {
45
+ "generic_ids": [
46
+ "qwen-generic-000",
47
+ "qwen-generic-001",
48
+ "qwen-generic-002",
49
+ "qwen-generic-003",
50
+ "qwen-generic-004",
51
+ "qwen-generic-005",
52
+ "qwen-generic-006",
53
+ "qwen-generic-007"
54
+ ],
55
+ "training_ids": [
56
+ "qwen-coding-000",
57
+ "qwen-coding-001",
58
+ "qwen-coding-002",
59
+ "qwen-coding-003",
60
+ "qwen-coding-004",
61
+ "qwen-coding-005",
62
+ "qwen-coding-007",
63
+ "qwen-coding-008",
64
+ "qwen-coding-009",
65
+ "qwen-coding-010",
66
+ "qwen-coding-011",
67
+ "qwen-coding-012",
68
+ "qwen-coding-014",
69
+ "qwen-coding-015",
70
+ "qwen-coding-016",
71
+ "qwen-coding-017",
72
+ "qwen-coding-019",
73
+ "qwen-coding-020",
74
+ "qwen-coding-021",
75
+ "qwen-coding-022"
76
+ ],
77
+ "validation_ids": [
78
+ "qwen-coding-006",
79
+ "qwen-coding-013",
80
+ "qwen-coding-018",
81
+ "qwen-coding-023"
82
+ ]
83
+ },
84
+ "teacher": {
85
+ "arch": "qwen3_5",
86
+ "capabilities": [
87
+ "tool_use"
88
+ ],
89
+ "compatibility_type": "mlx",
90
+ "id": "qwen/qwen3.8-27b",
91
+ "loaded_context_length": 42496,
92
+ "max_context_length": 262144,
93
+ "object": "model",
94
+ "publisher": "qwen",
95
+ "quantization": "4bit",
96
+ "state": "loaded",
97
+ "type": "vlm"
98
+ }
99
+ }
provenance/training-summary.json ADDED
@@ -0,0 +1,1737 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "completed_at": "2026-08-27T13:04:49Z",
3
+ "final_checkpoint": "<workspace>\\artifacts\\router-training-qwen-all30-fixed16-top4\\checkpoint-00000060",
4
+ "final_expert_off_exactness": {
5
+ "atol": 0.0,
6
+ "exact_equal": true,
7
+ "max_abs_diff": 0.0,
8
+ "within_tolerance": true
9
+ },
10
+ "final_metrics": {
11
+ "coding_sampler_epoch": 2,
12
+ "cuda": {
13
+ "allocated_bytes": 5474311680,
14
+ "max_allocated_bytes": 12469938176,
15
+ "reserved_bytes": 14224982016
16
+ },
17
+ "expert_off_exactness": {
18
+ "atol": 0.0,
19
+ "exact_equal": true,
20
+ "max_abs_diff": 0.0,
21
+ "within_tolerance": true
22
+ },
23
+ "generic_sampler_epoch": 7,
24
+ "global_step": 60,
25
+ "grad_norm": 0.015457727015018463,
26
+ "learning_rate": 0.0005,
27
+ "learning_rates": {
28
+ "residual_scale": 0.05,
29
+ "router": 0.0005,
30
+ "token_gate": 0.001
31
+ },
32
+ "loss": {
33
+ "coding_ce": 0.3947601616382599,
34
+ "coding_gate_target": 0.40677282214164734,
35
+ "generic_gate_sparsity": 0.036865234375,
36
+ "generic_kl": 0.0010666541056707501,
37
+ "router_load_balance": 0.9907996654510498,
38
+ "total": 0.5061666369438171
39
+ },
40
+ "router_diagnostics": [
41
+ {
42
+ "domain": "coding",
43
+ "expert_counts": [
44
+ 123,
45
+ 219,
46
+ 189,
47
+ 205,
48
+ 175,
49
+ 180,
50
+ 187,
51
+ 164,
52
+ 101,
53
+ 119,
54
+ 234,
55
+ 170,
56
+ 203,
57
+ 192,
58
+ 163,
59
+ 180
60
+ ],
61
+ "layer": 0,
62
+ "mean_selected_weight": 0.25,
63
+ "residual_scale": 7.45758370612748e-05,
64
+ "router_entropy": 2.703125,
65
+ "token_gate_active_fraction": 0.0,
66
+ "token_gate_mean": 0.058837890625,
67
+ "valid_tokens": 701
68
+ },
69
+ {
70
+ "domain": "coding",
71
+ "expert_counts": [
72
+ 140,
73
+ 179,
74
+ 181,
75
+ 170,
76
+ 138,
77
+ 170,
78
+ 192,
79
+ 253,
80
+ 155,
81
+ 144,
82
+ 213,
83
+ 204,
84
+ 200,
85
+ 206,
86
+ 180,
87
+ 79
88
+ ],
89
+ "layer": 1,
90
+ "mean_selected_weight": 0.25,
91
+ "residual_scale": -0.07198415696620941,
92
+ "router_entropy": 2.75,
93
+ "token_gate_active_fraction": 0.0,
94
+ "token_gate_mean": 0.04345703125,
95
+ "valid_tokens": 701
96
+ },
97
+ {
98
+ "domain": "coding",
99
+ "expert_counts": [
100
+ 167,
101
+ 138,
102
+ 202,
103
+ 209,
104
+ 134,
105
+ 170,
106
+ 192,
107
+ 264,
108
+ 174,
109
+ 148,
110
+ 136,
111
+ 140,
112
+ 167,
113
+ 160,
114
+ 190,
115
+ 213
116
+ ],
117
+ "layer": 2,
118
+ "mean_selected_weight": 0.25,
119
+ "residual_scale": 0.0014509361935779452,
120
+ "router_entropy": 2.734375,
121
+ "token_gate_active_fraction": 0.0,
122
+ "token_gate_mean": 0.0771484375,
123
+ "valid_tokens": 701
124
+ },
125
+ {
126
+ "domain": "coding",
127
+ "expert_counts": [
128
+ 251,
129
+ 237,
130
+ 206,
131
+ 136,
132
+ 146,
133
+ 132,
134
+ 170,
135
+ 158,
136
+ 191,
137
+ 161,
138
+ 0,
139
+ 202,
140
+ 157,
141
+ 210,
142
+ 247,
143
+ 200
144
+ ],
145
+ "layer": 3,
146
+ "mean_selected_weight": 0.25,
147
+ "residual_scale": -0.0868370309472084,
148
+ "router_entropy": 2.734375,
149
+ "token_gate_active_fraction": 0.0,
150
+ "token_gate_mean": 0.0615234375,
151
+ "valid_tokens": 701
152
+ },
153
+ {
154
+ "domain": "coding",
155
+ "expert_counts": [
156
+ 252,
157
+ 167,
158
+ 150,
159
+ 191,
160
+ 235,
161
+ 182,
162
+ 134,
163
+ 0,
164
+ 198,
165
+ 244,
166
+ 181,
167
+ 201,
168
+ 112,
169
+ 190,
170
+ 175,
171
+ 192
172
+ ],
173
+ "layer": 4,
174
+ "mean_selected_weight": 0.25,
175
+ "residual_scale": -0.08832801133394241,
176
+ "router_entropy": 2.75,
177
+ "token_gate_active_fraction": 0.0,
178
+ "token_gate_mean": 0.04736328125,
179
+ "valid_tokens": 701
180
+ },
181
+ {
182
+ "domain": "coding",
183
+ "expert_counts": [
184
+ 178,
185
+ 129,
186
+ 217,
187
+ 126,
188
+ 143,
189
+ 192,
190
+ 171,
191
+ 220,
192
+ 189,
193
+ 245,
194
+ 133,
195
+ 391,
196
+ 0,
197
+ 149,
198
+ 186,
199
+ 135
200
+ ],
201
+ "layer": 5,
202
+ "mean_selected_weight": 0.25,
203
+ "residual_scale": 0.014818619005382061,
204
+ "router_entropy": 2.75,
205
+ "token_gate_active_fraction": 0.0,
206
+ "token_gate_mean": 0.056884765625,
207
+ "valid_tokens": 701
208
+ },
209
+ {
210
+ "domain": "coding",
211
+ "expert_counts": [
212
+ 128,
213
+ 128,
214
+ 238,
215
+ 194,
216
+ 257,
217
+ 141,
218
+ 125,
219
+ 181,
220
+ 218,
221
+ 278,
222
+ 172,
223
+ 238,
224
+ 0,
225
+ 121,
226
+ 225,
227
+ 160
228
+ ],
229
+ "layer": 6,
230
+ "mean_selected_weight": 0.25,
231
+ "residual_scale": -0.08805593848228455,
232
+ "router_entropy": 2.75,
233
+ "token_gate_active_fraction": 0.0,
234
+ "token_gate_mean": 0.052001953125,
235
+ "valid_tokens": 701
236
+ },
237
+ {
238
+ "domain": "coding",
239
+ "expert_counts": [
240
+ 216,
241
+ 145,
242
+ 148,
243
+ 169,
244
+ 173,
245
+ 194,
246
+ 141,
247
+ 157,
248
+ 186,
249
+ 203,
250
+ 22,
251
+ 277,
252
+ 197,
253
+ 264,
254
+ 149,
255
+ 163
256
+ ],
257
+ "layer": 7,
258
+ "mean_selected_weight": 0.25,
259
+ "residual_scale": -0.06830453872680664,
260
+ "router_entropy": 2.75,
261
+ "token_gate_active_fraction": 0.0,
262
+ "token_gate_mean": 0.048095703125,
263
+ "valid_tokens": 701
264
+ },
265
+ {
266
+ "domain": "coding",
267
+ "expert_counts": [
268
+ 180,
269
+ 194,
270
+ 248,
271
+ 207,
272
+ 180,
273
+ 276,
274
+ 184,
275
+ 113,
276
+ 248,
277
+ 195,
278
+ 124,
279
+ 134,
280
+ 125,
281
+ 20,
282
+ 132,
283
+ 244
284
+ ],
285
+ "layer": 8,
286
+ "mean_selected_weight": 0.25,
287
+ "residual_scale": 0.09049388021230698,
288
+ "router_entropy": 2.75,
289
+ "token_gate_active_fraction": 0.0,
290
+ "token_gate_mean": 0.046875,
291
+ "valid_tokens": 701
292
+ },
293
+ {
294
+ "domain": "coding",
295
+ "expert_counts": [
296
+ 346,
297
+ 292,
298
+ 124,
299
+ 226,
300
+ 198,
301
+ 262,
302
+ 148,
303
+ 256,
304
+ 90,
305
+ 34,
306
+ 147,
307
+ 189,
308
+ 0,
309
+ 180,
310
+ 218,
311
+ 94
312
+ ],
313
+ "layer": 9,
314
+ "mean_selected_weight": 0.25,
315
+ "residual_scale": -0.09548121690750122,
316
+ "router_entropy": 2.71875,
317
+ "token_gate_active_fraction": 0.0,
318
+ "token_gate_mean": 0.060302734375,
319
+ "valid_tokens": 701
320
+ },
321
+ {
322
+ "domain": "coding",
323
+ "expert_counts": [
324
+ 238,
325
+ 178,
326
+ 190,
327
+ 61,
328
+ 218,
329
+ 152,
330
+ 158,
331
+ 143,
332
+ 253,
333
+ 190,
334
+ 0,
335
+ 191,
336
+ 235,
337
+ 154,
338
+ 406,
339
+ 37
340
+ ],
341
+ "layer": 10,
342
+ "mean_selected_weight": 0.25,
343
+ "residual_scale": -0.09226511418819427,
344
+ "router_entropy": 2.75,
345
+ "token_gate_active_fraction": 0.0,
346
+ "token_gate_mean": 0.047607421875,
347
+ "valid_tokens": 701
348
+ },
349
+ {
350
+ "domain": "coding",
351
+ "expert_counts": [
352
+ 218,
353
+ 158,
354
+ 16,
355
+ 167,
356
+ 229,
357
+ 176,
358
+ 0,
359
+ 93,
360
+ 157,
361
+ 186,
362
+ 182,
363
+ 203,
364
+ 262,
365
+ 210,
366
+ 338,
367
+ 209
368
+ ],
369
+ "layer": 11,
370
+ "mean_selected_weight": 0.25,
371
+ "residual_scale": -0.08412390202283859,
372
+ "router_entropy": 2.75,
373
+ "token_gate_active_fraction": 0.0,
374
+ "token_gate_mean": 0.044677734375,
375
+ "valid_tokens": 701
376
+ },
377
+ {
378
+ "domain": "coding",
379
+ "expert_counts": [
380
+ 238,
381
+ 195,
382
+ 242,
383
+ 203,
384
+ 303,
385
+ 217,
386
+ 73,
387
+ 0,
388
+ 36,
389
+ 193,
390
+ 144,
391
+ 95,
392
+ 222,
393
+ 341,
394
+ 147,
395
+ 155
396
+ ],
397
+ "layer": 12,
398
+ "mean_selected_weight": 0.25,
399
+ "residual_scale": 0.09192470461130142,
400
+ "router_entropy": 2.734375,
401
+ "token_gate_active_fraction": 0.0,
402
+ "token_gate_mean": 0.047607421875,
403
+ "valid_tokens": 701
404
+ },
405
+ {
406
+ "domain": "coding",
407
+ "expert_counts": [
408
+ 242,
409
+ 176,
410
+ 1,
411
+ 203,
412
+ 176,
413
+ 304,
414
+ 216,
415
+ 165,
416
+ 112,
417
+ 145,
418
+ 130,
419
+ 126,
420
+ 139,
421
+ 201,
422
+ 149,
423
+ 319
424
+ ],
425
+ "layer": 13,
426
+ "mean_selected_weight": 0.25,
427
+ "residual_scale": 0.0032708614598959684,
428
+ "router_entropy": 2.734375,
429
+ "token_gate_active_fraction": 0.0,
430
+ "token_gate_mean": 0.06396484375,
431
+ "valid_tokens": 701
432
+ },
433
+ {
434
+ "domain": "coding",
435
+ "expert_counts": [
436
+ 192,
437
+ 161,
438
+ 272,
439
+ 219,
440
+ 1,
441
+ 219,
442
+ 118,
443
+ 279,
444
+ 197,
445
+ 67,
446
+ 197,
447
+ 85,
448
+ 168,
449
+ 160,
450
+ 267,
451
+ 202
452
+ ],
453
+ "layer": 14,
454
+ "mean_selected_weight": 0.25,
455
+ "residual_scale": -0.08825033158063889,
456
+ "router_entropy": 2.75,
457
+ "token_gate_active_fraction": 0.0,
458
+ "token_gate_mean": 0.05908203125,
459
+ "valid_tokens": 701
460
+ },
461
+ {
462
+ "domain": "coding",
463
+ "expert_counts": [
464
+ 180,
465
+ 106,
466
+ 257,
467
+ 221,
468
+ 243,
469
+ 186,
470
+ 296,
471
+ 167,
472
+ 0,
473
+ 191,
474
+ 157,
475
+ 150,
476
+ 201,
477
+ 122,
478
+ 173,
479
+ 154
480
+ ],
481
+ "layer": 15,
482
+ "mean_selected_weight": 0.25,
483
+ "residual_scale": 0.08818262815475464,
484
+ "router_entropy": 2.734375,
485
+ "token_gate_active_fraction": 0.0,
486
+ "token_gate_mean": 0.059814453125,
487
+ "valid_tokens": 701
488
+ },
489
+ {
490
+ "domain": "coding",
491
+ "expert_counts": [
492
+ 133,
493
+ 188,
494
+ 234,
495
+ 223,
496
+ 141,
497
+ 174,
498
+ 152,
499
+ 165,
500
+ 162,
501
+ 159,
502
+ 119,
503
+ 166,
504
+ 186,
505
+ 216,
506
+ 208,
507
+ 178
508
+ ],
509
+ "layer": 16,
510
+ "mean_selected_weight": 0.25,
511
+ "residual_scale": -0.0897134467959404,
512
+ "router_entropy": 2.71875,
513
+ "token_gate_active_fraction": 0.0,
514
+ "token_gate_mean": 0.0693359375,
515
+ "valid_tokens": 701
516
+ },
517
+ {
518
+ "domain": "coding",
519
+ "expert_counts": [
520
+ 211,
521
+ 156,
522
+ 168,
523
+ 183,
524
+ 259,
525
+ 163,
526
+ 154,
527
+ 155,
528
+ 130,
529
+ 164,
530
+ 128,
531
+ 352,
532
+ 215,
533
+ 36,
534
+ 169,
535
+ 161
536
+ ],
537
+ "layer": 17,
538
+ "mean_selected_weight": 0.25,
539
+ "residual_scale": 0.0917714461684227,
540
+ "router_entropy": 2.734375,
541
+ "token_gate_active_fraction": 0.0,
542
+ "token_gate_mean": 0.16015625,
543
+ "valid_tokens": 701
544
+ },
545
+ {
546
+ "domain": "coding",
547
+ "expert_counts": [
548
+ 163,
549
+ 141,
550
+ 173,
551
+ 157,
552
+ 170,
553
+ 142,
554
+ 247,
555
+ 199,
556
+ 144,
557
+ 127,
558
+ 218,
559
+ 147,
560
+ 199,
561
+ 210,
562
+ 114,
563
+ 253
564
+ ],
565
+ "layer": 18,
566
+ "mean_selected_weight": 0.25,
567
+ "residual_scale": 0.09746404737234116,
568
+ "router_entropy": 2.71875,
569
+ "token_gate_active_fraction": 0.0057061342522501945,
570
+ "token_gate_mean": 0.1787109375,
571
+ "valid_tokens": 701
572
+ },
573
+ {
574
+ "domain": "coding",
575
+ "expert_counts": [
576
+ 140,
577
+ 242,
578
+ 192,
579
+ 123,
580
+ 218,
581
+ 101,
582
+ 138,
583
+ 230,
584
+ 179,
585
+ 265,
586
+ 265,
587
+ 137,
588
+ 81,
589
+ 205,
590
+ 148,
591
+ 140
592
+ ],
593
+ "layer": 19,
594
+ "mean_selected_weight": 0.25,
595
+ "residual_scale": -0.09797238558530807,
596
+ "router_entropy": 2.734375,
597
+ "token_gate_active_fraction": 0.03423680365085602,
598
+ "token_gate_mean": 0.2021484375,
599
+ "valid_tokens": 701
600
+ },
601
+ {
602
+ "domain": "coding",
603
+ "expert_counts": [
604
+ 103,
605
+ 123,
606
+ 141,
607
+ 152,
608
+ 173,
609
+ 135,
610
+ 244,
611
+ 171,
612
+ 176,
613
+ 146,
614
+ 216,
615
+ 249,
616
+ 129,
617
+ 321,
618
+ 177,
619
+ 148
620
+ ],
621
+ "layer": 20,
622
+ "mean_selected_weight": 0.25,
623
+ "residual_scale": 0.09263704717159271,
624
+ "router_entropy": 2.734375,
625
+ "token_gate_active_fraction": 0.08131241053342819,
626
+ "token_gate_mean": 0.234375,
627
+ "valid_tokens": 701
628
+ },
629
+ {
630
+ "domain": "coding",
631
+ "expert_counts": [
632
+ 124,
633
+ 268,
634
+ 158,
635
+ 85,
636
+ 192,
637
+ 181,
638
+ 220,
639
+ 101,
640
+ 156,
641
+ 254,
642
+ 191,
643
+ 171,
644
+ 92,
645
+ 148,
646
+ 152,
647
+ 311
648
+ ],
649
+ "layer": 21,
650
+ "mean_selected_weight": 0.25,
651
+ "residual_scale": 0.09646926075220108,
652
+ "router_entropy": 2.734375,
653
+ "token_gate_active_fraction": 0.28388017416000366,
654
+ "token_gate_mean": 0.396484375,
655
+ "valid_tokens": 701
656
+ },
657
+ {
658
+ "domain": "coding",
659
+ "expert_counts": [
660
+ 175,
661
+ 179,
662
+ 222,
663
+ 147,
664
+ 304,
665
+ 237,
666
+ 182,
667
+ 156,
668
+ 212,
669
+ 214,
670
+ 180,
671
+ 72,
672
+ 144,
673
+ 137,
674
+ 63,
675
+ 180
676
+ ],
677
+ "layer": 22,
678
+ "mean_selected_weight": 0.25,
679
+ "residual_scale": 0.09666198492050171,
680
+ "router_entropy": 2.734375,
681
+ "token_gate_active_fraction": 0.38944366574287415,
682
+ "token_gate_mean": 0.439453125,
683
+ "valid_tokens": 701
684
+ },
685
+ {
686
+ "domain": "coding",
687
+ "expert_counts": [
688
+ 228,
689
+ 196,
690
+ 196,
691
+ 128,
692
+ 168,
693
+ 106,
694
+ 146,
695
+ 271,
696
+ 140,
697
+ 220,
698
+ 153,
699
+ 135,
700
+ 208,
701
+ 99,
702
+ 193,
703
+ 217
704
+ ],
705
+ "layer": 23,
706
+ "mean_selected_weight": 0.25,
707
+ "residual_scale": -0.08689017593860626,
708
+ "router_entropy": 2.703125,
709
+ "token_gate_active_fraction": 0.5049929022789001,
710
+ "token_gate_mean": 0.4921875,
711
+ "valid_tokens": 701
712
+ },
713
+ {
714
+ "domain": "coding",
715
+ "expert_counts": [
716
+ 233,
717
+ 183,
718
+ 123,
719
+ 161,
720
+ 133,
721
+ 251,
722
+ 236,
723
+ 81,
724
+ 290,
725
+ 120,
726
+ 213,
727
+ 134,
728
+ 212,
729
+ 155,
730
+ 125,
731
+ 154
732
+ ],
733
+ "layer": 24,
734
+ "mean_selected_weight": 0.25,
735
+ "residual_scale": 0.09673594683408737,
736
+ "router_entropy": 2.71875,
737
+ "token_gate_active_fraction": 0.48074179887771606,
738
+ "token_gate_mean": 0.474609375,
739
+ "valid_tokens": 701
740
+ },
741
+ {
742
+ "domain": "coding",
743
+ "expert_counts": [
744
+ 284,
745
+ 185,
746
+ 166,
747
+ 123,
748
+ 115,
749
+ 166,
750
+ 175,
751
+ 136,
752
+ 297,
753
+ 140,
754
+ 278,
755
+ 217,
756
+ 90,
757
+ 200,
758
+ 140,
759
+ 92
760
+ ],
761
+ "layer": 25,
762
+ "mean_selected_weight": 0.25,
763
+ "residual_scale": 0.09465997666120529,
764
+ "router_entropy": 2.703125,
765
+ "token_gate_active_fraction": 0.48644793033599854,
766
+ "token_gate_mean": 0.462890625,
767
+ "valid_tokens": 701
768
+ },
769
+ {
770
+ "domain": "coding",
771
+ "expert_counts": [
772
+ 294,
773
+ 195,
774
+ 80,
775
+ 127,
776
+ 89,
777
+ 170,
778
+ 172,
779
+ 139,
780
+ 243,
781
+ 279,
782
+ 145,
783
+ 241,
784
+ 169,
785
+ 106,
786
+ 176,
787
+ 179
788
+ ],
789
+ "layer": 26,
790
+ "mean_selected_weight": 0.25,
791
+ "residual_scale": 0.09768165647983551,
792
+ "router_entropy": 2.671875,
793
+ "token_gate_active_fraction": 0.47931528091430664,
794
+ "token_gate_mean": 0.4609375,
795
+ "valid_tokens": 701
796
+ },
797
+ {
798
+ "domain": "coding",
799
+ "expert_counts": [
800
+ 118,
801
+ 116,
802
+ 190,
803
+ 217,
804
+ 242,
805
+ 166,
806
+ 184,
807
+ 168,
808
+ 100,
809
+ 208,
810
+ 184,
811
+ 213,
812
+ 138,
813
+ 219,
814
+ 143,
815
+ 198
816
+ ],
817
+ "layer": 27,
818
+ "mean_selected_weight": 0.25,
819
+ "residual_scale": -0.0952037125825882,
820
+ "router_entropy": 2.734375,
821
+ "token_gate_active_fraction": 0.5606276988983154,
822
+ "token_gate_mean": 0.53515625,
823
+ "valid_tokens": 701
824
+ },
825
+ {
826
+ "domain": "coding",
827
+ "expert_counts": [
828
+ 147,
829
+ 258,
830
+ 176,
831
+ 108,
832
+ 151,
833
+ 184,
834
+ 228,
835
+ 93,
836
+ 95,
837
+ 101,
838
+ 217,
839
+ 183,
840
+ 146,
841
+ 307,
842
+ 157,
843
+ 253
844
+ ],
845
+ "layer": 28,
846
+ "mean_selected_weight": 0.25,
847
+ "residual_scale": -0.09579590708017349,
848
+ "router_entropy": 2.703125,
849
+ "token_gate_active_fraction": 0.8388017416000366,
850
+ "token_gate_mean": 0.73828125,
851
+ "valid_tokens": 701
852
+ },
853
+ {
854
+ "domain": "coding",
855
+ "expert_counts": [
856
+ 208,
857
+ 134,
858
+ 183,
859
+ 56,
860
+ 379,
861
+ 296,
862
+ 181,
863
+ 169,
864
+ 212,
865
+ 73,
866
+ 255,
867
+ 172,
868
+ 80,
869
+ 75,
870
+ 199,
871
+ 132
872
+ ],
873
+ "layer": 29,
874
+ "mean_selected_weight": 0.25,
875
+ "residual_scale": 0.09640846401453018,
876
+ "router_entropy": 2.625,
877
+ "token_gate_active_fraction": 0.9358060359954834,
878
+ "token_gate_mean": 0.796875,
879
+ "valid_tokens": 701
880
+ },
881
+ {
882
+ "domain": "generic",
883
+ "expert_counts": [
884
+ 52,
885
+ 76,
886
+ 54,
887
+ 68,
888
+ 59,
889
+ 76,
890
+ 76,
891
+ 59,
892
+ 40,
893
+ 51,
894
+ 65,
895
+ 49,
896
+ 74,
897
+ 56,
898
+ 49,
899
+ 60
900
+ ],
901
+ "layer": 0,
902
+ "mean_selected_weight": 0.25,
903
+ "residual_scale": 7.45758370612748e-05,
904
+ "router_entropy": 2.703125,
905
+ "token_gate_active_fraction": 0.0,
906
+ "token_gate_mean": 0.034912109375,
907
+ "valid_tokens": 241
908
+ },
909
+ {
910
+ "domain": "generic",
911
+ "expert_counts": [
912
+ 46,
913
+ 48,
914
+ 71,
915
+ 59,
916
+ 57,
917
+ 65,
918
+ 64,
919
+ 86,
920
+ 51,
921
+ 48,
922
+ 71,
923
+ 79,
924
+ 66,
925
+ 74,
926
+ 65,
927
+ 14
928
+ ],
929
+ "layer": 1,
930
+ "mean_selected_weight": 0.25,
931
+ "residual_scale": -0.07198415696620941,
932
+ "router_entropy": 2.75,
933
+ "token_gate_active_fraction": 0.0,
934
+ "token_gate_mean": 0.0242919921875,
935
+ "valid_tokens": 241
936
+ },
937
+ {
938
+ "domain": "generic",
939
+ "expert_counts": [
940
+ 70,
941
+ 61,
942
+ 53,
943
+ 52,
944
+ 52,
945
+ 60,
946
+ 68,
947
+ 107,
948
+ 75,
949
+ 15,
950
+ 57,
951
+ 65,
952
+ 55,
953
+ 57,
954
+ 56,
955
+ 61
956
+ ],
957
+ "layer": 2,
958
+ "mean_selected_weight": 0.25,
959
+ "residual_scale": 0.0014509361935779452,
960
+ "router_entropy": 2.734375,
961
+ "token_gate_active_fraction": 0.0,
962
+ "token_gate_mean": 0.0260009765625,
963
+ "valid_tokens": 241
964
+ },
965
+ {
966
+ "domain": "generic",
967
+ "expert_counts": [
968
+ 60,
969
+ 94,
970
+ 63,
971
+ 90,
972
+ 41,
973
+ 56,
974
+ 65,
975
+ 59,
976
+ 59,
977
+ 52,
978
+ 0,
979
+ 56,
980
+ 65,
981
+ 58,
982
+ 63,
983
+ 83
984
+ ],
985
+ "layer": 3,
986
+ "mean_selected_weight": 0.25,
987
+ "residual_scale": -0.0868370309472084,
988
+ "router_entropy": 2.734375,
989
+ "token_gate_active_fraction": 0.0,
990
+ "token_gate_mean": 0.0224609375,
991
+ "valid_tokens": 241
992
+ },
993
+ {
994
+ "domain": "generic",
995
+ "expert_counts": [
996
+ 63,
997
+ 67,
998
+ 60,
999
+ 67,
1000
+ 59,
1001
+ 65,
1002
+ 66,
1003
+ 0,
1004
+ 62,
1005
+ 76,
1006
+ 56,
1007
+ 51,
1008
+ 63,
1009
+ 58,
1010
+ 76,
1011
+ 75
1012
+ ],
1013
+ "layer": 4,
1014
+ "mean_selected_weight": 0.25,
1015
+ "residual_scale": -0.08832801133394241,
1016
+ "router_entropy": 2.75,
1017
+ "token_gate_active_fraction": 0.0,
1018
+ "token_gate_mean": 0.022216796875,
1019
+ "valid_tokens": 241
1020
+ },
1021
+ {
1022
+ "domain": "generic",
1023
+ "expert_counts": [
1024
+ 58,
1025
+ 62,
1026
+ 64,
1027
+ 58,
1028
+ 62,
1029
+ 75,
1030
+ 66,
1031
+ 50,
1032
+ 61,
1033
+ 55,
1034
+ 60,
1035
+ 114,
1036
+ 0,
1037
+ 61,
1038
+ 62,
1039
+ 56
1040
+ ],
1041
+ "layer": 5,
1042
+ "mean_selected_weight": 0.25,
1043
+ "residual_scale": 0.014818619005382061,
1044
+ "router_entropy": 2.75,
1045
+ "token_gate_active_fraction": 0.0,
1046
+ "token_gate_mean": 0.0230712890625,
1047
+ "valid_tokens": 241
1048
+ },
1049
+ {
1050
+ "domain": "generic",
1051
+ "expert_counts": [
1052
+ 51,
1053
+ 66,
1054
+ 72,
1055
+ 55,
1056
+ 81,
1057
+ 53,
1058
+ 67,
1059
+ 59,
1060
+ 67,
1061
+ 71,
1062
+ 53,
1063
+ 99,
1064
+ 0,
1065
+ 59,
1066
+ 52,
1067
+ 59
1068
+ ],
1069
+ "layer": 6,
1070
+ "mean_selected_weight": 0.25,
1071
+ "residual_scale": -0.08805593848228455,
1072
+ "router_entropy": 2.75,
1073
+ "token_gate_active_fraction": 0.0,
1074
+ "token_gate_mean": 0.0238037109375,
1075
+ "valid_tokens": 241
1076
+ },
1077
+ {
1078
+ "domain": "generic",
1079
+ "expert_counts": [
1080
+ 61,
1081
+ 53,
1082
+ 67,
1083
+ 56,
1084
+ 63,
1085
+ 56,
1086
+ 44,
1087
+ 95,
1088
+ 64,
1089
+ 57,
1090
+ 22,
1091
+ 101,
1092
+ 60,
1093
+ 59,
1094
+ 47,
1095
+ 59
1096
+ ],
1097
+ "layer": 7,
1098
+ "mean_selected_weight": 0.25,
1099
+ "residual_scale": -0.06830453872680664,
1100
+ "router_entropy": 2.75,
1101
+ "token_gate_active_fraction": 0.0,
1102
+ "token_gate_mean": 0.0230712890625,
1103
+ "valid_tokens": 241
1104
+ },
1105
+ {
1106
+ "domain": "generic",
1107
+ "expert_counts": [
1108
+ 59,
1109
+ 69,
1110
+ 126,
1111
+ 62,
1112
+ 58,
1113
+ 60,
1114
+ 54,
1115
+ 51,
1116
+ 65,
1117
+ 76,
1118
+ 46,
1119
+ 58,
1120
+ 59,
1121
+ 9,
1122
+ 55,
1123
+ 57
1124
+ ],
1125
+ "layer": 8,
1126
+ "mean_selected_weight": 0.25,
1127
+ "residual_scale": 0.09049388021230698,
1128
+ "router_entropy": 2.75,
1129
+ "token_gate_active_fraction": 0.0,
1130
+ "token_gate_mean": 0.0233154296875,
1131
+ "valid_tokens": 241
1132
+ },
1133
+ {
1134
+ "domain": "generic",
1135
+ "expert_counts": [
1136
+ 69,
1137
+ 66,
1138
+ 66,
1139
+ 72,
1140
+ 56,
1141
+ 75,
1142
+ 73,
1143
+ 63,
1144
+ 66,
1145
+ 6,
1146
+ 77,
1147
+ 67,
1148
+ 1,
1149
+ 67,
1150
+ 77,
1151
+ 63
1152
+ ],
1153
+ "layer": 9,
1154
+ "mean_selected_weight": 0.25,
1155
+ "residual_scale": -0.09548121690750122,
1156
+ "router_entropy": 2.71875,
1157
+ "token_gate_active_fraction": 0.0,
1158
+ "token_gate_mean": 0.024658203125,
1159
+ "valid_tokens": 241
1160
+ },
1161
+ {
1162
+ "domain": "generic",
1163
+ "expert_counts": [
1164
+ 60,
1165
+ 72,
1166
+ 63,
1167
+ 38,
1168
+ 60,
1169
+ 61,
1170
+ 57,
1171
+ 105,
1172
+ 65,
1173
+ 56,
1174
+ 0,
1175
+ 66,
1176
+ 66,
1177
+ 65,
1178
+ 88,
1179
+ 42
1180
+ ],
1181
+ "layer": 10,
1182
+ "mean_selected_weight": 0.25,
1183
+ "residual_scale": -0.09226511418819427,
1184
+ "router_entropy": 2.734375,
1185
+ "token_gate_active_fraction": 0.0,
1186
+ "token_gate_mean": 0.02197265625,
1187
+ "valid_tokens": 241
1188
+ },
1189
+ {
1190
+ "domain": "generic",
1191
+ "expert_counts": [
1192
+ 73,
1193
+ 65,
1194
+ 51,
1195
+ 49,
1196
+ 68,
1197
+ 68,
1198
+ 0,
1199
+ 22,
1200
+ 50,
1201
+ 110,
1202
+ 64,
1203
+ 75,
1204
+ 61,
1205
+ 68,
1206
+ 74,
1207
+ 66
1208
+ ],
1209
+ "layer": 11,
1210
+ "mean_selected_weight": 0.25,
1211
+ "residual_scale": -0.08412390202283859,
1212
+ "router_entropy": 2.734375,
1213
+ "token_gate_active_fraction": 0.0,
1214
+ "token_gate_mean": 0.0213623046875,
1215
+ "valid_tokens": 241
1216
+ },
1217
+ {
1218
+ "domain": "generic",
1219
+ "expert_counts": [
1220
+ 63,
1221
+ 55,
1222
+ 75,
1223
+ 67,
1224
+ 66,
1225
+ 73,
1226
+ 21,
1227
+ 0,
1228
+ 49,
1229
+ 61,
1230
+ 63,
1231
+ 86,
1232
+ 69,
1233
+ 86,
1234
+ 65,
1235
+ 65
1236
+ ],
1237
+ "layer": 12,
1238
+ "mean_selected_weight": 0.25,
1239
+ "residual_scale": 0.09192470461130142,
1240
+ "router_entropy": 2.734375,
1241
+ "token_gate_active_fraction": 0.0,
1242
+ "token_gate_mean": 0.023681640625,
1243
+ "valid_tokens": 241
1244
+ },
1245
+ {
1246
+ "domain": "generic",
1247
+ "expert_counts": [
1248
+ 76,
1249
+ 34,
1250
+ 5,
1251
+ 44,
1252
+ 58,
1253
+ 103,
1254
+ 64,
1255
+ 59,
1256
+ 47,
1257
+ 50,
1258
+ 56,
1259
+ 91,
1260
+ 64,
1261
+ 77,
1262
+ 71,
1263
+ 65
1264
+ ],
1265
+ "layer": 13,
1266
+ "mean_selected_weight": 0.25,
1267
+ "residual_scale": 0.0032708614598959684,
1268
+ "router_entropy": 2.71875,
1269
+ "token_gate_active_fraction": 0.0,
1270
+ "token_gate_mean": 0.0242919921875,
1271
+ "valid_tokens": 241
1272
+ },
1273
+ {
1274
+ "domain": "generic",
1275
+ "expert_counts": [
1276
+ 77,
1277
+ 50,
1278
+ 61,
1279
+ 71,
1280
+ 31,
1281
+ 42,
1282
+ 62,
1283
+ 57,
1284
+ 62,
1285
+ 54,
1286
+ 58,
1287
+ 59,
1288
+ 69,
1289
+ 67,
1290
+ 76,
1291
+ 68
1292
+ ],
1293
+ "layer": 14,
1294
+ "mean_selected_weight": 0.25,
1295
+ "residual_scale": -0.08825033158063889,
1296
+ "router_entropy": 2.75,
1297
+ "token_gate_active_fraction": 0.0,
1298
+ "token_gate_mean": 0.022705078125,
1299
+ "valid_tokens": 241
1300
+ },
1301
+ {
1302
+ "domain": "generic",
1303
+ "expert_counts": [
1304
+ 61,
1305
+ 65,
1306
+ 93,
1307
+ 58,
1308
+ 58,
1309
+ 67,
1310
+ 65,
1311
+ 60,
1312
+ 0,
1313
+ 63,
1314
+ 38,
1315
+ 59,
1316
+ 60,
1317
+ 65,
1318
+ 60,
1319
+ 92
1320
+ ],
1321
+ "layer": 15,
1322
+ "mean_selected_weight": 0.25,
1323
+ "residual_scale": 0.08818262815475464,
1324
+ "router_entropy": 2.734375,
1325
+ "token_gate_active_fraction": 0.0,
1326
+ "token_gate_mean": 0.0240478515625,
1327
+ "valid_tokens": 241
1328
+ },
1329
+ {
1330
+ "domain": "generic",
1331
+ "expert_counts": [
1332
+ 57,
1333
+ 94,
1334
+ 66,
1335
+ 48,
1336
+ 51,
1337
+ 65,
1338
+ 47,
1339
+ 66,
1340
+ 47,
1341
+ 103,
1342
+ 54,
1343
+ 50,
1344
+ 51,
1345
+ 59,
1346
+ 57,
1347
+ 49
1348
+ ],
1349
+ "layer": 16,
1350
+ "mean_selected_weight": 0.25,
1351
+ "residual_scale": -0.0897134467959404,
1352
+ "router_entropy": 2.71875,
1353
+ "token_gate_active_fraction": 0.0,
1354
+ "token_gate_mean": 0.0264892578125,
1355
+ "valid_tokens": 241
1356
+ },
1357
+ {
1358
+ "domain": "generic",
1359
+ "expert_counts": [
1360
+ 58,
1361
+ 74,
1362
+ 41,
1363
+ 64,
1364
+ 60,
1365
+ 64,
1366
+ 49,
1367
+ 65,
1368
+ 48,
1369
+ 60,
1370
+ 78,
1371
+ 65,
1372
+ 65,
1373
+ 31,
1374
+ 72,
1375
+ 70
1376
+ ],
1377
+ "layer": 17,
1378
+ "mean_selected_weight": 0.25,
1379
+ "residual_scale": 0.0917714461684227,
1380
+ "router_entropy": 2.71875,
1381
+ "token_gate_active_fraction": 0.0,
1382
+ "token_gate_mean": 0.0380859375,
1383
+ "valid_tokens": 241
1384
+ },
1385
+ {
1386
+ "domain": "generic",
1387
+ "expert_counts": [
1388
+ 65,
1389
+ 51,
1390
+ 76,
1391
+ 77,
1392
+ 61,
1393
+ 48,
1394
+ 59,
1395
+ 61,
1396
+ 46,
1397
+ 47,
1398
+ 55,
1399
+ 120,
1400
+ 60,
1401
+ 34,
1402
+ 55,
1403
+ 49
1404
+ ],
1405
+ "layer": 18,
1406
+ "mean_selected_weight": 0.25,
1407
+ "residual_scale": 0.09746404737234116,
1408
+ "router_entropy": 2.703125,
1409
+ "token_gate_active_fraction": 0.0,
1410
+ "token_gate_mean": 0.035888671875,
1411
+ "valid_tokens": 241
1412
+ },
1413
+ {
1414
+ "domain": "generic",
1415
+ "expert_counts": [
1416
+ 49,
1417
+ 58,
1418
+ 64,
1419
+ 38,
1420
+ 61,
1421
+ 67,
1422
+ 79,
1423
+ 65,
1424
+ 71,
1425
+ 52,
1426
+ 56,
1427
+ 51,
1428
+ 53,
1429
+ 85,
1430
+ 81,
1431
+ 34
1432
+ ],
1433
+ "layer": 19,
1434
+ "mean_selected_weight": 0.25,
1435
+ "residual_scale": -0.09797238558530807,
1436
+ "router_entropy": 2.734375,
1437
+ "token_gate_active_fraction": 0.0,
1438
+ "token_gate_mean": 0.03857421875,
1439
+ "valid_tokens": 241
1440
+ },
1441
+ {
1442
+ "domain": "generic",
1443
+ "expert_counts": [
1444
+ 61,
1445
+ 87,
1446
+ 68,
1447
+ 63,
1448
+ 56,
1449
+ 61,
1450
+ 61,
1451
+ 59,
1452
+ 58,
1453
+ 61,
1454
+ 33,
1455
+ 75,
1456
+ 51,
1457
+ 67,
1458
+ 44,
1459
+ 59
1460
+ ],
1461
+ "layer": 20,
1462
+ "mean_selected_weight": 0.25,
1463
+ "residual_scale": 0.09263704717159271,
1464
+ "router_entropy": 2.71875,
1465
+ "token_gate_active_fraction": 0.0,
1466
+ "token_gate_mean": 0.043212890625,
1467
+ "valid_tokens": 241
1468
+ },
1469
+ {
1470
+ "domain": "generic",
1471
+ "expert_counts": [
1472
+ 43,
1473
+ 92,
1474
+ 66,
1475
+ 61,
1476
+ 53,
1477
+ 49,
1478
+ 62,
1479
+ 61,
1480
+ 53,
1481
+ 69,
1482
+ 73,
1483
+ 56,
1484
+ 38,
1485
+ 61,
1486
+ 51,
1487
+ 76
1488
+ ],
1489
+ "layer": 21,
1490
+ "mean_selected_weight": 0.25,
1491
+ "residual_scale": 0.09646926075220108,
1492
+ "router_entropy": 2.734375,
1493
+ "token_gate_active_fraction": 0.0,
1494
+ "token_gate_mean": 0.04833984375,
1495
+ "valid_tokens": 241
1496
+ },
1497
+ {
1498
+ "domain": "generic",
1499
+ "expert_counts": [
1500
+ 64,
1501
+ 59,
1502
+ 72,
1503
+ 63,
1504
+ 55,
1505
+ 60,
1506
+ 61,
1507
+ 55,
1508
+ 74,
1509
+ 61,
1510
+ 56,
1511
+ 25,
1512
+ 62,
1513
+ 86,
1514
+ 41,
1515
+ 70
1516
+ ],
1517
+ "layer": 22,
1518
+ "mean_selected_weight": 0.25,
1519
+ "residual_scale": 0.09666198492050171,
1520
+ "router_entropy": 2.734375,
1521
+ "token_gate_active_fraction": 0.0,
1522
+ "token_gate_mean": 0.047607421875,
1523
+ "valid_tokens": 241
1524
+ },
1525
+ {
1526
+ "domain": "generic",
1527
+ "expert_counts": [
1528
+ 64,
1529
+ 64,
1530
+ 54,
1531
+ 68,
1532
+ 48,
1533
+ 62,
1534
+ 65,
1535
+ 57,
1536
+ 63,
1537
+ 70,
1538
+ 70,
1539
+ 41,
1540
+ 62,
1541
+ 68,
1542
+ 50,
1543
+ 58
1544
+ ],
1545
+ "layer": 23,
1546
+ "mean_selected_weight": 0.25,
1547
+ "residual_scale": -0.08689017593860626,
1548
+ "router_entropy": 2.703125,
1549
+ "token_gate_active_fraction": 0.0,
1550
+ "token_gate_mean": 0.04833984375,
1551
+ "valid_tokens": 241
1552
+ },
1553
+ {
1554
+ "domain": "generic",
1555
+ "expert_counts": [
1556
+ 53,
1557
+ 67,
1558
+ 62,
1559
+ 65,
1560
+ 58,
1561
+ 57,
1562
+ 59,
1563
+ 66,
1564
+ 61,
1565
+ 52,
1566
+ 55,
1567
+ 62,
1568
+ 57,
1569
+ 59,
1570
+ 76,
1571
+ 55
1572
+ ],
1573
+ "layer": 24,
1574
+ "mean_selected_weight": 0.25,
1575
+ "residual_scale": 0.09673594683408737,
1576
+ "router_entropy": 2.734375,
1577
+ "token_gate_active_fraction": 0.0,
1578
+ "token_gate_mean": 0.0322265625,
1579
+ "valid_tokens": 241
1580
+ },
1581
+ {
1582
+ "domain": "generic",
1583
+ "expert_counts": [
1584
+ 56,
1585
+ 54,
1586
+ 63,
1587
+ 57,
1588
+ 63,
1589
+ 58,
1590
+ 43,
1591
+ 78,
1592
+ 54,
1593
+ 63,
1594
+ 61,
1595
+ 56,
1596
+ 58,
1597
+ 75,
1598
+ 53,
1599
+ 72
1600
+ ],
1601
+ "layer": 25,
1602
+ "mean_selected_weight": 0.25,
1603
+ "residual_scale": 0.09465997666120529,
1604
+ "router_entropy": 2.71875,
1605
+ "token_gate_active_fraction": 0.0,
1606
+ "token_gate_mean": 0.031494140625,
1607
+ "valid_tokens": 241
1608
+ },
1609
+ {
1610
+ "domain": "generic",
1611
+ "expert_counts": [
1612
+ 69,
1613
+ 58,
1614
+ 63,
1615
+ 70,
1616
+ 61,
1617
+ 51,
1618
+ 60,
1619
+ 61,
1620
+ 62,
1621
+ 49,
1622
+ 73,
1623
+ 59,
1624
+ 57,
1625
+ 56,
1626
+ 52,
1627
+ 63
1628
+ ],
1629
+ "layer": 26,
1630
+ "mean_selected_weight": 0.25,
1631
+ "residual_scale": 0.09768165647983551,
1632
+ "router_entropy": 2.671875,
1633
+ "token_gate_active_fraction": 0.0,
1634
+ "token_gate_mean": 0.03125,
1635
+ "valid_tokens": 241
1636
+ },
1637
+ {
1638
+ "domain": "generic",
1639
+ "expert_counts": [
1640
+ 56,
1641
+ 60,
1642
+ 51,
1643
+ 71,
1644
+ 72,
1645
+ 75,
1646
+ 59,
1647
+ 46,
1648
+ 43,
1649
+ 65,
1650
+ 60,
1651
+ 70,
1652
+ 75,
1653
+ 50,
1654
+ 43,
1655
+ 68
1656
+ ],
1657
+ "layer": 27,
1658
+ "mean_selected_weight": 0.25,
1659
+ "residual_scale": -0.0952037125825882,
1660
+ "router_entropy": 2.734375,
1661
+ "token_gate_active_fraction": 0.0,
1662
+ "token_gate_mean": 0.05029296875,
1663
+ "valid_tokens": 241
1664
+ },
1665
+ {
1666
+ "domain": "generic",
1667
+ "expert_counts": [
1668
+ 49,
1669
+ 76,
1670
+ 43,
1671
+ 71,
1672
+ 76,
1673
+ 78,
1674
+ 56,
1675
+ 63,
1676
+ 58,
1677
+ 51,
1678
+ 55,
1679
+ 61,
1680
+ 75,
1681
+ 52,
1682
+ 39,
1683
+ 61
1684
+ ],
1685
+ "layer": 28,
1686
+ "mean_selected_weight": 0.25,
1687
+ "residual_scale": -0.09579590708017349,
1688
+ "router_entropy": 2.6875,
1689
+ "token_gate_active_fraction": 0.012448133900761604,
1690
+ "token_gate_mean": 0.10693359375,
1691
+ "valid_tokens": 241
1692
+ },
1693
+ {
1694
+ "domain": "generic",
1695
+ "expert_counts": [
1696
+ 83,
1697
+ 35,
1698
+ 60,
1699
+ 52,
1700
+ 76,
1701
+ 74,
1702
+ 83,
1703
+ 57,
1704
+ 73,
1705
+ 54,
1706
+ 44,
1707
+ 63,
1708
+ 73,
1709
+ 49,
1710
+ 39,
1711
+ 49
1712
+ ],
1713
+ "layer": 29,
1714
+ "mean_selected_weight": 0.25,
1715
+ "residual_scale": 0.09640846401453018,
1716
+ "router_entropy": 2.640625,
1717
+ "token_gate_active_fraction": 0.0456431545317173,
1718
+ "token_gate_mean": 0.1435546875,
1719
+ "valid_tokens": 241
1720
+ }
1721
+ ],
1722
+ "timestamp": "2026-08-27T13:02:49Z"
1723
+ },
1724
+ "global_step": 60,
1725
+ "run_fingerprint": "68f9fa90e18e180f7037dea5e057aa296c95b59267aa09f38285363b5e517c2a",
1726
+ "validation": {
1727
+ "ce_improvement": 0.0043891161448869065,
1728
+ "finite": true,
1729
+ "fused_ce": 0.6014361901441425,
1730
+ "host_expert_off_ce": 0.6058253062890294,
1731
+ "mean_absolute_residual_scale": 0.07969798704336123,
1732
+ "mean_residual_scale": -0.002938792503376438,
1733
+ "mean_token_gate": 0.19380086263020832,
1734
+ "records": 4,
1735
+ "supervised_tokens": 1417
1736
+ }
1737
+ }
provenance/validation-metrics.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "ce_improvement": 0.0043891161448869065,
3
+ "finite": true,
4
+ "fused_ce": 0.6014361901441425,
5
+ "host_expert_off_ce": 0.6058253062890294,
6
+ "mean_absolute_residual_scale": 0.07969798704336123,
7
+ "mean_residual_scale": -0.002938792503376438,
8
+ "mean_token_gate": 0.19380086263020832,
9
+ "records": 4,
10
+ "supervised_tokens": 1417
11
+ }
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ torch>=2.12.0,<2.13
2
+ transformers>=5.16.1,<5.17
3
+ accelerate>=1.13.0
4
+ safetensors>=0.8.0
5
+ torchao==0.15.0
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:695be7802a0e4b8a81048f0ff5ebb7fc811a0ba5a6be63dbb24deb5a81096f41
3
+ size 17905598
tokenizer_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<|startoftext|>",
4
+ "clean_up_tokenization_spaces": false,
5
+ "eos_token": "<|im_end|>",
6
+ "legacy": false,
7
+ "model_max_length": 1000000000000000019884624838656,
8
+ "pad_token": "<|pad|>",
9
+ "tokenizer_class": "TokenizersBackend",
10
+ "use_default_system_prompt": false
11
+ }