Text Generation
Transformers
Safetensors
Russian
English
berrylm
Mixture of Experts
hybrid
linear-attention
thinking
russian
conversational
custom_code
Run this model with HF Jobs
Run rwb-ai/BerryLM-OS on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/rwb-ai/BerryLM-OS. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/rwb-ai/BerryLM-OS on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/rwb-ai/BerryLM-OS. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/rwb-ai/BerryLM-OS. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use rwb-ai/BerryLM-OS with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rwb-ai/BerryLM-OS with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rwb-ai/BerryLM-OS", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("rwb-ai/BerryLM-OS", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use rwb-ai/BerryLM-OS with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rwb-ai/BerryLM-OS" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rwb-ai/BerryLM-OS", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/rwb-ai/BerryLM-OS
- SGLang
How to use rwb-ai/BerryLM-OS with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "rwb-ai/BerryLM-OS" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rwb-ai/BerryLM-OS", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "rwb-ai/BerryLM-OS" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rwb-ai/BerryLM-OS", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use rwb-ai/BerryLM-OS with Docker Model Runner:
docker model run hf.co/rwb-ai/BerryLM-OS
Commit ·
8fc608b
0
Parent(s):
BerryLM-OS
Browse filesCo-authored-by: yuliya ivanova <yuliya ivanova@users.noreply.huggingface.co>
Co-authored-by: mysterious-pie <mysterious-pie@users.noreply.huggingface.co>
Files changed (22)
- .gitattributesAdded+40
- LICENSEAdded+202
- README.mdAdded+207
- assets/architecture.pngAdded
- assets/pareto-average.pngAdded
- assets/pareto-russian.pngAdded
- chat_template.jinjaAdded+147
- config.jsonAdded+94
- configuration_berrylm.pyAdded+159
- generation_config.jsonAdded+11
- model-00001-of-00008.safetensorsAdded+3
- model-00002-of-00008.safetensorsAdded+3
- model-00003-of-00008.safetensorsAdded+3
- model-00004-of-00008.safetensorsAdded+3
- model-00005-of-00008.safetensorsAdded+3
- model-00006-of-00008.safetensorsAdded+3
- model-00007-of-00008.safetensorsAdded+3
- model-00008-of-00008.safetensorsAdded+3
- model.safetensors.index.jsonAdded+811
- modeling_berrylm.pyAdded+1149
- tokenizer.jsonAdded+3
- tokenizer_config.jsonAdded+14
12345678910111213141516171819202122232425262728293031323334353637383940*.7z filter=lfs diff=lfs merge=lfs -text*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ckpt filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.mlmodel filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.npy filter=lfs diff=lfs merge=lfs -text*.npz filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pickle filter=lfs diff=lfs merge=lfs -text*.pkl filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -text*.safetensors filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tar filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -texttokenizer.json filter=lfs diff=lfs merge=lfs -textassets/architecture.png filter=lfs diff=lfs merge=lfs -textassets/pareto-average.png filter=lfs diff=lfs merge=lfs -textassets/pareto-russian.png filter=lfs diff=lfs merge=lfs -text*.png filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"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.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"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.
"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 (an example is provided in the Appendix below).
"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.
"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."
"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.
2. Grant of Copyright License. Subject to the terms and conditions of this License, 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.
3. Grant of Patent License. Subject to the terms and conditions of this License, 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.
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:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(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
(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.
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.
5. 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.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. 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.
8. 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.
9. 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.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207---license: apache-2.0language: [ru, en]pipeline_tag: text-generationlibrary_name: transformerstags: [berrylm, moe, hybrid, linear-attention, thinking, russian]---
# BerryLM-OS
Hybrid MoE language model for Russian and English with a thinking mode: 40 decoder layers(three linear-attention layers, then one full-attention layer, repeated), sparse MoE FFN with 128 routed experts(top-8) plus a shared expert, **Gated Block AttnRes** depth mixing and **KDA forget gates** onthe linear-attention layers. ~3.2B active / ~18.3B total parameters (bf16, 36.6 GB of weights), 180 224-tokenbyte-level BPE vocabulary, 256k context.
## Architecture
The stack is on the left, one layer on the right. Every layer first mixes in the residual streams committed at earlierblock boundaries (AttnRes, a block is 8 layers), then runs its token mixer (KDA linear attention in three layers out offour, full attention in the fourth) and a sparse MoE feed-forward.

## Quick start (transformers)
```bashpython -m pip install "transformers==5.16.1" accelerate torch```
Fused kernels are optional: `pip install flash-linear-attention` adds the Triton kernels of the linear-attention layers;without it the torch reference path runs (correct, slower on long prompts). `causal-conv1d` is picked up too when installed;it compiles from source unless a prebuilt wheel matches your torch.
```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerm = "rwb-ai/BerryLM-OS"tok = AutoTokenizer.from_pretrained(m, trust_remote_code=True)model = AutoModelForCausalLM.from_pretrained(m, dtype="auto", device_map="auto", trust_remote_code=True)msgs = [{"role": "user", "content": "Объясни, что такое линейное внимание, в трёх предложениях."}]inputs = tok.apply_chat_template(msgs, add_generation_prompt=True, return_dict=True, return_tensors="pt", enable_thinking=True).to(model.device)out = model.generate(**inputs, max_new_tokens=2048, do_sample=True, temperature=0.8, top_p=0.95, top_k=20)print(tok.decode(out[0, inputs["input_ids"].shape[1]:]))```
Thinking is on by default: the reply starts with the reasoning and `</think>` separates it from the answer. Pass`enable_thinking=False` to the chat template for direct answers.
## Sampling
| mode | temperature | top_p | top_k ||---|---|---|---|| thinking (default, shipped in `generation_config.json`) | 0.8 (0.6–0.8) | 0.95 | 20 || direct answers (`enable_thinking=False`) | 0.7 | 0.8 | 20 |
## Serving
**vLLM** (until [vllm-project/vllm#57384](https://github.com/vllm-project/vllm/pull/57384) is merged):
```bashgit clone https://github.com/vllm-project/vllm.git && cd vllmgit fetch origin pull/57384/headgit checkout -b berrylm 7060026c613db283d70efc250f05ab6bbced9317VLLM_USE_PRECOMPILED=1 VLLM_PRECOMPILED_WHEEL_COMMIT=cb6458c5ce61632524c0447d49790725c1e1d9a2 pip install -e .vllm serve rwb-ai/BerryLM-OS --reasoning-parser berrylm --tool-call-parser berrylm --enable-auto-tool-choice```
**SGLang** (until [sgl-project/sglang#55435](https://github.com/sgl-project/sglang/pull/55435) is merged):
```bashgit clone https://github.com/sgl-project/sglang.git && cd sglanggit fetch origin pull/55435/headgit checkout -b berrylm ebedc568181c5290660b3295666382556976ff05pip install -e "python"python -m sglang.launch_server --model-path rwb-ai/BerryLM-OS --port 8000 \ --reasoning-parser berrylm --tool-call-parser berrylm```
Installing SGLang from source builds its Rust extensions: have a Rust toolchain installed, or set`SGLANG_BUILD_RUST_EXTS=none` for the install.
Both servers read the sampling defaults from `generation_config.json`, split the reasoning into the`reasoning` / `reasoning_content` field of the OpenAI-compatible response and parse tool calls (if you render promptsyourself with `apply_chat_template`, pass the `arguments` of earlier tool calls as a mapping, not as a JSON string).Thinking is switched per request; both commands above serve on port 8000:
```bashcurl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{ "model": "rwb-ai/BerryLM-OS", "messages": [{"role": "user", "content": "Сколько будет 17 * 23?"}], "max_tokens": 4096, "chat_template_kwargs": {"enable_thinking": false}}'```
## Hardware
bf16 weights take 34 GiB; the KV cache of the full-attention layers costs about 20 KB per token (5 GiB for the whole256k context) and the linear-attention state 60 MiB per running sequence. vLLM reserves one state block per`--max-num-seqs` slot (1024 by default). On an 80 GB card the commands above work as written; on a smaller one pass alower `--max-num-seqs` and, if the full context does not fit, a lower `--max-model-len` (vLLM) / `--context-length`(SGLang). Measured: under a 46 GiB memory cap (a 48 GB card) `vllm serve ... --max-model-len 32768 --max-num-seqs 64`starts and serves.
## Other formats
- [BerryLM-OS-FP8](https://huggingface.co/rwb-ai/BerryLM-OS-FP8): block-wise FP8 weights for vLLM and SGLang, 17.8 GiB instead of 34 GiB, within two points of these weights on the thinking benchmarks below.- [BerryLM-OS-GGUF](https://huggingface.co/rwb-ai/BerryLM-OS-GGUF): Q6_K and Q4_K_M for llama.cpp. They need llama.cpp with BerryLM support, proposed in [ggml-org/llama.cpp#30234](https://github.com/ggml-org/llama.cpp/pull/30234) and not merged yet.
## Evaluation
### Pareto plot for averaged scores (all benchmarks)
<img src="assets/pareto-average.png" alt="Pareto of average score against active parameters" width="100%">
Unweighted mean of 25 scores:
- **No-think (12):** MMLU-ProX, AA-LCR, WMT24++ en→ru, LIBRA, RULER 32k, RULER 64k, RULER 128k, GSM8K, MATH-500, MGSM ru, WikiWebFacts, HardMultiQA.- **Think (13):** GPQA, AIME 2026, HMMT Feb 2025, DOOM, IFEval, Multi-IF, BFCL v4, RU Arena-Hard, IFBench, MERA v2, HumanEval, MBPP, BigCodeBench.
LFM2.5-2.6B is averaged over 23 scores (no AA-LCR and RULER 128k) and gpt-oss-20b over 24 (no RULER 128k). LFM2.5-2.6B has no no-think mode, so all its scores here and in the table below were measured in think mode.
### Pareto plot for averaged scores (Russian benchmarks subset)
<img src="assets/pareto-russian.png" alt="Pareto of the average Russian benchmark score against active parameters" width="100%">
Equal-weight mean of the nine Russian benchmark scores: DOOM, RU Arena-Hard, MMLU-ProX ru, WMT24++ en→ru, LIBRA, MGSM ru, WikiWebFacts, HardMultiQA, MERA v2.
<div style="font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;margin:8px 0 16px;overflow-x:auto"><table style="width:100%;border-collapse:collapse;font-size:12.5px;line-height:1.35"> <thead> <tr> <th style="padding:6px 6px;text-align:left;font-weight:600;font-size:11px;vertical-align:bottom;border-bottom:2px solid rgba(128,128,128,0.35)">Benchmark</th> <th style="padding:6px 6px;text-align:left;font-weight:600;font-size:11px;vertical-align:bottom;border-bottom:2px solid rgba(128,128,128,0.35)">Mode</th> <th style="padding:6px 5px;text-align:right;font-weight:600;font-size:11px;line-height:1.25;color:#5b3fa0;background:rgba(124,92,191,0.10);vertical-align:bottom;border-bottom:2px solid #5b3fa0;white-space:nowrap">BerryLM-OS</th> <th style="padding:6px 5px;text-align:right;font-weight:600;font-size:11px;line-height:1.25;vertical-align:bottom;border-bottom:2px solid rgba(128,128,128,0.35);white-space:nowrap">LFM2.5<br>2.6B<sup>*</sup></th> <th style="padding:6px 5px;text-align:right;font-weight:600;font-size:11px;line-height:1.25;vertical-align:bottom;border-bottom:2px solid rgba(128,128,128,0.35);white-space:nowrap">Qwen3.5<br>4B</th> <th style="padding:6px 5px;text-align:right;font-weight:600;font-size:11px;line-height:1.25;vertical-align:bottom;border-bottom:2px solid rgba(128,128,128,0.35);white-space:nowrap">Qwen3.5<br>9B</th> <th style="padding:6px 5px;text-align:right;font-weight:600;font-size:11px;line-height:1.25;vertical-align:bottom;border-bottom:2px solid rgba(128,128,128,0.35);white-space:nowrap">Nemotron 3.5<br>30B-A3B</th> <th style="padding:6px 5px;text-align:right;font-weight:600;font-size:11px;line-height:1.25;vertical-align:bottom;border-bottom:2px solid rgba(128,128,128,0.35);white-space:nowrap">gpt-oss<br>20b</th> <th style="padding:6px 5px;text-align:right;font-weight:600;font-size:11px;line-height:1.25;vertical-align:bottom;border-bottom:2px solid rgba(128,128,128,0.35);white-space:nowrap">Qwen3.5<br>35B-A3B</th> <th style="padding:6px 5px;text-align:right;font-weight:600;font-size:11px;line-height:1.25;vertical-align:bottom;border-bottom:2px solid rgba(128,128,128,0.35);white-space:nowrap">Qwen3.6<br>35B-A3B</th> <th style="padding:6px 5px;text-align:right;font-weight:600;font-size:11px;line-height:1.25;vertical-align:bottom;border-bottom:2px solid rgba(128,128,128,0.35);white-space:nowrap">Gemma 4<br>26B-A4B</th> </tr> </thead> <tbody> <tr><th colspan="11" style="text-align:left;background:rgba(124,92,191,0.12);color:#5b3fa0;font-weight:600;font-size:11px;letter-spacing:0.04em;text-transform:uppercase;padding:8px 8px 6px;border-bottom:1px solid rgba(124,92,191,0.28)">General knowledge and reasoning</th></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">MMLU-ProX en+ru<br><span style="font-weight:400;font-size:10px;opacity:0.62">pass@1</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">79.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">64.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">73.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">78.1</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">74.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">69.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">83.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>83.1</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">81.5</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">GPQA<br><span style="font-weight:400;font-size:10px;opacity:0.62">pass@1</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">79.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">56.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">77.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">81.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">75.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">71.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>83.5</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">79.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">79.7</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">DOOM<sup>1</sup><br><span style="font-weight:400;font-size:10px;opacity:0.62">pass@1</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">75.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">45.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">71.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">73.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">63.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">62.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>78.3</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">72.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">77.2</td></tr> <tr><th colspan="11" style="text-align:left;background:rgba(124,92,191,0.12);color:#5b3fa0;font-weight:600;font-size:11px;letter-spacing:0.04em;text-transform:uppercase;padding:8px 8px 6px;border-bottom:1px solid rgba(124,92,191,0.28)">Math</th></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">AIME 2026<br><span style="font-weight:400;font-size:10px;opacity:0.62">pass@1</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">90.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">65.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">82.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">87.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">87.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">84.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">90.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>90.8</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">86.5</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">HMMT Feb 2025<br><span style="font-weight:400;font-size:10px;opacity:0.62">pass@1</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">80.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">47.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">71.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">81.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">85.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">71.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">84.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>89.2</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">79.2</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">GSM8K<br><span style="font-weight:400;font-size:10px;opacity:0.62">8-shot CoT, exact match</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">96.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">89.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">91.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">95.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">89.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">77.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">96.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">96.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>96.5</strong></td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">MATH-500<br><span style="font-weight:400;font-size:10px;opacity:0.62">4-shot, pass@32</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">98.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">98.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">97.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">98.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">85.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">95.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>99.4</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">99.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">98.6</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">MGSM ru<br><span style="font-weight:400;font-size:10px;opacity:0.62">symbolic match</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)"><strong>94.0</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">82.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">87.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">88.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">80.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">71.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">92.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">92.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">91.6</td></tr> <tr><th colspan="11" style="text-align:left;background:rgba(124,92,191,0.12);color:#5b3fa0;font-weight:600;font-size:11px;letter-spacing:0.04em;text-transform:uppercase;padding:8px 8px 6px;border-bottom:1px solid rgba(124,92,191,0.28)">Code and agentic</th></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">HumanEval<br><span style="font-weight:400;font-size:10px;opacity:0.62">pass@1</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">97.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">84.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">84.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">91.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">95.1</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">84.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">96.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">97.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>99.0</strong></td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">MBPP<br><span style="font-weight:400;font-size:10px;opacity:0.62">pass@1</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">92.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">77.1</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">69.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">80.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">87.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">89.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">85.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">92.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>96.8</strong></td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">BigCodeBench-Hard<br><span style="font-weight:400;font-size:10px;opacity:0.62">pass@1</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">48.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">31.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">32.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">39.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">49.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">46.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">45.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>50.6</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">48.5</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">BFCL v4<sup>2</sup><br><span style="font-weight:400;font-size:10px;opacity:0.62">overall</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">66.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">58.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">54.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">62.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">57.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">32.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>66.3</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">63.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">60.7</td></tr> <tr><th colspan="11" style="text-align:left;background:rgba(124,92,191,0.12);color:#5b3fa0;font-weight:600;font-size:11px;letter-spacing:0.04em;text-transform:uppercase;padding:8px 8px 6px;border-bottom:1px solid rgba(124,92,191,0.28)">Instruction following</th></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">IFEval<br><span style="font-weight:400;font-size:10px;opacity:0.62">prompt-level strict</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">93.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">93.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">88.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">89.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">91.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">88.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">90.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">88.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>94.8</strong></td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">Multi-IF en+ru<br><span style="font-weight:400;font-size:10px;opacity:0.62">mean of 3 turns</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">85.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">82.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">79.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">84.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">83.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">81.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">85.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">86.1</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>88.8</strong></td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">IFBench<br><span style="font-weight:400;font-size:10px;opacity:0.62">strict / loose mean</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">73.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">57.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">54.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">61.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">70.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">66.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">65.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">58.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>77.3</strong></td></tr> <tr><th colspan="11" style="text-align:left;background:rgba(124,92,191,0.12);color:#5b3fa0;font-weight:600;font-size:11px;letter-spacing:0.04em;text-transform:uppercase;padding:8px 8px 6px;border-bottom:1px solid rgba(124,92,191,0.28)">Russian</th></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">RU Arena-Hard<sup>3</sup><br><span style="font-weight:400;font-size:10px;opacity:0.62">win rate</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">49.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">5.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">8.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">18.1</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">16.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">44.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">38.1</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">66.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>69.2</strong></td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">WMT24++ en→ru<sup>4</sup><br><span style="font-weight:400;font-size:10px;opacity:0.62">COMET</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">85.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">75.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">81.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">84.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">75.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">79.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">86.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">85.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>86.5</strong></td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">WikiWebFacts<sup>5</sup><br><span style="font-weight:400;font-size:10px;opacity:0.62">judged accuracy</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">53.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">38.1</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">37.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">48.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">42.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">46.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>62.9</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">60.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">60.2</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">HardMultiQA<sup>5</sup><br><span style="font-weight:400;font-size:10px;opacity:0.62">judged accuracy</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">39.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">21.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">22.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">35.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">29.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">34.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>45.3</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">42.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">44.4</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">MERA v2<sup>6</sup><br><span style="font-weight:400;font-size:10px;opacity:0.62">overall</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">40.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">12.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">9.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">18.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">23.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">27.4</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">33.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">39.1</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>45.2</strong></td></tr> <tr><th colspan="11" style="text-align:left;background:rgba(124,92,191,0.12);color:#5b3fa0;font-weight:600;font-size:11px;letter-spacing:0.04em;text-transform:uppercase;padding:8px 8px 6px;border-bottom:1px solid rgba(124,92,191,0.28)">Long context</th></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">AA-LCR<sup>7</sup><br><span style="font-weight:400;font-size:10px;opacity:0.62">pass@1</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">44.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;opacity:0.45">—</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">36.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">36.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">13.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">31.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">57.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>58.5</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">39.3</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">LIBRA<br><span style="font-weight:400;font-size:10px;opacity:0.62">mean of 21 sets</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)"><strong>63.9</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">42.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">59.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">60.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">52.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">54.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">61.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">61.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">62.3</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">RULER 32k<br><span style="font-weight:400;font-size:10px;opacity:0.62">accuracy</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">96.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">67.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">95.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">96.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>97.1</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">74.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">96.5</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">96.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">96.5</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">RULER 64k<br><span style="font-weight:400;font-size:10px;opacity:0.62">accuracy</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">95.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">45.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">95.2</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">96.1</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>96.8</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">68.0</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">96.1</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">96.7</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">95.0</td></tr> <tr><td style="padding:4px 6px;text-align:left;font-weight:600;font-size:11px;line-height:1.3;border-bottom:1px solid rgba(128,128,128,0.2)">RULER 128k<br><span style="font-weight:400;font-size:10px;opacity:0.62">accuracy</span></td><td style="padding:4px 5px;text-align:left;font-weight:500;font-size:10.5px;line-height:1.25;opacity:0.72;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">no-think</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;background:rgba(124,92,191,0.10)">95.1</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;opacity:0.45">—</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">94.8</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">95.6</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap"><strong>96.5</strong></td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap;opacity:0.45">—</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">95.9</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">96.3</td><td style="padding:6px 5px;text-align:right;border-bottom:1px solid rgba(128,128,128,0.2);white-space:nowrap">91.9</td></tr> </tbody></table></div>
<div style="font-size:12px;line-height:1.45;opacity:0.85;margin:4px 0 8px"><p style="margin:0 0 5px"><sup>1</sup> <b>DOOM</b>: mean of the math and physics subsets.</p><p style="margin:0 0 5px"><sup>2</sup> <b>BFCL v4</b>: overall score without the web-search category.</p><p style="margin:0 0 5px"><sup>3</sup> <b>RU Arena-Hard</b> (474 prompts): GLM-4.7-FP8 compares each answer with the fixed DeepSeek-V3.2 baseline answers, in both orders; the score is the win rate against that baseline (the baseline itself would score 50).</p><p style="margin:0 0 5px"><sup>4</sup> <b>WMT24++</b>: scored by the XCOMET-XXL metric model, not an LLM judge.</p><p style="margin:0 0 5px"><sup>5</sup> <b>WikiWebFacts</b> (1365 questions) and <b>HardMultiQA</b> (670): no comparison model; Qwen3.5-122B-A10B grades each answer against the reference answer as −1, 0 or 1, and the score is the share of answers graded 1.</p><p style="margin:0 0 5px"><sup>6</sup> <b>MERA v2</b>: LFM2.5-2.6B, Qwen3.5-4B, Qwen3.5-9B, Qwen3.5-35B-A3B and Qwen3.6-35B-A3B are taken from the <a href="https://mera.a-ai.ru/en/text/leaderboard">official leaderboard</a>; Nemotron 3.5 30B-A3B, gpt-oss-20b, Gemma 4 26B-A4B and BerryLM-OS were run with the official MERA v2 code and scored by the MERA scoring system (the leaderboard has Gemma 4 26B-A4B only in non-reasoning mode).</p><p style="margin:0 0 5px"><sup>7</sup> <b>AA-LCR</b>: judged by GLM-4.7-FP8, which checks the answer against the reference.</p><p style="margin:0 0 5px"><sup>*</sup> <b>LFM2.5-2.6B</b> has no no-think mode: all its scores were measured in think mode.</p><p style="margin:6px 0 0">The other benchmarks are scored without a model, by answer matching or unit tests. <b>Bold</b>: best in the row; —: not measured.</p></div>
## Authors
Danil Smorchkov, Anton Tikhonov, Yulia Ivanova, Matvey Saprykin, Anton Egorov,Yuriy Sofronov, Adel Khalilov, Andrey Yakuboy, Igor Bogdanov, Maria Korshunova,Mikhail Aleshin, Alexander Kostylev, Damir Chanyshev.
## License
Released under the Apache License 2.0.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147{%- macro render_content(content) %} {%- if content is string %} {{- content }} {%- elif content is iterable and content is not mapping %} {%- for item in content %} {%- if 'text' in item %} {{- item.text }} {%- else %} {{- raise_exception('Unexpected item type in content: this is a text-only model.') }} {%- endif %} {%- endfor %} {%- elif content is none or content is undefined %} {{- '' }} {%- else %} {{- raise_exception('Unexpected content type.') }} {%- endif %}{%- endmacro %}{%- if not messages %} {{- raise_exception('No messages provided.') }}{%- endif %}{%- if use_default_system is defined and not use_default_system %} {%- set dev_system = '' %}{%- elif default_system is defined %} {%- set dev_system = default_system|trim %}{%- else %} {%- set dev_system = 'При ответах соблюдай действующее законодательство Российской Федерации.' %}{%- endif %}{%- if tools and tools is iterable and tools is not mapping %} {{- '<|im_start|>system\n' }} {%- if dev_system %} {{- dev_system + '\n\n' }} {%- endif %} {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }} {%- for tool in tools %} {{- "\n" }} {{- tool | tojson }} {%- endfor %} {{- "\n</tools>" }} {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }} {%- if messages[0].role == 'system' %} {%- set content = render_content(messages[0].content)|trim %} {%- if content %} {{- '\n\n' + content }} {%- endif %} {%- endif %} {{- '<|im_end|>\n' }}{%- else %} {%- if messages[0].role == 'system' %} {%- set content = render_content(messages[0].content)|trim %} {%- if dev_system and content %} {%- set content = dev_system + '\n\n' + content %} {%- elif dev_system %} {%- set content = dev_system %} {%- endif %} {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }} {%- elif dev_system %} {{- '<|im_start|>system\n' + dev_system + '<|im_end|>\n' }} {%- endif %}{%- endif %}{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}{%- for message in messages[::-1] %} {%- set index = (messages|length - 1) - loop.index0 %} {%- if ns.multi_step_tool and message.role == "user" %} {%- set content = render_content(message.content)|trim %} {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %} {%- set ns.multi_step_tool = false %} {%- set ns.last_query_index = index %} {%- endif %} {%- endif %}{%- endfor %}{%- if ns.multi_step_tool %} {{- raise_exception('No user query found in messages.') }}{%- endif %}{%- for message in messages %} {%- set content = render_content(message.content)|trim %} {%- if message.role == "system" %} {%- if not loop.first %} {{- raise_exception('System message must be at the beginning.') }} {%- endif %} {%- elif message.role == "user" %} {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} {%- elif message.role == "assistant" %} {%- set reasoning_content = '' %} {%- if message.reasoning_content is string %} {%- set reasoning_content = message.reasoning_content %} {%- else %} {%- if '</think>' in content %} {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %} {%- set content = content.split('</think>')[-1].lstrip('\n') %} {%- endif %} {%- endif %} {%- set reasoning_content = reasoning_content|trim %} {%- if (preserve_thinking is defined and preserve_thinking is true) or (loop.index0 > ns.last_query_index) %} {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }} {%- else %} {{- '<|im_start|>' + message.role + '\n' + content }} {%- endif %} {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %} {%- for tool_call in message.tool_calls %} {%- if tool_call.function is defined %} {%- set tool_call = tool_call.function %} {%- endif %} {%- if loop.first %} {%- if content|trim %} {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- else %} {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- endif %} {%- else %} {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- endif %} {%- if tool_call.arguments is defined %} {%- for args_name, args_value in tool_call.arguments|items %} {{- '<parameter=' + args_name + '>\n' }} {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %} {{- args_value }} {{- '\n</parameter>\n' }} {%- endfor %} {%- endif %} {{- '</function>\n</tool_call>' }} {%- endfor %} {%- endif %} {{- '<|im_end|>\n' }} {%- elif message.role == "tool" %} {%- if loop.previtem and loop.previtem.role != "tool" %} {{- '<|im_start|>user' }} {%- endif %} {{- '\n<tool_response>\n' }} {{- content }} {{- '\n</tool_response>' }} {%- if not loop.last and loop.nextitem.role != "tool" %} {{- '<|im_end|>\n' }} {%- elif loop.last %} {{- '<|im_end|>\n' }} {%- endif %} {%- else %} {{- raise_exception('Unexpected message role.') }} {%- endif %}{%- endfor %}{%- if add_generation_prompt %} {{- '<|im_start|>assistant\n' }} {%- if enable_thinking is defined and enable_thinking is false %} {{- '<think>\n\n</think>\n\n' }} {%- else %} {{- '<think>\n' }} {%- endif %}{%- endif %}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394{ "attention_bias": false, "attention_dropout": 0.0, "attn_output_gate": true, "attn_res_block_size": 8, "attn_res_gated": true, "bos_token_id": 180215, "dtype": "bfloat16", "eos_token_id": 180215, "full_attention_interval": 4, "head_dim": 256, "hidden_act": "silu", "hidden_size": 2048, "initializer_range": 0.02, "kda_gate_bottleneck": 128, "kda_safe_gate": false, "layer_types": [ "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention", "linear_attention", "linear_attention", "linear_attention", "full_attention" ], "linear_conv_kernel_dim": 4, "linear_key_head_dim": 128, "linear_num_key_heads": 16, "linear_num_value_heads": 32, "linear_value_head_dim": 128, "max_position_embeddings": 262144, "model_type": "berrylm", "moe_intermediate_size": 512, "num_attention_heads": 16, "num_experts": 128, "num_experts_per_tok": 8, "num_hidden_layers": 40, "num_key_value_heads": 2, "output_router_logits": false, "pad_token_id": null, "partial_rotary_factor": 0.25, "rms_norm_eps": 1e-06, "rope_parameters": { "partial_rotary_factor": 0.25, "rope_theta": 10000000, "rope_type": "default" }, "router_aux_loss_coef": 0.001, "shared_expert_intermediate_size": 512, "tie_word_embeddings": false, "use_cache": true, "vocab_size": 180224, "architectures": [ "BerryLMForCausalLM" ], "auto_map": { "AutoConfig": "configuration_berrylm.BerryLMConfig", "AutoModelForCausalLM": "modeling_berrylm.BerryLMForCausalLM" }, "transformers_version": "5.16.1"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159# Copyright (c) 2026 The RWB AI Assist team and The HuggingFace Inc. team.# SPDX-License-Identifier: Apache-2.0"""BerryLM-OS model configuration."""
from huggingface_hub.dataclasses import strict
from transformers.configuration_utils import PreTrainedConfigfrom transformers.modeling_rope_utils import RopeParametersfrom transformers.utils import auto_docstring
@auto_docstring(checkpoint="rwb-ai/BerryLM-OS")@strictclass BerryLMConfig(PreTrainedConfig): r""" attn_output_gate (`bool`, *optional*, defaults to `True`): Whether the full-attention layers gate their output with a sigmoid branch of the query projection. linear_conv_kernel_dim (`int`, *optional*, defaults to 4): Kernel size of the convolution used in linear attention layers. linear_key_head_dim (`int`, *optional*, defaults to 128): Dimension of each key head in linear attention. linear_value_head_dim (`int`, *optional*, defaults to 128): Dimension of each value head in linear attention. linear_num_key_heads (`int`, *optional*, defaults to 16): Number of key heads used in linear attention layers. linear_num_value_heads (`int`, *optional*, defaults to 32): Number of value heads used in linear attention layers. Must be a multiple of `linear_num_key_heads`. attn_res_block_size (`int`, *optional*, defaults to 8): Block size of the Gated Block AttnRes mixer: every decoder layer reads a softmax mixture of the residual streams committed every `attn_res_block_size` layers (the embeddings count as block 0) and the current stream, gated back toward the identity by a per-layer scalar. `0` disables the mixer. attn_res_gated (`bool`, *optional*, defaults to `True`): Whether the mixer output is gated toward the identity (`y = x + tanh(g) * (mix - x)`, `g = 0` is the exact identity). `False` feeds the plain mixture to the layer. attn_res_eps (`float`, *optional*, defaults to 1e-06): Epsilon of the RMS normalization applied to the mixer keys. kda_gate_bottleneck (`int`, *optional*, defaults to 128): Rank of the low-rank per-channel forget gate of the linear-attention layers (`g = -exp(A_log) * softplus(f_up(f_down(x)) + dt_bias)`, shape `[linear_num_value_heads, linear_key_head_dim]`; `f_down_proj` / `f_up_proj`). kda_safe_gate (`bool`, *optional*, defaults to `False`): Whether the forget gate is clamped from below by `kda_gate_lower_bound`. kda_gate_lower_bound (`float`, *optional*): Lower bound of the log-decay when `kda_safe_gate` is enabled.
```python >>> from transformers import BerryLMModel, BerryLMConfig
>>> # Initializing a BerryLM style configuration >>> configuration = BerryLMConfig()
>>> # Initializing a model from the BerryLM-OS style configuration >>> model = BerryLMModel(configuration)
>>> # Accessing the model configuration >>> configuration = model.config ``` """
model_type = "berrylm" keys_to_ignore_at_inference = ["past_key_values"]
# The small KDA gate projections (f_down_proj / f_up_proj) and the AttnRes parameters stay replicated. base_model_tp_plan = { "layers.*.self_attn.q_proj": "colwise", "layers.*.self_attn.k_proj": "colwise", "layers.*.self_attn.v_proj": "colwise", "layers.*.self_attn.o_proj": "rowwise", "layers.*.self_attn.q_norm": "replicated_with_grad_allreduce", "layers.*.self_attn.k_norm": "replicated_with_grad_allreduce", "layers.*.mlp.experts.gate_up_proj": "packed_colwise", "layers.*.mlp.experts.down_proj": "rowwise", "layers.*.mlp.experts": "moe_tp_experts", "layers.*.mlp.shared_expert.gate_proj": "colwise", "layers.*.mlp.shared_expert.up_proj": "colwise", "layers.*.mlp.shared_expert.down_proj": "rowwise", "layers.*.kda.in_proj_qkv": "colwise_gather_output", "layers.*.kda.in_proj_z": "colwise_gather_output", "layers.*.kda.in_proj_b": "colwise_gather_output", "layers.*.kda.out_proj": "colwise_gather_output", } base_model_pp_plan = { "embed_tokens": (["input_ids"], ["inputs_embeds"]), "layers": (["hidden_states", "attention_mask"], ["hidden_states"]), "norm": (["hidden_states"], ["hidden_states"]), } base_model_ep_plan = { "layers.*.mlp.gate": "ep_router", "layers.*.mlp.experts.gate_up_proj": "grouped_gemm", "layers.*.mlp.experts.down_proj": "grouped_gemm", "layers.*.mlp.experts": "moe_tp_experts", }
vocab_size: int = 180224 hidden_size: int = 2048 num_hidden_layers: int = 40 num_attention_heads: int = 16 num_key_value_heads: int = 2 hidden_act: str = "silu" max_position_embeddings: int = 262144 initializer_range: float = 0.02 rms_norm_eps: float = 1e-6 use_cache: bool = True tie_word_embeddings: bool = False rope_parameters: RopeParameters | dict | None = None attention_bias: bool = False attention_dropout: float | int = 0.0 attn_output_gate: bool = True head_dim: int = 256 linear_conv_kernel_dim: int = 4 linear_key_head_dim: int = 128 linear_value_head_dim: int = 128 linear_num_key_heads: int = 16 linear_num_value_heads: int = 32 moe_intermediate_size: int = 512 shared_expert_intermediate_size: int = 512 num_experts_per_tok: int = 8 num_experts: int = 128 norm_topk_prob: bool = True output_router_logits: bool = False router_aux_loss_coef: float = 0.001 layer_types: list[str] | None = None attn_res_block_size: int = 8 attn_res_gated: bool = True attn_res_eps: float = 1e-6 kda_gate_bottleneck: int = 128 kda_safe_gate: bool = False kda_gate_lower_bound: float | None = None pad_token_id: int | None = None bos_token_id: int | None = None eos_token_id: int | list[int] | None = None
def __post_init__(self, **kwargs): kwargs.setdefault("partial_rotary_factor", 0.25) # assign default for BC # `full_attention_interval` only seeds `layer_types` (one full-attention layer per `interval` layers). interval_pattern = kwargs.pop("full_attention_interval", 4) if self.layer_types is None: self.layer_types = [ "linear_attention" if bool((i + 1) % interval_pattern) else "full_attention" for i in range(self.num_hidden_layers) ] bad = sorted({t for t in self.layer_types if t not in ("linear_attention", "full_attention")}) if bad: raise ValueError(f"`layer_types` must contain only 'linear_attention'/'full_attention', got {bad}") if len(self.layer_types) != self.num_hidden_layers: raise ValueError( f"`layer_types` has {len(self.layer_types)} entries for {self.num_hidden_layers} hidden layers" ) if self.linear_num_value_heads % self.linear_num_key_heads != 0: raise ValueError("`linear_num_value_heads` must be a multiple of `linear_num_key_heads`") if self.attn_res_block_size < 0: raise ValueError("`attn_res_block_size` must be >= 0") if self.kda_safe_gate and self.kda_gate_lower_bound is None: raise ValueError("`kda_gate_lower_bound` is required when `kda_safe_gate=True`")
super().__post_init__(**kwargs)
__all__ = ["BerryLMConfig"]1234567891011{ "do_sample": true, "temperature": 0.8, "top_p": 0.95, "top_k": 20, "eos_token_id": [ 180217, 180215 ], "pad_token_id": 180215}123version https://git-lfs.github.com/spec/v1oid sha256:7121f9cf91c8c7134b5fee7c266383210683d94e7d04f670b0e14d5f7263cfc4size 4987932746123version https://git-lfs.github.com/spec/v1oid sha256:f92f53303c63b46a771d7137d32c97bdccd7550f8cf9600f866075e127f991d7size 4726323458123version https://git-lfs.github.com/spec/v1oid sha256:ca39c8825e0b562dc557724ae9c47ae8b4d66ae845f5ccdc68a546d4fe2594bbsize 4934482564123version https://git-lfs.github.com/spec/v1oid sha256:4e26e28f92b14e611515e2f6da05488296f5d2d466ec597b8ce5403e8fc6af59size 4713741674123version https://git-lfs.github.com/spec/v1oid sha256:4f864eab1a40c44f65b192abd9649fb3fa54b516898bcb57f4c781605c51de6asize 4986593276123version https://git-lfs.github.com/spec/v1oid sha256:319631203d694f7442469783afb4b3e6771297c9bf23bb7abf475ca06a9f38besize 4607103410123version https://git-lfs.github.com/spec/v1oid sha256:d7e3bdce5c2fbfd9545f1f6a5eab3de15a6548904055e2f32f1b65a618b863d2size 4990788692123version https://git-lfs.github.com/spec/v1oid sha256:f6c73d9a57d70100f38158c46d09b01d7268dbdab4d012c0e532aec75fb0869dsize 2626940220123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811{ "metadata": { "total_parameters": 18286907112, "total_size": 36573814224 }, "weight_map": { "lm_head.weight": "model-00001-of-00008.safetensors", "model.embed_tokens.weight": "model-00001-of-00008.safetensors", "model.layers.0.attn_res.gate": "model-00001-of-00008.safetensors", "model.layers.0.attn_res.pseudo_query": "model-00001-of-00008.safetensors", "model.layers.0.input_layernorm.weight": "model-00001-of-00008.safetensors", "model.layers.0.kda.A_log": "model-00001-of-00008.safetensors", "model.layers.0.kda.conv1d.weight": "model-00001-of-00008.safetensors", "model.layers.0.kda.dt_bias": "model-00001-of-00008.safetensors", "model.layers.0.kda.f_down_proj.weight": "model-00001-of-00008.safetensors", "model.layers.0.kda.f_up_proj.weight": "model-00001-of-00008.safetensors", "model.layers.0.kda.in_proj_b.weight": "model-00001-of-00008.safetensors", "model.layers.0.kda.in_proj_qkv.weight": "model-00001-of-00008.safetensors", "model.layers.0.kda.in_proj_z.weight": "model-00001-of-00008.safetensors", "model.layers.0.kda.norm.weight": "model-00001-of-00008.safetensors", "model.layers.0.kda.out_proj.weight": "model-00001-of-00008.safetensors", "model.layers.0.mlp.experts.down_proj": "model-00001-of-00008.safetensors", "model.layers.0.mlp.experts.gate_up_proj": "model-00001-of-00008.safetensors", "model.layers.0.mlp.gate.weight": "model-00001-of-00008.safetensors", "model.layers.0.mlp.shared_expert.down_proj.weight": "model-00001-of-00008.safetensors", "model.layers.0.mlp.shared_expert.gate_proj.weight": "model-00001-of-00008.safetensors", "model.layers.0.mlp.shared_expert.up_proj.weight": "model-00001-of-00008.safetensors", "model.layers.0.mlp.shared_expert_gate.weight": "model-00001-of-00008.safetensors", "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00008.safetensors", "model.layers.1.attn_res.gate": "model-00001-of-00008.safetensors", "model.layers.1.attn_res.pseudo_query": "model-00001-of-00008.safetensors", "model.layers.1.input_layernorm.weight": "model-00001-of-00008.safetensors", "model.layers.1.kda.A_log": "model-00001-of-00008.safetensors", "model.layers.1.kda.conv1d.weight": "model-00001-of-00008.safetensors", "model.layers.1.kda.dt_bias": "model-00001-of-00008.safetensors", "model.layers.1.kda.f_down_proj.weight": "model-00001-of-00008.safetensors", "model.layers.1.kda.f_up_proj.weight": "model-00001-of-00008.safetensors", "model.layers.1.kda.in_proj_b.weight": "model-00001-of-00008.safetensors", "model.layers.1.kda.in_proj_qkv.weight": "model-00001-of-00008.safetensors", "model.layers.1.kda.in_proj_z.weight": "model-00001-of-00008.safetensors", "model.layers.1.kda.norm.weight": "model-00001-of-00008.safetensors", "model.layers.1.kda.out_proj.weight": "model-00001-of-00008.safetensors", "model.layers.1.mlp.experts.down_proj": "model-00001-of-00008.safetensors", "model.layers.1.mlp.experts.gate_up_proj": "model-00001-of-00008.safetensors", "model.layers.1.mlp.gate.weight": "model-00001-of-00008.safetensors", "model.layers.1.mlp.shared_expert.down_proj.weight": "model-00001-of-00008.safetensors", "model.layers.1.mlp.shared_expert.gate_proj.weight": "model-00001-of-00008.safetensors", "model.layers.1.mlp.shared_expert.up_proj.weight": "model-00001-of-00008.safetensors", "model.layers.1.mlp.shared_expert_gate.weight": "model-00001-of-00008.safetensors", "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00008.safetensors", "model.layers.10.attn_res.gate": "model-00003-of-00008.safetensors", "model.layers.10.attn_res.pseudo_query": "model-00003-of-00008.safetensors", "model.layers.10.input_layernorm.weight": "model-00003-of-00008.safetensors", "model.layers.10.kda.A_log": "model-00003-of-00008.safetensors", "model.layers.10.kda.conv1d.weight": "model-00003-of-00008.safetensors", "model.layers.10.kda.dt_bias": "model-00003-of-00008.safetensors", "model.layers.10.kda.f_down_proj.weight": "model-00003-of-00008.safetensors", "model.layers.10.kda.f_up_proj.weight": "model-00003-of-00008.safetensors", "model.layers.10.kda.in_proj_b.weight": "model-00003-of-00008.safetensors", "model.layers.10.kda.in_proj_qkv.weight": "model-00003-of-00008.safetensors", "model.layers.10.kda.in_proj_z.weight": "model-00003-of-00008.safetensors", "model.layers.10.kda.norm.weight": "model-00003-of-00008.safetensors", "model.layers.10.kda.out_proj.weight": "model-00003-of-00008.safetensors", "model.layers.10.mlp.experts.down_proj": "model-00003-of-00008.safetensors", "model.layers.10.mlp.experts.gate_up_proj": "model-00003-of-00008.safetensors", "model.layers.10.mlp.gate.weight": "model-00003-of-00008.safetensors", "model.layers.10.mlp.shared_expert.down_proj.weight": "model-00003-of-00008.safetensors", "model.layers.10.mlp.shared_expert.gate_proj.weight": "model-00003-of-00008.safetensors", "model.layers.10.mlp.shared_expert.up_proj.weight": "model-00003-of-00008.safetensors", "model.layers.10.mlp.shared_expert_gate.weight": "model-00003-of-00008.safetensors", "model.layers.10.post_attention_layernorm.weight": "model-00003-of-00008.safetensors", "model.layers.11.attn_res.gate": "model-00003-of-00008.safetensors", "model.layers.11.attn_res.pseudo_query": "model-00003-of-00008.safetensors", "model.layers.11.input_layernorm.weight": "model-00003-of-00008.safetensors", "model.layers.11.mlp.experts.down_proj": "model-00003-of-00008.safetensors", "model.layers.11.mlp.experts.gate_up_proj": "model-00003-of-00008.safetensors", "model.layers.11.mlp.gate.weight": "model-00003-of-00008.safetensors", "model.layers.11.mlp.shared_expert.down_proj.weight": "model-00003-of-00008.safetensors", "model.layers.11.mlp.shared_expert.gate_proj.weight": "model-00003-of-00008.safetensors", "model.layers.11.mlp.shared_expert.up_proj.weight": "model-00003-of-00008.safetensors", "model.layers.11.mlp.shared_expert_gate.weight": "model-00003-of-00008.safetensors", "model.layers.11.post_attention_layernorm.weight": "model-00003-of-00008.safetensors", "model.layers.11.self_attn.k_norm.weight": "model-00003-of-00008.safetensors", "model.layers.11.self_attn.k_proj.weight": "model-00003-of-00008.safetensors", "model.layers.11.self_attn.o_proj.weight": "model-00003-of-00008.safetensors", "model.layers.11.self_attn.q_norm.weight": "model-00003-of-00008.safetensors", "model.layers.11.self_attn.q_proj.weight": "model-00003-of-00008.safetensors", "model.layers.11.self_attn.v_proj.weight": "model-00003-of-00008.safetensors", "model.layers.12.attn_res.gate": "model-00003-of-00008.safetensors", "model.layers.12.attn_res.pseudo_query": "model-00003-of-00008.safetensors", "model.layers.12.input_layernorm.weight": "model-00003-of-00008.safetensors", "model.layers.12.kda.A_log": "model-00003-of-00008.safetensors", "model.layers.12.kda.conv1d.weight": "model-00003-of-00008.safetensors", "model.layers.12.kda.dt_bias": "model-00003-of-00008.safetensors", "model.layers.12.kda.f_down_proj.weight": "model-00003-of-00008.safetensors", "model.layers.12.kda.f_up_proj.weight": "model-00003-of-00008.safetensors", "model.layers.12.kda.in_proj_b.weight": "model-00003-of-00008.safetensors", "model.layers.12.kda.in_proj_qkv.weight": "model-00003-of-00008.safetensors", "model.layers.12.kda.in_proj_z.weight": "model-00003-of-00008.safetensors", "model.layers.12.kda.norm.weight": "model-00003-of-00008.safetensors", "model.layers.12.kda.out_proj.weight": "model-00003-of-00008.safetensors", "model.layers.12.mlp.experts.down_proj": "model-00003-of-00008.safetensors", "model.layers.12.mlp.experts.gate_up_proj": "model-00003-of-00008.safetensors", "model.layers.12.mlp.gate.weight": "model-00003-of-00008.safetensors", "model.layers.12.mlp.shared_expert.down_proj.weight": "model-00003-of-00008.safetensors", "model.layers.12.mlp.shared_expert.gate_proj.weight": "model-00003-of-00008.safetensors", "model.layers.12.mlp.shared_expert.up_proj.weight": "model-00003-of-00008.safetensors", "model.layers.12.mlp.shared_expert_gate.weight": "model-00003-of-00008.safetensors", "model.layers.12.post_attention_layernorm.weight": "model-00003-of-00008.safetensors", "model.layers.13.attn_res.gate": "model-00003-of-00008.safetensors", "model.layers.13.attn_res.pseudo_query": "model-00003-of-00008.safetensors", "model.layers.13.input_layernorm.weight": "model-00003-of-00008.safetensors", "model.layers.13.kda.A_log": "model-00003-of-00008.safetensors", "model.layers.13.kda.conv1d.weight": "model-00003-of-00008.safetensors", "model.layers.13.kda.dt_bias": "model-00003-of-00008.safetensors", "model.layers.13.kda.f_down_proj.weight": "model-00003-of-00008.safetensors", "model.layers.13.kda.f_up_proj.weight": "model-00003-of-00008.safetensors", "model.layers.13.kda.in_proj_b.weight": "model-00003-of-00008.safetensors", "model.layers.13.kda.in_proj_qkv.weight": "model-00003-of-00008.safetensors", "model.layers.13.kda.in_proj_z.weight": "model-00003-of-00008.safetensors", "model.layers.13.kda.norm.weight": "model-00003-of-00008.safetensors", "model.layers.13.kda.out_proj.weight": "model-00003-of-00008.safetensors", "model.layers.13.mlp.experts.down_proj": "model-00003-of-00008.safetensors", "model.layers.13.mlp.experts.gate_up_proj": "model-00003-of-00008.safetensors", "model.layers.13.mlp.gate.weight": "model-00003-of-00008.safetensors", "model.layers.13.mlp.shared_expert.down_proj.weight": "model-00003-of-00008.safetensors", "model.layers.13.mlp.shared_expert.gate_proj.weight": "model-00003-of-00008.safetensors", "model.layers.13.mlp.shared_expert.up_proj.weight": "model-00003-of-00008.safetensors", "model.layers.13.mlp.shared_expert_gate.weight": "model-00003-of-00008.safetensors", "model.layers.13.post_attention_layernorm.weight": "model-00003-of-00008.safetensors", "model.layers.14.attn_res.gate": "model-00003-of-00008.safetensors", "model.layers.14.attn_res.pseudo_query": "model-00003-of-00008.safetensors", "model.layers.14.input_layernorm.weight": "model-00003-of-00008.safetensors", "model.layers.14.kda.A_log": "model-00003-of-00008.safetensors", "model.layers.14.kda.conv1d.weight": "model-00003-of-00008.safetensors", "model.layers.14.kda.dt_bias": "model-00003-of-00008.safetensors", "model.layers.14.kda.f_down_proj.weight": "model-00003-of-00008.safetensors", "model.layers.14.kda.f_up_proj.weight": "model-00003-of-00008.safetensors", "model.layers.14.kda.in_proj_b.weight": "model-00003-of-00008.safetensors", "model.layers.14.kda.in_proj_qkv.weight": "model-00003-of-00008.safetensors", "model.layers.14.kda.in_proj_z.weight": "model-00003-of-00008.safetensors", "model.layers.14.kda.norm.weight": "model-00003-of-00008.safetensors", "model.layers.14.kda.out_proj.weight": "model-00003-of-00008.safetensors", "model.layers.14.mlp.experts.down_proj": "model-00003-of-00008.safetensors", "model.layers.14.mlp.experts.gate_up_proj": "model-00003-of-00008.safetensors", "model.layers.14.mlp.gate.weight": "model-00003-of-00008.safetensors", "model.layers.14.mlp.shared_expert.down_proj.weight": "model-00003-of-00008.safetensors", "model.layers.14.mlp.shared_expert.gate_proj.weight": "model-00003-of-00008.safetensors", "model.layers.14.mlp.shared_expert.up_proj.weight": "model-00003-of-00008.safetensors", "model.layers.14.mlp.shared_expert_gate.weight": "model-00003-of-00008.safetensors", "model.layers.14.post_attention_layernorm.weight": "model-00003-of-00008.safetensors", "model.layers.15.attn_res.gate": "model-00003-of-00008.safetensors", "model.layers.15.attn_res.pseudo_query": "model-00003-of-00008.safetensors", "model.layers.15.input_layernorm.weight": "model-00003-of-00008.safetensors", "model.layers.15.mlp.experts.down_proj": "model-00004-of-00008.safetensors", "model.layers.15.mlp.experts.gate_up_proj": "model-00004-of-00008.safetensors", "model.layers.15.mlp.gate.weight": "model-00004-of-00008.safetensors", "model.layers.15.mlp.shared_expert.down_proj.weight": "model-00004-of-00008.safetensors", "model.layers.15.mlp.shared_expert.gate_proj.weight": "model-00004-of-00008.safetensors", "model.layers.15.mlp.shared_expert.up_proj.weight": "model-00004-of-00008.safetensors", "model.layers.15.mlp.shared_expert_gate.weight": "model-00004-of-00008.safetensors", "model.layers.15.post_attention_layernorm.weight": "model-00004-of-00008.safetensors", "model.layers.15.self_attn.k_norm.weight": "model-00004-of-00008.safetensors", "model.layers.15.self_attn.k_proj.weight": "model-00004-of-00008.safetensors", "model.layers.15.self_attn.o_proj.weight": "model-00004-of-00008.safetensors", "model.layers.15.self_attn.q_norm.weight": "model-00004-of-00008.safetensors", "model.layers.15.self_attn.q_proj.weight": "model-00004-of-00008.safetensors", "model.layers.15.self_attn.v_proj.weight": "model-00004-of-00008.safetensors", "model.layers.16.attn_res.gate": "model-00004-of-00008.safetensors", "model.layers.16.attn_res.pseudo_query": "model-00004-of-00008.safetensors", "model.layers.16.input_layernorm.weight": "model-00004-of-00008.safetensors", "model.layers.16.kda.A_log": "model-00004-of-00008.safetensors", "model.layers.16.kda.conv1d.weight": "model-00004-of-00008.safetensors", "model.layers.16.kda.dt_bias": "model-00004-of-00008.safetensors", "model.layers.16.kda.f_down_proj.weight": "model-00004-of-00008.safetensors", "model.layers.16.kda.f_up_proj.weight": "model-00004-of-00008.safetensors", "model.layers.16.kda.in_proj_b.weight": "model-00004-of-00008.safetensors", "model.layers.16.kda.in_proj_qkv.weight": "model-00004-of-00008.safetensors", "model.layers.16.kda.in_proj_z.weight": "model-00004-of-00008.safetensors", "model.layers.16.kda.norm.weight": "model-00004-of-00008.safetensors", "model.layers.16.kda.out_proj.weight": "model-00004-of-00008.safetensors", "model.layers.16.mlp.experts.down_proj": "model-00004-of-00008.safetensors", "model.layers.16.mlp.experts.gate_up_proj": "model-00004-of-00008.safetensors", "model.layers.16.mlp.gate.weight": "model-00004-of-00008.safetensors", "model.layers.16.mlp.shared_expert.down_proj.weight": "model-00004-of-00008.safetensors", "model.layers.16.mlp.shared_expert.gate_proj.weight": "model-00004-of-00008.safetensors", "model.layers.16.mlp.shared_expert.up_proj.weight": "model-00004-of-00008.safetensors", "model.layers.16.mlp.shared_expert_gate.weight": "model-00004-of-00008.safetensors", "model.layers.16.post_attention_layernorm.weight": "model-00004-of-00008.safetensors", "model.layers.17.attn_res.gate": "model-00004-of-00008.safetensors", "model.layers.17.attn_res.pseudo_query": "model-00004-of-00008.safetensors", "model.layers.17.input_layernorm.weight": "model-00004-of-00008.safetensors", "model.layers.17.kda.A_log": "model-00004-of-00008.safetensors", "model.layers.17.kda.conv1d.weight": "model-00004-of-00008.safetensors", "model.layers.17.kda.dt_bias": "model-00004-of-00008.safetensors", "model.layers.17.kda.f_down_proj.weight": "model-00004-of-00008.safetensors", "model.layers.17.kda.f_up_proj.weight": "model-00004-of-00008.safetensors", "model.layers.17.kda.in_proj_b.weight": "model-00004-of-00008.safetensors", "model.layers.17.kda.in_proj_qkv.weight": "model-00004-of-00008.safetensors", "model.layers.17.kda.in_proj_z.weight": "model-00004-of-00008.safetensors", "model.layers.17.kda.norm.weight": "model-00004-of-00008.safetensors", "model.layers.17.kda.out_proj.weight": "model-00004-of-00008.safetensors", "model.layers.17.mlp.experts.down_proj": "model-00004-of-00008.safetensors", "model.layers.17.mlp.experts.gate_up_proj": "model-00004-of-00008.safetensors", "model.layers.17.mlp.gate.weight": "model-00004-of-00008.safetensors", "model.layers.17.mlp.shared_expert.down_proj.weight": "model-00004-of-00008.safetensors", "model.layers.17.mlp.shared_expert.gate_proj.weight": "model-00004-of-00008.safetensors", "model.layers.17.mlp.shared_expert.up_proj.weight": "model-00004-of-00008.safetensors", "model.layers.17.mlp.shared_expert_gate.weight": "model-00004-of-00008.safetensors", "model.layers.17.post_attention_layernorm.weight": "model-00004-of-00008.safetensors", "model.layers.18.attn_res.gate": "model-00004-of-00008.safetensors", "model.layers.18.attn_res.pseudo_query": "model-00004-of-00008.safetensors", "model.layers.18.input_layernorm.weight": "model-00004-of-00008.safetensors", "model.layers.18.kda.A_log": "model-00004-of-00008.safetensors", "model.layers.18.kda.conv1d.weight": "model-00004-of-00008.safetensors", "model.layers.18.kda.dt_bias": "model-00004-of-00008.safetensors", "model.layers.18.kda.f_down_proj.weight": "model-00004-of-00008.safetensors", "model.layers.18.kda.f_up_proj.weight": "model-00004-of-00008.safetensors", "model.layers.18.kda.in_proj_b.weight": "model-00004-of-00008.safetensors", "model.layers.18.kda.in_proj_qkv.weight": "model-00004-of-00008.safetensors", "model.layers.18.kda.in_proj_z.weight": "model-00004-of-00008.safetensors", "model.layers.18.kda.norm.weight": "model-00004-of-00008.safetensors", "model.layers.18.kda.out_proj.weight": "model-00004-of-00008.safetensors", "model.layers.18.mlp.experts.down_proj": "model-00004-of-00008.safetensors", "model.layers.18.mlp.experts.gate_up_proj": "model-00004-of-00008.safetensors", "model.layers.18.mlp.gate.weight": "model-00004-of-00008.safetensors", "model.layers.18.mlp.shared_expert.down_proj.weight": "model-00004-of-00008.safetensors", "model.layers.18.mlp.shared_expert.gate_proj.weight": "model-00004-of-00008.safetensors", "model.layers.18.mlp.shared_expert.up_proj.weight": "model-00004-of-00008.safetensors", "model.layers.18.mlp.shared_expert_gate.weight": "model-00004-of-00008.safetensors", "model.layers.18.post_attention_layernorm.weight": "model-00004-of-00008.safetensors", "model.layers.19.attn_res.gate": "model-00004-of-00008.safetensors", "model.layers.19.attn_res.pseudo_query": "model-00004-of-00008.safetensors", "model.layers.19.input_layernorm.weight": "model-00004-of-00008.safetensors", "model.layers.19.mlp.experts.down_proj": "model-00004-of-00008.safetensors", "model.layers.19.mlp.experts.gate_up_proj": "model-00004-of-00008.safetensors", "model.layers.19.mlp.gate.weight": "model-00004-of-00008.safetensors", "model.layers.19.mlp.shared_expert.down_proj.weight": "model-00004-of-00008.safetensors", "model.layers.19.mlp.shared_expert.gate_proj.weight": "model-00004-of-00008.safetensors", "model.layers.19.mlp.shared_expert.up_proj.weight": "model-00004-of-00008.safetensors", "model.layers.19.mlp.shared_expert_gate.weight": "model-00004-of-00008.safetensors", "model.layers.19.post_attention_layernorm.weight": "model-00004-of-00008.safetensors", "model.layers.19.self_attn.k_norm.weight": "model-00004-of-00008.safetensors", "model.layers.19.self_attn.k_proj.weight": "model-00004-of-00008.safetensors", "model.layers.19.self_attn.o_proj.weight": "model-00004-of-00008.safetensors", "model.layers.19.self_attn.q_norm.weight": "model-00004-of-00008.safetensors", "model.layers.19.self_attn.q_proj.weight": "model-00004-of-00008.safetensors", "model.layers.19.self_attn.v_proj.weight": "model-00004-of-00008.safetensors", "model.layers.2.attn_res.gate": "model-00001-of-00008.safetensors", "model.layers.2.attn_res.pseudo_query": "model-00001-of-00008.safetensors", "model.layers.2.input_layernorm.weight": "model-00001-of-00008.safetensors", "model.layers.2.kda.A_log": "model-00001-of-00008.safetensors", "model.layers.2.kda.conv1d.weight": "model-00001-of-00008.safetensors", "model.layers.2.kda.dt_bias": "model-00001-of-00008.safetensors", "model.layers.2.kda.f_down_proj.weight": "model-00001-of-00008.safetensors", "model.layers.2.kda.f_up_proj.weight": "model-00001-of-00008.safetensors", "model.layers.2.kda.in_proj_b.weight": "model-00001-of-00008.safetensors", "model.layers.2.kda.in_proj_qkv.weight": "model-00001-of-00008.safetensors", "model.layers.2.kda.in_proj_z.weight": "model-00001-of-00008.safetensors", "model.layers.2.kda.norm.weight": "model-00001-of-00008.safetensors", "model.layers.2.kda.out_proj.weight": "model-00001-of-00008.safetensors", "model.layers.2.mlp.experts.down_proj": "model-00001-of-00008.safetensors", "model.layers.2.mlp.experts.gate_up_proj": "model-00001-of-00008.safetensors", "model.layers.2.mlp.gate.weight": "model-00001-of-00008.safetensors", "model.layers.2.mlp.shared_expert.down_proj.weight": "model-00001-of-00008.safetensors", "model.layers.2.mlp.shared_expert.gate_proj.weight": "model-00001-of-00008.safetensors", "model.layers.2.mlp.shared_expert.up_proj.weight": "model-00001-of-00008.safetensors", "model.layers.2.mlp.shared_expert_gate.weight": "model-00001-of-00008.safetensors", "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00008.safetensors", "model.layers.20.attn_res.gate": "model-00004-of-00008.safetensors", "model.layers.20.attn_res.pseudo_query": "model-00004-of-00008.safetensors", "model.layers.20.input_layernorm.weight": "model-00004-of-00008.safetensors", "model.layers.20.kda.A_log": "model-00004-of-00008.safetensors", "model.layers.20.kda.conv1d.weight": "model-00004-of-00008.safetensors", "model.layers.20.kda.dt_bias": "model-00004-of-00008.safetensors", "model.layers.20.kda.f_down_proj.weight": "model-00004-of-00008.safetensors", "model.layers.20.kda.f_up_proj.weight": "model-00004-of-00008.safetensors", "model.layers.20.kda.in_proj_b.weight": "model-00004-of-00008.safetensors", "model.layers.20.kda.in_proj_qkv.weight": "model-00004-of-00008.safetensors", "model.layers.20.kda.in_proj_z.weight": "model-00004-of-00008.safetensors", "model.layers.20.kda.norm.weight": "model-00004-of-00008.safetensors", "model.layers.20.kda.out_proj.weight": "model-00004-of-00008.safetensors", "model.layers.20.mlp.experts.down_proj": "model-00004-of-00008.safetensors", "model.layers.20.mlp.experts.gate_up_proj": "model-00005-of-00008.safetensors", "model.layers.20.mlp.gate.weight": "model-00005-of-00008.safetensors", "model.layers.20.mlp.shared_expert.down_proj.weight": "model-00005-of-00008.safetensors", "model.layers.20.mlp.shared_expert.gate_proj.weight": "model-00005-of-00008.safetensors", "model.layers.20.mlp.shared_expert.up_proj.weight": "model-00005-of-00008.safetensors", "model.layers.20.mlp.shared_expert_gate.weight": "model-00005-of-00008.safetensors", "model.layers.20.post_attention_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.21.attn_res.gate": "model-00005-of-00008.safetensors", "model.layers.21.attn_res.pseudo_query": "model-00005-of-00008.safetensors", "model.layers.21.input_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.21.kda.A_log": "model-00005-of-00008.safetensors", "model.layers.21.kda.conv1d.weight": "model-00005-of-00008.safetensors", "model.layers.21.kda.dt_bias": "model-00005-of-00008.safetensors", "model.layers.21.kda.f_down_proj.weight": "model-00005-of-00008.safetensors", "model.layers.21.kda.f_up_proj.weight": "model-00005-of-00008.safetensors", "model.layers.21.kda.in_proj_b.weight": "model-00005-of-00008.safetensors", "model.layers.21.kda.in_proj_qkv.weight": "model-00005-of-00008.safetensors", "model.layers.21.kda.in_proj_z.weight": "model-00005-of-00008.safetensors", "model.layers.21.kda.norm.weight": "model-00005-of-00008.safetensors", "model.layers.21.kda.out_proj.weight": "model-00005-of-00008.safetensors", "model.layers.21.mlp.experts.down_proj": "model-00005-of-00008.safetensors", "model.layers.21.mlp.experts.gate_up_proj": "model-00005-of-00008.safetensors", "model.layers.21.mlp.gate.weight": "model-00005-of-00008.safetensors", "model.layers.21.mlp.shared_expert.down_proj.weight": "model-00005-of-00008.safetensors", "model.layers.21.mlp.shared_expert.gate_proj.weight": "model-00005-of-00008.safetensors", "model.layers.21.mlp.shared_expert.up_proj.weight": "model-00005-of-00008.safetensors", "model.layers.21.mlp.shared_expert_gate.weight": "model-00005-of-00008.safetensors", "model.layers.21.post_attention_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.22.attn_res.gate": "model-00005-of-00008.safetensors", "model.layers.22.attn_res.pseudo_query": "model-00005-of-00008.safetensors", "model.layers.22.input_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.22.kda.A_log": "model-00005-of-00008.safetensors", "model.layers.22.kda.conv1d.weight": "model-00005-of-00008.safetensors", "model.layers.22.kda.dt_bias": "model-00005-of-00008.safetensors", "model.layers.22.kda.f_down_proj.weight": "model-00005-of-00008.safetensors", "model.layers.22.kda.f_up_proj.weight": "model-00005-of-00008.safetensors", "model.layers.22.kda.in_proj_b.weight": "model-00005-of-00008.safetensors", "model.layers.22.kda.in_proj_qkv.weight": "model-00005-of-00008.safetensors", "model.layers.22.kda.in_proj_z.weight": "model-00005-of-00008.safetensors", "model.layers.22.kda.norm.weight": "model-00005-of-00008.safetensors", "model.layers.22.kda.out_proj.weight": "model-00005-of-00008.safetensors", "model.layers.22.mlp.experts.down_proj": "model-00005-of-00008.safetensors", "model.layers.22.mlp.experts.gate_up_proj": "model-00005-of-00008.safetensors", "model.layers.22.mlp.gate.weight": "model-00005-of-00008.safetensors", "model.layers.22.mlp.shared_expert.down_proj.weight": "model-00005-of-00008.safetensors", "model.layers.22.mlp.shared_expert.gate_proj.weight": "model-00005-of-00008.safetensors", "model.layers.22.mlp.shared_expert.up_proj.weight": "model-00005-of-00008.safetensors", "model.layers.22.mlp.shared_expert_gate.weight": "model-00005-of-00008.safetensors", "model.layers.22.post_attention_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.23.attn_res.gate": "model-00005-of-00008.safetensors", "model.layers.23.attn_res.pseudo_query": "model-00005-of-00008.safetensors", "model.layers.23.input_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.23.mlp.experts.down_proj": "model-00005-of-00008.safetensors", "model.layers.23.mlp.experts.gate_up_proj": "model-00005-of-00008.safetensors", "model.layers.23.mlp.gate.weight": "model-00005-of-00008.safetensors", "model.layers.23.mlp.shared_expert.down_proj.weight": "model-00005-of-00008.safetensors", "model.layers.23.mlp.shared_expert.gate_proj.weight": "model-00005-of-00008.safetensors", "model.layers.23.mlp.shared_expert.up_proj.weight": "model-00005-of-00008.safetensors", "model.layers.23.mlp.shared_expert_gate.weight": "model-00005-of-00008.safetensors", "model.layers.23.post_attention_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.23.self_attn.k_norm.weight": "model-00005-of-00008.safetensors", "model.layers.23.self_attn.k_proj.weight": "model-00005-of-00008.safetensors", "model.layers.23.self_attn.o_proj.weight": "model-00005-of-00008.safetensors", "model.layers.23.self_attn.q_norm.weight": "model-00005-of-00008.safetensors", "model.layers.23.self_attn.q_proj.weight": "model-00005-of-00008.safetensors", "model.layers.23.self_attn.v_proj.weight": "model-00005-of-00008.safetensors", "model.layers.24.attn_res.gate": "model-00005-of-00008.safetensors", "model.layers.24.attn_res.pseudo_query": "model-00005-of-00008.safetensors", "model.layers.24.input_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.24.kda.A_log": "model-00005-of-00008.safetensors", "model.layers.24.kda.conv1d.weight": "model-00005-of-00008.safetensors", "model.layers.24.kda.dt_bias": "model-00005-of-00008.safetensors", "model.layers.24.kda.f_down_proj.weight": "model-00005-of-00008.safetensors", "model.layers.24.kda.f_up_proj.weight": "model-00005-of-00008.safetensors", "model.layers.24.kda.in_proj_b.weight": "model-00005-of-00008.safetensors", "model.layers.24.kda.in_proj_qkv.weight": "model-00005-of-00008.safetensors", "model.layers.24.kda.in_proj_z.weight": "model-00005-of-00008.safetensors", "model.layers.24.kda.norm.weight": "model-00005-of-00008.safetensors", "model.layers.24.kda.out_proj.weight": "model-00005-of-00008.safetensors", "model.layers.24.mlp.experts.down_proj": "model-00005-of-00008.safetensors", "model.layers.24.mlp.experts.gate_up_proj": "model-00005-of-00008.safetensors", "model.layers.24.mlp.gate.weight": "model-00005-of-00008.safetensors", "model.layers.24.mlp.shared_expert.down_proj.weight": "model-00005-of-00008.safetensors", "model.layers.24.mlp.shared_expert.gate_proj.weight": "model-00005-of-00008.safetensors", "model.layers.24.mlp.shared_expert.up_proj.weight": "model-00005-of-00008.safetensors", "model.layers.24.mlp.shared_expert_gate.weight": "model-00005-of-00008.safetensors", "model.layers.24.post_attention_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.25.attn_res.gate": "model-00005-of-00008.safetensors", "model.layers.25.attn_res.pseudo_query": "model-00005-of-00008.safetensors", "model.layers.25.input_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.25.kda.A_log": "model-00005-of-00008.safetensors", "model.layers.25.kda.conv1d.weight": "model-00005-of-00008.safetensors", "model.layers.25.kda.dt_bias": "model-00005-of-00008.safetensors", "model.layers.25.kda.f_down_proj.weight": "model-00005-of-00008.safetensors", "model.layers.25.kda.f_up_proj.weight": "model-00005-of-00008.safetensors", "model.layers.25.kda.in_proj_b.weight": "model-00005-of-00008.safetensors", "model.layers.25.kda.in_proj_qkv.weight": "model-00005-of-00008.safetensors", "model.layers.25.kda.in_proj_z.weight": "model-00005-of-00008.safetensors", "model.layers.25.kda.norm.weight": "model-00005-of-00008.safetensors", "model.layers.25.kda.out_proj.weight": "model-00005-of-00008.safetensors", "model.layers.25.mlp.experts.down_proj": "model-00005-of-00008.safetensors", "model.layers.25.mlp.experts.gate_up_proj": "model-00005-of-00008.safetensors", "model.layers.25.mlp.gate.weight": "model-00005-of-00008.safetensors", "model.layers.25.mlp.shared_expert.down_proj.weight": "model-00005-of-00008.safetensors", "model.layers.25.mlp.shared_expert.gate_proj.weight": "model-00005-of-00008.safetensors", "model.layers.25.mlp.shared_expert.up_proj.weight": "model-00005-of-00008.safetensors", "model.layers.25.mlp.shared_expert_gate.weight": "model-00005-of-00008.safetensors", "model.layers.25.post_attention_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.26.attn_res.gate": "model-00005-of-00008.safetensors", "model.layers.26.attn_res.pseudo_query": "model-00005-of-00008.safetensors", "model.layers.26.input_layernorm.weight": "model-00005-of-00008.safetensors", "model.layers.26.kda.A_log": "model-00005-of-00008.safetensors", "model.layers.26.kda.conv1d.weight": "model-00005-of-00008.safetensors", "model.layers.26.kda.dt_bias": "model-00005-of-00008.safetensors", "model.layers.26.kda.f_down_proj.weight": "model-00005-of-00008.safetensors", "model.layers.26.kda.f_up_proj.weight": "model-00005-of-00008.safetensors", "model.layers.26.kda.in_proj_b.weight": "model-00005-of-00008.safetensors", "model.layers.26.kda.in_proj_qkv.weight": "model-00005-of-00008.safetensors", "model.layers.26.kda.in_proj_z.weight": "model-00005-of-00008.safetensors", "model.layers.26.kda.norm.weight": "model-00005-of-00008.safetensors", "model.layers.26.kda.out_proj.weight": "model-00006-of-00008.safetensors", "model.layers.26.mlp.experts.down_proj": "model-00006-of-00008.safetensors", "model.layers.26.mlp.experts.gate_up_proj": "model-00006-of-00008.safetensors", "model.layers.26.mlp.gate.weight": "model-00006-of-00008.safetensors", "model.layers.26.mlp.shared_expert.down_proj.weight": "model-00006-of-00008.safetensors", "model.layers.26.mlp.shared_expert.gate_proj.weight": "model-00006-of-00008.safetensors", "model.layers.26.mlp.shared_expert.up_proj.weight": "model-00006-of-00008.safetensors", "model.layers.26.mlp.shared_expert_gate.weight": "model-00006-of-00008.safetensors", "model.layers.26.post_attention_layernorm.weight": "model-00006-of-00008.safetensors", "model.layers.27.attn_res.gate": "model-00006-of-00008.safetensors", "model.layers.27.attn_res.pseudo_query": "model-00006-of-00008.safetensors", "model.layers.27.input_layernorm.weight": "model-00006-of-00008.safetensors", "model.layers.27.mlp.experts.down_proj": "model-00006-of-00008.safetensors", "model.layers.27.mlp.experts.gate_up_proj": "model-00006-of-00008.safetensors", "model.layers.27.mlp.gate.weight": "model-00006-of-00008.safetensors", "model.layers.27.mlp.shared_expert.down_proj.weight": "model-00006-of-00008.safetensors", "model.layers.27.mlp.shared_expert.gate_proj.weight": "model-00006-of-00008.safetensors", "model.layers.27.mlp.shared_expert.up_proj.weight": "model-00006-of-00008.safetensors", "model.layers.27.mlp.shared_expert_gate.weight": "model-00006-of-00008.safetensors", "model.layers.27.post_attention_layernorm.weight": "model-00006-of-00008.safetensors", "model.layers.27.self_attn.k_norm.weight": "model-00006-of-00008.safetensors", "model.layers.27.self_attn.k_proj.weight": "model-00006-of-00008.safetensors", "model.layers.27.self_attn.o_proj.weight": "model-00006-of-00008.safetensors", "model.layers.27.self_attn.q_norm.weight": "model-00006-of-00008.safetensors", "model.layers.27.self_attn.q_proj.weight": "model-00006-of-00008.safetensors", "model.layers.27.self_attn.v_proj.weight": "model-00006-of-00008.safetensors", "model.layers.28.attn_res.gate": "model-00006-of-00008.safetensors", "model.layers.28.attn_res.pseudo_query": "model-00006-of-00008.safetensors", "model.layers.28.input_layernorm.weight": "model-00006-of-00008.safetensors", "model.layers.28.kda.A_log": "model-00006-of-00008.safetensors", "model.layers.28.kda.conv1d.weight": "model-00006-of-00008.safetensors", "model.layers.28.kda.dt_bias": "model-00006-of-00008.safetensors", "model.layers.28.kda.f_down_proj.weight": "model-00006-of-00008.safetensors", "model.layers.28.kda.f_up_proj.weight": "model-00006-of-00008.safetensors", "model.layers.28.kda.in_proj_b.weight": "model-00006-of-00008.safetensors", "model.layers.28.kda.in_proj_qkv.weight": "model-00006-of-00008.safetensors", "model.layers.28.kda.in_proj_z.weight": "model-00006-of-00008.safetensors", "model.layers.28.kda.norm.weight": "model-00006-of-00008.safetensors", "model.layers.28.kda.out_proj.weight": "model-00006-of-00008.safetensors", "model.layers.28.mlp.experts.down_proj": "model-00006-of-00008.safetensors", "model.layers.28.mlp.experts.gate_up_proj": "model-00006-of-00008.safetensors", "model.layers.28.mlp.gate.weight": "model-00006-of-00008.safetensors", "model.layers.28.mlp.shared_expert.down_proj.weight": "model-00006-of-00008.safetensors", "model.layers.28.mlp.shared_expert.gate_proj.weight": "model-00006-of-00008.safetensors", "model.layers.28.mlp.shared_expert.up_proj.weight": "model-00006-of-00008.safetensors", "model.layers.28.mlp.shared_expert_gate.weight": "model-00006-of-00008.safetensors", "model.layers.28.post_attention_layernorm.weight": "model-00006-of-00008.safetensors", "model.layers.29.attn_res.gate": "model-00006-of-00008.safetensors", "model.layers.29.attn_res.pseudo_query": "model-00006-of-00008.safetensors", "model.layers.29.input_layernorm.weight": "model-00006-of-00008.safetensors", "model.layers.29.kda.A_log": "model-00006-of-00008.safetensors", "model.layers.29.kda.conv1d.weight": "model-00006-of-00008.safetensors", "model.layers.29.kda.dt_bias": "model-00006-of-00008.safetensors", "model.layers.29.kda.f_down_proj.weight": "model-00006-of-00008.safetensors", "model.layers.29.kda.f_up_proj.weight": "model-00006-of-00008.safetensors", "model.layers.29.kda.in_proj_b.weight": "model-00006-of-00008.safetensors", "model.layers.29.kda.in_proj_qkv.weight": "model-00006-of-00008.safetensors", "model.layers.29.kda.in_proj_z.weight": "model-00006-of-00008.safetensors", "model.layers.29.kda.norm.weight": "model-00006-of-00008.safetensors", "model.layers.29.kda.out_proj.weight": "model-00006-of-00008.safetensors", "model.layers.29.mlp.experts.down_proj": "model-00006-of-00008.safetensors", "model.layers.29.mlp.experts.gate_up_proj": "model-00006-of-00008.safetensors", "model.layers.29.mlp.gate.weight": "model-00006-of-00008.safetensors", "model.layers.29.mlp.shared_expert.down_proj.weight": "model-00006-of-00008.safetensors", "model.layers.29.mlp.shared_expert.gate_proj.weight": "model-00006-of-00008.safetensors", "model.layers.29.mlp.shared_expert.up_proj.weight": "model-00006-of-00008.safetensors", "model.layers.29.mlp.shared_expert_gate.weight": "model-00006-of-00008.safetensors", "model.layers.29.post_attention_layernorm.weight": "model-00006-of-00008.safetensors", "model.layers.3.attn_res.gate": "model-00001-of-00008.safetensors", "model.layers.3.attn_res.pseudo_query": "model-00001-of-00008.safetensors", "model.layers.3.input_layernorm.weight": "model-00001-of-00008.safetensors", "model.layers.3.mlp.experts.down_proj": "model-00001-of-00008.safetensors", "model.layers.3.mlp.experts.gate_up_proj": "model-00001-of-00008.safetensors", "model.layers.3.mlp.gate.weight": "model-00001-of-00008.safetensors", "model.layers.3.mlp.shared_expert.down_proj.weight": "model-00001-of-00008.safetensors", "model.layers.3.mlp.shared_expert.gate_proj.weight": "model-00001-of-00008.safetensors", "model.layers.3.mlp.shared_expert.up_proj.weight": "model-00001-of-00008.safetensors", "model.layers.3.mlp.shared_expert_gate.weight": "model-00001-of-00008.safetensors", "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00008.safetensors", "model.layers.3.self_attn.k_norm.weight": "model-00001-of-00008.safetensors", "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00008.safetensors", "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00008.safetensors", "model.layers.3.self_attn.q_norm.weight": "model-00001-of-00008.safetensors", "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00008.safetensors", "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00008.safetensors", "model.layers.30.attn_res.gate": "model-00006-of-00008.safetensors", "model.layers.30.attn_res.pseudo_query": "model-00006-of-00008.safetensors", "model.layers.30.input_layernorm.weight": "model-00006-of-00008.safetensors", "model.layers.30.kda.A_log": "model-00006-of-00008.safetensors", "model.layers.30.kda.conv1d.weight": "model-00006-of-00008.safetensors", "model.layers.30.kda.dt_bias": "model-00006-of-00008.safetensors", "model.layers.30.kda.f_down_proj.weight": "model-00006-of-00008.safetensors", "model.layers.30.kda.f_up_proj.weight": "model-00006-of-00008.safetensors", "model.layers.30.kda.in_proj_b.weight": "model-00006-of-00008.safetensors", "model.layers.30.kda.in_proj_qkv.weight": "model-00006-of-00008.safetensors", "model.layers.30.kda.in_proj_z.weight": "model-00006-of-00008.safetensors", "model.layers.30.kda.norm.weight": "model-00006-of-00008.safetensors", "model.layers.30.kda.out_proj.weight": "model-00006-of-00008.safetensors", "model.layers.30.mlp.experts.down_proj": "model-00006-of-00008.safetensors", "model.layers.30.mlp.experts.gate_up_proj": "model-00006-of-00008.safetensors", "model.layers.30.mlp.gate.weight": "model-00006-of-00008.safetensors", "model.layers.30.mlp.shared_expert.down_proj.weight": "model-00006-of-00008.safetensors", "model.layers.30.mlp.shared_expert.gate_proj.weight": "model-00006-of-00008.safetensors", "model.layers.30.mlp.shared_expert.up_proj.weight": "model-00006-of-00008.safetensors", "model.layers.30.mlp.shared_expert_gate.weight": "model-00006-of-00008.safetensors", "model.layers.30.post_attention_layernorm.weight": "model-00006-of-00008.safetensors", "model.layers.31.attn_res.gate": "model-00006-of-00008.safetensors", "model.layers.31.attn_res.pseudo_query": "model-00006-of-00008.safetensors", "model.layers.31.input_layernorm.weight": "model-00006-of-00008.safetensors", "model.layers.31.mlp.experts.down_proj": "model-00006-of-00008.safetensors", "model.layers.31.mlp.experts.gate_up_proj": "model-00007-of-00008.safetensors", "model.layers.31.mlp.gate.weight": "model-00007-of-00008.safetensors", "model.layers.31.mlp.shared_expert.down_proj.weight": "model-00007-of-00008.safetensors", "model.layers.31.mlp.shared_expert.gate_proj.weight": "model-00007-of-00008.safetensors", "model.layers.31.mlp.shared_expert.up_proj.weight": "model-00007-of-00008.safetensors", "model.layers.31.mlp.shared_expert_gate.weight": "model-00007-of-00008.safetensors", "model.layers.31.post_attention_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.31.self_attn.k_norm.weight": "model-00007-of-00008.safetensors", "model.layers.31.self_attn.k_proj.weight": "model-00007-of-00008.safetensors", "model.layers.31.self_attn.o_proj.weight": "model-00007-of-00008.safetensors", "model.layers.31.self_attn.q_norm.weight": "model-00007-of-00008.safetensors", "model.layers.31.self_attn.q_proj.weight": "model-00007-of-00008.safetensors", "model.layers.31.self_attn.v_proj.weight": "model-00007-of-00008.safetensors", "model.layers.32.attn_res.gate": "model-00007-of-00008.safetensors", "model.layers.32.attn_res.pseudo_query": "model-00007-of-00008.safetensors", "model.layers.32.input_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.32.kda.A_log": "model-00007-of-00008.safetensors", "model.layers.32.kda.conv1d.weight": "model-00007-of-00008.safetensors", "model.layers.32.kda.dt_bias": "model-00007-of-00008.safetensors", "model.layers.32.kda.f_down_proj.weight": "model-00007-of-00008.safetensors", "model.layers.32.kda.f_up_proj.weight": "model-00007-of-00008.safetensors", "model.layers.32.kda.in_proj_b.weight": "model-00007-of-00008.safetensors", "model.layers.32.kda.in_proj_qkv.weight": "model-00007-of-00008.safetensors", "model.layers.32.kda.in_proj_z.weight": "model-00007-of-00008.safetensors", "model.layers.32.kda.norm.weight": "model-00007-of-00008.safetensors", "model.layers.32.kda.out_proj.weight": "model-00007-of-00008.safetensors", "model.layers.32.mlp.experts.down_proj": "model-00007-of-00008.safetensors", "model.layers.32.mlp.experts.gate_up_proj": "model-00007-of-00008.safetensors", "model.layers.32.mlp.gate.weight": "model-00007-of-00008.safetensors", "model.layers.32.mlp.shared_expert.down_proj.weight": "model-00007-of-00008.safetensors", "model.layers.32.mlp.shared_expert.gate_proj.weight": "model-00007-of-00008.safetensors", "model.layers.32.mlp.shared_expert.up_proj.weight": "model-00007-of-00008.safetensors", "model.layers.32.mlp.shared_expert_gate.weight": "model-00007-of-00008.safetensors", "model.layers.32.post_attention_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.33.attn_res.gate": "model-00007-of-00008.safetensors", "model.layers.33.attn_res.pseudo_query": "model-00007-of-00008.safetensors", "model.layers.33.input_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.33.kda.A_log": "model-00007-of-00008.safetensors", "model.layers.33.kda.conv1d.weight": "model-00007-of-00008.safetensors", "model.layers.33.kda.dt_bias": "model-00007-of-00008.safetensors", "model.layers.33.kda.f_down_proj.weight": "model-00007-of-00008.safetensors", "model.layers.33.kda.f_up_proj.weight": "model-00007-of-00008.safetensors", "model.layers.33.kda.in_proj_b.weight": "model-00007-of-00008.safetensors", "model.layers.33.kda.in_proj_qkv.weight": "model-00007-of-00008.safetensors", "model.layers.33.kda.in_proj_z.weight": "model-00007-of-00008.safetensors", "model.layers.33.kda.norm.weight": "model-00007-of-00008.safetensors", "model.layers.33.kda.out_proj.weight": "model-00007-of-00008.safetensors", "model.layers.33.mlp.experts.down_proj": "model-00007-of-00008.safetensors", "model.layers.33.mlp.experts.gate_up_proj": "model-00007-of-00008.safetensors", "model.layers.33.mlp.gate.weight": "model-00007-of-00008.safetensors", "model.layers.33.mlp.shared_expert.down_proj.weight": "model-00007-of-00008.safetensors", "model.layers.33.mlp.shared_expert.gate_proj.weight": "model-00007-of-00008.safetensors", "model.layers.33.mlp.shared_expert.up_proj.weight": "model-00007-of-00008.safetensors", "model.layers.33.mlp.shared_expert_gate.weight": "model-00007-of-00008.safetensors", "model.layers.33.post_attention_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.34.attn_res.gate": "model-00007-of-00008.safetensors", "model.layers.34.attn_res.pseudo_query": "model-00007-of-00008.safetensors", "model.layers.34.input_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.34.kda.A_log": "model-00007-of-00008.safetensors", "model.layers.34.kda.conv1d.weight": "model-00007-of-00008.safetensors", "model.layers.34.kda.dt_bias": "model-00007-of-00008.safetensors", "model.layers.34.kda.f_down_proj.weight": "model-00007-of-00008.safetensors", "model.layers.34.kda.f_up_proj.weight": "model-00007-of-00008.safetensors", "model.layers.34.kda.in_proj_b.weight": "model-00007-of-00008.safetensors", "model.layers.34.kda.in_proj_qkv.weight": "model-00007-of-00008.safetensors", "model.layers.34.kda.in_proj_z.weight": "model-00007-of-00008.safetensors", "model.layers.34.kda.norm.weight": "model-00007-of-00008.safetensors", "model.layers.34.kda.out_proj.weight": "model-00007-of-00008.safetensors", "model.layers.34.mlp.experts.down_proj": "model-00007-of-00008.safetensors", "model.layers.34.mlp.experts.gate_up_proj": "model-00007-of-00008.safetensors", "model.layers.34.mlp.gate.weight": "model-00007-of-00008.safetensors", "model.layers.34.mlp.shared_expert.down_proj.weight": "model-00007-of-00008.safetensors", "model.layers.34.mlp.shared_expert.gate_proj.weight": "model-00007-of-00008.safetensors", "model.layers.34.mlp.shared_expert.up_proj.weight": "model-00007-of-00008.safetensors", "model.layers.34.mlp.shared_expert_gate.weight": "model-00007-of-00008.safetensors", "model.layers.34.post_attention_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.35.attn_res.gate": "model-00007-of-00008.safetensors", "model.layers.35.attn_res.pseudo_query": "model-00007-of-00008.safetensors", "model.layers.35.input_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.35.mlp.experts.down_proj": "model-00007-of-00008.safetensors", "model.layers.35.mlp.experts.gate_up_proj": "model-00007-of-00008.safetensors", "model.layers.35.mlp.gate.weight": "model-00007-of-00008.safetensors", "model.layers.35.mlp.shared_expert.down_proj.weight": "model-00007-of-00008.safetensors", "model.layers.35.mlp.shared_expert.gate_proj.weight": "model-00007-of-00008.safetensors", "model.layers.35.mlp.shared_expert.up_proj.weight": "model-00007-of-00008.safetensors", "model.layers.35.mlp.shared_expert_gate.weight": "model-00007-of-00008.safetensors", "model.layers.35.post_attention_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.35.self_attn.k_norm.weight": "model-00007-of-00008.safetensors", "model.layers.35.self_attn.k_proj.weight": "model-00007-of-00008.safetensors", "model.layers.35.self_attn.o_proj.weight": "model-00007-of-00008.safetensors", "model.layers.35.self_attn.q_norm.weight": "model-00007-of-00008.safetensors", "model.layers.35.self_attn.q_proj.weight": "model-00007-of-00008.safetensors", "model.layers.35.self_attn.v_proj.weight": "model-00007-of-00008.safetensors", "model.layers.36.attn_res.gate": "model-00007-of-00008.safetensors", "model.layers.36.attn_res.pseudo_query": "model-00007-of-00008.safetensors", "model.layers.36.input_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.36.kda.A_log": "model-00007-of-00008.safetensors", "model.layers.36.kda.conv1d.weight": "model-00007-of-00008.safetensors", "model.layers.36.kda.dt_bias": "model-00007-of-00008.safetensors", "model.layers.36.kda.f_down_proj.weight": "model-00007-of-00008.safetensors", "model.layers.36.kda.f_up_proj.weight": "model-00007-of-00008.safetensors", "model.layers.36.kda.in_proj_b.weight": "model-00007-of-00008.safetensors", "model.layers.36.kda.in_proj_qkv.weight": "model-00007-of-00008.safetensors", "model.layers.36.kda.in_proj_z.weight": "model-00007-of-00008.safetensors", "model.layers.36.kda.norm.weight": "model-00007-of-00008.safetensors", "model.layers.36.kda.out_proj.weight": "model-00007-of-00008.safetensors", "model.layers.36.mlp.experts.down_proj": "model-00007-of-00008.safetensors", "model.layers.36.mlp.experts.gate_up_proj": "model-00007-of-00008.safetensors", "model.layers.36.mlp.gate.weight": "model-00007-of-00008.safetensors", "model.layers.36.mlp.shared_expert.down_proj.weight": "model-00007-of-00008.safetensors", "model.layers.36.mlp.shared_expert.gate_proj.weight": "model-00007-of-00008.safetensors", "model.layers.36.mlp.shared_expert.up_proj.weight": "model-00007-of-00008.safetensors", "model.layers.36.mlp.shared_expert_gate.weight": "model-00007-of-00008.safetensors", "model.layers.36.post_attention_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.37.attn_res.gate": "model-00007-of-00008.safetensors", "model.layers.37.attn_res.pseudo_query": "model-00007-of-00008.safetensors", "model.layers.37.input_layernorm.weight": "model-00007-of-00008.safetensors", "model.layers.37.kda.A_log": "model-00007-of-00008.safetensors", "model.layers.37.kda.conv1d.weight": "model-00007-of-00008.safetensors", "model.layers.37.kda.dt_bias": "model-00007-of-00008.safetensors", "model.layers.37.kda.f_down_proj.weight": "model-00007-of-00008.safetensors", "model.layers.37.kda.f_up_proj.weight": "model-00007-of-00008.safetensors", "model.layers.37.kda.in_proj_b.weight": "model-00007-of-00008.safetensors", "model.layers.37.kda.in_proj_qkv.weight": "model-00008-of-00008.safetensors", "model.layers.37.kda.in_proj_z.weight": "model-00008-of-00008.safetensors", "model.layers.37.kda.norm.weight": "model-00008-of-00008.safetensors", "model.layers.37.kda.out_proj.weight": "model-00008-of-00008.safetensors", "model.layers.37.mlp.experts.down_proj": "model-00008-of-00008.safetensors", "model.layers.37.mlp.experts.gate_up_proj": "model-00008-of-00008.safetensors", "model.layers.37.mlp.gate.weight": "model-00008-of-00008.safetensors", "model.layers.37.mlp.shared_expert.down_proj.weight": "model-00008-of-00008.safetensors", "model.layers.37.mlp.shared_expert.gate_proj.weight": "model-00008-of-00008.safetensors", "model.layers.37.mlp.shared_expert.up_proj.weight": "model-00008-of-00008.safetensors", "model.layers.37.mlp.shared_expert_gate.weight": "model-00008-of-00008.safetensors", "model.layers.37.post_attention_layernorm.weight": "model-00008-of-00008.safetensors", "model.layers.38.attn_res.gate": "model-00008-of-00008.safetensors", "model.layers.38.attn_res.pseudo_query": "model-00008-of-00008.safetensors", "model.layers.38.input_layernorm.weight": "model-00008-of-00008.safetensors", "model.layers.38.kda.A_log": "model-00008-of-00008.safetensors", "model.layers.38.kda.conv1d.weight": "model-00008-of-00008.safetensors", "model.layers.38.kda.dt_bias": "model-00008-of-00008.safetensors", "model.layers.38.kda.f_down_proj.weight": "model-00008-of-00008.safetensors", "model.layers.38.kda.f_up_proj.weight": "model-00008-of-00008.safetensors", "model.layers.38.kda.in_proj_b.weight": "model-00008-of-00008.safetensors", "model.layers.38.kda.in_proj_qkv.weight": "model-00008-of-00008.safetensors", "model.layers.38.kda.in_proj_z.weight": "model-00008-of-00008.safetensors", "model.layers.38.kda.norm.weight": "model-00008-of-00008.safetensors", "model.layers.38.kda.out_proj.weight": "model-00008-of-00008.safetensors", "model.layers.38.mlp.experts.down_proj": "model-00008-of-00008.safetensors", "model.layers.38.mlp.experts.gate_up_proj": "model-00008-of-00008.safetensors", "model.layers.38.mlp.gate.weight": "model-00008-of-00008.safetensors", "model.layers.38.mlp.shared_expert.down_proj.weight": "model-00008-of-00008.safetensors", "model.layers.38.mlp.shared_expert.gate_proj.weight": "model-00008-of-00008.safetensors", "model.layers.38.mlp.shared_expert.up_proj.weight": "model-00008-of-00008.safetensors", "model.layers.38.mlp.shared_expert_gate.weight": "model-00008-of-00008.safetensors", "model.layers.38.post_attention_layernorm.weight": "model-00008-of-00008.safetensors", "model.layers.39.attn_res.gate": "model-00008-of-00008.safetensors", "model.layers.39.attn_res.pseudo_query": "model-00008-of-00008.safetensors", "model.layers.39.input_layernorm.weight": "model-00008-of-00008.safetensors", "model.layers.39.mlp.experts.down_proj": "model-00008-of-00008.safetensors", "model.layers.39.mlp.experts.gate_up_proj": "model-00008-of-00008.safetensors", "model.layers.39.mlp.gate.weight": "model-00008-of-00008.safetensors", "model.layers.39.mlp.shared_expert.down_proj.weight": "model-00008-of-00008.safetensors", "model.layers.39.mlp.shared_expert.gate_proj.weight": "model-00008-of-00008.safetensors", "model.layers.39.mlp.shared_expert.up_proj.weight": "model-00008-of-00008.safetensors", "model.layers.39.mlp.shared_expert_gate.weight": "model-00008-of-00008.safetensors", "model.layers.39.post_attention_layernorm.weight": "model-00008-of-00008.safetensors", "model.layers.39.self_attn.k_norm.weight": "model-00008-of-00008.safetensors", "model.layers.39.self_attn.k_proj.weight": "model-00008-of-00008.safetensors", "model.layers.39.self_attn.o_proj.weight": "model-00008-of-00008.safetensors", "model.layers.39.self_attn.q_norm.weight": "model-00008-of-00008.safetensors", "model.layers.39.self_attn.q_proj.weight": "model-00008-of-00008.safetensors", "model.layers.39.self_attn.v_proj.weight": "model-00008-of-00008.safetensors", "model.layers.4.attn_res.gate": "model-00001-of-00008.safetensors", "model.layers.4.attn_res.pseudo_query": "model-00001-of-00008.safetensors", "model.layers.4.input_layernorm.weight": "model-00001-of-00008.safetensors", "model.layers.4.kda.A_log": "model-00001-of-00008.safetensors", "model.layers.4.kda.conv1d.weight": "model-00001-of-00008.safetensors", "model.layers.4.kda.dt_bias": "model-00001-of-00008.safetensors", "model.layers.4.kda.f_down_proj.weight": "model-00001-of-00008.safetensors", "model.layers.4.kda.f_up_proj.weight": "model-00001-of-00008.safetensors", "model.layers.4.kda.in_proj_b.weight": "model-00001-of-00008.safetensors", "model.layers.4.kda.in_proj_qkv.weight": "model-00002-of-00008.safetensors", "model.layers.4.kda.in_proj_z.weight": "model-00002-of-00008.safetensors", "model.layers.4.kda.norm.weight": "model-00002-of-00008.safetensors", "model.layers.4.kda.out_proj.weight": "model-00002-of-00008.safetensors", "model.layers.4.mlp.experts.down_proj": "model-00002-of-00008.safetensors", "model.layers.4.mlp.experts.gate_up_proj": "model-00002-of-00008.safetensors", "model.layers.4.mlp.gate.weight": "model-00002-of-00008.safetensors", "model.layers.4.mlp.shared_expert.down_proj.weight": "model-00002-of-00008.safetensors", "model.layers.4.mlp.shared_expert.gate_proj.weight": "model-00002-of-00008.safetensors", "model.layers.4.mlp.shared_expert.up_proj.weight": "model-00002-of-00008.safetensors", "model.layers.4.mlp.shared_expert_gate.weight": "model-00002-of-00008.safetensors", "model.layers.4.post_attention_layernorm.weight": "model-00002-of-00008.safetensors", "model.layers.5.attn_res.gate": "model-00002-of-00008.safetensors", "model.layers.5.attn_res.pseudo_query": "model-00002-of-00008.safetensors", "model.layers.5.input_layernorm.weight": "model-00002-of-00008.safetensors", "model.layers.5.kda.A_log": "model-00002-of-00008.safetensors", "model.layers.5.kda.conv1d.weight": "model-00002-of-00008.safetensors", "model.layers.5.kda.dt_bias": "model-00002-of-00008.safetensors", "model.layers.5.kda.f_down_proj.weight": "model-00002-of-00008.safetensors", "model.layers.5.kda.f_up_proj.weight": "model-00002-of-00008.safetensors", "model.layers.5.kda.in_proj_b.weight": "model-00002-of-00008.safetensors", "model.layers.5.kda.in_proj_qkv.weight": "model-00002-of-00008.safetensors", "model.layers.5.kda.in_proj_z.weight": "model-00002-of-00008.safetensors", "model.layers.5.kda.norm.weight": "model-00002-of-00008.safetensors", "model.layers.5.kda.out_proj.weight": "model-00002-of-00008.safetensors", "model.layers.5.mlp.experts.down_proj": "model-00002-of-00008.safetensors", "model.layers.5.mlp.experts.gate_up_proj": "model-00002-of-00008.safetensors", "model.layers.5.mlp.gate.weight": "model-00002-of-00008.safetensors", "model.layers.5.mlp.shared_expert.down_proj.weight": "model-00002-of-00008.safetensors", "model.layers.5.mlp.shared_expert.gate_proj.weight": "model-00002-of-00008.safetensors", "model.layers.5.mlp.shared_expert.up_proj.weight": "model-00002-of-00008.safetensors", "model.layers.5.mlp.shared_expert_gate.weight": "model-00002-of-00008.safetensors", "model.layers.5.post_attention_layernorm.weight": "model-00002-of-00008.safetensors", "model.layers.6.attn_res.gate": "model-00002-of-00008.safetensors", "model.layers.6.attn_res.pseudo_query": "model-00002-of-00008.safetensors", "model.layers.6.input_layernorm.weight": "model-00002-of-00008.safetensors", "model.layers.6.kda.A_log": "model-00002-of-00008.safetensors", "model.layers.6.kda.conv1d.weight": "model-00002-of-00008.safetensors", "model.layers.6.kda.dt_bias": "model-00002-of-00008.safetensors", "model.layers.6.kda.f_down_proj.weight": "model-00002-of-00008.safetensors", "model.layers.6.kda.f_up_proj.weight": "model-00002-of-00008.safetensors", "model.layers.6.kda.in_proj_b.weight": "model-00002-of-00008.safetensors", "model.layers.6.kda.in_proj_qkv.weight": "model-00002-of-00008.safetensors", "model.layers.6.kda.in_proj_z.weight": "model-00002-of-00008.safetensors", "model.layers.6.kda.norm.weight": "model-00002-of-00008.safetensors", "model.layers.6.kda.out_proj.weight": "model-00002-of-00008.safetensors", "model.layers.6.mlp.experts.down_proj": "model-00002-of-00008.safetensors", "model.layers.6.mlp.experts.gate_up_proj": "model-00002-of-00008.safetensors", "model.layers.6.mlp.gate.weight": "model-00002-of-00008.safetensors", "model.layers.6.mlp.shared_expert.down_proj.weight": "model-00002-of-00008.safetensors", "model.layers.6.mlp.shared_expert.gate_proj.weight": "model-00002-of-00008.safetensors", "model.layers.6.mlp.shared_expert.up_proj.weight": "model-00002-of-00008.safetensors", "model.layers.6.mlp.shared_expert_gate.weight": "model-00002-of-00008.safetensors", "model.layers.6.post_attention_layernorm.weight": "model-00002-of-00008.safetensors", "model.layers.7.attn_res.gate": "model-00002-of-00008.safetensors", "model.layers.7.attn_res.pseudo_query": "model-00002-of-00008.safetensors", "model.layers.7.input_layernorm.weight": "model-00002-of-00008.safetensors", "model.layers.7.mlp.experts.down_proj": "model-00002-of-00008.safetensors", "model.layers.7.mlp.experts.gate_up_proj": "model-00002-of-00008.safetensors", "model.layers.7.mlp.gate.weight": "model-00002-of-00008.safetensors", "model.layers.7.mlp.shared_expert.down_proj.weight": "model-00002-of-00008.safetensors", "model.layers.7.mlp.shared_expert.gate_proj.weight": "model-00002-of-00008.safetensors", "model.layers.7.mlp.shared_expert.up_proj.weight": "model-00002-of-00008.safetensors", "model.layers.7.mlp.shared_expert_gate.weight": "model-00002-of-00008.safetensors", "model.layers.7.post_attention_layernorm.weight": "model-00002-of-00008.safetensors", "model.layers.7.self_attn.k_norm.weight": "model-00002-of-00008.safetensors", "model.layers.7.self_attn.k_proj.weight": "model-00002-of-00008.safetensors", "model.layers.7.self_attn.o_proj.weight": "model-00002-of-00008.safetensors", "model.layers.7.self_attn.q_norm.weight": "model-00002-of-00008.safetensors", "model.layers.7.self_attn.q_proj.weight": "model-00002-of-00008.safetensors", "model.layers.7.self_attn.v_proj.weight": "model-00002-of-00008.safetensors", "model.layers.8.attn_res.gate": "model-00002-of-00008.safetensors", "model.layers.8.attn_res.pseudo_query": "model-00002-of-00008.safetensors", "model.layers.8.input_layernorm.weight": "model-00002-of-00008.safetensors", "model.layers.8.kda.A_log": "model-00002-of-00008.safetensors", "model.layers.8.kda.conv1d.weight": "model-00002-of-00008.safetensors", "model.layers.8.kda.dt_bias": "model-00002-of-00008.safetensors", "model.layers.8.kda.f_down_proj.weight": "model-00002-of-00008.safetensors", "model.layers.8.kda.f_up_proj.weight": "model-00002-of-00008.safetensors", "model.layers.8.kda.in_proj_b.weight": "model-00002-of-00008.safetensors", "model.layers.8.kda.in_proj_qkv.weight": "model-00002-of-00008.safetensors", "model.layers.8.kda.in_proj_z.weight": "model-00002-of-00008.safetensors", "model.layers.8.kda.norm.weight": "model-00002-of-00008.safetensors", "model.layers.8.kda.out_proj.weight": "model-00002-of-00008.safetensors", "model.layers.8.mlp.experts.down_proj": "model-00002-of-00008.safetensors", "model.layers.8.mlp.experts.gate_up_proj": "model-00002-of-00008.safetensors", "model.layers.8.mlp.gate.weight": "model-00002-of-00008.safetensors", "model.layers.8.mlp.shared_expert.down_proj.weight": "model-00002-of-00008.safetensors", "model.layers.8.mlp.shared_expert.gate_proj.weight": "model-00002-of-00008.safetensors", "model.layers.8.mlp.shared_expert.up_proj.weight": "model-00002-of-00008.safetensors", "model.layers.8.mlp.shared_expert_gate.weight": "model-00002-of-00008.safetensors", "model.layers.8.post_attention_layernorm.weight": "model-00002-of-00008.safetensors", "model.layers.9.attn_res.gate": "model-00002-of-00008.safetensors", "model.layers.9.attn_res.pseudo_query": "model-00002-of-00008.safetensors", "model.layers.9.input_layernorm.weight": "model-00002-of-00008.safetensors", "model.layers.9.kda.A_log": "model-00002-of-00008.safetensors", "model.layers.9.kda.conv1d.weight": "model-00002-of-00008.safetensors", "model.layers.9.kda.dt_bias": "model-00002-of-00008.safetensors", "model.layers.9.kda.f_down_proj.weight": "model-00002-of-00008.safetensors", "model.layers.9.kda.f_up_proj.weight": "model-00002-of-00008.safetensors", "model.layers.9.kda.in_proj_b.weight": "model-00002-of-00008.safetensors", "model.layers.9.kda.in_proj_qkv.weight": "model-00002-of-00008.safetensors", "model.layers.9.kda.in_proj_z.weight": "model-00002-of-00008.safetensors", "model.layers.9.kda.norm.weight": "model-00002-of-00008.safetensors", "model.layers.9.kda.out_proj.weight": "model-00002-of-00008.safetensors", "model.layers.9.mlp.experts.down_proj": "model-00002-of-00008.safetensors", "model.layers.9.mlp.experts.gate_up_proj": "model-00003-of-00008.safetensors", "model.layers.9.mlp.gate.weight": "model-00003-of-00008.safetensors", "model.layers.9.mlp.shared_expert.down_proj.weight": "model-00003-of-00008.safetensors", "model.layers.9.mlp.shared_expert.gate_proj.weight": "model-00003-of-00008.safetensors", "model.layers.9.mlp.shared_expert.up_proj.weight": "model-00003-of-00008.safetensors", "model.layers.9.mlp.shared_expert_gate.weight": "model-00003-of-00008.safetensors", "model.layers.9.post_attention_layernorm.weight": "model-00003-of-00008.safetensors", "model.norm.weight": "model-00008-of-00008.safetensors" }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149# coding=utf-8# Copyright 2026 The RWB AI Assist team and The HuggingFace Inc. team. All rights reserved.## Licensed under the Apache License, Version 2.0 (the "License"); you may not use this# file except in compliance with the License. You may obtain a copy of the License at# http://www.apache.org/licenses/LICENSE-2.0# Unless required by applicable law or agreed to in writing, software distributed under# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY# KIND, either express or implied. See the License for the specific language governing# permissions and limitations under the License."""BerryLM-OS modeling — self-contained transformers implementation.
Architecture: hybrid decoder(3 linear-attention + 1 full-attention layers per macro-block) with a sparse MoE FFN(routed + shared expert), **Gated Block AttnRes** in front of every layer and **KDAforget gates** on the linear-attention layers. See ``BerryLMAttnRes`` / ``BerryLMKDA``."""
import mathfrom collections.abc import Callable
import torchimport torch.nn.functional as Ffrom torch import nn
from transformers import initialization as initfrom transformers.activations import ACT2FNfrom transformers.cache_utils import Cache, DynamicCachefrom transformers.generation import GenerationMixinfrom transformers.integrations import ( use_experts_implementation, use_kernel_forward_from_hub, use_kernel_func_from_hub_with_fallback, use_kernelized_func,)from transformers.integrations.accelerate import force_accelerate_hooksfrom transformers.masking_utils import create_causal_mask, create_recurrent_attention_maskfrom transformers.modeling_flash_attention_utils import FlashAttentionKwargsfrom transformers.modeling_layers import GradientCheckpointingLayerfrom transformers.modeling_outputs import MoeCausalLMOutputWithPast, MoeModelOutputWithPastfrom transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_updatefrom transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModelfrom transformers.processing_utils import Unpackfrom transformers.utils import TransformersKwargs, auto_docstring, can_return_tuplefrom transformers.utils.deprecation import deprecate_kwargfrom transformers.utils.generic import maybe_autocast, merge_with_config_defaultsfrom transformers.utils.output_capturing import OutputRecorder, capture_outputs
try: from .configuration_berrylm import BerryLMConfigexcept ImportError: # pragma: no cover from configuration_berrylm import BerryLMConfig
class BerryLMRotaryEmbedding(nn.Module): @deprecate_kwarg("device", version="5.18") def __init__(self, config: BerryLMConfig, device=None): super().__init__() self.max_seq_len_cached = config.max_position_embeddings self.original_max_seq_len = config.max_position_embeddings
self.config = config
self.rope_type = self.config.rope_parameters["rope_type"] rope_init_fn: Callable = self.compute_default_rope_parameters if self.rope_type != "default": rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type] inv_freq, self.attention_scaling = rope_init_fn(self.config, device)
self.inv_freq = nn.Buffer(inv_freq, persistent=False) self.original_inv_freq = nn.Buffer(inv_freq.clone(), persistent=False)
@staticmethod @deprecate_kwarg("device", version="5.18") def compute_default_rope_parameters(config: BerryLMConfig, device=None, **kwargs) -> tuple[torch.Tensor, float]: """ Computes the inverse frequencies according to the original RoPE implementation Args: config ([`~transformers.PreTrainedConfig`]): The model configuration. Returns: Tuple of (`torch.Tensor`, `float`), containing the inverse frequencies for the RoPE embeddings and the post-processing scaling factor applied to the computed cos/sin (unused in this type of RoPE). """ base = config.rope_parameters["rope_theta"] partial_rotary_factor = config.rope_parameters.get("partial_rotary_factor", 1.0) head_dim = getattr(config, "head_dim", None) or config.hidden_size // config.num_attention_heads dim = int(head_dim * partial_rotary_factor)
attention_factor = 1.0 # Unused in this type of RoPE # Compute the inverse frequencies inv_freq = 1.0 / (base ** (torch.arange(0, dim, 2, dtype=torch.float) / dim)) return inv_freq.to(device), attention_factor
@torch.no_grad() @dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope) def forward(self, x, position_ids): inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device) position_ids_expanded = position_ids[:, None, :].float()
device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu" with maybe_autocast(device_type=device_type, enabled=False): # Force float32 freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2) emb = torch.cat((freqs, freqs), dim=-1) cos = emb.cos() * self.attention_scaling sin = emb.sin() * self.attention_scaling
return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
@use_kernel_forward_from_hub("RMSNormGated")class BerryLMRMSNormGated(nn.Module): def __init__(self, hidden_size: int, eps: float = 1e-6, **kwargs) -> None: super().__init__() self.weight = nn.Parameter(torch.ones(hidden_size)) self.variance_epsilon = eps self.activation = "silu"
def forward(self, hidden_states: torch.Tensor, gate: torch.Tensor) -> torch.Tensor: input_dtype = hidden_states.dtype hidden_states = hidden_states.to(torch.float32) variance = hidden_states.pow(2).mean(-1, keepdim=True) # Norm before gate hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon) hidden_states = self.weight * hidden_states.to(input_dtype) hidden_states = hidden_states * ACT2FN[self.activation](gate.to(torch.float32))
return hidden_states.to(input_dtype)
def apply_mask_to_padding_states(hidden_states, attention_mask): """ Tunes out the hidden states for padding tokens, see https://github.com/state-spaces/mamba/issues/66 """ # NOTE: attention mask is a 2D boolean tensor if attention_mask is not None: dtype = hidden_states.dtype hidden_states = (hidden_states * attention_mask[:, :, None]).to(dtype)
return hidden_states
@use_kernel_func_from_hub_with_fallback("causal_conv1d_update", "causal_conv1d")def causal_conv1d_update( hidden_states: torch.Tensor, conv_state: torch.Tensor, weight: nn.Parameter, bias: nn.Parameter | None = None, activation: str | None = None,): _, hidden_size, seq_len = hidden_states.shape state_len = conv_state.shape[-1]
hidden_states_new = torch.cat([conv_state, hidden_states], dim=-1).to(weight.dtype) conv_state.copy_(hidden_states_new[:, :, -state_len:]) out = F.conv1d(hidden_states_new, weight.unsqueeze(1), bias, padding=0, groups=hidden_size) out = out[:, :, -seq_len:] if activation is not None: out = ACT2FN[activation](out) return out.to(hidden_states.dtype)
@use_kernel_func_from_hub_with_fallback("causal_conv1d_fn", "causal_conv1d")def causal_conv1d_fn( hidden_states: torch.Tensor, weight: nn.Parameter, bias: nn.Parameter | None = None, activation: str | None = None, **kwargs,): _, hidden_size, seq_len = hidden_states.shape padding = weight.shape[-1] - 1
out = F.conv1d( hidden_states.to(weight.dtype), weight=weight.unsqueeze(1), bias=bias, padding=padding, groups=hidden_size, )[:, :, :seq_len] if activation is not None: out = ACT2FN[activation](out) return out.to(hidden_states.dtype)
def l2norm(x: torch.FloatTensor, dim: int = -1, eps: float = 1e-6): """This function is intended to align with the l2norm implementation in the FLA library.""" inv_norm = torch.rsqrt((x * x).sum(dim=dim, keepdim=True) + eps) return x * inv_norm
def rotate_half(x): """Rotates half the hidden dims of the input.""" x1 = x[..., : x.shape[-1] // 2] x2 = x[..., x.shape[-1] // 2 :] return torch.cat((-x2, x1), dim=-1)
def apply_rotary_pos_emb(q, k, cos, sin, unsqueeze_dim=1): """Applies Rotary Position Embedding to the query and key tensors.
Removes the interleaving of cos and sin from GLM
Args: q (`torch.Tensor`): The query tensor. k (`torch.Tensor`): The key tensor. cos (`torch.Tensor`): The cosine part of the rotary embedding. sin (`torch.Tensor`): The sine part of the rotary embedding. unsqueeze_dim (`int`, *optional*, defaults to 1): The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2. Returns: `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding. """ cos = cos.unsqueeze(unsqueeze_dim) sin = sin.unsqueeze(unsqueeze_dim)
# Keep half or full tensor for later concatenation rotary_dim = cos.shape[-1] q_rot, q_pass = q[..., :rotary_dim], q[..., rotary_dim:] k_rot, k_pass = k[..., :rotary_dim], k[..., rotary_dim:]
# Apply rotary embeddings on the first half or full tensor q_embed = (q_rot * cos) + (rotate_half(q_rot) * sin) k_embed = (k_rot * cos) + (rotate_half(k_rot) * sin)
# Concatenate back to full shape q_embed = torch.cat([q_embed, q_pass], dim=-1) k_embed = torch.cat([k_embed, k_pass], dim=-1) return q_embed, k_embed
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor: """ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch, num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim) """ batch, num_key_value_heads, slen, head_dim = hidden_states.shape if n_rep == 1: return hidden_states hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim) return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
def eager_attention_forward( module: nn.Module, query: torch.Tensor, key: torch.Tensor, value: torch.Tensor, attention_mask: torch.Tensor | None, scaling: float, dropout: float = 0.0, **kwargs: Unpack[TransformersKwargs],): key_states = repeat_kv(key, module.num_key_value_groups) value_states = repeat_kv(value, module.num_key_value_groups)
attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling if attention_mask is not None: attn_weights = attn_weights + attention_mask
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype) attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training) attn_output = torch.matmul(attn_weights, value_states) attn_output = attn_output.transpose(1, 2).contiguous()
return attn_output, attn_weights
class BerryLMAttention(nn.Module): """Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config: BerryLMConfig, layer_idx: int): super().__init__() self.config = config self.layer_idx = layer_idx self.head_dim = getattr(config, "head_dim", config.hidden_size // config.num_attention_heads) self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads self.scaling = self.head_dim**-0.5 self.attention_dropout = config.attention_dropout self.is_causal = True # With the output gate on, the query projection also emits the per-channel sigmoid gate (doubled width). self.attn_output_gate = config.attn_output_gate self.q_proj = nn.Linear( config.hidden_size, config.num_attention_heads * self.head_dim * (2 if self.attn_output_gate else 1), bias=config.attention_bias, ) self.k_proj = nn.Linear( config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias ) self.v_proj = nn.Linear( config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias ) self.o_proj = nn.Linear( config.num_attention_heads * self.head_dim, config.hidden_size, bias=config.attention_bias ) self.q_norm = BerryLMRMSNorm(self.head_dim, eps=config.rms_norm_eps) # unlike olmo, only on the head dim! self.k_norm = BerryLMRMSNorm(self.head_dim, eps=config.rms_norm_eps) # thus post q_norm does not need reshape
def forward( self, hidden_states: torch.Tensor, position_embeddings: tuple[torch.Tensor, torch.Tensor], attention_mask: torch.Tensor | None, past_key_values: Cache | None = None, **kwargs: Unpack[FlashAttentionKwargs], ) -> tuple[torch.Tensor, torch.Tensor | None]: input_shape = hidden_states.shape[:-1] hidden_shape = (*input_shape, -1, self.head_dim)
query_states = self.q_proj(hidden_states) gate = None if self.attn_output_gate: query_states, gate = torch.chunk(query_states.view(*input_shape, -1, self.head_dim * 2), 2, dim=-1) gate = gate.reshape(*input_shape, -1)
query_states = self.q_norm(query_states.view(hidden_shape)).transpose(1, 2) key_states = self.k_norm(self.k_proj(hidden_states).view(hidden_shape)).transpose(1, 2) value_states = self.v_proj(hidden_states).view(hidden_shape).transpose(1, 2)
cos, sin = position_embeddings query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
if past_key_values is not None: key_states, value_states = past_key_values.update(key_states, value_states, self.layer_idx)
attention_interface: Callable = ALL_ATTENTION_FUNCTIONS.get_interface( self.config._attn_implementation, eager_attention_forward )
attn_output, attn_weights = attention_interface( self, query_states, key_states, value_states, attention_mask, dropout=0.0 if not self.training else self.attention_dropout, scaling=self.scaling, **kwargs, )
attn_output = attn_output.reshape(*input_shape, -1).contiguous() if gate is not None: attn_output = attn_output * torch.sigmoid(gate)
attn_output = self.o_proj(attn_output) return attn_output, attn_weights
class BerryLMMLP(nn.Module): """The shared expert of the sparse MoE block: a dense gated MLP of `shared_expert_intermediate_size`."""
def __init__(self, config: BerryLMConfig): super().__init__() self.config = config self.hidden_size = config.hidden_size self.intermediate_size = config.shared_expert_intermediate_size self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False) self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False) self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False) self.act_fn = ACT2FN[config.hidden_act]
def forward(self, x): down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x)) return down_proj
@use_experts_implementationclass BerryLMExperts(nn.Module): """Collection of expert weights stored as 3D tensors."""
def __init__(self, config): super().__init__() self.num_experts = config.num_experts self.hidden_dim = config.hidden_size self.intermediate_dim = config.moe_intermediate_size self.gate_up_proj = nn.Parameter(torch.empty(self.num_experts, 2 * self.intermediate_dim, self.hidden_dim)) self.down_proj = nn.Parameter(torch.empty(self.num_experts, self.hidden_dim, self.intermediate_dim)) self.act_fn = ACT2FN[config.hidden_act]
def forward( self, hidden_states: torch.Tensor, top_k_index: torch.Tensor, top_k_weights: torch.Tensor, ) -> torch.Tensor: final_hidden_states = torch.zeros_like(hidden_states) with torch.no_grad(): expert_mask = torch.nn.functional.one_hot(top_k_index, num_classes=self.num_experts + 1) expert_mask = expert_mask.permute(2, 1, 0) expert_hit = torch.greater(expert_mask.sum(dim=(-1, -2)), 0).nonzero()
for expert_idx in expert_hit: expert_idx = expert_idx[0] if expert_idx == self.num_experts: continue top_k_pos, token_idx = torch.where(expert_mask[expert_idx]) current_state = hidden_states[token_idx] gate, up = nn.functional.linear(current_state, self.gate_up_proj[expert_idx]).chunk(2, dim=-1) current_hidden_states = self.act_fn(gate) * up current_hidden_states = nn.functional.linear(current_hidden_states, self.down_proj[expert_idx]) current_hidden_states = current_hidden_states * top_k_weights[token_idx, top_k_pos, None] final_hidden_states.index_add_(0, token_idx, current_hidden_states.to(final_hidden_states.dtype))
return final_hidden_states
@use_kernel_forward_from_hub("SoftmaxTopKRouter")class BerryLMTopKRouter(nn.Module): def __init__(self, config): super().__init__() self.top_k = config.num_experts_per_tok self.num_experts = config.num_experts self.norm_topk_prob = config.norm_topk_prob self.hidden_dim = config.hidden_size self.weight = nn.Parameter(torch.zeros(self.num_experts, self.hidden_dim))
def forward(self, hidden_states): hidden_states = hidden_states.reshape(-1, self.hidden_dim) router_logits = F.linear(hidden_states, self.weight) # (seq_len, num_experts) router_probs = torch.nn.functional.softmax(router_logits, dtype=torch.float, dim=-1) router_top_value, router_indices = torch.topk(router_probs, self.top_k, dim=-1) # (seq_len, top_k) if self.norm_topk_prob: router_top_value /= router_top_value.sum(dim=-1, keepdim=True) router_top_value = router_top_value.to(router_logits.dtype) router_scores = router_top_value return router_logits, router_scores, router_indices
class BerryLMSparseMoeBlock(nn.Module): def __init__(self, config): super().__init__() self.gate = BerryLMTopKRouter(config) self.experts = BerryLMExperts(config) self.shared_expert = BerryLMMLP(config) self.shared_expert_gate = torch.nn.Linear(config.hidden_size, 1, bias=False)
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: batch_size, sequence_length, hidden_dim = hidden_states.shape hidden_states_reshaped = hidden_states.view(-1, hidden_dim) shared_expert_output = self.shared_expert(hidden_states_reshaped) _, routing_weights, selected_experts = self.gate(hidden_states_reshaped) expert_output = self.experts(hidden_states_reshaped, selected_experts, routing_weights)
shared_expert_output = F.sigmoid(self.shared_expert_gate(hidden_states_reshaped)) * shared_expert_output
expert_output = expert_output + shared_expert_output expert_output = expert_output.reshape(batch_size, sequence_length, hidden_dim) return expert_output
@use_kernel_forward_from_hub("RMSNormZeroCentered")class BerryLMRMSNorm(nn.Module): def __init__(self, dim: int, eps: float = 1e-6): super().__init__() self.eps = eps self.weight = nn.Parameter(torch.zeros(dim))
def _norm(self, x): return x * torch.rsqrt(x.pow(2).mean(-1, keepdim=True) + self.eps)
def forward(self, x): output = self._norm(x.float()) # Llama does x.to(float16) * w whilst BerryLM is (x * w).to(float16) # See https://github.com/huggingface/transformers/pull/29402 output = output * (1.0 + self.weight.float()) return output.type_as(x)
def extra_repr(self): return f"{tuple(self.weight.shape)}, eps={self.eps}"
def load_balancing_loss_func( gate_logits: torch.Tensor | tuple[torch.Tensor] | None, num_experts: int | None = None, top_k=2, attention_mask: torch.Tensor | None = None,) -> torch.Tensor | int: r""" Computes auxiliary load balancing loss as in Switch Transformer - implemented in Pytorch.
See Switch Transformer (https://huggingface.co/papers/2101.03961) for more details. This function implements the loss function presented in equations (4) - (6) of the paper. It aims at penalizing cases where the routing between experts is too unbalanced.
Args: gate_logits: Logits from the `gate`, should be a tuple of model.config.num_hidden_layers tensors of shape [batch_size X sequence_length, num_experts]. num_experts: Number of experts top_k: The number of experts to route per-token, can be also interpreted as the `top-k` routing parameter. attention_mask (`torch.Tensor`, *optional*): The attention_mask used in forward function shape [batch_size X sequence_length] if not None.
Returns: The auxiliary loss. """ if gate_logits is None or not isinstance(gate_logits, tuple): return 0
# Accumulate assignment counts and probability sums layer by layer, normalizing at the end, # so peak memory stays O(seq_len * num_experts) regardless of the number of layers. compute_device = gate_logits[0].device tokens_per_expert_sum = torch.zeros(num_experts, dtype=torch.float32, device=compute_device) router_prob_sum = torch.zeros(num_experts, dtype=torch.float32, device=compute_device) total_rows = 0.0
if attention_mask is not None: # The same flat mask applies to every layer's [batch_size * sequence_length] rows. flat_mask = attention_mask.reshape(-1).to(device=compute_device, dtype=torch.float32)
for layer_gate in gate_logits: routing_weights = torch.nn.functional.softmax(layer_gate.to(compute_device), dim=-1) _, selected_experts = torch.topk(routing_weights, top_k, dim=-1) if attention_mask is None: # Count of top-k assignments per expert tokens_per_expert_sum = ( tokens_per_expert_sum + torch.bincount(selected_experts.reshape(-1), minlength=num_experts).float() ) # Sum of routing probabilities per expert router_prob_sum = router_prob_sum + routing_weights.float().sum(dim=0) total_rows = total_rows + routing_weights.shape[0] else: # Same reductions, weighted by the attention mask to exclude padding tokens tokens_per_expert_sum = tokens_per_expert_sum + torch.zeros( num_experts, dtype=torch.float32, device=compute_device ).scatter_add_(0, selected_experts.reshape(-1), flat_mask.repeat_interleave(top_k)) router_prob_sum = router_prob_sum + (routing_weights.float() * flat_mask.unsqueeze(-1)).sum(dim=0) total_rows = total_rows + flat_mask.sum()
tokens_per_expert = tokens_per_expert_sum / total_rows router_prob_per_expert = router_prob_sum / total_rows
overall_loss = torch.sum(tokens_per_expert * router_prob_per_expert.unsqueeze(0)) return overall_loss * num_experts
# ======================================================================================# BerryLM additions# ======================================================================================class BerryLMAttnRes(nn.Module): """Gated Block AttnRes: depth mix of committed block residuals + current stream, gated toward identity. ``pseudo_query`` [hidden] (zero == uniform mean), ``gate`` scalar (zero == exact identity). Token-local, hence cache-transparent."""
def __init__(self, hidden_size: int, eps: float = 1e-6, gated: bool = True): super().__init__() self.hidden_size = hidden_size self.eps = eps self.pseudo_query = nn.Parameter(torch.zeros(hidden_size)) self.gate = nn.Parameter(torch.zeros(())) if gated else None
def forward(self, stream: torch.Tensor, block_streams: torch.Tensor) -> torch.Tensor: """`block_streams` [n_blocks, batch, seq, hidden]: the residual streams committed at the block boundaries so far (the embeddings first); `stream` is the current residual stream.""" stacked = torch.cat([block_streams, stream.unsqueeze(0)], dim=0).float() keys = F.rms_norm(stacked, (self.hidden_size,), None, self.eps) logits = torch.einsum("nbtd,d->nbt", keys, self.pseudo_query.float()) probs = logits.softmax(dim=0) mixed = (probs.unsqueeze(-1) * stacked).sum(dim=0).to(stream.dtype) if self.gate is None: return mixed scale = torch.tanh(self.gate.float()).to(stream.dtype) return stream + scale * (mixed - stream)
def _recurrent_kda_reference( query: torch.Tensor, key: torch.Tensor, value: torch.Tensor, g: torch.Tensor, beta: torch.Tensor, scale: float | None = None, initial_state: torch.Tensor | None = None, output_final_state: bool = False, use_qk_l2norm_in_kernel: bool = False, **kwargs,) -> tuple[torch.Tensor, torch.Tensor | None]: """Token-by-token KDA delta rule (reference implementation).
The gated delta rule (``S_t = S_{t-1} * exp(g_t) + k_t (beta_t (v_t - S_{t-1}^T k_t))^T``) with a **per-channel** log-decay: ``g`` has shape [batch_size, sequence_length, num_v_heads, k_head_dim] (entries <= 0) and multiplies the recurrent state along its key axis, instead of one scalar decay per head. Argument names follow ``fla.ops.kda.fused_recurrent_kda`` so the hub-kernels fallback decorator can dispatch to the Triton kernel when flash-linear-attention is installed.
Args: query / key: [batch_size, sequence_length, num_v_heads, k_head_dim] value: [batch_size, sequence_length, num_v_heads, v_head_dim] g: per-channel decay in log space, [batch_size, sequence_length, num_v_heads, k_head_dim] beta: [batch_size, sequence_length, num_v_heads] scale: query scaling, ``k_head_dim ** -0.5`` when None. initial_state: optional recurrent state [batch_size, num_v_heads, k_head_dim, v_head_dim] output_final_state: whether to return the new recurrent state. use_qk_l2norm_in_kernel: L2-normalize query and key first (fp32). Returns: the output [batch_size, sequence_length, num_v_heads, v_head_dim] and the new recurrent state (or None). """ initial_dtype = value.dtype batch_size, sequence_length, num_v_heads, k_head_dim = query.shape v_head_dim = value.shape[-1] if scale is None: scale = k_head_dim**-0.5 query, key, value, decay, beta = (x.float() for x in (query, key, value, g, beta)) if use_qk_l2norm_in_kernel: query, key = l2norm(query), l2norm(key) query = query * scale
last_recurrent_state = query.new_zeros(batch_size, num_v_heads, k_head_dim, v_head_dim) if initial_state is not None: last_recurrent_state = last_recurrent_state + initial_state.float() core_attn_out = torch.zeros_like(value) for t in range(sequence_length): q_t, k_t, v_t, decay_t, beta_t = query[:, t], key[:, t], value[:, t], decay[:, t], beta[:, t] # Per-channel decay of the recurrent state along the key axis last_recurrent_state = last_recurrent_state * decay_t.exp().unsqueeze(-1) # Delta rule: write only the part of the value the state does not predict yet kv_mem = (k_t.unsqueeze(-1) * last_recurrent_state).sum(dim=-2) delta = beta_t.unsqueeze(-1) * (v_t - kv_mem) last_recurrent_state = last_recurrent_state + k_t.unsqueeze(-1) * delta.unsqueeze(-2) core_attn_out[:, t] = (q_t.unsqueeze(-1) * last_recurrent_state).sum(dim=-2) last_recurrent_state = last_recurrent_state if output_final_state else None return core_attn_out.to(initial_dtype), last_recurrent_state
@use_kernel_func_from_hub_with_fallback("fused_recurrent_kda", "fla")def torch_recurrent_kda( query: torch.Tensor, key: torch.Tensor, value: torch.Tensor, g: torch.Tensor, beta: torch.Tensor, scale: float | None = None, initial_state: torch.Tensor | None = None, output_final_state: bool = False, use_qk_l2norm_in_kernel: bool = False, **kwargs,) -> tuple[torch.Tensor, torch.Tensor | None]: """``_recurrent_kda_reference`` behind the hub-kernels dispatch: the Triton kernel of flash-linear-attention when it is installed, the torch reference otherwise (same arguments and return value).""" return _recurrent_kda_reference( query, key, value, g, beta, scale=scale, initial_state=initial_state, output_final_state=output_final_state, use_qk_l2norm_in_kernel=use_qk_l2norm_in_kernel, **kwargs, )
@use_kernel_func_from_hub_with_fallback("chunk_kda", "fla")def torch_chunk_kda( query: torch.Tensor, key: torch.Tensor, value: torch.Tensor, g: torch.Tensor, beta: torch.Tensor, scale: float | None = None, initial_state: torch.Tensor | None = None, output_final_state: bool = False, use_qk_l2norm_in_kernel: bool = False, **kwargs,) -> tuple[torch.Tensor, torch.Tensor | None]: """Chunked KDA (reference): same args and return value as ``torch_recurrent_kda``. The torch path is the sequential recurrence — correct on any device but slow; ``fla.ops.kda.chunk_kda`` replaces it when flash-linear-attention is installed.""" return torch_recurrent_kda( query, key, value, g, beta, scale=scale, initial_state=initial_state, output_final_state=output_final_state, use_qk_l2norm_in_kernel=use_qk_l2norm_in_kernel, )
@use_kernelized_func([torch_recurrent_kda, torch_chunk_kda, causal_conv1d_fn, causal_conv1d_update])class BerryLMKDA(nn.Module): """Linear attention with a per-channel KDA forget gate: the gated delta-net projection layout (``in_proj_qkv`` / ``in_proj_z`` / ``in_proj_b``, short causal conv, gated RMS norm, ``out_proj``) with the per-head decay replaced by ``f_down_proj`` [bottleneck, hidden], ``f_up_proj`` [HV*K, bottleneck] and a channel-wise ``dt_bias`` [HV*K]: ``g = -exp(A_log)[h] * softplus(f_up(f_down(x))[h,k] + dt_bias[h,k])``."""
def __init__(self, config: BerryLMConfig, layer_idx: int): super().__init__() self.hidden_size = config.hidden_size self.num_v_heads = config.linear_num_value_heads self.num_k_heads = config.linear_num_key_heads self.head_k_dim = config.linear_key_head_dim self.head_v_dim = config.linear_value_head_dim self.key_dim = self.head_k_dim * self.num_k_heads self.value_dim = self.head_v_dim * self.num_v_heads
self.conv_kernel_size = config.linear_conv_kernel_dim self.layer_idx = layer_idx self.activation = config.hidden_act self.layer_norm_epsilon = config.rms_norm_eps
# QKV self.conv_dim = self.key_dim * 2 + self.value_dim self.conv1d = nn.Conv1d( in_channels=self.conv_dim, out_channels=self.conv_dim, bias=False, kernel_size=self.conv_kernel_size, groups=self.conv_dim, padding=self.conv_kernel_size - 1, )
self.in_proj_qkv = nn.Linear(self.hidden_size, self.key_dim * 2 + self.value_dim, bias=False) self.in_proj_z = nn.Linear(self.hidden_size, self.value_dim, bias=False) self.in_proj_b = nn.Linear(self.hidden_size, self.num_v_heads, bias=False)
# Per-channel forget gate: low-rank projection + channel bias, scaled by a per-head A_log # (both initialized in `_init_weights` of the pretrained model) self.gate_bottleneck = config.kda_gate_bottleneck self.safe_gate = config.kda_safe_gate self.gate_lower_bound = config.kda_gate_lower_bound self.gate_dim = self.num_v_heads * self.head_k_dim self.f_down_proj = nn.Linear(self.hidden_size, self.gate_bottleneck, bias=False) self.f_up_proj = nn.Linear(self.gate_bottleneck, self.gate_dim, bias=False) self.dt_bias = nn.Parameter(torch.zeros(self.gate_dim)) self.A_log = nn.Parameter(torch.zeros(self.num_v_heads))
self.norm = BerryLMRMSNormGated(self.head_v_dim, eps=self.layer_norm_epsilon) self.out_proj = nn.Linear(self.value_dim, self.hidden_size, bias=False)
def _forget_gate(self, hidden_states: torch.Tensor) -> torch.Tensor: raw = self.f_up_proj(self.f_down_proj(hidden_states)).float() raw = raw.view(*raw.shape[:-1], self.num_v_heads, self.head_k_dim) bias = self.dt_bias.float().view(self.num_v_heads, self.head_k_dim) g = -self.A_log.float().exp().unsqueeze(-1) * F.softplus(raw + bias) if self.safe_gate: g = torch.maximum(g, torch.full_like(g, float(self.gate_lower_bound))) return g
@force_accelerate_hooks("conv1d") def forward( self, hidden_states: torch.Tensor, cache_params: Cache | None = None, attention_mask: torch.Tensor | None = None, **kwargs, ): hidden_states = apply_mask_to_padding_states(hidden_states, attention_mask)
# Set up dimensions for reshapes later batch_size, seq_len, _ = hidden_states.shape use_precomputed_states = cache_params is not None and cache_params.has_previous_state( self.layer_idx, state_idx=0 )
mixed_qkv = self.in_proj_qkv(hidden_states) mixed_qkv = mixed_qkv.transpose(1, 2)
z = self.in_proj_z(hidden_states) z = z.reshape(batch_size, seq_len, -1, self.head_v_dim)
beta = self.in_proj_b(hidden_states).float().sigmoid() g = self._forget_gate(hidden_states)
if use_precomputed_states and seq_len == 1 and not cache_params.layers[self.layer_idx].record_past: conv_state = cache_params.layers[self.layer_idx].conv_states[0] # Single-token cached decode: the fused per-step kernel updates the conv state in-place. mixed_qkv = causal_conv1d_update( mixed_qkv, conv_state, self.conv1d.weight.squeeze(1), self.conv1d.bias, self.activation, ) else: if cache_params is not None: mixed_qkv = cache_params.update_conv_state( mixed_qkv, self.layer_idx, conv_kernel_size=self.conv_kernel_size )
mixed_qkv = causal_conv1d_fn( mixed_qkv, self.conv1d.weight.squeeze(1), self.conv1d.bias, activation=self.activation, **kwargs, )
# Drop the additional previous states if cache_params is not None: mixed_qkv = mixed_qkv[:, :, -seq_len:]
mixed_qkv = mixed_qkv.transpose(1, 2) query, key, value = torch.split(mixed_qkv, [self.key_dim, self.key_dim, self.value_dim], dim=-1)
query = query.reshape(batch_size, seq_len, -1, self.head_k_dim) key = key.reshape(batch_size, seq_len, -1, self.head_k_dim) value = value.reshape(batch_size, seq_len, -1, self.head_v_dim)
if self.num_v_heads // self.num_k_heads > 1: query = query.repeat_interleave(self.num_v_heads // self.num_k_heads, dim=2) key = key.repeat_interleave(self.num_v_heads // self.num_k_heads, dim=2)
recurrent_state = cache_params.layers[self.layer_idx].recurrent_states[0] if use_precomputed_states else None kda_kwargs = { "g": g, "beta": beta, "initial_state": recurrent_state, "output_final_state": cache_params is not None, "use_qk_l2norm_in_kernel": True, "cu_seqlens": kwargs.pop("cu_seq_lens_q", None), } if use_precomputed_states and seq_len == 1: # flash-linear-attention's recurrent kernel is `torch.compiler.disable`d (a graph break under fullgraph # compilation); under torch.compile the single-token step runs the torch reference instead. recurrent_kda = _recurrent_kda_reference if torch.compiler.is_compiling() else torch_recurrent_kda core_attn_out, last_recurrent_state = recurrent_kda(query, key, value, **kda_kwargs, **kwargs) else: core_attn_out, last_recurrent_state = torch_chunk_kda(query, key, value, **kda_kwargs, **kwargs)
# Update cache if cache_params is not None: cache_params.update_recurrent_state(last_recurrent_state, self.layer_idx)
# reshape input data into 2D tensor core_attn_out = core_attn_out.reshape(-1, self.head_v_dim) z = z.reshape(-1, self.head_v_dim) core_attn_out = self.norm(core_attn_out, z) core_attn_out = core_attn_out.reshape(batch_size, seq_len, -1)
output = self.out_proj(core_attn_out) return output
class BerryLMDecoderLayer(GradientCheckpointingLayer): def __init__(self, config: BerryLMConfig, layer_idx: int): super().__init__() self.hidden_size = config.hidden_size self.block_type = config.layer_types[layer_idx] if self.block_type == "linear_attention": self.kda = BerryLMKDA(config, layer_idx) elif self.block_type == "full_attention": self.self_attn = BerryLMAttention(config, layer_idx) self.mlp = BerryLMSparseMoeBlock(config) self.input_layernorm = BerryLMRMSNorm(config.hidden_size, eps=config.rms_norm_eps) self.post_attention_layernorm = BerryLMRMSNorm(config.hidden_size, eps=config.rms_norm_eps) # Gated Block AttnRes in front of the layer; the model owns the committed block residuals it reads. self.attn_res = None # CODEPATH: BerryLM-OS (attn_res_block_size=8) builds the mixer; 0 is the plain residual stream (ablations). if config.attn_res_block_size > 0: self.attn_res = BerryLMAttnRes(config.hidden_size, config.attn_res_eps, config.attn_res_gated)
def forward( self, hidden_states: torch.Tensor, block_streams: torch.Tensor | None = None, position_embeddings: tuple[torch.Tensor, torch.Tensor] | None = None, attention_mask: torch.Tensor | None = None, position_ids: torch.LongTensor | None = None, past_key_values: Cache | None = None, **kwargs: Unpack[FlashAttentionKwargs], ) -> torch.FloatTensor: # `block_streams` is a positional tensor on purpose: gradient checkpointing (reentrant included) then treats # the committed streams as inputs of the checkpointed call rather than as closure constants. if self.attn_res is not None: hidden_states = self.attn_res(hidden_states, block_streams) residual = hidden_states
hidden_states = self.input_layernorm(hidden_states)
# Token Mixer if self.block_type == "linear_attention": hidden_states = self.kda( hidden_states=hidden_states, cache_params=past_key_values, attention_mask=attention_mask, **kwargs, ) elif self.block_type == "full_attention": # Self Attention hidden_states, _ = self.self_attn( hidden_states=hidden_states, attention_mask=attention_mask, position_ids=position_ids, past_key_values=past_key_values, position_embeddings=position_embeddings, **kwargs, )
hidden_states = residual + hidden_states
# Fully Connected residual = hidden_states hidden_states = self.post_attention_layernorm(hidden_states) hidden_states = self.mlp(hidden_states) # For the MoE layers, we need to unpack if isinstance(hidden_states, tuple): hidden_states, _ = hidden_states hidden_states = residual + hidden_states
return hidden_states
@auto_docstringclass BerryLMPreTrainedModel(PreTrainedModel): config: BerryLMConfig base_model_prefix = "model" supports_gradient_checkpointing = True _no_split_modules = ["BerryLMDecoderLayer"] _skip_keys_device_placement = ["past_key_values"] _supports_flash_attn = True _supports_sdpa = True _can_record_outputs = { "router_logits": OutputRecorder(BerryLMTopKRouter, index=0), "hidden_states": BerryLMDecoderLayer, "attentions": BerryLMAttention, } _is_stateful = True # The depth stack of the AttnRes mixer has not been validated under fullgraph compilation yet. _can_compile_fullgraph = True
@torch.no_grad() def _init_weights(self, module): super()._init_weights(module) if isinstance(module, BerryLMAttnRes): init.zeros_(module.pseudo_query) if module.gate is not None: init.zeros_(module.gate) elif isinstance(module, BerryLMKDA): init.copy_(module.A_log, torch.empty_like(module.A_log, dtype=torch.float32).uniform_(1, 16).log_()) dt = torch.exp( torch.rand_like(module.dt_bias, dtype=torch.float32) * (math.log(0.1) - math.log(1e-3)) + math.log(1e-3) ) init.copy_(module.dt_bias, dt + torch.log(-torch.expm1(-dt))) # We initialize with 0s to be 1 centered as the RMSNorm here does (1 + weight) elif isinstance(module, BerryLMRMSNorm): init.zeros_(module.weight) elif isinstance(module, BerryLMExperts): init.normal_(module.gate_up_proj, mean=0.0, std=self.config.initializer_range) init.normal_(module.down_proj, mean=0.0, std=self.config.initializer_range) elif isinstance(module, BerryLMSparseMoeBlock): init.normal_(module.gate.weight, mean=0.0, std=self.config.initializer_range)
@auto_docstringclass BerryLMModel(BerryLMPreTrainedModel): config: BerryLMConfig
def __init__(self, config: BerryLMConfig): super().__init__(config) self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, config.pad_token_id) self.layers = nn.ModuleList( [BerryLMDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)] ) self.norm = BerryLMRMSNorm(config.hidden_size, eps=config.rms_norm_eps) self.rotary_emb = BerryLMRotaryEmbedding(config=config) self.gradient_checkpointing = False # Initialize weights and apply final processing self.post_init()
@merge_with_config_defaults @capture_outputs @auto_docstring def forward( self, input_ids: torch.LongTensor | None = None, attention_mask: torch.Tensor | None = None, position_ids: torch.LongTensor | None = None, past_key_values: Cache | None = None, inputs_embeds: torch.FloatTensor | None = None, use_cache: bool | None = None, **kwargs: Unpack[TransformersKwargs], ) -> MoeModelOutputWithPast: if (input_ids is None) ^ (inputs_embeds is not None): raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
if inputs_embeds is None: inputs_embeds = self.embed_tokens(input_ids)
if use_cache and past_key_values is None: past_key_values = DynamicCache(config=self.config)
if position_ids is None: past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0 position_ids = torch.arange(inputs_embeds.shape[1], device=inputs_embeds.device) + past_seen_tokens position_ids = position_ids.unsqueeze(0)
if not isinstance(causal_mask_mapping := attention_mask, dict): # Prepare mask arguments mask_kwargs = { "config": self.config, "inputs_embeds": inputs_embeds, "attention_mask": attention_mask, "past_key_values": past_key_values, "position_ids": position_ids, } # Create the masks causal_mask_mapping = { "full_attention": create_causal_mask(**mask_kwargs), "linear_attention": create_recurrent_attention_mask(**mask_kwargs), }
hidden_states = inputs_embeds position_embeddings = self.rotary_emb(hidden_states, position_ids)
# Gated Block AttnRes: every layer reads a gated mix of the residual streams committed at block boundaries # (the embeddings count as block 0) and the current stream. Token-local, so it is cache-transparent. block = self.config.attn_res_block_size block_streams = hidden_states.unsqueeze(0) if block else None # [n_blocks, batch, seq, hidden]
for i, decoder_layer in enumerate(self.layers[: self.config.num_hidden_layers]): hidden_states = decoder_layer( hidden_states, block_streams, position_embeddings=position_embeddings, attention_mask=causal_mask_mapping[self.config.layer_types[i]], position_ids=position_ids, past_key_values=past_key_values, use_cache=use_cache, **kwargs, ) if block and (i + 1) % block == 0: # The commits stay on the device of the first one; a model dispatched over several devices runs # this layer on its own device, so its stream is moved over before it is committed. commit = hidden_states.unsqueeze(0).to(block_streams.device) block_streams = torch.cat([block_streams, commit], dim=0)
hidden_states = self.norm(hidden_states)
return MoeModelOutputWithPast( last_hidden_state=hidden_states, past_key_values=past_key_values, )
@auto_docstringclass BerryLMForCausalLM(BerryLMPreTrainedModel, GenerationMixin): _tied_weights_keys = {"lm_head.weight": "model.embed_tokens.weight"} _tp_plan = {"lm_head": "colwise_gather_output"} _pp_plan = {"lm_head": (["hidden_states"], ["logits"])} _fsdp_plan = {"lm_head": "keep_full_weight"} config: BerryLMConfig
def __init__(self, config): super().__init__(config) self.model = BerryLMModel(config) self.vocab_size = config.vocab_size self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False) self.router_aux_loss_coef = config.router_aux_loss_coef self.num_experts = config.num_experts self.num_experts_per_tok = config.num_experts_per_tok
# Initialize weights and apply final processing self.post_init()
@can_return_tuple @auto_docstring def forward( self, input_ids: torch.LongTensor | None = None, attention_mask: torch.Tensor | None = None, position_ids: torch.LongTensor | None = None, past_key_values: Cache | None = None, inputs_embeds: torch.FloatTensor | None = None, labels: torch.LongTensor | None = None, use_cache: bool | None = None, output_router_logits: bool | None = None, logits_to_keep: int | torch.Tensor = 0, **kwargs: Unpack[TransformersKwargs], ) -> MoeCausalLMOutputWithPast: r""" Example:
```python >>> from transformers import AutoTokenizer, BerryLMForCausalLM
>>> model = BerryLMForCausalLM.from_pretrained("rwb-ai/BerryLM-OS") >>> tokenizer = AutoTokenizer.from_pretrained("rwb-ai/BerryLM-OS")
>>> prompt = "Hey, are you conscious? Can you talk to me?" >>> inputs = tokenizer(prompt, return_tensors="pt")
>>> # Generate >>> generate_ids = model.generate(inputs.input_ids, max_length=30) >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0] "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you." ```"""
output_router_logits = ( output_router_logits if output_router_logits is not None else self.config.output_router_logits )
# decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn) outputs: MoeModelOutputWithPast = self.model( input_ids=input_ids, attention_mask=attention_mask, position_ids=position_ids, past_key_values=past_key_values, inputs_embeds=inputs_embeds, use_cache=use_cache, output_router_logits=output_router_logits, **kwargs, )
hidden_states = outputs.last_hidden_state # Only compute necessary logits, and do not upcast them to float if we are not computing the loss slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep logits = self.lm_head(hidden_states[:, slice_indices, :])
loss = None if labels is not None: loss = self.loss_function(logits, labels, self.vocab_size, **kwargs)
aux_loss = None if output_router_logits: aux_loss = load_balancing_loss_func( outputs.router_logits, self.num_experts, self.num_experts_per_tok, attention_mask, ) if labels is not None: loss += self.router_aux_loss_coef * aux_loss.to(loss.device) # make sure to reside in the same device
return MoeCausalLMOutputWithPast( loss=loss, aux_loss=aux_loss, logits=logits, past_key_values=outputs.past_key_values, hidden_states=outputs.hidden_states, attentions=outputs.attentions, router_logits=outputs.router_logits, )
__all__ = ["BerryLMConfig", "BerryLMForCausalLM", "BerryLMModel", "BerryLMPreTrainedModel"]123version https://git-lfs.github.com/spec/v1oid sha256:ef1f7011f5105348446b7d270e2109807f8fcb24dae8c5ae7d3ad975d31bae21size 137784151234567891011121314{ "add_prefix_space": false, "backend": "tokenizers", "bos_token": null, "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "errors": "replace", "model_max_length": 262144, "pad_token": "<|endoftext|>", "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+", "split_special_tokens": false, "tokenizer_class": "PreTrainedTokenizerFast", "unk_token": null}.gitattributesAdded+40
LICENSEAdded+202
README.mdAdded+207
assets/architecture.pngAdded

Large File Pointer Details
- SHA256: bc5b1fb44f4c529e1162d553b3d68b0cd2d77614cfbf9d7e82a8074f636c026d
- Pointer size: 131 Bytes
- Size of remote file: 629 kB
assets/pareto-average.pngAdded

Large File Pointer Details
- SHA256: 25ecdcc938af128c2e0808b025ac0b9246fad79272385e3c6c66b27cf1384c7b
- Pointer size: 131 Bytes
- Size of remote file: 215 kB
assets/pareto-russian.pngAdded

Large File Pointer Details
- SHA256: 89320a4253a4e4615e362bac8b98f2cc48628f872dd7061aba160c438eac31d8
- Pointer size: 131 Bytes
- Size of remote file: 218 kB
chat_template.jinjaAdded+147
config.jsonAdded+94
configuration_berrylm.pyAdded+159
generation_config.jsonAdded+11
model-00001-of-00008.safetensorsAdded+3
model-00002-of-00008.safetensorsAdded+3
model-00003-of-00008.safetensorsAdded+3
model-00004-of-00008.safetensorsAdded+3
model-00005-of-00008.safetensorsAdded+3
model-00006-of-00008.safetensorsAdded+3
model-00007-of-00008.safetensorsAdded+3
model-00008-of-00008.safetensorsAdded+3
model.safetensors.index.jsonAdded+811
modeling_berrylm.pyAdded+1149
tokenizer.jsonAdded+3
tokenizer_config.jsonAdded+14