fredchu commited on
Commit
59237c3
·
verified ·
1 Parent(s): fdacf91

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ mlx_llm/tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: OpenMOSS-Team/MOSS-Audio-8B-Instruct
4
+ tags:
5
+ - mlx
6
+ - audio
7
+ - moss-audio
8
+ - asr
9
+ - int4
10
+ - apple-silicon
11
+ language:
12
+ - en
13
+ - zh
14
+ pipeline_tag: audio-text-to-text
15
+ library_name: mlx
16
+ ---
17
+
18
+ # MOSS-Audio-8B-Instruct-MLX (hybrid: INT4 LLM + BF16 audio)
19
+
20
+ An Apple MLX conversion of **MOSS-Audio-8B-Instruct** — the ASR-strongest MOSS-Audio
21
+ checkpoint — for fast, low-memory inference on Apple Silicon. LLM quantized to uniform
22
+ INT4 (group_size 64); audio encoder + adapter + DeepStack kept in BF16.
23
+
24
+ > **Why this exists.** The community had MLX builds only of the *Thinking* variant.
25
+ > But Thinking is not ASR-optimized: under identical INT4 quantization it mis-spells
26
+ > letter-spoken tickers (e.g. "CRWD" → "CWD") and is unstable. **Instruct** transcribes
27
+ > them correctly. This build brings Instruct's transcription quality to MLX speed/memory.
28
+
29
+ 中文:這是 **MOSS-Audio-8B-Instruct** 的 Apple MLX 轉換版(LLM uniform INT4 + audio 路徑 BF16)。
30
+ 社群原本只有 *Thinking* 變體的 MLX 版,但 Thinking 非 ASR 優化——相同 INT4 量化下會把唸出字母的
31
+ ticker(如 "CRWD")辨識成 "CWD" 且不穩定。**Instruct** 辨識正確。本版把 Instruct 的轉錄品質
32
+ 帶到 MLX 的速度與記憶體。
33
+
34
+ ## Measured (Apple M1 Max 32GB, 28s zh+en clip)
35
+
36
+ | Metric | PyTorch Instruct | **This (Instruct-MLX)** | Thinking-MLX |
37
+ |---|:---:|:---:|:---:|
38
+ | Ticker "CRWD" | C R W D ✅ | **C R W D ✅** | CWD ❌ |
39
+ | English term (TradingView) | ✅ | ✅ | ✅(loops) |
40
+ | Numerals | Chinese chars | **Arabic 47%** | Arabic |
41
+ | Speed | 1.8x realtime | **6–9x** | 5–8x |
42
+ | Peak memory | ~17 GB | **7.85 GB** | 7.85 GB |
43
+ | Disk | 18 GB | **5.9 GB** | 5.9 GB |
44
+
45
+ **Key finding.** Ticker-ASR degradation in the Thinking-MLX builds comes from the
46
+ Thinking/Instruct *training difference*, not from INT4 quantization — under the same
47
+ uniform INT4, Instruct keeps the ticker. So uniform 4-bit suffices; no mixed-precision needed.
48
+
49
+ ## Usage
50
+
51
+ ```bash
52
+ pip install mlx mlx-lm soundfile numpy
53
+ python inference.py --audio your_clip_16k_mono.wav
54
+ ```
55
+
56
+ Transcription with per-segment timestamps (a Traditional-Chinese prompt triggers
57
+ zh-Hant output):
58
+
59
+ ```bash
60
+ python run_moss.py --model . --audio clip.wav \
61
+ --prompt "請逐句轉錄這段音訊,每句標註開始時間。" --temp 0 --repetition-penalty 1.02
62
+ ```
63
+
64
+ - **Audio**: 16 kHz mono. Encoder window is Whisper-style **30 s max** — chunk longer audio.
65
+ - **Decoding**: use **greedy (temp=0)** for ASR fidelity. `temp>0` removes the rare
66
+ tail digit-loop but degrades content (wrong numerals, out-of-order timestamps).
67
+ - **digit-loop**: occasionally the model fails to emit EOS and repeats a digit token
68
+ at the very tail; post-truncate repeated trailing digits. Quantization weakens EOS;
69
+ it is a known, harmless tail artifact for transcription use.
70
+
71
+ ## How it was converted
72
+
73
+ Pure metadata-mapped weight conversion (no retraining):
74
+
75
+ 1. `stage1_mapping.py` — verify every MLX target key is sourceable from the PyTorch
76
+ checkpoint; discover the conv layout transform `transpose(0,2,3,1)`
77
+ (PyTorch `[out,in,h,w]` → MLX `[out,h,w,in]`).
78
+ 2. `stage2_convert.py` — extract `language_model.*` + `lm_head`, quantize to INT4
79
+ (group_size 64) via mlx; extract audio encoder/adapter/DeepStack, apply the conv
80
+ transpose, save BF16. Output mirrors the RumiLabs bridge layout exactly.
81
+
82
+ ## Limitations
83
+
84
+ - 30-second audio window (chunk + offset timestamps for longer input).
85
+ - Tail digit-loop under greedy (post-truncate).
86
+ - Homophone errors on domain terms (e.g. 300均 → 三百軍) — fix with a glossary/post-pass.
87
+
88
+ ## Credits
89
+
90
+ - Base model: [OpenMOSS-Team/MOSS-Audio](https://github.com/OpenMOSS/MOSS-Audio) (Apache-2.0)
91
+ - MLX bridge (encoder/mel/DeepStack port): [RumiLabs](https://huggingface.co/RumiLabs) Thinking-MLX builds
92
+ - Instruct→MLX conversion: this work
93
+
94
+ ## License
95
+
96
+ Apache-2.0 (inherited from base model).
inference.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Standalone MOSS-Audio-{4B,8B}-Thinking MLX inference.
2
+
3
+ Usage:
4
+ python inference.py --audio path/to/clip.wav [--max-tokens 2048]
5
+
6
+ Both 4B INT4 and 8B hybrid bundles work with this script. Audio-path
7
+ dtype is inferred from the saved adapter weights (`scales` key => INT4).
8
+ """
9
+ from __future__ import annotations
10
+ import argparse, sys, time
11
+ from pathlib import Path
12
+
13
+ HERE = Path(__file__).resolve().parent
14
+ sys.path.insert(0, str(HERE / "scripts"))
15
+
16
+ import librosa
17
+ import mlx.core as mx
18
+ import numpy as np
19
+ from mlx_lm import load as mlx_load
20
+ from mlx_lm.generate import generate_step
21
+ from mlx_lm.sample_utils import make_sampler, make_logits_processors
22
+
23
+ from moss_audio_mlx_bridge_v3 import (
24
+ load_mlx_audio_path,
25
+ build_mel_spectrogram,
26
+ run_mlx_audio_pipeline,
27
+ install_deepstack_hooks,
28
+ )
29
+
30
+
31
+ def main():
32
+ p = argparse.ArgumentParser()
33
+ p.add_argument("--audio", required=True, help="Path to input .wav (16 kHz, mono)")
34
+ p.add_argument("--max-tokens", type=int, default=2048)
35
+ p.add_argument("--repetition-penalty", type=float, default=1.02,
36
+ help="1.02 kills decode-loops without over-penalizing descriptions")
37
+ args = p.parse_args()
38
+
39
+ ad_w = mx.load(str(HERE / "mlx_audio/audio_adapter.safetensors"))
40
+ if "down_proj.scales" in ad_w:
41
+ llm_hidden = ad_w["down_proj.scales"].shape[0]
42
+ int4_audio = True
43
+ else:
44
+ llm_hidden = ad_w["down_proj.weight"].shape[0]
45
+ int4_audio = False
46
+ size_tag = "4B" if llm_hidden == 2560 else "8B"
47
+ print(f"[detect] {size_tag} bundle, audio int4={int4_audio}")
48
+
49
+ print(f"[load] LLM from {HERE / 'mlx_llm'}")
50
+ t0 = time.perf_counter()
51
+ mlx_model, mlx_tokenizer = mlx_load(str(HERE / "mlx_llm"))
52
+ print(f"[load] LLM: {time.perf_counter()-t0:.1f}s")
53
+
54
+ t0 = time.perf_counter()
55
+ encoder, adapter, mergers = load_mlx_audio_path(HERE / "mlx_audio", int4=int4_audio)
56
+ print(f"[load] audio path: {time.perf_counter()-t0:.1f}s")
57
+
58
+ y, _ = librosa.load(args.audio, sr=16000, mono=True)
59
+ y = y.astype(np.float32)
60
+ print(f"[audio] {args.audio} ({len(y)/16000:.1f}s)")
61
+
62
+ # Pure-MLX mel + input_ids (no torch).
63
+ mel, lens, input_ids_mx, audio_token_id = build_mel_spectrogram(y, mlx_tokenizer)
64
+ primary, ds_embeds = run_mlx_audio_pipeline(encoder, adapter, mergers, mel, lens)
65
+ primary = primary.astype(mx.bfloat16)
66
+ ds_embeds = [d.astype(mx.bfloat16) for d in ds_embeds]
67
+ mx.eval(primary, *ds_embeds)
68
+
69
+ del encoder, adapter, mergers, mel, lens
70
+ import gc; gc.collect(); mx.clear_cache()
71
+
72
+ audio_mask = input_ids_mx == audio_token_id
73
+ audio_positions = np.where(np.array(audio_mask[0]))[0]
74
+ text_embeds = mlx_model.model.embed_tokens(input_ids_mx)
75
+ text_np = np.array(text_embeds.astype(mx.float32))
76
+ primary_np = np.array(primary.astype(mx.float32))
77
+ text_np[0, audio_positions, :] = primary_np[0, :, :]
78
+ merged = mx.array(text_np).astype(mx.bfloat16)
79
+
80
+ ds_flat = [d[0] for d in ds_embeds]
81
+ install_deepstack_hooks(mlx_model, ds_flat, audio_positions)
82
+
83
+ sampler = make_sampler(temp=1.0, top_p=1.0, top_k=50)
84
+ logits_processors = make_logits_processors(
85
+ repetition_penalty=args.repetition_penalty, repetition_context_size=20
86
+ ) if args.repetition_penalty else None
87
+
88
+ gen_kwargs = dict(
89
+ prompt=input_ids_mx[0], model=mlx_model,
90
+ input_embeddings=merged[0], max_tokens=args.max_tokens, sampler=sampler,
91
+ )
92
+ if logits_processors:
93
+ gen_kwargs["logits_processors"] = logits_processors
94
+
95
+ t0 = time.perf_counter()
96
+ generated = []
97
+ for tok, _ in generate_step(**gen_kwargs):
98
+ generated.append(int(tok))
99
+ if tok == mlx_tokenizer.eos_token_id:
100
+ break
101
+ elapsed = time.perf_counter() - t0
102
+ print(f"[gen] {len(generated)} tokens in {elapsed:.2f}s ({len(generated)/elapsed:.1f} t/s)")
103
+ print(f"\n=== OUTPUT ===\n{mlx_tokenizer.decode(generated)}\n=== END ===")
104
+
105
+
106
+ if __name__ == "__main__":
107
+ main()
mlx_audio/audio_adapter.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7cad6dec43c8c29b84842bff4ee7f95212e0a61b0a8aab3c7947362d3291d2f4
3
+ size 109052198
mlx_audio/audio_encoder.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa2e9a39a5291851e0ed473d0ee8da090af33ed15499bed93b3c9dc4b7f6b452
3
+ size 1287299131
mlx_audio/deepstack_mergers.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:54454963494a509c9bc4f4e77cfe7a838398b5087fe325166b62870220c998a3
3
+ size 327156578
mlx_llm/added_tokens.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</think>": 151668,
3
+ "</tool_call>": 151658,
4
+ "</tool_response>": 151666,
5
+ "<think>": 151667,
6
+ "<tool_call>": 151657,
7
+ "<tool_response>": 151665,
8
+ "<|assistant|>": 151671,
9
+ "<|box_end|>": 151649,
10
+ "<|box_start|>": 151648,
11
+ "<|endoftext|>": 151643,
12
+ "<|eot|>": 151672,
13
+ "<|file_sep|>": 151664,
14
+ "<|fim_middle|>": 151660,
15
+ "<|fim_pad|>": 151662,
16
+ "<|fim_prefix|>": 151659,
17
+ "<|fim_suffix|>": 151661,
18
+ "<|im_end|>": 151645,
19
+ "<|im_start|>": 151644,
20
+ "<|image_pad|>": 151655,
21
+ "<|object_ref_end|>": 151647,
22
+ "<|object_ref_start|>": 151646,
23
+ "<|quad_end|>": 151651,
24
+ "<|quad_start|>": 151650,
25
+ "<|repo_name|>": 151663,
26
+ "<|system|>": 151669,
27
+ "<|user|>": 151670,
28
+ "<|video_pad|>": 151656,
29
+ "<|vision_end|>": 151653,
30
+ "<|vision_pad|>": 151654,
31
+ "<|vision_start|>": 151652
32
+ }
mlx_llm/chat_template.jinja ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
27
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
28
+ {%- elif message.role == "assistant" %}
29
+ {%- set content = message.content %}
30
+ {%- set reasoning_content = '' %}
31
+ {%- if message.reasoning_content is defined and message.reasoning_content is not none %}
32
+ {%- set reasoning_content = message.reasoning_content %}
33
+ {%- else %}
34
+ {%- if '</think>' in message.content %}
35
+ {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
36
+ {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
37
+ {%- endif %}
38
+ {%- endif %}
39
+ {%- if loop.index0 > ns.last_query_index %}
40
+ {%- if loop.last or (not loop.last and reasoning_content) %}
41
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
42
+ {%- else %}
43
+ {{- '<|im_start|>' + message.role + '\n' + content }}
44
+ {%- endif %}
45
+ {%- else %}
46
+ {{- '<|im_start|>' + message.role + '\n' + content }}
47
+ {%- endif %}
48
+ {%- if message.tool_calls %}
49
+ {%- for tool_call in message.tool_calls %}
50
+ {%- if (loop.first and content) or (not loop.first) %}
51
+ {{- '\n' }}
52
+ {%- endif %}
53
+ {%- if tool_call.function %}
54
+ {%- set tool_call = tool_call.function %}
55
+ {%- endif %}
56
+ {{- '<tool_call>\n{"name": "' }}
57
+ {{- tool_call.name }}
58
+ {{- '", "arguments": ' }}
59
+ {%- if tool_call.arguments is string %}
60
+ {{- tool_call.arguments }}
61
+ {%- else %}
62
+ {{- tool_call.arguments | tojson }}
63
+ {%- endif %}
64
+ {{- '}\n</tool_call>' }}
65
+ {%- endfor %}
66
+ {%- endif %}
67
+ {{- '<|im_end|>\n' }}
68
+ {%- elif message.role == "tool" %}
69
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
70
+ {{- '<|im_start|>user' }}
71
+ {%- endif %}
72
+ {{- '\n<tool_response>\n' }}
73
+ {{- message.content }}
74
+ {{- '\n</tool_response>' }}
75
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
76
+ {{- '<|im_end|>\n' }}
77
+ {%- endif %}
78
+ {%- endif %}
79
+ {%- endfor %}
80
+ {%- if add_generation_prompt %}
81
+ {{- '<|im_start|>assistant\n' }}
82
+ {%- if enable_thinking is defined and enable_thinking is false %}
83
+ {{- '<think>\n\n</think>\n\n' }}
84
+ {%- endif %}
85
+ {%- endif %}
mlx_llm/config.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 151643,
8
+ "eos_token_id": 151645,
9
+ "head_dim": 128,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 4096,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 12288,
14
+ "layer_types": [
15
+ "full_attention",
16
+ "full_attention",
17
+ "full_attention",
18
+ "full_attention",
19
+ "full_attention",
20
+ "full_attention",
21
+ "full_attention",
22
+ "full_attention",
23
+ "full_attention",
24
+ "full_attention",
25
+ "full_attention",
26
+ "full_attention",
27
+ "full_attention",
28
+ "full_attention",
29
+ "full_attention",
30
+ "full_attention",
31
+ "full_attention",
32
+ "full_attention",
33
+ "full_attention",
34
+ "full_attention",
35
+ "full_attention",
36
+ "full_attention",
37
+ "full_attention",
38
+ "full_attention",
39
+ "full_attention",
40
+ "full_attention",
41
+ "full_attention",
42
+ "full_attention",
43
+ "full_attention",
44
+ "full_attention",
45
+ "full_attention",
46
+ "full_attention",
47
+ "full_attention",
48
+ "full_attention",
49
+ "full_attention",
50
+ "full_attention"
51
+ ],
52
+ "max_position_embeddings": 40960,
53
+ "max_window_layers": 36,
54
+ "model_type": "qwen3",
55
+ "num_attention_heads": 32,
56
+ "num_hidden_layers": 36,
57
+ "num_key_value_heads": 8,
58
+ "quantization": {
59
+ "group_size": 64,
60
+ "bits": 4,
61
+ "mode": "affine"
62
+ },
63
+ "quantization_config": {
64
+ "group_size": 64,
65
+ "bits": 4,
66
+ "mode": "affine"
67
+ },
68
+ "rms_norm_eps": 1e-06,
69
+ "rope_scaling": null,
70
+ "rope_theta": 1000000,
71
+ "sliding_window": null,
72
+ "tie_word_embeddings": false,
73
+ "torch_dtype": "bfloat16",
74
+ "use_cache": true,
75
+ "use_sliding_window": false,
76
+ "vocab_size": 151936
77
+ }
mlx_llm/generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 151643,
4
+ "eos_token_id": 151645,
5
+ "transformers_version": "4.57.1"
6
+ }
mlx_llm/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
mlx_llm/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3125621c811c0d8ec5ad6a0e871b8a76e37ec08d3bb54342c73fbacb1e682433
3
+ size 4607834992
mlx_llm/model.safetensors.index.json ADDED
@@ -0,0 +1,915 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 4607731712,
4
+ "total_parameters": 8190735360
5
+ },
6
+ "weight_map": {
7
+ "lm_head.biases": "model.safetensors",
8
+ "lm_head.scales": "model.safetensors",
9
+ "lm_head.weight": "model.safetensors",
10
+ "model.embed_tokens.biases": "model.safetensors",
11
+ "model.embed_tokens.scales": "model.safetensors",
12
+ "model.embed_tokens.weight": "model.safetensors",
13
+ "model.layers.0.input_layernorm.weight": "model.safetensors",
14
+ "model.layers.0.mlp.down_proj.biases": "model.safetensors",
15
+ "model.layers.0.mlp.down_proj.scales": "model.safetensors",
16
+ "model.layers.0.mlp.down_proj.weight": "model.safetensors",
17
+ "model.layers.0.mlp.gate_proj.biases": "model.safetensors",
18
+ "model.layers.0.mlp.gate_proj.scales": "model.safetensors",
19
+ "model.layers.0.mlp.gate_proj.weight": "model.safetensors",
20
+ "model.layers.0.mlp.up_proj.biases": "model.safetensors",
21
+ "model.layers.0.mlp.up_proj.scales": "model.safetensors",
22
+ "model.layers.0.mlp.up_proj.weight": "model.safetensors",
23
+ "model.layers.0.post_attention_layernorm.weight": "model.safetensors",
24
+ "model.layers.0.self_attn.k_norm.weight": "model.safetensors",
25
+ "model.layers.0.self_attn.k_proj.biases": "model.safetensors",
26
+ "model.layers.0.self_attn.k_proj.scales": "model.safetensors",
27
+ "model.layers.0.self_attn.k_proj.weight": "model.safetensors",
28
+ "model.layers.0.self_attn.o_proj.biases": "model.safetensors",
29
+ "model.layers.0.self_attn.o_proj.scales": "model.safetensors",
30
+ "model.layers.0.self_attn.o_proj.weight": "model.safetensors",
31
+ "model.layers.0.self_attn.q_norm.weight": "model.safetensors",
32
+ "model.layers.0.self_attn.q_proj.biases": "model.safetensors",
33
+ "model.layers.0.self_attn.q_proj.scales": "model.safetensors",
34
+ "model.layers.0.self_attn.q_proj.weight": "model.safetensors",
35
+ "model.layers.0.self_attn.v_proj.biases": "model.safetensors",
36
+ "model.layers.0.self_attn.v_proj.scales": "model.safetensors",
37
+ "model.layers.0.self_attn.v_proj.weight": "model.safetensors",
38
+ "model.layers.1.input_layernorm.weight": "model.safetensors",
39
+ "model.layers.1.mlp.down_proj.biases": "model.safetensors",
40
+ "model.layers.1.mlp.down_proj.scales": "model.safetensors",
41
+ "model.layers.1.mlp.down_proj.weight": "model.safetensors",
42
+ "model.layers.1.mlp.gate_proj.biases": "model.safetensors",
43
+ "model.layers.1.mlp.gate_proj.scales": "model.safetensors",
44
+ "model.layers.1.mlp.gate_proj.weight": "model.safetensors",
45
+ "model.layers.1.mlp.up_proj.biases": "model.safetensors",
46
+ "model.layers.1.mlp.up_proj.scales": "model.safetensors",
47
+ "model.layers.1.mlp.up_proj.weight": "model.safetensors",
48
+ "model.layers.1.post_attention_layernorm.weight": "model.safetensors",
49
+ "model.layers.1.self_attn.k_norm.weight": "model.safetensors",
50
+ "model.layers.1.self_attn.k_proj.biases": "model.safetensors",
51
+ "model.layers.1.self_attn.k_proj.scales": "model.safetensors",
52
+ "model.layers.1.self_attn.k_proj.weight": "model.safetensors",
53
+ "model.layers.1.self_attn.o_proj.biases": "model.safetensors",
54
+ "model.layers.1.self_attn.o_proj.scales": "model.safetensors",
55
+ "model.layers.1.self_attn.o_proj.weight": "model.safetensors",
56
+ "model.layers.1.self_attn.q_norm.weight": "model.safetensors",
57
+ "model.layers.1.self_attn.q_proj.biases": "model.safetensors",
58
+ "model.layers.1.self_attn.q_proj.scales": "model.safetensors",
59
+ "model.layers.1.self_attn.q_proj.weight": "model.safetensors",
60
+ "model.layers.1.self_attn.v_proj.biases": "model.safetensors",
61
+ "model.layers.1.self_attn.v_proj.scales": "model.safetensors",
62
+ "model.layers.1.self_attn.v_proj.weight": "model.safetensors",
63
+ "model.layers.10.input_layernorm.weight": "model.safetensors",
64
+ "model.layers.10.mlp.down_proj.biases": "model.safetensors",
65
+ "model.layers.10.mlp.down_proj.scales": "model.safetensors",
66
+ "model.layers.10.mlp.down_proj.weight": "model.safetensors",
67
+ "model.layers.10.mlp.gate_proj.biases": "model.safetensors",
68
+ "model.layers.10.mlp.gate_proj.scales": "model.safetensors",
69
+ "model.layers.10.mlp.gate_proj.weight": "model.safetensors",
70
+ "model.layers.10.mlp.up_proj.biases": "model.safetensors",
71
+ "model.layers.10.mlp.up_proj.scales": "model.safetensors",
72
+ "model.layers.10.mlp.up_proj.weight": "model.safetensors",
73
+ "model.layers.10.post_attention_layernorm.weight": "model.safetensors",
74
+ "model.layers.10.self_attn.k_norm.weight": "model.safetensors",
75
+ "model.layers.10.self_attn.k_proj.biases": "model.safetensors",
76
+ "model.layers.10.self_attn.k_proj.scales": "model.safetensors",
77
+ "model.layers.10.self_attn.k_proj.weight": "model.safetensors",
78
+ "model.layers.10.self_attn.o_proj.biases": "model.safetensors",
79
+ "model.layers.10.self_attn.o_proj.scales": "model.safetensors",
80
+ "model.layers.10.self_attn.o_proj.weight": "model.safetensors",
81
+ "model.layers.10.self_attn.q_norm.weight": "model.safetensors",
82
+ "model.layers.10.self_attn.q_proj.biases": "model.safetensors",
83
+ "model.layers.10.self_attn.q_proj.scales": "model.safetensors",
84
+ "model.layers.10.self_attn.q_proj.weight": "model.safetensors",
85
+ "model.layers.10.self_attn.v_proj.biases": "model.safetensors",
86
+ "model.layers.10.self_attn.v_proj.scales": "model.safetensors",
87
+ "model.layers.10.self_attn.v_proj.weight": "model.safetensors",
88
+ "model.layers.11.input_layernorm.weight": "model.safetensors",
89
+ "model.layers.11.mlp.down_proj.biases": "model.safetensors",
90
+ "model.layers.11.mlp.down_proj.scales": "model.safetensors",
91
+ "model.layers.11.mlp.down_proj.weight": "model.safetensors",
92
+ "model.layers.11.mlp.gate_proj.biases": "model.safetensors",
93
+ "model.layers.11.mlp.gate_proj.scales": "model.safetensors",
94
+ "model.layers.11.mlp.gate_proj.weight": "model.safetensors",
95
+ "model.layers.11.mlp.up_proj.biases": "model.safetensors",
96
+ "model.layers.11.mlp.up_proj.scales": "model.safetensors",
97
+ "model.layers.11.mlp.up_proj.weight": "model.safetensors",
98
+ "model.layers.11.post_attention_layernorm.weight": "model.safetensors",
99
+ "model.layers.11.self_attn.k_norm.weight": "model.safetensors",
100
+ "model.layers.11.self_attn.k_proj.biases": "model.safetensors",
101
+ "model.layers.11.self_attn.k_proj.scales": "model.safetensors",
102
+ "model.layers.11.self_attn.k_proj.weight": "model.safetensors",
103
+ "model.layers.11.self_attn.o_proj.biases": "model.safetensors",
104
+ "model.layers.11.self_attn.o_proj.scales": "model.safetensors",
105
+ "model.layers.11.self_attn.o_proj.weight": "model.safetensors",
106
+ "model.layers.11.self_attn.q_norm.weight": "model.safetensors",
107
+ "model.layers.11.self_attn.q_proj.biases": "model.safetensors",
108
+ "model.layers.11.self_attn.q_proj.scales": "model.safetensors",
109
+ "model.layers.11.self_attn.q_proj.weight": "model.safetensors",
110
+ "model.layers.11.self_attn.v_proj.biases": "model.safetensors",
111
+ "model.layers.11.self_attn.v_proj.scales": "model.safetensors",
112
+ "model.layers.11.self_attn.v_proj.weight": "model.safetensors",
113
+ "model.layers.12.input_layernorm.weight": "model.safetensors",
114
+ "model.layers.12.mlp.down_proj.biases": "model.safetensors",
115
+ "model.layers.12.mlp.down_proj.scales": "model.safetensors",
116
+ "model.layers.12.mlp.down_proj.weight": "model.safetensors",
117
+ "model.layers.12.mlp.gate_proj.biases": "model.safetensors",
118
+ "model.layers.12.mlp.gate_proj.scales": "model.safetensors",
119
+ "model.layers.12.mlp.gate_proj.weight": "model.safetensors",
120
+ "model.layers.12.mlp.up_proj.biases": "model.safetensors",
121
+ "model.layers.12.mlp.up_proj.scales": "model.safetensors",
122
+ "model.layers.12.mlp.up_proj.weight": "model.safetensors",
123
+ "model.layers.12.post_attention_layernorm.weight": "model.safetensors",
124
+ "model.layers.12.self_attn.k_norm.weight": "model.safetensors",
125
+ "model.layers.12.self_attn.k_proj.biases": "model.safetensors",
126
+ "model.layers.12.self_attn.k_proj.scales": "model.safetensors",
127
+ "model.layers.12.self_attn.k_proj.weight": "model.safetensors",
128
+ "model.layers.12.self_attn.o_proj.biases": "model.safetensors",
129
+ "model.layers.12.self_attn.o_proj.scales": "model.safetensors",
130
+ "model.layers.12.self_attn.o_proj.weight": "model.safetensors",
131
+ "model.layers.12.self_attn.q_norm.weight": "model.safetensors",
132
+ "model.layers.12.self_attn.q_proj.biases": "model.safetensors",
133
+ "model.layers.12.self_attn.q_proj.scales": "model.safetensors",
134
+ "model.layers.12.self_attn.q_proj.weight": "model.safetensors",
135
+ "model.layers.12.self_attn.v_proj.biases": "model.safetensors",
136
+ "model.layers.12.self_attn.v_proj.scales": "model.safetensors",
137
+ "model.layers.12.self_attn.v_proj.weight": "model.safetensors",
138
+ "model.layers.13.input_layernorm.weight": "model.safetensors",
139
+ "model.layers.13.mlp.down_proj.biases": "model.safetensors",
140
+ "model.layers.13.mlp.down_proj.scales": "model.safetensors",
141
+ "model.layers.13.mlp.down_proj.weight": "model.safetensors",
142
+ "model.layers.13.mlp.gate_proj.biases": "model.safetensors",
143
+ "model.layers.13.mlp.gate_proj.scales": "model.safetensors",
144
+ "model.layers.13.mlp.gate_proj.weight": "model.safetensors",
145
+ "model.layers.13.mlp.up_proj.biases": "model.safetensors",
146
+ "model.layers.13.mlp.up_proj.scales": "model.safetensors",
147
+ "model.layers.13.mlp.up_proj.weight": "model.safetensors",
148
+ "model.layers.13.post_attention_layernorm.weight": "model.safetensors",
149
+ "model.layers.13.self_attn.k_norm.weight": "model.safetensors",
150
+ "model.layers.13.self_attn.k_proj.biases": "model.safetensors",
151
+ "model.layers.13.self_attn.k_proj.scales": "model.safetensors",
152
+ "model.layers.13.self_attn.k_proj.weight": "model.safetensors",
153
+ "model.layers.13.self_attn.o_proj.biases": "model.safetensors",
154
+ "model.layers.13.self_attn.o_proj.scales": "model.safetensors",
155
+ "model.layers.13.self_attn.o_proj.weight": "model.safetensors",
156
+ "model.layers.13.self_attn.q_norm.weight": "model.safetensors",
157
+ "model.layers.13.self_attn.q_proj.biases": "model.safetensors",
158
+ "model.layers.13.self_attn.q_proj.scales": "model.safetensors",
159
+ "model.layers.13.self_attn.q_proj.weight": "model.safetensors",
160
+ "model.layers.13.self_attn.v_proj.biases": "model.safetensors",
161
+ "model.layers.13.self_attn.v_proj.scales": "model.safetensors",
162
+ "model.layers.13.self_attn.v_proj.weight": "model.safetensors",
163
+ "model.layers.14.input_layernorm.weight": "model.safetensors",
164
+ "model.layers.14.mlp.down_proj.biases": "model.safetensors",
165
+ "model.layers.14.mlp.down_proj.scales": "model.safetensors",
166
+ "model.layers.14.mlp.down_proj.weight": "model.safetensors",
167
+ "model.layers.14.mlp.gate_proj.biases": "model.safetensors",
168
+ "model.layers.14.mlp.gate_proj.scales": "model.safetensors",
169
+ "model.layers.14.mlp.gate_proj.weight": "model.safetensors",
170
+ "model.layers.14.mlp.up_proj.biases": "model.safetensors",
171
+ "model.layers.14.mlp.up_proj.scales": "model.safetensors",
172
+ "model.layers.14.mlp.up_proj.weight": "model.safetensors",
173
+ "model.layers.14.post_attention_layernorm.weight": "model.safetensors",
174
+ "model.layers.14.self_attn.k_norm.weight": "model.safetensors",
175
+ "model.layers.14.self_attn.k_proj.biases": "model.safetensors",
176
+ "model.layers.14.self_attn.k_proj.scales": "model.safetensors",
177
+ "model.layers.14.self_attn.k_proj.weight": "model.safetensors",
178
+ "model.layers.14.self_attn.o_proj.biases": "model.safetensors",
179
+ "model.layers.14.self_attn.o_proj.scales": "model.safetensors",
180
+ "model.layers.14.self_attn.o_proj.weight": "model.safetensors",
181
+ "model.layers.14.self_attn.q_norm.weight": "model.safetensors",
182
+ "model.layers.14.self_attn.q_proj.biases": "model.safetensors",
183
+ "model.layers.14.self_attn.q_proj.scales": "model.safetensors",
184
+ "model.layers.14.self_attn.q_proj.weight": "model.safetensors",
185
+ "model.layers.14.self_attn.v_proj.biases": "model.safetensors",
186
+ "model.layers.14.self_attn.v_proj.scales": "model.safetensors",
187
+ "model.layers.14.self_attn.v_proj.weight": "model.safetensors",
188
+ "model.layers.15.input_layernorm.weight": "model.safetensors",
189
+ "model.layers.15.mlp.down_proj.biases": "model.safetensors",
190
+ "model.layers.15.mlp.down_proj.scales": "model.safetensors",
191
+ "model.layers.15.mlp.down_proj.weight": "model.safetensors",
192
+ "model.layers.15.mlp.gate_proj.biases": "model.safetensors",
193
+ "model.layers.15.mlp.gate_proj.scales": "model.safetensors",
194
+ "model.layers.15.mlp.gate_proj.weight": "model.safetensors",
195
+ "model.layers.15.mlp.up_proj.biases": "model.safetensors",
196
+ "model.layers.15.mlp.up_proj.scales": "model.safetensors",
197
+ "model.layers.15.mlp.up_proj.weight": "model.safetensors",
198
+ "model.layers.15.post_attention_layernorm.weight": "model.safetensors",
199
+ "model.layers.15.self_attn.k_norm.weight": "model.safetensors",
200
+ "model.layers.15.self_attn.k_proj.biases": "model.safetensors",
201
+ "model.layers.15.self_attn.k_proj.scales": "model.safetensors",
202
+ "model.layers.15.self_attn.k_proj.weight": "model.safetensors",
203
+ "model.layers.15.self_attn.o_proj.biases": "model.safetensors",
204
+ "model.layers.15.self_attn.o_proj.scales": "model.safetensors",
205
+ "model.layers.15.self_attn.o_proj.weight": "model.safetensors",
206
+ "model.layers.15.self_attn.q_norm.weight": "model.safetensors",
207
+ "model.layers.15.self_attn.q_proj.biases": "model.safetensors",
208
+ "model.layers.15.self_attn.q_proj.scales": "model.safetensors",
209
+ "model.layers.15.self_attn.q_proj.weight": "model.safetensors",
210
+ "model.layers.15.self_attn.v_proj.biases": "model.safetensors",
211
+ "model.layers.15.self_attn.v_proj.scales": "model.safetensors",
212
+ "model.layers.15.self_attn.v_proj.weight": "model.safetensors",
213
+ "model.layers.16.input_layernorm.weight": "model.safetensors",
214
+ "model.layers.16.mlp.down_proj.biases": "model.safetensors",
215
+ "model.layers.16.mlp.down_proj.scales": "model.safetensors",
216
+ "model.layers.16.mlp.down_proj.weight": "model.safetensors",
217
+ "model.layers.16.mlp.gate_proj.biases": "model.safetensors",
218
+ "model.layers.16.mlp.gate_proj.scales": "model.safetensors",
219
+ "model.layers.16.mlp.gate_proj.weight": "model.safetensors",
220
+ "model.layers.16.mlp.up_proj.biases": "model.safetensors",
221
+ "model.layers.16.mlp.up_proj.scales": "model.safetensors",
222
+ "model.layers.16.mlp.up_proj.weight": "model.safetensors",
223
+ "model.layers.16.post_attention_layernorm.weight": "model.safetensors",
224
+ "model.layers.16.self_attn.k_norm.weight": "model.safetensors",
225
+ "model.layers.16.self_attn.k_proj.biases": "model.safetensors",
226
+ "model.layers.16.self_attn.k_proj.scales": "model.safetensors",
227
+ "model.layers.16.self_attn.k_proj.weight": "model.safetensors",
228
+ "model.layers.16.self_attn.o_proj.biases": "model.safetensors",
229
+ "model.layers.16.self_attn.o_proj.scales": "model.safetensors",
230
+ "model.layers.16.self_attn.o_proj.weight": "model.safetensors",
231
+ "model.layers.16.self_attn.q_norm.weight": "model.safetensors",
232
+ "model.layers.16.self_attn.q_proj.biases": "model.safetensors",
233
+ "model.layers.16.self_attn.q_proj.scales": "model.safetensors",
234
+ "model.layers.16.self_attn.q_proj.weight": "model.safetensors",
235
+ "model.layers.16.self_attn.v_proj.biases": "model.safetensors",
236
+ "model.layers.16.self_attn.v_proj.scales": "model.safetensors",
237
+ "model.layers.16.self_attn.v_proj.weight": "model.safetensors",
238
+ "model.layers.17.input_layernorm.weight": "model.safetensors",
239
+ "model.layers.17.mlp.down_proj.biases": "model.safetensors",
240
+ "model.layers.17.mlp.down_proj.scales": "model.safetensors",
241
+ "model.layers.17.mlp.down_proj.weight": "model.safetensors",
242
+ "model.layers.17.mlp.gate_proj.biases": "model.safetensors",
243
+ "model.layers.17.mlp.gate_proj.scales": "model.safetensors",
244
+ "model.layers.17.mlp.gate_proj.weight": "model.safetensors",
245
+ "model.layers.17.mlp.up_proj.biases": "model.safetensors",
246
+ "model.layers.17.mlp.up_proj.scales": "model.safetensors",
247
+ "model.layers.17.mlp.up_proj.weight": "model.safetensors",
248
+ "model.layers.17.post_attention_layernorm.weight": "model.safetensors",
249
+ "model.layers.17.self_attn.k_norm.weight": "model.safetensors",
250
+ "model.layers.17.self_attn.k_proj.biases": "model.safetensors",
251
+ "model.layers.17.self_attn.k_proj.scales": "model.safetensors",
252
+ "model.layers.17.self_attn.k_proj.weight": "model.safetensors",
253
+ "model.layers.17.self_attn.o_proj.biases": "model.safetensors",
254
+ "model.layers.17.self_attn.o_proj.scales": "model.safetensors",
255
+ "model.layers.17.self_attn.o_proj.weight": "model.safetensors",
256
+ "model.layers.17.self_attn.q_norm.weight": "model.safetensors",
257
+ "model.layers.17.self_attn.q_proj.biases": "model.safetensors",
258
+ "model.layers.17.self_attn.q_proj.scales": "model.safetensors",
259
+ "model.layers.17.self_attn.q_proj.weight": "model.safetensors",
260
+ "model.layers.17.self_attn.v_proj.biases": "model.safetensors",
261
+ "model.layers.17.self_attn.v_proj.scales": "model.safetensors",
262
+ "model.layers.17.self_attn.v_proj.weight": "model.safetensors",
263
+ "model.layers.18.input_layernorm.weight": "model.safetensors",
264
+ "model.layers.18.mlp.down_proj.biases": "model.safetensors",
265
+ "model.layers.18.mlp.down_proj.scales": "model.safetensors",
266
+ "model.layers.18.mlp.down_proj.weight": "model.safetensors",
267
+ "model.layers.18.mlp.gate_proj.biases": "model.safetensors",
268
+ "model.layers.18.mlp.gate_proj.scales": "model.safetensors",
269
+ "model.layers.18.mlp.gate_proj.weight": "model.safetensors",
270
+ "model.layers.18.mlp.up_proj.biases": "model.safetensors",
271
+ "model.layers.18.mlp.up_proj.scales": "model.safetensors",
272
+ "model.layers.18.mlp.up_proj.weight": "model.safetensors",
273
+ "model.layers.18.post_attention_layernorm.weight": "model.safetensors",
274
+ "model.layers.18.self_attn.k_norm.weight": "model.safetensors",
275
+ "model.layers.18.self_attn.k_proj.biases": "model.safetensors",
276
+ "model.layers.18.self_attn.k_proj.scales": "model.safetensors",
277
+ "model.layers.18.self_attn.k_proj.weight": "model.safetensors",
278
+ "model.layers.18.self_attn.o_proj.biases": "model.safetensors",
279
+ "model.layers.18.self_attn.o_proj.scales": "model.safetensors",
280
+ "model.layers.18.self_attn.o_proj.weight": "model.safetensors",
281
+ "model.layers.18.self_attn.q_norm.weight": "model.safetensors",
282
+ "model.layers.18.self_attn.q_proj.biases": "model.safetensors",
283
+ "model.layers.18.self_attn.q_proj.scales": "model.safetensors",
284
+ "model.layers.18.self_attn.q_proj.weight": "model.safetensors",
285
+ "model.layers.18.self_attn.v_proj.biases": "model.safetensors",
286
+ "model.layers.18.self_attn.v_proj.scales": "model.safetensors",
287
+ "model.layers.18.self_attn.v_proj.weight": "model.safetensors",
288
+ "model.layers.19.input_layernorm.weight": "model.safetensors",
289
+ "model.layers.19.mlp.down_proj.biases": "model.safetensors",
290
+ "model.layers.19.mlp.down_proj.scales": "model.safetensors",
291
+ "model.layers.19.mlp.down_proj.weight": "model.safetensors",
292
+ "model.layers.19.mlp.gate_proj.biases": "model.safetensors",
293
+ "model.layers.19.mlp.gate_proj.scales": "model.safetensors",
294
+ "model.layers.19.mlp.gate_proj.weight": "model.safetensors",
295
+ "model.layers.19.mlp.up_proj.biases": "model.safetensors",
296
+ "model.layers.19.mlp.up_proj.scales": "model.safetensors",
297
+ "model.layers.19.mlp.up_proj.weight": "model.safetensors",
298
+ "model.layers.19.post_attention_layernorm.weight": "model.safetensors",
299
+ "model.layers.19.self_attn.k_norm.weight": "model.safetensors",
300
+ "model.layers.19.self_attn.k_proj.biases": "model.safetensors",
301
+ "model.layers.19.self_attn.k_proj.scales": "model.safetensors",
302
+ "model.layers.19.self_attn.k_proj.weight": "model.safetensors",
303
+ "model.layers.19.self_attn.o_proj.biases": "model.safetensors",
304
+ "model.layers.19.self_attn.o_proj.scales": "model.safetensors",
305
+ "model.layers.19.self_attn.o_proj.weight": "model.safetensors",
306
+ "model.layers.19.self_attn.q_norm.weight": "model.safetensors",
307
+ "model.layers.19.self_attn.q_proj.biases": "model.safetensors",
308
+ "model.layers.19.self_attn.q_proj.scales": "model.safetensors",
309
+ "model.layers.19.self_attn.q_proj.weight": "model.safetensors",
310
+ "model.layers.19.self_attn.v_proj.biases": "model.safetensors",
311
+ "model.layers.19.self_attn.v_proj.scales": "model.safetensors",
312
+ "model.layers.19.self_attn.v_proj.weight": "model.safetensors",
313
+ "model.layers.2.input_layernorm.weight": "model.safetensors",
314
+ "model.layers.2.mlp.down_proj.biases": "model.safetensors",
315
+ "model.layers.2.mlp.down_proj.scales": "model.safetensors",
316
+ "model.layers.2.mlp.down_proj.weight": "model.safetensors",
317
+ "model.layers.2.mlp.gate_proj.biases": "model.safetensors",
318
+ "model.layers.2.mlp.gate_proj.scales": "model.safetensors",
319
+ "model.layers.2.mlp.gate_proj.weight": "model.safetensors",
320
+ "model.layers.2.mlp.up_proj.biases": "model.safetensors",
321
+ "model.layers.2.mlp.up_proj.scales": "model.safetensors",
322
+ "model.layers.2.mlp.up_proj.weight": "model.safetensors",
323
+ "model.layers.2.post_attention_layernorm.weight": "model.safetensors",
324
+ "model.layers.2.self_attn.k_norm.weight": "model.safetensors",
325
+ "model.layers.2.self_attn.k_proj.biases": "model.safetensors",
326
+ "model.layers.2.self_attn.k_proj.scales": "model.safetensors",
327
+ "model.layers.2.self_attn.k_proj.weight": "model.safetensors",
328
+ "model.layers.2.self_attn.o_proj.biases": "model.safetensors",
329
+ "model.layers.2.self_attn.o_proj.scales": "model.safetensors",
330
+ "model.layers.2.self_attn.o_proj.weight": "model.safetensors",
331
+ "model.layers.2.self_attn.q_norm.weight": "model.safetensors",
332
+ "model.layers.2.self_attn.q_proj.biases": "model.safetensors",
333
+ "model.layers.2.self_attn.q_proj.scales": "model.safetensors",
334
+ "model.layers.2.self_attn.q_proj.weight": "model.safetensors",
335
+ "model.layers.2.self_attn.v_proj.biases": "model.safetensors",
336
+ "model.layers.2.self_attn.v_proj.scales": "model.safetensors",
337
+ "model.layers.2.self_attn.v_proj.weight": "model.safetensors",
338
+ "model.layers.20.input_layernorm.weight": "model.safetensors",
339
+ "model.layers.20.mlp.down_proj.biases": "model.safetensors",
340
+ "model.layers.20.mlp.down_proj.scales": "model.safetensors",
341
+ "model.layers.20.mlp.down_proj.weight": "model.safetensors",
342
+ "model.layers.20.mlp.gate_proj.biases": "model.safetensors",
343
+ "model.layers.20.mlp.gate_proj.scales": "model.safetensors",
344
+ "model.layers.20.mlp.gate_proj.weight": "model.safetensors",
345
+ "model.layers.20.mlp.up_proj.biases": "model.safetensors",
346
+ "model.layers.20.mlp.up_proj.scales": "model.safetensors",
347
+ "model.layers.20.mlp.up_proj.weight": "model.safetensors",
348
+ "model.layers.20.post_attention_layernorm.weight": "model.safetensors",
349
+ "model.layers.20.self_attn.k_norm.weight": "model.safetensors",
350
+ "model.layers.20.self_attn.k_proj.biases": "model.safetensors",
351
+ "model.layers.20.self_attn.k_proj.scales": "model.safetensors",
352
+ "model.layers.20.self_attn.k_proj.weight": "model.safetensors",
353
+ "model.layers.20.self_attn.o_proj.biases": "model.safetensors",
354
+ "model.layers.20.self_attn.o_proj.scales": "model.safetensors",
355
+ "model.layers.20.self_attn.o_proj.weight": "model.safetensors",
356
+ "model.layers.20.self_attn.q_norm.weight": "model.safetensors",
357
+ "model.layers.20.self_attn.q_proj.biases": "model.safetensors",
358
+ "model.layers.20.self_attn.q_proj.scales": "model.safetensors",
359
+ "model.layers.20.self_attn.q_proj.weight": "model.safetensors",
360
+ "model.layers.20.self_attn.v_proj.biases": "model.safetensors",
361
+ "model.layers.20.self_attn.v_proj.scales": "model.safetensors",
362
+ "model.layers.20.self_attn.v_proj.weight": "model.safetensors",
363
+ "model.layers.21.input_layernorm.weight": "model.safetensors",
364
+ "model.layers.21.mlp.down_proj.biases": "model.safetensors",
365
+ "model.layers.21.mlp.down_proj.scales": "model.safetensors",
366
+ "model.layers.21.mlp.down_proj.weight": "model.safetensors",
367
+ "model.layers.21.mlp.gate_proj.biases": "model.safetensors",
368
+ "model.layers.21.mlp.gate_proj.scales": "model.safetensors",
369
+ "model.layers.21.mlp.gate_proj.weight": "model.safetensors",
370
+ "model.layers.21.mlp.up_proj.biases": "model.safetensors",
371
+ "model.layers.21.mlp.up_proj.scales": "model.safetensors",
372
+ "model.layers.21.mlp.up_proj.weight": "model.safetensors",
373
+ "model.layers.21.post_attention_layernorm.weight": "model.safetensors",
374
+ "model.layers.21.self_attn.k_norm.weight": "model.safetensors",
375
+ "model.layers.21.self_attn.k_proj.biases": "model.safetensors",
376
+ "model.layers.21.self_attn.k_proj.scales": "model.safetensors",
377
+ "model.layers.21.self_attn.k_proj.weight": "model.safetensors",
378
+ "model.layers.21.self_attn.o_proj.biases": "model.safetensors",
379
+ "model.layers.21.self_attn.o_proj.scales": "model.safetensors",
380
+ "model.layers.21.self_attn.o_proj.weight": "model.safetensors",
381
+ "model.layers.21.self_attn.q_norm.weight": "model.safetensors",
382
+ "model.layers.21.self_attn.q_proj.biases": "model.safetensors",
383
+ "model.layers.21.self_attn.q_proj.scales": "model.safetensors",
384
+ "model.layers.21.self_attn.q_proj.weight": "model.safetensors",
385
+ "model.layers.21.self_attn.v_proj.biases": "model.safetensors",
386
+ "model.layers.21.self_attn.v_proj.scales": "model.safetensors",
387
+ "model.layers.21.self_attn.v_proj.weight": "model.safetensors",
388
+ "model.layers.22.input_layernorm.weight": "model.safetensors",
389
+ "model.layers.22.mlp.down_proj.biases": "model.safetensors",
390
+ "model.layers.22.mlp.down_proj.scales": "model.safetensors",
391
+ "model.layers.22.mlp.down_proj.weight": "model.safetensors",
392
+ "model.layers.22.mlp.gate_proj.biases": "model.safetensors",
393
+ "model.layers.22.mlp.gate_proj.scales": "model.safetensors",
394
+ "model.layers.22.mlp.gate_proj.weight": "model.safetensors",
395
+ "model.layers.22.mlp.up_proj.biases": "model.safetensors",
396
+ "model.layers.22.mlp.up_proj.scales": "model.safetensors",
397
+ "model.layers.22.mlp.up_proj.weight": "model.safetensors",
398
+ "model.layers.22.post_attention_layernorm.weight": "model.safetensors",
399
+ "model.layers.22.self_attn.k_norm.weight": "model.safetensors",
400
+ "model.layers.22.self_attn.k_proj.biases": "model.safetensors",
401
+ "model.layers.22.self_attn.k_proj.scales": "model.safetensors",
402
+ "model.layers.22.self_attn.k_proj.weight": "model.safetensors",
403
+ "model.layers.22.self_attn.o_proj.biases": "model.safetensors",
404
+ "model.layers.22.self_attn.o_proj.scales": "model.safetensors",
405
+ "model.layers.22.self_attn.o_proj.weight": "model.safetensors",
406
+ "model.layers.22.self_attn.q_norm.weight": "model.safetensors",
407
+ "model.layers.22.self_attn.q_proj.biases": "model.safetensors",
408
+ "model.layers.22.self_attn.q_proj.scales": "model.safetensors",
409
+ "model.layers.22.self_attn.q_proj.weight": "model.safetensors",
410
+ "model.layers.22.self_attn.v_proj.biases": "model.safetensors",
411
+ "model.layers.22.self_attn.v_proj.scales": "model.safetensors",
412
+ "model.layers.22.self_attn.v_proj.weight": "model.safetensors",
413
+ "model.layers.23.input_layernorm.weight": "model.safetensors",
414
+ "model.layers.23.mlp.down_proj.biases": "model.safetensors",
415
+ "model.layers.23.mlp.down_proj.scales": "model.safetensors",
416
+ "model.layers.23.mlp.down_proj.weight": "model.safetensors",
417
+ "model.layers.23.mlp.gate_proj.biases": "model.safetensors",
418
+ "model.layers.23.mlp.gate_proj.scales": "model.safetensors",
419
+ "model.layers.23.mlp.gate_proj.weight": "model.safetensors",
420
+ "model.layers.23.mlp.up_proj.biases": "model.safetensors",
421
+ "model.layers.23.mlp.up_proj.scales": "model.safetensors",
422
+ "model.layers.23.mlp.up_proj.weight": "model.safetensors",
423
+ "model.layers.23.post_attention_layernorm.weight": "model.safetensors",
424
+ "model.layers.23.self_attn.k_norm.weight": "model.safetensors",
425
+ "model.layers.23.self_attn.k_proj.biases": "model.safetensors",
426
+ "model.layers.23.self_attn.k_proj.scales": "model.safetensors",
427
+ "model.layers.23.self_attn.k_proj.weight": "model.safetensors",
428
+ "model.layers.23.self_attn.o_proj.biases": "model.safetensors",
429
+ "model.layers.23.self_attn.o_proj.scales": "model.safetensors",
430
+ "model.layers.23.self_attn.o_proj.weight": "model.safetensors",
431
+ "model.layers.23.self_attn.q_norm.weight": "model.safetensors",
432
+ "model.layers.23.self_attn.q_proj.biases": "model.safetensors",
433
+ "model.layers.23.self_attn.q_proj.scales": "model.safetensors",
434
+ "model.layers.23.self_attn.q_proj.weight": "model.safetensors",
435
+ "model.layers.23.self_attn.v_proj.biases": "model.safetensors",
436
+ "model.layers.23.self_attn.v_proj.scales": "model.safetensors",
437
+ "model.layers.23.self_attn.v_proj.weight": "model.safetensors",
438
+ "model.layers.24.input_layernorm.weight": "model.safetensors",
439
+ "model.layers.24.mlp.down_proj.biases": "model.safetensors",
440
+ "model.layers.24.mlp.down_proj.scales": "model.safetensors",
441
+ "model.layers.24.mlp.down_proj.weight": "model.safetensors",
442
+ "model.layers.24.mlp.gate_proj.biases": "model.safetensors",
443
+ "model.layers.24.mlp.gate_proj.scales": "model.safetensors",
444
+ "model.layers.24.mlp.gate_proj.weight": "model.safetensors",
445
+ "model.layers.24.mlp.up_proj.biases": "model.safetensors",
446
+ "model.layers.24.mlp.up_proj.scales": "model.safetensors",
447
+ "model.layers.24.mlp.up_proj.weight": "model.safetensors",
448
+ "model.layers.24.post_attention_layernorm.weight": "model.safetensors",
449
+ "model.layers.24.self_attn.k_norm.weight": "model.safetensors",
450
+ "model.layers.24.self_attn.k_proj.biases": "model.safetensors",
451
+ "model.layers.24.self_attn.k_proj.scales": "model.safetensors",
452
+ "model.layers.24.self_attn.k_proj.weight": "model.safetensors",
453
+ "model.layers.24.self_attn.o_proj.biases": "model.safetensors",
454
+ "model.layers.24.self_attn.o_proj.scales": "model.safetensors",
455
+ "model.layers.24.self_attn.o_proj.weight": "model.safetensors",
456
+ "model.layers.24.self_attn.q_norm.weight": "model.safetensors",
457
+ "model.layers.24.self_attn.q_proj.biases": "model.safetensors",
458
+ "model.layers.24.self_attn.q_proj.scales": "model.safetensors",
459
+ "model.layers.24.self_attn.q_proj.weight": "model.safetensors",
460
+ "model.layers.24.self_attn.v_proj.biases": "model.safetensors",
461
+ "model.layers.24.self_attn.v_proj.scales": "model.safetensors",
462
+ "model.layers.24.self_attn.v_proj.weight": "model.safetensors",
463
+ "model.layers.25.input_layernorm.weight": "model.safetensors",
464
+ "model.layers.25.mlp.down_proj.biases": "model.safetensors",
465
+ "model.layers.25.mlp.down_proj.scales": "model.safetensors",
466
+ "model.layers.25.mlp.down_proj.weight": "model.safetensors",
467
+ "model.layers.25.mlp.gate_proj.biases": "model.safetensors",
468
+ "model.layers.25.mlp.gate_proj.scales": "model.safetensors",
469
+ "model.layers.25.mlp.gate_proj.weight": "model.safetensors",
470
+ "model.layers.25.mlp.up_proj.biases": "model.safetensors",
471
+ "model.layers.25.mlp.up_proj.scales": "model.safetensors",
472
+ "model.layers.25.mlp.up_proj.weight": "model.safetensors",
473
+ "model.layers.25.post_attention_layernorm.weight": "model.safetensors",
474
+ "model.layers.25.self_attn.k_norm.weight": "model.safetensors",
475
+ "model.layers.25.self_attn.k_proj.biases": "model.safetensors",
476
+ "model.layers.25.self_attn.k_proj.scales": "model.safetensors",
477
+ "model.layers.25.self_attn.k_proj.weight": "model.safetensors",
478
+ "model.layers.25.self_attn.o_proj.biases": "model.safetensors",
479
+ "model.layers.25.self_attn.o_proj.scales": "model.safetensors",
480
+ "model.layers.25.self_attn.o_proj.weight": "model.safetensors",
481
+ "model.layers.25.self_attn.q_norm.weight": "model.safetensors",
482
+ "model.layers.25.self_attn.q_proj.biases": "model.safetensors",
483
+ "model.layers.25.self_attn.q_proj.scales": "model.safetensors",
484
+ "model.layers.25.self_attn.q_proj.weight": "model.safetensors",
485
+ "model.layers.25.self_attn.v_proj.biases": "model.safetensors",
486
+ "model.layers.25.self_attn.v_proj.scales": "model.safetensors",
487
+ "model.layers.25.self_attn.v_proj.weight": "model.safetensors",
488
+ "model.layers.26.input_layernorm.weight": "model.safetensors",
489
+ "model.layers.26.mlp.down_proj.biases": "model.safetensors",
490
+ "model.layers.26.mlp.down_proj.scales": "model.safetensors",
491
+ "model.layers.26.mlp.down_proj.weight": "model.safetensors",
492
+ "model.layers.26.mlp.gate_proj.biases": "model.safetensors",
493
+ "model.layers.26.mlp.gate_proj.scales": "model.safetensors",
494
+ "model.layers.26.mlp.gate_proj.weight": "model.safetensors",
495
+ "model.layers.26.mlp.up_proj.biases": "model.safetensors",
496
+ "model.layers.26.mlp.up_proj.scales": "model.safetensors",
497
+ "model.layers.26.mlp.up_proj.weight": "model.safetensors",
498
+ "model.layers.26.post_attention_layernorm.weight": "model.safetensors",
499
+ "model.layers.26.self_attn.k_norm.weight": "model.safetensors",
500
+ "model.layers.26.self_attn.k_proj.biases": "model.safetensors",
501
+ "model.layers.26.self_attn.k_proj.scales": "model.safetensors",
502
+ "model.layers.26.self_attn.k_proj.weight": "model.safetensors",
503
+ "model.layers.26.self_attn.o_proj.biases": "model.safetensors",
504
+ "model.layers.26.self_attn.o_proj.scales": "model.safetensors",
505
+ "model.layers.26.self_attn.o_proj.weight": "model.safetensors",
506
+ "model.layers.26.self_attn.q_norm.weight": "model.safetensors",
507
+ "model.layers.26.self_attn.q_proj.biases": "model.safetensors",
508
+ "model.layers.26.self_attn.q_proj.scales": "model.safetensors",
509
+ "model.layers.26.self_attn.q_proj.weight": "model.safetensors",
510
+ "model.layers.26.self_attn.v_proj.biases": "model.safetensors",
511
+ "model.layers.26.self_attn.v_proj.scales": "model.safetensors",
512
+ "model.layers.26.self_attn.v_proj.weight": "model.safetensors",
513
+ "model.layers.27.input_layernorm.weight": "model.safetensors",
514
+ "model.layers.27.mlp.down_proj.biases": "model.safetensors",
515
+ "model.layers.27.mlp.down_proj.scales": "model.safetensors",
516
+ "model.layers.27.mlp.down_proj.weight": "model.safetensors",
517
+ "model.layers.27.mlp.gate_proj.biases": "model.safetensors",
518
+ "model.layers.27.mlp.gate_proj.scales": "model.safetensors",
519
+ "model.layers.27.mlp.gate_proj.weight": "model.safetensors",
520
+ "model.layers.27.mlp.up_proj.biases": "model.safetensors",
521
+ "model.layers.27.mlp.up_proj.scales": "model.safetensors",
522
+ "model.layers.27.mlp.up_proj.weight": "model.safetensors",
523
+ "model.layers.27.post_attention_layernorm.weight": "model.safetensors",
524
+ "model.layers.27.self_attn.k_norm.weight": "model.safetensors",
525
+ "model.layers.27.self_attn.k_proj.biases": "model.safetensors",
526
+ "model.layers.27.self_attn.k_proj.scales": "model.safetensors",
527
+ "model.layers.27.self_attn.k_proj.weight": "model.safetensors",
528
+ "model.layers.27.self_attn.o_proj.biases": "model.safetensors",
529
+ "model.layers.27.self_attn.o_proj.scales": "model.safetensors",
530
+ "model.layers.27.self_attn.o_proj.weight": "model.safetensors",
531
+ "model.layers.27.self_attn.q_norm.weight": "model.safetensors",
532
+ "model.layers.27.self_attn.q_proj.biases": "model.safetensors",
533
+ "model.layers.27.self_attn.q_proj.scales": "model.safetensors",
534
+ "model.layers.27.self_attn.q_proj.weight": "model.safetensors",
535
+ "model.layers.27.self_attn.v_proj.biases": "model.safetensors",
536
+ "model.layers.27.self_attn.v_proj.scales": "model.safetensors",
537
+ "model.layers.27.self_attn.v_proj.weight": "model.safetensors",
538
+ "model.layers.28.input_layernorm.weight": "model.safetensors",
539
+ "model.layers.28.mlp.down_proj.biases": "model.safetensors",
540
+ "model.layers.28.mlp.down_proj.scales": "model.safetensors",
541
+ "model.layers.28.mlp.down_proj.weight": "model.safetensors",
542
+ "model.layers.28.mlp.gate_proj.biases": "model.safetensors",
543
+ "model.layers.28.mlp.gate_proj.scales": "model.safetensors",
544
+ "model.layers.28.mlp.gate_proj.weight": "model.safetensors",
545
+ "model.layers.28.mlp.up_proj.biases": "model.safetensors",
546
+ "model.layers.28.mlp.up_proj.scales": "model.safetensors",
547
+ "model.layers.28.mlp.up_proj.weight": "model.safetensors",
548
+ "model.layers.28.post_attention_layernorm.weight": "model.safetensors",
549
+ "model.layers.28.self_attn.k_norm.weight": "model.safetensors",
550
+ "model.layers.28.self_attn.k_proj.biases": "model.safetensors",
551
+ "model.layers.28.self_attn.k_proj.scales": "model.safetensors",
552
+ "model.layers.28.self_attn.k_proj.weight": "model.safetensors",
553
+ "model.layers.28.self_attn.o_proj.biases": "model.safetensors",
554
+ "model.layers.28.self_attn.o_proj.scales": "model.safetensors",
555
+ "model.layers.28.self_attn.o_proj.weight": "model.safetensors",
556
+ "model.layers.28.self_attn.q_norm.weight": "model.safetensors",
557
+ "model.layers.28.self_attn.q_proj.biases": "model.safetensors",
558
+ "model.layers.28.self_attn.q_proj.scales": "model.safetensors",
559
+ "model.layers.28.self_attn.q_proj.weight": "model.safetensors",
560
+ "model.layers.28.self_attn.v_proj.biases": "model.safetensors",
561
+ "model.layers.28.self_attn.v_proj.scales": "model.safetensors",
562
+ "model.layers.28.self_attn.v_proj.weight": "model.safetensors",
563
+ "model.layers.29.input_layernorm.weight": "model.safetensors",
564
+ "model.layers.29.mlp.down_proj.biases": "model.safetensors",
565
+ "model.layers.29.mlp.down_proj.scales": "model.safetensors",
566
+ "model.layers.29.mlp.down_proj.weight": "model.safetensors",
567
+ "model.layers.29.mlp.gate_proj.biases": "model.safetensors",
568
+ "model.layers.29.mlp.gate_proj.scales": "model.safetensors",
569
+ "model.layers.29.mlp.gate_proj.weight": "model.safetensors",
570
+ "model.layers.29.mlp.up_proj.biases": "model.safetensors",
571
+ "model.layers.29.mlp.up_proj.scales": "model.safetensors",
572
+ "model.layers.29.mlp.up_proj.weight": "model.safetensors",
573
+ "model.layers.29.post_attention_layernorm.weight": "model.safetensors",
574
+ "model.layers.29.self_attn.k_norm.weight": "model.safetensors",
575
+ "model.layers.29.self_attn.k_proj.biases": "model.safetensors",
576
+ "model.layers.29.self_attn.k_proj.scales": "model.safetensors",
577
+ "model.layers.29.self_attn.k_proj.weight": "model.safetensors",
578
+ "model.layers.29.self_attn.o_proj.biases": "model.safetensors",
579
+ "model.layers.29.self_attn.o_proj.scales": "model.safetensors",
580
+ "model.layers.29.self_attn.o_proj.weight": "model.safetensors",
581
+ "model.layers.29.self_attn.q_norm.weight": "model.safetensors",
582
+ "model.layers.29.self_attn.q_proj.biases": "model.safetensors",
583
+ "model.layers.29.self_attn.q_proj.scales": "model.safetensors",
584
+ "model.layers.29.self_attn.q_proj.weight": "model.safetensors",
585
+ "model.layers.29.self_attn.v_proj.biases": "model.safetensors",
586
+ "model.layers.29.self_attn.v_proj.scales": "model.safetensors",
587
+ "model.layers.29.self_attn.v_proj.weight": "model.safetensors",
588
+ "model.layers.3.input_layernorm.weight": "model.safetensors",
589
+ "model.layers.3.mlp.down_proj.biases": "model.safetensors",
590
+ "model.layers.3.mlp.down_proj.scales": "model.safetensors",
591
+ "model.layers.3.mlp.down_proj.weight": "model.safetensors",
592
+ "model.layers.3.mlp.gate_proj.biases": "model.safetensors",
593
+ "model.layers.3.mlp.gate_proj.scales": "model.safetensors",
594
+ "model.layers.3.mlp.gate_proj.weight": "model.safetensors",
595
+ "model.layers.3.mlp.up_proj.biases": "model.safetensors",
596
+ "model.layers.3.mlp.up_proj.scales": "model.safetensors",
597
+ "model.layers.3.mlp.up_proj.weight": "model.safetensors",
598
+ "model.layers.3.post_attention_layernorm.weight": "model.safetensors",
599
+ "model.layers.3.self_attn.k_norm.weight": "model.safetensors",
600
+ "model.layers.3.self_attn.k_proj.biases": "model.safetensors",
601
+ "model.layers.3.self_attn.k_proj.scales": "model.safetensors",
602
+ "model.layers.3.self_attn.k_proj.weight": "model.safetensors",
603
+ "model.layers.3.self_attn.o_proj.biases": "model.safetensors",
604
+ "model.layers.3.self_attn.o_proj.scales": "model.safetensors",
605
+ "model.layers.3.self_attn.o_proj.weight": "model.safetensors",
606
+ "model.layers.3.self_attn.q_norm.weight": "model.safetensors",
607
+ "model.layers.3.self_attn.q_proj.biases": "model.safetensors",
608
+ "model.layers.3.self_attn.q_proj.scales": "model.safetensors",
609
+ "model.layers.3.self_attn.q_proj.weight": "model.safetensors",
610
+ "model.layers.3.self_attn.v_proj.biases": "model.safetensors",
611
+ "model.layers.3.self_attn.v_proj.scales": "model.safetensors",
612
+ "model.layers.3.self_attn.v_proj.weight": "model.safetensors",
613
+ "model.layers.30.input_layernorm.weight": "model.safetensors",
614
+ "model.layers.30.mlp.down_proj.biases": "model.safetensors",
615
+ "model.layers.30.mlp.down_proj.scales": "model.safetensors",
616
+ "model.layers.30.mlp.down_proj.weight": "model.safetensors",
617
+ "model.layers.30.mlp.gate_proj.biases": "model.safetensors",
618
+ "model.layers.30.mlp.gate_proj.scales": "model.safetensors",
619
+ "model.layers.30.mlp.gate_proj.weight": "model.safetensors",
620
+ "model.layers.30.mlp.up_proj.biases": "model.safetensors",
621
+ "model.layers.30.mlp.up_proj.scales": "model.safetensors",
622
+ "model.layers.30.mlp.up_proj.weight": "model.safetensors",
623
+ "model.layers.30.post_attention_layernorm.weight": "model.safetensors",
624
+ "model.layers.30.self_attn.k_norm.weight": "model.safetensors",
625
+ "model.layers.30.self_attn.k_proj.biases": "model.safetensors",
626
+ "model.layers.30.self_attn.k_proj.scales": "model.safetensors",
627
+ "model.layers.30.self_attn.k_proj.weight": "model.safetensors",
628
+ "model.layers.30.self_attn.o_proj.biases": "model.safetensors",
629
+ "model.layers.30.self_attn.o_proj.scales": "model.safetensors",
630
+ "model.layers.30.self_attn.o_proj.weight": "model.safetensors",
631
+ "model.layers.30.self_attn.q_norm.weight": "model.safetensors",
632
+ "model.layers.30.self_attn.q_proj.biases": "model.safetensors",
633
+ "model.layers.30.self_attn.q_proj.scales": "model.safetensors",
634
+ "model.layers.30.self_attn.q_proj.weight": "model.safetensors",
635
+ "model.layers.30.self_attn.v_proj.biases": "model.safetensors",
636
+ "model.layers.30.self_attn.v_proj.scales": "model.safetensors",
637
+ "model.layers.30.self_attn.v_proj.weight": "model.safetensors",
638
+ "model.layers.31.input_layernorm.weight": "model.safetensors",
639
+ "model.layers.31.mlp.down_proj.biases": "model.safetensors",
640
+ "model.layers.31.mlp.down_proj.scales": "model.safetensors",
641
+ "model.layers.31.mlp.down_proj.weight": "model.safetensors",
642
+ "model.layers.31.mlp.gate_proj.biases": "model.safetensors",
643
+ "model.layers.31.mlp.gate_proj.scales": "model.safetensors",
644
+ "model.layers.31.mlp.gate_proj.weight": "model.safetensors",
645
+ "model.layers.31.mlp.up_proj.biases": "model.safetensors",
646
+ "model.layers.31.mlp.up_proj.scales": "model.safetensors",
647
+ "model.layers.31.mlp.up_proj.weight": "model.safetensors",
648
+ "model.layers.31.post_attention_layernorm.weight": "model.safetensors",
649
+ "model.layers.31.self_attn.k_norm.weight": "model.safetensors",
650
+ "model.layers.31.self_attn.k_proj.biases": "model.safetensors",
651
+ "model.layers.31.self_attn.k_proj.scales": "model.safetensors",
652
+ "model.layers.31.self_attn.k_proj.weight": "model.safetensors",
653
+ "model.layers.31.self_attn.o_proj.biases": "model.safetensors",
654
+ "model.layers.31.self_attn.o_proj.scales": "model.safetensors",
655
+ "model.layers.31.self_attn.o_proj.weight": "model.safetensors",
656
+ "model.layers.31.self_attn.q_norm.weight": "model.safetensors",
657
+ "model.layers.31.self_attn.q_proj.biases": "model.safetensors",
658
+ "model.layers.31.self_attn.q_proj.scales": "model.safetensors",
659
+ "model.layers.31.self_attn.q_proj.weight": "model.safetensors",
660
+ "model.layers.31.self_attn.v_proj.biases": "model.safetensors",
661
+ "model.layers.31.self_attn.v_proj.scales": "model.safetensors",
662
+ "model.layers.31.self_attn.v_proj.weight": "model.safetensors",
663
+ "model.layers.32.input_layernorm.weight": "model.safetensors",
664
+ "model.layers.32.mlp.down_proj.biases": "model.safetensors",
665
+ "model.layers.32.mlp.down_proj.scales": "model.safetensors",
666
+ "model.layers.32.mlp.down_proj.weight": "model.safetensors",
667
+ "model.layers.32.mlp.gate_proj.biases": "model.safetensors",
668
+ "model.layers.32.mlp.gate_proj.scales": "model.safetensors",
669
+ "model.layers.32.mlp.gate_proj.weight": "model.safetensors",
670
+ "model.layers.32.mlp.up_proj.biases": "model.safetensors",
671
+ "model.layers.32.mlp.up_proj.scales": "model.safetensors",
672
+ "model.layers.32.mlp.up_proj.weight": "model.safetensors",
673
+ "model.layers.32.post_attention_layernorm.weight": "model.safetensors",
674
+ "model.layers.32.self_attn.k_norm.weight": "model.safetensors",
675
+ "model.layers.32.self_attn.k_proj.biases": "model.safetensors",
676
+ "model.layers.32.self_attn.k_proj.scales": "model.safetensors",
677
+ "model.layers.32.self_attn.k_proj.weight": "model.safetensors",
678
+ "model.layers.32.self_attn.o_proj.biases": "model.safetensors",
679
+ "model.layers.32.self_attn.o_proj.scales": "model.safetensors",
680
+ "model.layers.32.self_attn.o_proj.weight": "model.safetensors",
681
+ "model.layers.32.self_attn.q_norm.weight": "model.safetensors",
682
+ "model.layers.32.self_attn.q_proj.biases": "model.safetensors",
683
+ "model.layers.32.self_attn.q_proj.scales": "model.safetensors",
684
+ "model.layers.32.self_attn.q_proj.weight": "model.safetensors",
685
+ "model.layers.32.self_attn.v_proj.biases": "model.safetensors",
686
+ "model.layers.32.self_attn.v_proj.scales": "model.safetensors",
687
+ "model.layers.32.self_attn.v_proj.weight": "model.safetensors",
688
+ "model.layers.33.input_layernorm.weight": "model.safetensors",
689
+ "model.layers.33.mlp.down_proj.biases": "model.safetensors",
690
+ "model.layers.33.mlp.down_proj.scales": "model.safetensors",
691
+ "model.layers.33.mlp.down_proj.weight": "model.safetensors",
692
+ "model.layers.33.mlp.gate_proj.biases": "model.safetensors",
693
+ "model.layers.33.mlp.gate_proj.scales": "model.safetensors",
694
+ "model.layers.33.mlp.gate_proj.weight": "model.safetensors",
695
+ "model.layers.33.mlp.up_proj.biases": "model.safetensors",
696
+ "model.layers.33.mlp.up_proj.scales": "model.safetensors",
697
+ "model.layers.33.mlp.up_proj.weight": "model.safetensors",
698
+ "model.layers.33.post_attention_layernorm.weight": "model.safetensors",
699
+ "model.layers.33.self_attn.k_norm.weight": "model.safetensors",
700
+ "model.layers.33.self_attn.k_proj.biases": "model.safetensors",
701
+ "model.layers.33.self_attn.k_proj.scales": "model.safetensors",
702
+ "model.layers.33.self_attn.k_proj.weight": "model.safetensors",
703
+ "model.layers.33.self_attn.o_proj.biases": "model.safetensors",
704
+ "model.layers.33.self_attn.o_proj.scales": "model.safetensors",
705
+ "model.layers.33.self_attn.o_proj.weight": "model.safetensors",
706
+ "model.layers.33.self_attn.q_norm.weight": "model.safetensors",
707
+ "model.layers.33.self_attn.q_proj.biases": "model.safetensors",
708
+ "model.layers.33.self_attn.q_proj.scales": "model.safetensors",
709
+ "model.layers.33.self_attn.q_proj.weight": "model.safetensors",
710
+ "model.layers.33.self_attn.v_proj.biases": "model.safetensors",
711
+ "model.layers.33.self_attn.v_proj.scales": "model.safetensors",
712
+ "model.layers.33.self_attn.v_proj.weight": "model.safetensors",
713
+ "model.layers.34.input_layernorm.weight": "model.safetensors",
714
+ "model.layers.34.mlp.down_proj.biases": "model.safetensors",
715
+ "model.layers.34.mlp.down_proj.scales": "model.safetensors",
716
+ "model.layers.34.mlp.down_proj.weight": "model.safetensors",
717
+ "model.layers.34.mlp.gate_proj.biases": "model.safetensors",
718
+ "model.layers.34.mlp.gate_proj.scales": "model.safetensors",
719
+ "model.layers.34.mlp.gate_proj.weight": "model.safetensors",
720
+ "model.layers.34.mlp.up_proj.biases": "model.safetensors",
721
+ "model.layers.34.mlp.up_proj.scales": "model.safetensors",
722
+ "model.layers.34.mlp.up_proj.weight": "model.safetensors",
723
+ "model.layers.34.post_attention_layernorm.weight": "model.safetensors",
724
+ "model.layers.34.self_attn.k_norm.weight": "model.safetensors",
725
+ "model.layers.34.self_attn.k_proj.biases": "model.safetensors",
726
+ "model.layers.34.self_attn.k_proj.scales": "model.safetensors",
727
+ "model.layers.34.self_attn.k_proj.weight": "model.safetensors",
728
+ "model.layers.34.self_attn.o_proj.biases": "model.safetensors",
729
+ "model.layers.34.self_attn.o_proj.scales": "model.safetensors",
730
+ "model.layers.34.self_attn.o_proj.weight": "model.safetensors",
731
+ "model.layers.34.self_attn.q_norm.weight": "model.safetensors",
732
+ "model.layers.34.self_attn.q_proj.biases": "model.safetensors",
733
+ "model.layers.34.self_attn.q_proj.scales": "model.safetensors",
734
+ "model.layers.34.self_attn.q_proj.weight": "model.safetensors",
735
+ "model.layers.34.self_attn.v_proj.biases": "model.safetensors",
736
+ "model.layers.34.self_attn.v_proj.scales": "model.safetensors",
737
+ "model.layers.34.self_attn.v_proj.weight": "model.safetensors",
738
+ "model.layers.35.input_layernorm.weight": "model.safetensors",
739
+ "model.layers.35.mlp.down_proj.biases": "model.safetensors",
740
+ "model.layers.35.mlp.down_proj.scales": "model.safetensors",
741
+ "model.layers.35.mlp.down_proj.weight": "model.safetensors",
742
+ "model.layers.35.mlp.gate_proj.biases": "model.safetensors",
743
+ "model.layers.35.mlp.gate_proj.scales": "model.safetensors",
744
+ "model.layers.35.mlp.gate_proj.weight": "model.safetensors",
745
+ "model.layers.35.mlp.up_proj.biases": "model.safetensors",
746
+ "model.layers.35.mlp.up_proj.scales": "model.safetensors",
747
+ "model.layers.35.mlp.up_proj.weight": "model.safetensors",
748
+ "model.layers.35.post_attention_layernorm.weight": "model.safetensors",
749
+ "model.layers.35.self_attn.k_norm.weight": "model.safetensors",
750
+ "model.layers.35.self_attn.k_proj.biases": "model.safetensors",
751
+ "model.layers.35.self_attn.k_proj.scales": "model.safetensors",
752
+ "model.layers.35.self_attn.k_proj.weight": "model.safetensors",
753
+ "model.layers.35.self_attn.o_proj.biases": "model.safetensors",
754
+ "model.layers.35.self_attn.o_proj.scales": "model.safetensors",
755
+ "model.layers.35.self_attn.o_proj.weight": "model.safetensors",
756
+ "model.layers.35.self_attn.q_norm.weight": "model.safetensors",
757
+ "model.layers.35.self_attn.q_proj.biases": "model.safetensors",
758
+ "model.layers.35.self_attn.q_proj.scales": "model.safetensors",
759
+ "model.layers.35.self_attn.q_proj.weight": "model.safetensors",
760
+ "model.layers.35.self_attn.v_proj.biases": "model.safetensors",
761
+ "model.layers.35.self_attn.v_proj.scales": "model.safetensors",
762
+ "model.layers.35.self_attn.v_proj.weight": "model.safetensors",
763
+ "model.layers.4.input_layernorm.weight": "model.safetensors",
764
+ "model.layers.4.mlp.down_proj.biases": "model.safetensors",
765
+ "model.layers.4.mlp.down_proj.scales": "model.safetensors",
766
+ "model.layers.4.mlp.down_proj.weight": "model.safetensors",
767
+ "model.layers.4.mlp.gate_proj.biases": "model.safetensors",
768
+ "model.layers.4.mlp.gate_proj.scales": "model.safetensors",
769
+ "model.layers.4.mlp.gate_proj.weight": "model.safetensors",
770
+ "model.layers.4.mlp.up_proj.biases": "model.safetensors",
771
+ "model.layers.4.mlp.up_proj.scales": "model.safetensors",
772
+ "model.layers.4.mlp.up_proj.weight": "model.safetensors",
773
+ "model.layers.4.post_attention_layernorm.weight": "model.safetensors",
774
+ "model.layers.4.self_attn.k_norm.weight": "model.safetensors",
775
+ "model.layers.4.self_attn.k_proj.biases": "model.safetensors",
776
+ "model.layers.4.self_attn.k_proj.scales": "model.safetensors",
777
+ "model.layers.4.self_attn.k_proj.weight": "model.safetensors",
778
+ "model.layers.4.self_attn.o_proj.biases": "model.safetensors",
779
+ "model.layers.4.self_attn.o_proj.scales": "model.safetensors",
780
+ "model.layers.4.self_attn.o_proj.weight": "model.safetensors",
781
+ "model.layers.4.self_attn.q_norm.weight": "model.safetensors",
782
+ "model.layers.4.self_attn.q_proj.biases": "model.safetensors",
783
+ "model.layers.4.self_attn.q_proj.scales": "model.safetensors",
784
+ "model.layers.4.self_attn.q_proj.weight": "model.safetensors",
785
+ "model.layers.4.self_attn.v_proj.biases": "model.safetensors",
786
+ "model.layers.4.self_attn.v_proj.scales": "model.safetensors",
787
+ "model.layers.4.self_attn.v_proj.weight": "model.safetensors",
788
+ "model.layers.5.input_layernorm.weight": "model.safetensors",
789
+ "model.layers.5.mlp.down_proj.biases": "model.safetensors",
790
+ "model.layers.5.mlp.down_proj.scales": "model.safetensors",
791
+ "model.layers.5.mlp.down_proj.weight": "model.safetensors",
792
+ "model.layers.5.mlp.gate_proj.biases": "model.safetensors",
793
+ "model.layers.5.mlp.gate_proj.scales": "model.safetensors",
794
+ "model.layers.5.mlp.gate_proj.weight": "model.safetensors",
795
+ "model.layers.5.mlp.up_proj.biases": "model.safetensors",
796
+ "model.layers.5.mlp.up_proj.scales": "model.safetensors",
797
+ "model.layers.5.mlp.up_proj.weight": "model.safetensors",
798
+ "model.layers.5.post_attention_layernorm.weight": "model.safetensors",
799
+ "model.layers.5.self_attn.k_norm.weight": "model.safetensors",
800
+ "model.layers.5.self_attn.k_proj.biases": "model.safetensors",
801
+ "model.layers.5.self_attn.k_proj.scales": "model.safetensors",
802
+ "model.layers.5.self_attn.k_proj.weight": "model.safetensors",
803
+ "model.layers.5.self_attn.o_proj.biases": "model.safetensors",
804
+ "model.layers.5.self_attn.o_proj.scales": "model.safetensors",
805
+ "model.layers.5.self_attn.o_proj.weight": "model.safetensors",
806
+ "model.layers.5.self_attn.q_norm.weight": "model.safetensors",
807
+ "model.layers.5.self_attn.q_proj.biases": "model.safetensors",
808
+ "model.layers.5.self_attn.q_proj.scales": "model.safetensors",
809
+ "model.layers.5.self_attn.q_proj.weight": "model.safetensors",
810
+ "model.layers.5.self_attn.v_proj.biases": "model.safetensors",
811
+ "model.layers.5.self_attn.v_proj.scales": "model.safetensors",
812
+ "model.layers.5.self_attn.v_proj.weight": "model.safetensors",
813
+ "model.layers.6.input_layernorm.weight": "model.safetensors",
814
+ "model.layers.6.mlp.down_proj.biases": "model.safetensors",
815
+ "model.layers.6.mlp.down_proj.scales": "model.safetensors",
816
+ "model.layers.6.mlp.down_proj.weight": "model.safetensors",
817
+ "model.layers.6.mlp.gate_proj.biases": "model.safetensors",
818
+ "model.layers.6.mlp.gate_proj.scales": "model.safetensors",
819
+ "model.layers.6.mlp.gate_proj.weight": "model.safetensors",
820
+ "model.layers.6.mlp.up_proj.biases": "model.safetensors",
821
+ "model.layers.6.mlp.up_proj.scales": "model.safetensors",
822
+ "model.layers.6.mlp.up_proj.weight": "model.safetensors",
823
+ "model.layers.6.post_attention_layernorm.weight": "model.safetensors",
824
+ "model.layers.6.self_attn.k_norm.weight": "model.safetensors",
825
+ "model.layers.6.self_attn.k_proj.biases": "model.safetensors",
826
+ "model.layers.6.self_attn.k_proj.scales": "model.safetensors",
827
+ "model.layers.6.self_attn.k_proj.weight": "model.safetensors",
828
+ "model.layers.6.self_attn.o_proj.biases": "model.safetensors",
829
+ "model.layers.6.self_attn.o_proj.scales": "model.safetensors",
830
+ "model.layers.6.self_attn.o_proj.weight": "model.safetensors",
831
+ "model.layers.6.self_attn.q_norm.weight": "model.safetensors",
832
+ "model.layers.6.self_attn.q_proj.biases": "model.safetensors",
833
+ "model.layers.6.self_attn.q_proj.scales": "model.safetensors",
834
+ "model.layers.6.self_attn.q_proj.weight": "model.safetensors",
835
+ "model.layers.6.self_attn.v_proj.biases": "model.safetensors",
836
+ "model.layers.6.self_attn.v_proj.scales": "model.safetensors",
837
+ "model.layers.6.self_attn.v_proj.weight": "model.safetensors",
838
+ "model.layers.7.input_layernorm.weight": "model.safetensors",
839
+ "model.layers.7.mlp.down_proj.biases": "model.safetensors",
840
+ "model.layers.7.mlp.down_proj.scales": "model.safetensors",
841
+ "model.layers.7.mlp.down_proj.weight": "model.safetensors",
842
+ "model.layers.7.mlp.gate_proj.biases": "model.safetensors",
843
+ "model.layers.7.mlp.gate_proj.scales": "model.safetensors",
844
+ "model.layers.7.mlp.gate_proj.weight": "model.safetensors",
845
+ "model.layers.7.mlp.up_proj.biases": "model.safetensors",
846
+ "model.layers.7.mlp.up_proj.scales": "model.safetensors",
847
+ "model.layers.7.mlp.up_proj.weight": "model.safetensors",
848
+ "model.layers.7.post_attention_layernorm.weight": "model.safetensors",
849
+ "model.layers.7.self_attn.k_norm.weight": "model.safetensors",
850
+ "model.layers.7.self_attn.k_proj.biases": "model.safetensors",
851
+ "model.layers.7.self_attn.k_proj.scales": "model.safetensors",
852
+ "model.layers.7.self_attn.k_proj.weight": "model.safetensors",
853
+ "model.layers.7.self_attn.o_proj.biases": "model.safetensors",
854
+ "model.layers.7.self_attn.o_proj.scales": "model.safetensors",
855
+ "model.layers.7.self_attn.o_proj.weight": "model.safetensors",
856
+ "model.layers.7.self_attn.q_norm.weight": "model.safetensors",
857
+ "model.layers.7.self_attn.q_proj.biases": "model.safetensors",
858
+ "model.layers.7.self_attn.q_proj.scales": "model.safetensors",
859
+ "model.layers.7.self_attn.q_proj.weight": "model.safetensors",
860
+ "model.layers.7.self_attn.v_proj.biases": "model.safetensors",
861
+ "model.layers.7.self_attn.v_proj.scales": "model.safetensors",
862
+ "model.layers.7.self_attn.v_proj.weight": "model.safetensors",
863
+ "model.layers.8.input_layernorm.weight": "model.safetensors",
864
+ "model.layers.8.mlp.down_proj.biases": "model.safetensors",
865
+ "model.layers.8.mlp.down_proj.scales": "model.safetensors",
866
+ "model.layers.8.mlp.down_proj.weight": "model.safetensors",
867
+ "model.layers.8.mlp.gate_proj.biases": "model.safetensors",
868
+ "model.layers.8.mlp.gate_proj.scales": "model.safetensors",
869
+ "model.layers.8.mlp.gate_proj.weight": "model.safetensors",
870
+ "model.layers.8.mlp.up_proj.biases": "model.safetensors",
871
+ "model.layers.8.mlp.up_proj.scales": "model.safetensors",
872
+ "model.layers.8.mlp.up_proj.weight": "model.safetensors",
873
+ "model.layers.8.post_attention_layernorm.weight": "model.safetensors",
874
+ "model.layers.8.self_attn.k_norm.weight": "model.safetensors",
875
+ "model.layers.8.self_attn.k_proj.biases": "model.safetensors",
876
+ "model.layers.8.self_attn.k_proj.scales": "model.safetensors",
877
+ "model.layers.8.self_attn.k_proj.weight": "model.safetensors",
878
+ "model.layers.8.self_attn.o_proj.biases": "model.safetensors",
879
+ "model.layers.8.self_attn.o_proj.scales": "model.safetensors",
880
+ "model.layers.8.self_attn.o_proj.weight": "model.safetensors",
881
+ "model.layers.8.self_attn.q_norm.weight": "model.safetensors",
882
+ "model.layers.8.self_attn.q_proj.biases": "model.safetensors",
883
+ "model.layers.8.self_attn.q_proj.scales": "model.safetensors",
884
+ "model.layers.8.self_attn.q_proj.weight": "model.safetensors",
885
+ "model.layers.8.self_attn.v_proj.biases": "model.safetensors",
886
+ "model.layers.8.self_attn.v_proj.scales": "model.safetensors",
887
+ "model.layers.8.self_attn.v_proj.weight": "model.safetensors",
888
+ "model.layers.9.input_layernorm.weight": "model.safetensors",
889
+ "model.layers.9.mlp.down_proj.biases": "model.safetensors",
890
+ "model.layers.9.mlp.down_proj.scales": "model.safetensors",
891
+ "model.layers.9.mlp.down_proj.weight": "model.safetensors",
892
+ "model.layers.9.mlp.gate_proj.biases": "model.safetensors",
893
+ "model.layers.9.mlp.gate_proj.scales": "model.safetensors",
894
+ "model.layers.9.mlp.gate_proj.weight": "model.safetensors",
895
+ "model.layers.9.mlp.up_proj.biases": "model.safetensors",
896
+ "model.layers.9.mlp.up_proj.scales": "model.safetensors",
897
+ "model.layers.9.mlp.up_proj.weight": "model.safetensors",
898
+ "model.layers.9.post_attention_layernorm.weight": "model.safetensors",
899
+ "model.layers.9.self_attn.k_norm.weight": "model.safetensors",
900
+ "model.layers.9.self_attn.k_proj.biases": "model.safetensors",
901
+ "model.layers.9.self_attn.k_proj.scales": "model.safetensors",
902
+ "model.layers.9.self_attn.k_proj.weight": "model.safetensors",
903
+ "model.layers.9.self_attn.o_proj.biases": "model.safetensors",
904
+ "model.layers.9.self_attn.o_proj.scales": "model.safetensors",
905
+ "model.layers.9.self_attn.o_proj.weight": "model.safetensors",
906
+ "model.layers.9.self_attn.q_norm.weight": "model.safetensors",
907
+ "model.layers.9.self_attn.q_proj.biases": "model.safetensors",
908
+ "model.layers.9.self_attn.q_proj.scales": "model.safetensors",
909
+ "model.layers.9.self_attn.q_proj.weight": "model.safetensors",
910
+ "model.layers.9.self_attn.v_proj.biases": "model.safetensors",
911
+ "model.layers.9.self_attn.v_proj.scales": "model.safetensors",
912
+ "model.layers.9.self_attn.v_proj.weight": "model.safetensors",
913
+ "model.norm.weight": "model.safetensors"
914
+ }
915
+ }
mlx_llm/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
mlx_llm/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e4855778eb5536cbc88a3ad243c339bce177b610474b2305dc1bdf322c65482
3
+ size 11423398
mlx_llm/tokenizer_config.json ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ },
181
+ "151665": {
182
+ "content": "<tool_response>",
183
+ "lstrip": false,
184
+ "normalized": false,
185
+ "rstrip": false,
186
+ "single_word": false,
187
+ "special": false
188
+ },
189
+ "151666": {
190
+ "content": "</tool_response>",
191
+ "lstrip": false,
192
+ "normalized": false,
193
+ "rstrip": false,
194
+ "single_word": false,
195
+ "special": false
196
+ },
197
+ "151667": {
198
+ "content": "<think>",
199
+ "lstrip": false,
200
+ "normalized": false,
201
+ "rstrip": false,
202
+ "single_word": false,
203
+ "special": false
204
+ },
205
+ "151668": {
206
+ "content": "</think>",
207
+ "lstrip": false,
208
+ "normalized": false,
209
+ "rstrip": false,
210
+ "single_word": false,
211
+ "special": false
212
+ },
213
+ "151669": {
214
+ "content": "<|system|>",
215
+ "lstrip": false,
216
+ "normalized": false,
217
+ "rstrip": false,
218
+ "single_word": false,
219
+ "special": false
220
+ },
221
+ "151670": {
222
+ "content": "<|user|>",
223
+ "lstrip": false,
224
+ "normalized": false,
225
+ "rstrip": false,
226
+ "single_word": false,
227
+ "special": false
228
+ },
229
+ "151671": {
230
+ "content": "<|assistant|>",
231
+ "lstrip": false,
232
+ "normalized": false,
233
+ "rstrip": false,
234
+ "single_word": false,
235
+ "special": false
236
+ },
237
+ "151672": {
238
+ "content": "<|eot|>",
239
+ "lstrip": false,
240
+ "normalized": false,
241
+ "rstrip": false,
242
+ "single_word": false,
243
+ "special": false
244
+ }
245
+ },
246
+ "additional_special_tokens": [
247
+ "<|im_start|>",
248
+ "<|im_end|>",
249
+ "<|object_ref_start|>",
250
+ "<|object_ref_end|>",
251
+ "<|box_start|>",
252
+ "<|box_end|>",
253
+ "<|quad_start|>",
254
+ "<|quad_end|>",
255
+ "<|vision_start|>",
256
+ "<|vision_end|>",
257
+ "<|vision_pad|>",
258
+ "<|image_pad|>",
259
+ "<|video_pad|>"
260
+ ],
261
+ "bos_token": null,
262
+ "clean_up_tokenization_spaces": false,
263
+ "eos_token": "<|im_end|>",
264
+ "errors": "replace",
265
+ "extra_special_tokens": {},
266
+ "model_max_length": 131072,
267
+ "pad_token": "<|endoftext|>",
268
+ "split_special_tokens": false,
269
+ "tokenizer_class": "Qwen2Tokenizer",
270
+ "unk_token": null
271
+ }
mlx_llm/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
run_moss.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """MOSS-Audio MLX runner for /srt eval — soundfile (no numba) + ASR transcription prompt + time markers.
2
+ Usage: python run_moss.py --model <dir> --audio clip.wav [--prompt "..."] [--max-tokens 4096] [--temp 0.0]
3
+ Works for both 4B-Thinking and 8B-hybrid bundles (audio int4 auto-detected).
4
+ """
5
+ from __future__ import annotations
6
+ import argparse, sys, time
7
+ from pathlib import Path
8
+
9
+ def main():
10
+ p = argparse.ArgumentParser()
11
+ p.add_argument("--model", required=True, help="bundle dir (has mlx_llm/ mlx_audio/ scripts/)")
12
+ p.add_argument("--audio", required=True)
13
+ p.add_argument("--prompt", default="Please transcribe this audio.")
14
+ p.add_argument("--max-tokens", type=int, default=4096)
15
+ p.add_argument("--temp", type=float, default=0.0)
16
+ p.add_argument("--repetition-penalty", type=float, default=1.02)
17
+ p.add_argument("--no-time-marker", action="store_true")
18
+ args = p.parse_args()
19
+
20
+ HERE = Path(args.model).resolve()
21
+ sys.path.insert(0, str(HERE / "scripts"))
22
+ import soundfile as sf
23
+ import mlx.core as mx
24
+ import numpy as np
25
+ from mlx_lm import load as mlx_load
26
+ from mlx_lm.generate import generate_step
27
+ from mlx_lm.sample_utils import make_sampler, make_logits_processors
28
+ from moss_audio_mlx_bridge_v3 import load_mlx_audio_path, run_mlx_audio_pipeline, install_deepstack_hooks
29
+ from moss_audio_mel_mlx import build_mel_and_input_ids
30
+
31
+ ad_w = mx.load(str(HERE / "mlx_audio/audio_adapter.safetensors"))
32
+ int4_audio = "down_proj.scales" in ad_w
33
+ llm_hidden = (ad_w["down_proj.scales"].shape[0] if int4_audio else ad_w["down_proj.weight"].shape[0])
34
+ size_tag = "4B" if llm_hidden == 2560 else "8B"
35
+ print(f"[detect] {size_tag} bundle, audio_int4={int4_audio}, prompt={args.prompt!r}, time_marker={not args.no_time_marker}", flush=True)
36
+
37
+ t0 = time.perf_counter()
38
+ mlx_model, tok = mlx_load(str(HERE / "mlx_llm"))
39
+ print(f"[load] LLM {time.perf_counter()-t0:.1f}s peak={mx.get_peak_memory()/1e9:.2f}GB", flush=True)
40
+ t0 = time.perf_counter()
41
+ encoder, adapter, mergers = load_mlx_audio_path(HERE / "mlx_audio", int4=int4_audio)
42
+ print(f"[load] audio path {time.perf_counter()-t0:.1f}s", flush=True)
43
+
44
+ y, sr = sf.read(args.audio)
45
+ y = np.asarray(y, dtype=np.float32)
46
+ if y.ndim > 1:
47
+ y = y.mean(axis=1)
48
+ assert sr == 16000, f"expected 16kHz, got {sr}"
49
+ print(f"[audio] {args.audio} ({len(y)/16000:.1f}s)", flush=True)
50
+
51
+ t0 = time.perf_counter()
52
+ mel, lens, input_ids_mx, audio_token_id = build_mel_and_input_ids(
53
+ y, tok, prompt=args.prompt, enable_time_marker=not args.no_time_marker)
54
+ primary, ds_embeds = run_mlx_audio_pipeline(encoder, adapter, mergers, mel, lens)
55
+ primary = primary.astype(mx.bfloat16)
56
+ ds_embeds = [d.astype(mx.bfloat16) for d in ds_embeds]
57
+ mx.eval(primary, *ds_embeds)
58
+ print(f"[encode] {time.perf_counter()-t0:.2f}s primary={primary.shape}", flush=True)
59
+ del encoder, adapter, mergers, mel, lens
60
+ import gc; gc.collect(); mx.clear_cache()
61
+
62
+ audio_mask = input_ids_mx == audio_token_id
63
+ audio_positions = np.where(np.array(audio_mask[0]))[0]
64
+ text_embeds = mlx_model.model.embed_tokens(input_ids_mx)
65
+ text_np = np.array(text_embeds.astype(mx.float32))
66
+ primary_np = np.array(primary.astype(mx.float32))
67
+ text_np[0, audio_positions, :] = primary_np[0, :, :]
68
+ merged = mx.array(text_np).astype(mx.bfloat16)
69
+ ds_flat = [d[0] for d in ds_embeds]
70
+ install_deepstack_hooks(mlx_model, ds_flat, audio_positions)
71
+
72
+ sampler = make_sampler(temp=args.temp, top_p=1.0, top_k=(0 if args.temp == 0 else 50))
73
+ gen_kwargs = dict(prompt=input_ids_mx[0], model=mlx_model,
74
+ input_embeddings=merged[0], max_tokens=args.max_tokens, sampler=sampler)
75
+ if args.repetition_penalty:
76
+ gen_kwargs["logits_processors"] = make_logits_processors(
77
+ repetition_penalty=args.repetition_penalty, repetition_context_size=20)
78
+
79
+ t0 = time.perf_counter(); generated = []; ttft = None
80
+ for tok_id, _ in generate_step(**gen_kwargs):
81
+ if ttft is None:
82
+ ttft = time.perf_counter() - t0
83
+ generated.append(int(tok_id))
84
+ if tok_id == tok.eos_token_id:
85
+ break
86
+ elapsed = time.perf_counter() - t0
87
+ n = len(generated)
88
+ decode_s = max(elapsed - (ttft or 0), 1e-6)
89
+ print(f"[gen] {n}tok in {elapsed:.1f}s ttft={ttft:.2f}s decode={max(n-1,0)/decode_s:.1f}t/s "
90
+ f"rtf={(len(y)/16000)/elapsed:.2f}x peak={mx.get_peak_memory()/1e9:.2f}GB", flush=True)
91
+ print(f"\n=== OUTPUT ===\n{tok.decode(generated)}\n=== END ===", flush=True)
92
+
93
+ if __name__ == "__main__":
94
+ main()
scripts/__pycache__/moss_audio_encoder_mlx.cpython-312.pyc ADDED
Binary file (13.5 kB). View file
 
scripts/__pycache__/moss_audio_mel_mlx.cpython-312.pyc ADDED
Binary file (9.35 kB). View file
 
scripts/__pycache__/moss_audio_mlx_bridge_v3.cpython-312.pyc ADDED
Binary file (18.8 kB). View file
 
scripts/assets/mel_filters.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7450ae70723a5ef9d341e3cee628c7cb0177f36ce42c44b7ed2bf3325f0f6d4c
3
+ size 4271
scripts/moss_audio_encoder_mlx.py ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """MLX-native MossAudioEncoder.
2
+
3
+ Direct port of src/modeling_moss_audio.py:36-155 (MossAudioEncoder).
4
+ Adapted from ml-explore/mlx-examples/whisper/mlx_whisper/whisper.py with:
5
+ - 3× Conv2d stride-2 stem (instead of Whisper's 2× Conv1d)
6
+ - Pre-existing HF Whisper attribute names (q_proj/k_proj/v_proj/out_proj, fc1/fc2,
7
+ self_attn_layer_norm/final_layer_norm) so weight remap is near-identity
8
+ - DeepStack taps: capture hidden state AFTER layers in deepstack_layer_indexes
9
+ - feature_lens-based padding mask
10
+ """
11
+ from __future__ import annotations
12
+
13
+ import math
14
+ from dataclasses import dataclass, field
15
+ from typing import List, Optional, Tuple
16
+
17
+ import mlx.core as mx
18
+ import mlx.nn as nn
19
+
20
+
21
+ # ---- helpers ----------------------------------------------------------
22
+
23
+
24
+ def sinusoids(length: int, channels: int, max_timescale: float = 10000.0) -> mx.array:
25
+ """Whisper-style sinusoidal position embeddings. Matches mlx-examples whisper."""
26
+ assert channels % 2 == 0
27
+ log_timescale_increment = math.log(max_timescale) / (channels // 2 - 1)
28
+ inv_timescales = mx.exp(-log_timescale_increment * mx.arange(channels // 2))
29
+ scaled_time = mx.arange(length)[:, None] * inv_timescales[None, :]
30
+ return mx.concatenate([mx.sin(scaled_time), mx.cos(scaled_time)], axis=1)
31
+
32
+
33
+ # ---- attention ------------------------------------------------------
34
+
35
+
36
+ class WhisperAttention(nn.Module):
37
+ """HF-Whisper-style self-attention. Layer-scaling convention (`1/sqrt(head_dim)`
38
+ applied to Q, not split between Q and K like mlx-examples does).
39
+
40
+ Attribute names match HF so weight remap is identity: q_proj/k_proj/v_proj/out_proj.
41
+ """
42
+
43
+ def __init__(self, d_model: int, n_heads: int):
44
+ super().__init__()
45
+ self.n_heads = n_heads
46
+ self.head_dim = d_model // n_heads
47
+ assert d_model == self.head_dim * n_heads
48
+ # HF Whisper: q/v/out have bias; k does not
49
+ self.q_proj = nn.Linear(d_model, d_model, bias=True)
50
+ self.k_proj = nn.Linear(d_model, d_model, bias=False)
51
+ self.v_proj = nn.Linear(d_model, d_model, bias=True)
52
+ self.out_proj = nn.Linear(d_model, d_model, bias=True)
53
+
54
+ def __call__(self, x: mx.array, mask: Optional[mx.array] = None) -> mx.array:
55
+ B, T, D = x.shape
56
+ q = self.q_proj(x).reshape(B, T, self.n_heads, self.head_dim).transpose(0, 2, 1, 3)
57
+ k = self.k_proj(x).reshape(B, T, self.n_heads, self.head_dim).transpose(0, 2, 1, 3)
58
+ v = self.v_proj(x).reshape(B, T, self.n_heads, self.head_dim).transpose(0, 2, 1, 3)
59
+ scale = self.head_dim ** -0.5
60
+ attn = (q * scale) @ k.transpose(0, 1, 3, 2) # (B, H, T, T)
61
+ if mask is not None:
62
+ attn = attn + mask
63
+ w = mx.softmax(attn, axis=-1, precise=True)
64
+ out = (w @ v).transpose(0, 2, 1, 3).reshape(B, T, D)
65
+ return self.out_proj(out)
66
+
67
+
68
+ # ---- encoder layer --------------------------------------------------
69
+
70
+
71
+ class WhisperEncoderBlock(nn.Module):
72
+ """Pre-LN Whisper encoder block. Matches transformers.WhisperEncoderLayer."""
73
+
74
+ def __init__(self, d_model: int, n_heads: int, ffn_dim: int):
75
+ super().__init__()
76
+ self.self_attn = WhisperAttention(d_model, n_heads)
77
+ self.self_attn_layer_norm = nn.LayerNorm(d_model)
78
+ self.fc1 = nn.Linear(d_model, ffn_dim)
79
+ self.fc2 = nn.Linear(ffn_dim, d_model)
80
+ self.final_layer_norm = nn.LayerNorm(d_model)
81
+
82
+ def __call__(self, x: mx.array, mask: Optional[mx.array] = None) -> mx.array:
83
+ h = self.self_attn_layer_norm(x)
84
+ x = x + self.self_attn(h, mask=mask)
85
+ h = self.final_layer_norm(x)
86
+ x = x + self.fc2(nn.gelu(self.fc1(h)))
87
+ return x
88
+
89
+
90
+ # ---- encoder --------------------------------------------------------
91
+
92
+
93
+ @dataclass
94
+ class EncoderConfig:
95
+ num_mel_bins: int = 128
96
+ downsample_hidden_size: int = 480
97
+ d_model: int = 1280
98
+ n_heads: int = 20
99
+ ffn_dim: int = 5120
100
+ n_layers: int = 32
101
+ max_source_positions: int = 1500
102
+ layer_norm_eps: float = 1e-5
103
+ output_dim: int = 1280
104
+ deepstack_layer_indexes: List[int] = field(default_factory=lambda: [8, 16, 24])
105
+
106
+
107
+ class MossAudioEncoderMLX(nn.Module):
108
+ def __init__(self, cfg: EncoderConfig):
109
+ super().__init__()
110
+ self.cfg = cfg
111
+ # Conv2d stem: 1 → 480 → 480 → 480, each stride-2
112
+ # MLX Conv2d expects NHWC, weight shape (OC, kH, kW, IC)
113
+ self.conv1 = nn.Conv2d(1, cfg.downsample_hidden_size, kernel_size=3, stride=2, padding=1)
114
+ self.conv2 = nn.Conv2d(cfg.downsample_hidden_size, cfg.downsample_hidden_size, kernel_size=3, stride=2, padding=1)
115
+ self.conv3 = nn.Conv2d(cfg.downsample_hidden_size, cfg.downsample_hidden_size, kernel_size=3, stride=2, padding=1)
116
+ # After 3× stride-2 on mel-axis (128→64→32→16): flat dim = 480*16 = 7680
117
+ self.stem_proj = nn.Linear(cfg.downsample_hidden_size * 16, cfg.d_model)
118
+ # Precomputed sinusoids, will be sliced
119
+ self._positions = sinusoids(cfg.max_source_positions, cfg.d_model)
120
+ self.layers = [
121
+ WhisperEncoderBlock(cfg.d_model, cfg.n_heads, cfg.ffn_dim)
122
+ for _ in range(cfg.n_layers)
123
+ ]
124
+ self.layer_norm = nn.LayerNorm(cfg.d_model, eps=cfg.layer_norm_eps)
125
+ # MOSS has optional out_proj; for 4B output_dim==d_model, so it's Identity in PyTorch
126
+ # We skip it entirely (equivalent).
127
+ assert cfg.output_dim == cfg.d_model, "non-identity out_proj not yet implemented"
128
+ self._deepstack_set = set(cfg.deepstack_layer_indexes)
129
+
130
+ def _compute_downsampled_length(self, L: int) -> int:
131
+ """3× stride-2 conv output length: ceil((((L-1)//2+1)-1)//2+1 ... )"""
132
+ def step(n): return (n - 1) // 2 + 1
133
+ return step(step(step(L)))
134
+
135
+ def __call__(
136
+ self,
137
+ input_features: mx.array, # (B, n_mels, T) bf16 mel spectrogram
138
+ feature_lens: Optional[mx.array] = None,
139
+ return_deepstack: bool = True,
140
+ ) -> Tuple[mx.array, Optional[List[mx.array]]]:
141
+ if input_features.ndim == 2:
142
+ input_features = input_features[None]
143
+ B, n_mels, T = input_features.shape
144
+ if feature_lens is None:
145
+ feature_lens = mx.full((B,), T, dtype=mx.int32)
146
+
147
+ # (B, n_mels, T) → (B, n_mels, T, 1) [NHWC with channels-last = 1 input channel]
148
+ # But MLX Conv2d expects input shape (B, H, W, C_in). We map:
149
+ # H = n_mels (128), W = T (frames), C_in = 1
150
+ x = input_features[..., None] # (B, n_mels, T, 1)
151
+ x = nn.gelu(self.conv1(x)) # (B, 64, T/2, 480)
152
+ x = nn.gelu(self.conv2(x)) # (B, 32, T/4, 480)
153
+ x = nn.gelu(self.conv3(x)) # (B, 16, T/8, 480)
154
+ # PyTorch reference: (B, C, F, T) → permute(0,3,1,2) → (B, T, C, F) → flatten → (B, T, C*F)
155
+ # MLX is (B, F, T, C) post-conv. Need transpose to (B, T, C, F) to match PT's flatten order.
156
+ B_, H_, W_, C_ = x.shape # H_=F, W_=T, C_=C
157
+ x = x.transpose(0, 2, 3, 1).reshape(B_, W_, C_ * H_) # (B, T, C*F)
158
+ x = self.stem_proj(x) # (B, T', d_model)
159
+
160
+ # Trim to actual downsampled length (in case input was padded)
161
+ max_len = self._compute_downsampled_length(int(feature_lens.max().item()))
162
+ if x.shape[1] > max_len:
163
+ x = x[:, :max_len, :]
164
+
165
+ # Add sinusoidal positions
166
+ seq_len = x.shape[1]
167
+ pos = self._positions[:seq_len].astype(x.dtype)
168
+ x = x + pos
169
+
170
+ # Build attention mask: (B, 1, 1, seq_len) additive
171
+ # padding_mask[b, t] = True if t >= downsampled_len[b] (this is where we mask out)
172
+ dsl = mx.stack([
173
+ mx.array(self._compute_downsampled_length(int(feature_lens[b].item())), dtype=mx.int32)
174
+ for b in range(B)
175
+ ]) # (B,)
176
+ ar = mx.arange(seq_len, dtype=mx.int32)
177
+ padding = ar[None, :] >= dsl[:, None] # (B, seq_len) bool
178
+ neg_inf = mx.array(-1e9, dtype=x.dtype)
179
+ mask = mx.where(padding, neg_inf, mx.array(0.0, dtype=x.dtype))
180
+ mask = mask[:, None, None, :] # (B, 1, 1, seq_len)
181
+
182
+ deepstack: List[mx.array] = []
183
+ for layer_idx, layer in enumerate(self.layers):
184
+ x = layer(x, mask=mask)
185
+ if return_deepstack and layer_idx in self._deepstack_set:
186
+ # Apply the final layer_norm snapshot at this point, per MOSS's output_deepstack_hidden_states
187
+ # Actually, MOSS captures x BEFORE the final layer_norm — matches what PyTorch does.
188
+ deepstack.append(x)
189
+
190
+ x = self.layer_norm(x)
191
+ return x, (deepstack if return_deepstack else None)
192
+
193
+
194
+ # ---- GatedMLP (for audio_adapter + deepstack_audio_merger_list) ----
195
+
196
+
197
+ class GatedMLP(nn.Module):
198
+ """MOSS's GatedMLP: down(silu(gate(x)) * up(x)). SwiGLU convention.
199
+
200
+ Matches MOSS/src/modeling_moss_audio.py:155-164.
201
+ All linears are bias=False.
202
+ """
203
+
204
+ def __init__(self, input_size: int, hidden_size: int, output_size: int):
205
+ super().__init__()
206
+ self.gate_proj = nn.Linear(input_size, hidden_size, bias=False)
207
+ self.up_proj = nn.Linear(input_size, hidden_size, bias=False)
208
+ self.down_proj = nn.Linear(hidden_size, output_size, bias=False)
209
+
210
+ def __call__(self, x: mx.array) -> mx.array:
211
+ return self.down_proj(nn.silu(self.gate_proj(x)) * self.up_proj(x))
212
+
213
+
214
+ __all__ = ["sinusoids", "WhisperAttention", "WhisperEncoderBlock",
215
+ "EncoderConfig", "MossAudioEncoderMLX", "GatedMLP"]
scripts/moss_audio_mel_mlx.py ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Pure-MLX mel-spectrogram + input_ids builder for MOSS-Audio.
2
+
3
+ Replaces the torch-dependent MossAudioProcessor at inference time. Matches the
4
+ upstream processor's output byte-for-byte on our test clips (see parity check
5
+ in test_moss_audio_mel_parity.py).
6
+
7
+ What's ported:
8
+ - Log-mel spectrogram (n_mels=128, n_fft=400, hop=160, sr=16000) via mx.fft.rfft,
9
+ reusing mlx-examples/whisper's mel_filters.npz for the filterbank.
10
+ - Whisper-style fbank normalization: log10 → clip to (max - 8.0) → (+4)/4.
11
+ - input_ids construction: audio-span expansion with 2-second time markers,
12
+ chat-template wrapping (<|im_start|>system/user/assistant).
13
+
14
+ What still uses a non-torch dep:
15
+ - Tokenization: HuggingFace AutoTokenizer (pure Python, no torch at runtime).
16
+ Install path: `pip install transformers` gets the slow BPE tokenizer; no
17
+ torch required at import.
18
+ """
19
+ from __future__ import annotations
20
+
21
+ from functools import lru_cache
22
+ from pathlib import Path
23
+ from typing import Sequence
24
+
25
+ import mlx.core as mx
26
+ import numpy as np
27
+
28
+ SAMPLE_RATE = 16_000
29
+ N_FFT = 400
30
+ HOP_LENGTH = 160
31
+ MEL_DIM = 128
32
+ AUDIO_TOKENS_PER_SECOND = 12.5
33
+
34
+ AUDIO_TOKEN_ID = 151654
35
+ AUDIO_START_ID = 151669
36
+ AUDIO_END_ID = 151670
37
+
38
+ DIGIT_TOKEN_IDS = {str(i): 15 + i for i in range(10)}
39
+
40
+ _ASSETS = Path(__file__).resolve().parent / "assets"
41
+
42
+
43
+ @lru_cache(maxsize=None)
44
+ def _mel_filters() -> mx.array:
45
+ return mx.load(str(_ASSETS / "mel_filters.npz"))[f"mel_{MEL_DIM}"]
46
+
47
+
48
+ @lru_cache(maxsize=None)
49
+ def _hann_window(size: int) -> mx.array:
50
+ return mx.array(np.hanning(size + 1)[:-1])
51
+
52
+
53
+ def _stft_rfft(x: mx.array) -> mx.array:
54
+ """STFT with reflect padding, returning rfft bins. Matches librosa defaults."""
55
+ padding = N_FFT // 2
56
+ prefix = x[1 : padding + 1][::-1]
57
+ suffix = x[-(padding + 1) : -1][::-1]
58
+ x = mx.concatenate([prefix, x, suffix])
59
+
60
+ noverlap = HOP_LENGTH
61
+ t = (x.size - N_FFT + noverlap) // noverlap
62
+ strides = [noverlap, 1]
63
+ x = mx.as_strided(x, shape=[t, N_FFT], strides=strides)
64
+ return mx.fft.rfft(x * _hann_window(N_FFT))
65
+
66
+
67
+ def log_mel_spectrogram_mlx(audio: np.ndarray) -> mx.array:
68
+ """Compute (MEL_DIM, n_frames) log-mel spectrogram in pure MLX.
69
+
70
+ Matches upstream's WhisperFeatureExtractor._np_extract_fbank_features with
71
+ n_mels=128. Used by the MOSS-Audio encoder, which crops/pads along the
72
+ frame axis.
73
+ """
74
+ if not isinstance(audio, mx.array):
75
+ audio = mx.array(audio.astype(np.float32))
76
+
77
+ freqs = _stft_rfft(audio)
78
+ magnitudes = freqs[:-1, :].abs().square()
79
+
80
+ filters = _mel_filters()
81
+ mel_spec = magnitudes @ filters.T
82
+ log_spec = mx.maximum(mel_spec, 1e-10).log10()
83
+ log_spec = mx.maximum(log_spec, log_spec.max() - 8.0)
84
+ log_spec = (log_spec + 4.0) / 4.0
85
+ return log_spec.T # (MEL_DIM, n_frames)
86
+
87
+
88
+ def _conv3_downsample_len(raw_mel_len: int) -> int:
89
+ """MOSS-Audio encoder stem: three conv/stride-2 layers → audio token count."""
90
+ n = int(raw_mel_len)
91
+ for _ in range(3):
92
+ n = (n - 1) // 2 + 1
93
+ return n
94
+
95
+
96
+ def _digit_token_ids(second: int) -> list[int]:
97
+ return [DIGIT_TOKEN_IDS[d] for d in str(second)]
98
+
99
+
100
+ def _build_audio_placeholder_ids(num_audio_tokens: int, *, enable_time_marker: bool) -> list[int]:
101
+ if not enable_time_marker:
102
+ return [AUDIO_TOKEN_ID] * num_audio_tokens
103
+
104
+ tokens_per_marker = int(AUDIO_TOKENS_PER_SECOND * 2) # every 2 seconds
105
+ total_seconds = num_audio_tokens / AUDIO_TOKENS_PER_SECOND
106
+ num_full_seconds = int(total_seconds)
107
+
108
+ out: list[int] = []
109
+ consumed = 0
110
+ for second in range(2, num_full_seconds + 1, 2):
111
+ marker_pos = (second // 2) * tokens_per_marker
112
+ segment_len = marker_pos - consumed
113
+ if segment_len > 0:
114
+ out.extend([AUDIO_TOKEN_ID] * segment_len)
115
+ consumed += segment_len
116
+ out.extend(_digit_token_ids(second))
117
+
118
+ remaining = num_audio_tokens - consumed
119
+ if remaining > 0:
120
+ out.extend([AUDIO_TOKEN_ID] * remaining)
121
+ return out
122
+
123
+
124
+ def _default_prompt(text: str) -> str:
125
+ return (
126
+ "<|im_start|>system\n"
127
+ "You are a helpful assistant.<|im_end|>\n"
128
+ "<|im_start|>user\n"
129
+ "<|audio_bos|><|AUDIO|><|audio_eos|>\n"
130
+ f"{text}<|im_end|>\n"
131
+ "<|im_start|>assistant\n"
132
+ )
133
+
134
+
135
+ def build_input_ids(tokenizer, prompt_text: str, *, audio_token_count: int,
136
+ enable_time_marker: bool = True) -> list[int]:
137
+ """Expand the <|audio_bos|><|AUDIO|><|audio_eos|> marker into audio_token_count tokens.
138
+
139
+ Mirrors MossAudioProcessor._build_input_from_prompt but without torch tensors.
140
+ """
141
+ import re
142
+ audio_span_re = re.compile(r"<\|audio_bos\|>(?:<\|AUDIO\|>)+<\|audio_eos\|>")
143
+
144
+ if audio_span_re.search(prompt_text) is None:
145
+ prompt_text = _default_prompt(prompt_text)
146
+
147
+ spans = list(audio_span_re.finditer(prompt_text))
148
+ if len(spans) != 1:
149
+ raise ValueError(f"Expected exactly 1 audio span, got {len(spans)}")
150
+
151
+ match = spans[0]
152
+ prefix = prompt_text[: match.start()]
153
+ suffix = prompt_text[match.end():]
154
+
155
+ ids: list[int] = []
156
+ if prefix:
157
+ ids.extend(tokenizer.encode(prefix, add_special_tokens=False))
158
+ ids.append(AUDIO_START_ID)
159
+ ids.extend(_build_audio_placeholder_ids(audio_token_count, enable_time_marker=enable_time_marker))
160
+ ids.append(AUDIO_END_ID)
161
+ if suffix:
162
+ ids.extend(tokenizer.encode(suffix, add_special_tokens=False))
163
+ return ids
164
+
165
+
166
+ def build_mel_and_input_ids(
167
+ audio: np.ndarray,
168
+ tokenizer,
169
+ *,
170
+ prompt: str,
171
+ enable_time_marker: bool = True,
172
+ ) -> tuple[mx.array, mx.array, mx.array, int]:
173
+ """Pure-MLX equivalent of MossAudioProcessor(text=prompt, audios=[audio]).
174
+
175
+ Returns (mel, lens, input_ids, audio_token_id) — same shapes and semantics
176
+ as the torch bridge's build_mel_spectrogram().
177
+ """
178
+ audio_f32 = audio.astype(np.float32)
179
+ mel = log_mel_spectrogram_mlx(audio_f32) # (MEL_DIM, T)
180
+ raw_mel_len = int(mel.shape[-1])
181
+ audio_token_count = _conv3_downsample_len(raw_mel_len)
182
+
183
+ mel = mel[None, ...] # (1, MEL_DIM, T)
184
+ lens = mx.array(np.array([raw_mel_len], dtype=np.int32))
185
+
186
+ input_ids = build_input_ids(
187
+ tokenizer, prompt, audio_token_count=audio_token_count,
188
+ enable_time_marker=enable_time_marker,
189
+ )
190
+ input_ids_mx = mx.array(np.array([input_ids], dtype=np.int64))
191
+
192
+ return mel, lens, input_ids_mx, AUDIO_TOKEN_ID
scripts/moss_audio_mlx_bridge_v3.py ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Pure-MLX MOSS-Audio hybrid bridge (v3). No PyTorch at runtime.
2
+
3
+ Uses:
4
+ - MLX INT4 Qwen3 LLM (existing moss4b_mlx_int4/)
5
+ - MLX BF16 MossAudioEncoder (ported to mlx.nn)
6
+ - MLX BF16 GatedMLP for audio_adapter + deepstack_audio_merger_list
7
+ - MossAudioProcessor from upstream repo (CPU/numpy only, used to compute mel spectrogram)
8
+
9
+ All compute on MLX; only mel-spectrogram construction uses CPU.
10
+ """
11
+ from __future__ import annotations
12
+
13
+ import argparse
14
+ import sys
15
+ import time
16
+ from pathlib import Path
17
+
18
+ sys.path.insert(0, str(Path.home() / "benchmark" / "moss-audio"))
19
+ sys.path.insert(0, str(Path.home() / "benchmark" / "scripts"))
20
+
21
+ import librosa
22
+ import mlx.core as mx
23
+ import mlx.nn as mnn
24
+ import numpy as np
25
+ from mlx_lm import load as mlx_load
26
+ from mlx_lm.generate import generate_step
27
+ from mlx_lm.sample_utils import make_sampler, make_logits_processors
28
+
29
+ from moss_audio_encoder_mlx import MossAudioEncoderMLX, EncoderConfig, GatedMLP
30
+
31
+
32
+ # ---- Load MLX encoder + adapter + mergers ----
33
+
34
+
35
+ def _infer_llm_hidden(ad_w: dict) -> int:
36
+ """Sniff the LLM hidden dim from the adapter's down_proj.
37
+
38
+ Supports both BF16 weights (`down_proj.weight` shape = (llm_hidden, 8192))
39
+ and INT4-quantized weights (`down_proj.scales` shape = (llm_hidden, n_groups)).
40
+ Returns 2560 for 4B, 4096 for 8B.
41
+ """
42
+ if "down_proj.scales" in ad_w:
43
+ return ad_w["down_proj.scales"].shape[0]
44
+ return ad_w["down_proj.weight"].shape[0]
45
+
46
+
47
+ def load_mlx_audio_path(weights_dir: Path, *, int4: bool = False):
48
+ """Load encoder + adapter + mergers into MLX.
49
+
50
+ Adapter/merger output dim (LLM hidden) is inferred from the saved weights,
51
+ so the same loader works for both 4B (2560) and 8B (4096).
52
+
53
+ When int4=True, weights_dir is expected to contain already-quantized
54
+ INT4 safetensors (see scripts/save_moss_audio_int4.py). This avoids
55
+ the double-buffer memory cost of live quantization from BF16.
56
+ """
57
+ ad_w = mx.load(str(weights_dir / "audio_adapter.safetensors"))
58
+ llm_hidden = _infer_llm_hidden(ad_w)
59
+
60
+ cfg = EncoderConfig()
61
+ enc = MossAudioEncoderMLX(cfg)
62
+ adapter = GatedMLP(1280, 8192, llm_hidden)
63
+ mergers = [GatedMLP(1280, 8192, llm_hidden) for _ in range(3)]
64
+
65
+ if int4:
66
+ # Build quantized module structure FIRST, then load INT4 weights directly.
67
+ # This avoids holding BF16 + INT4 copies in memory simultaneously.
68
+ mnn.quantize(enc, group_size=64, bits=4)
69
+ mnn.quantize(adapter, group_size=64, bits=4)
70
+ for m in mergers:
71
+ mnn.quantize(m, group_size=64, bits=4)
72
+
73
+ enc_w = mx.load(str(weights_dir / "audio_encoder.safetensors"))
74
+ enc.load_weights(list(enc_w.items()), strict=True)
75
+
76
+ adapter.load_weights(list(ad_w.items()), strict=True)
77
+
78
+ dm_w = mx.load(str(weights_dir / "deepstack_mergers.safetensors"))
79
+ for i, merger in enumerate(mergers):
80
+ subw = {k[len(f"{i}."):]: v for k, v in dm_w.items() if k.startswith(f"{i}.")}
81
+ merger.load_weights(list(subw.items()), strict=True)
82
+
83
+ mx.eval(enc.parameters(), adapter.parameters(), *[m.parameters() for m in mergers])
84
+ return enc, adapter, mergers
85
+
86
+
87
+ def build_mel_spectrogram(audio_np: np.ndarray, processor_or_tokenizer, *, fp32_compute: bool = True) -> tuple[mx.array, mx.array]:
88
+ """Build mel spectrogram + audio-expanded input_ids.
89
+
90
+ Two supported inputs for `processor_or_tokenizer`:
91
+ - A HuggingFace tokenizer (pure-Python, no torch) — pure-MLX path. Default.
92
+ - A MossAudioProcessor instance — delegates to upstream (kept for the
93
+ parity regression tests and anyone pinning to the old behavior).
94
+
95
+ `fp32_compute=True` (default) keeps the mel input as fp32, which causes
96
+ MLX to auto-promote all encoder activations to fp32 during forward
97
+ (weights stay BF16 on disk). This cuts relative error in the adapter
98
+ output from 6.5% to 0.98% vs PyTorch reference, at the cost of ~1 GB
99
+ extra peak memory during the one-shot encoder pass.
100
+ """
101
+ prompt = ("Describe this audio in detail. Include speech content, speaker "
102
+ "characteristics, background sounds, music, and any notable temporal events.")
103
+
104
+ # Pure-MLX path: the object has `.encode()` but not MossAudioProcessor's `audio_token_id`
105
+ # set alongside a `.tokenizer` attribute. Detect by method presence.
106
+ is_tokenizer = hasattr(processor_or_tokenizer, "encode") and not hasattr(processor_or_tokenizer, "audio_token_id")
107
+
108
+ if is_tokenizer:
109
+ from moss_audio_mel_mlx import build_mel_and_input_ids
110
+ mel_mx, lens_mx, input_ids_mx, audio_token_id = build_mel_and_input_ids(
111
+ audio_np, processor_or_tokenizer, prompt=prompt, enable_time_marker=True,
112
+ )
113
+ if not fp32_compute:
114
+ mel_mx = mel_mx.astype(mx.bfloat16)
115
+ return mel_mx, lens_mx, input_ids_mx, audio_token_id
116
+
117
+ # Legacy torch processor path (unchanged)
118
+ processor = processor_or_tokenizer
119
+ inputs = processor(text=prompt, audios=[audio_np], return_tensors="pt")
120
+ import torch
121
+ mel = inputs["audio_data"]
122
+ mel_np = mel.to(torch.float32).numpy()
123
+ mel_mx = mx.array(mel_np) if fp32_compute else mx.array(mel_np).astype(mx.bfloat16)
124
+ lens = inputs["audio_data_seqlens"].cpu().numpy().astype(np.int32) if inputs.get("audio_data_seqlens") is not None else None
125
+ lens_mx = mx.array(lens) if lens is not None else None
126
+ input_ids_np = inputs["input_ids"].cpu().numpy()
127
+ input_ids_mx = mx.array(input_ids_np)
128
+ audio_token_id = processor.audio_token_id
129
+ return mel_mx, lens_mx, input_ids_mx, audio_token_id
130
+
131
+
132
+ def run_mlx_audio_pipeline(encoder, adapter, mergers,
133
+ mel: mx.array, lens: mx.array):
134
+ """Returns (primary_embeds, deepstack_embeds) all on MLX."""
135
+ last, deepstack = encoder(mel, feature_lens=lens, return_deepstack=True)
136
+ primary = adapter(last) # (B, N_audio, llm_hidden)
137
+ ds_embeds = [mergers[i](ds) for i, ds in enumerate(deepstack)]
138
+ return primary, ds_embeds
139
+
140
+
141
+ # ---- DeepStack injection on MLX decoder ----
142
+
143
+
144
+ def install_deepstack_hooks(mlx_model, deepstack_embeds: list[mx.array], audio_positions: np.ndarray):
145
+ """Same class-level Qwen3Model.__call__ override as v2, but with MLX-native inputs."""
146
+ from mlx_lm.models.base import create_attention_mask
147
+
148
+ audio_positions_mx = mx.array(audio_positions.astype(np.int32))
149
+ num_inject = len(deepstack_embeds)
150
+
151
+ ModelCls = type(mlx_model.model)
152
+ orig_call = ModelCls.__call__
153
+
154
+ def new_call(self, inputs, cache=None, input_embeddings=None):
155
+ if self is not mlx_model.model:
156
+ return orig_call(self, inputs, cache, input_embeddings)
157
+
158
+ if input_embeddings is not None:
159
+ h = input_embeddings
160
+ else:
161
+ h = self.embed_tokens(inputs)
162
+
163
+ if cache is None:
164
+ cache = [None] * len(self.layers)
165
+ mask = create_attention_mask(h, cache[0])
166
+ is_prefill = h.shape[1] > 1
167
+
168
+ for layer_idx, (layer, c) in enumerate(zip(self.layers, cache)):
169
+ h = layer(h, mask, c)
170
+ if is_prefill and layer_idx < num_inject:
171
+ ds = deepstack_embeds[layer_idx]
172
+ if ds.dtype != h.dtype:
173
+ ds = ds.astype(h.dtype)
174
+ if ds.ndim == 3:
175
+ ds = ds[0] # flatten batch
176
+ h_batch0 = h[0]
177
+ h_batch0 = h_batch0.at[audio_positions_mx].add(ds)
178
+ h = h_batch0[None]
179
+
180
+ return self.norm(h)
181
+
182
+ ModelCls.__call__ = new_call
183
+
184
+
185
+ # ---- Main ----
186
+
187
+
188
+ def main():
189
+ parser = argparse.ArgumentParser()
190
+ parser.add_argument("--mlx-llm", default=str(Path.home() / "benchmark" / "moss4b_mlx_int4"))
191
+ parser.add_argument("--mlx-audio", default=str(Path.home() / "benchmark" / "moss4b_audio_mlx_int4"))
192
+ parser.add_argument("--moss-source", default="OpenMOSS-Team/MOSS-Audio-4B-Thinking",
193
+ help="HF repo for the processor only (mel spectrogram computation)")
194
+ parser.add_argument("--audio", required=True)
195
+ parser.add_argument("--max-tokens", type=int, default=2048)
196
+ parser.add_argument("--temp", type=float, default=1.0)
197
+ parser.add_argument("--int4-audio", action="store_true", default=True,
198
+ help="Load pre-quantized INT4 audio encoder + adapter + mergers from --mlx-audio")
199
+ parser.add_argument("--no-int4-audio", dest="int4_audio", action="store_false",
200
+ help="Use BF16 audio weights instead of INT4")
201
+ parser.add_argument("--repetition-penalty", type=float, default=1.02,
202
+ help="mlx_lm repetition_penalty. 1.02 is the shipped EN-scope default "
203
+ "(kills loop-decode on non-speech clips without starving genre descriptions).")
204
+ parser.add_argument("--repetition-context-size", type=int, default=20)
205
+ parser.add_argument("--use-torch-processor", action="store_true",
206
+ help="Use upstream MossAudioProcessor (torch+torchaudio) for mel "
207
+ "computation. Default off: pure-MLX mel path has <0.2%% "
208
+ "rel-err parity and no torch dep.")
209
+ args = parser.parse_args()
210
+
211
+ print(f"[mlx] loading LLM from {args.mlx_llm}", flush=True)
212
+ t0 = time.perf_counter()
213
+ mlx_model, mlx_tokenizer = mlx_load(args.mlx_llm)
214
+ print(f"[mlx] LLM loaded in {time.perf_counter()-t0:.1f}s peak={mx.get_peak_memory()/1e9:.2f}GB", flush=True)
215
+
216
+ print(f"[mlx] loading audio path from {args.mlx_audio} (int4={args.int4_audio})", flush=True)
217
+ t0 = time.perf_counter()
218
+ encoder, adapter, mergers = load_mlx_audio_path(Path(args.mlx_audio), int4=args.int4_audio)
219
+ print(f"[mlx] audio path loaded in {time.perf_counter()-t0:.1f}s peak={mx.get_peak_memory()/1e9:.2f}GB", flush=True)
220
+
221
+ # Pure-MLX path: use the MLX-LLM tokenizer directly for text encoding.
222
+ # Mel spectrogram + input_ids expansion are computed in pure MLX (no torch).
223
+ # The upstream MossAudioProcessor is only needed if you opt into the legacy
224
+ # torch mel path via `--use-torch-processor` (not on by default).
225
+ processor = mlx_tokenizer
226
+ if args.use_torch_processor:
227
+ from src.processing_moss_audio import MossAudioProcessor
228
+ processor = MossAudioProcessor.from_pretrained(
229
+ args.moss_source, trust_remote_code=True, enable_time_marker=True,
230
+ )
231
+
232
+ y, _ = librosa.load(args.audio, sr=16000, mono=True)
233
+ y = y.astype(np.float32)
234
+ print(f"[audio] {args.audio}: {len(y)/16000:.1f}s", flush=True)
235
+
236
+ t0 = time.perf_counter()
237
+ mel, lens, input_ids_mx, audio_token_id = build_mel_spectrogram(y, processor)
238
+ primary, ds_embeds = run_mlx_audio_pipeline(encoder, adapter, mergers, mel, lens)
239
+ # Cast to bf16 and force materialization NOW, so the fp32 activations can be freed
240
+ # before we start the decode phase (the encoder's fp32 forward is our peak-memory hotspot).
241
+ primary = primary.astype(mx.bfloat16)
242
+ ds_embeds = [d.astype(mx.bfloat16) for d in ds_embeds]
243
+ mx.eval(primary, *ds_embeds)
244
+ print(f"[mlx] audio encoded in {time.perf_counter()-t0:.2f}s primary={primary.shape}", flush=True)
245
+ print(f"[mem] after encode (pre-cleanup): peak={mx.get_peak_memory()/1e9:.2f}GB active={mx.get_active_memory()/1e9:.2f}GB", flush=True)
246
+
247
+ # FREE ENCODER + ADAPTER + MERGERS now that we have the embeddings.
248
+ # These modules are only needed at prefill; all downstream work (merge,
249
+ # deepstack injection, decode) uses only primary + ds_embeds tensors.
250
+ # Dropping them reclaims ~1.3 GB for clip_01 (up to ~2.5 GB if fp32
251
+ # activations were still held). Captured closures for install_deepstack_hooks
252
+ # keep only the embedding mx.array references, not the modules.
253
+ del encoder, adapter, mergers, mel, lens
254
+ import gc; gc.collect()
255
+ mx.clear_cache()
256
+ try: mx.reset_peak_memory()
257
+ except Exception: pass
258
+ print(f"[mem] after free encoder: peak={mx.get_peak_memory()/1e9:.2f}GB active={mx.get_active_memory()/1e9:.2f}GB", flush=True)
259
+
260
+ # Build merged text+audio embeddings
261
+ audio_mask = input_ids_mx == audio_token_id
262
+ audio_positions = np.where(np.array(audio_mask[0]))[0]
263
+ assert len(audio_positions) == primary.shape[1], \
264
+ f"mask positions {len(audio_positions)} != primary len {primary.shape[1]}"
265
+
266
+ text_embeds = mlx_model.model.embed_tokens(input_ids_mx) # (1, seq, hidden)
267
+ text_np = np.array(text_embeds.astype(mx.float32))
268
+ primary_np = np.array(primary.astype(mx.float32))
269
+ text_np[0, audio_positions, :] = primary_np[0, :, :]
270
+ merged = mx.array(text_np).astype(mx.bfloat16)
271
+ print(f"[bridge] merged embeds {merged.shape}", flush=True)
272
+
273
+ # Install DeepStack
274
+ ds_flat = [d[0] for d in ds_embeds] # drop batch dim
275
+ install_deepstack_hooks(mlx_model, ds_flat, audio_positions)
276
+ print(f"[deepstack] installed {len(ds_flat)} layer injections", flush=True)
277
+
278
+ # Generate
279
+ print(f"[gen] decoding max_tokens={args.max_tokens}...", flush=True)
280
+ sampler = make_sampler(temp=args.temp, top_p=1.0, top_k=50)
281
+ gen_kwargs = dict(
282
+ prompt=input_ids_mx[0],
283
+ model=mlx_model,
284
+ input_embeddings=merged[0],
285
+ max_tokens=args.max_tokens,
286
+ sampler=sampler,
287
+ )
288
+ if args.repetition_penalty:
289
+ gen_kwargs["logits_processors"] = make_logits_processors(
290
+ repetition_penalty=args.repetition_penalty,
291
+ repetition_context_size=args.repetition_context_size,
292
+ )
293
+ print(f"[gen] repetition_penalty={args.repetition_penalty} ctx={args.repetition_context_size}", flush=True)
294
+ t0 = time.perf_counter()
295
+ generated = []
296
+ ttft = None
297
+ for tok, _ in generate_step(**gen_kwargs):
298
+ if ttft is None:
299
+ ttft = time.perf_counter() - t0
300
+ generated.append(int(tok))
301
+ if tok == mlx_tokenizer.eos_token_id:
302
+ break
303
+ elapsed = time.perf_counter() - t0
304
+ n_tok = len(generated)
305
+ decode_s = max(elapsed - (ttft or 0), 1e-6)
306
+ print(f"[gen] elapsed={elapsed:.2f}s ttft={ttft:.3f}s out={n_tok}tok decode={max(n_tok-1,0)/decode_s:.1f}t/s", flush=True)
307
+ text = mlx_tokenizer.decode(generated)
308
+ print(f"\n=== OUTPUT ===\n{text[:1500]}\n=== END ===\n")
309
+
310
+ print(f"[mem] mlx peak={mx.get_peak_memory()/1e9:.2f}GB", flush=True)
311
+
312
+
313
+ if __name__ == "__main__":
314
+ main()