ashxhart commited on
Commit
b0b092e
·
verified ·
1 Parent(s): 22d2354

Add MLX 4-bit model card

Browse files
Files changed (1) hide show
  1. README.md +178 -0
README.md ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: inclusionAI/Ling-3.0-flash
4
+ library_name: mlx
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - mlx
8
+ - mlx-lm
9
+ - omlx
10
+ - bailing_hybrid
11
+ - mixture-of-experts
12
+ - quantized
13
+ - 4-bit
14
+ ---
15
+
16
+ <p align="center">
17
+ <img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*4QxcQrBlTiAAAAAAQXAAAAgAemJ7AQ/original" width="100" alt="Ling logo">
18
+ </p>
19
+
20
+ <h1 align="center">Ling 3.0 Flash — MLX 4-bit</h1>
21
+
22
+ <p align="center">
23
+ A native Apple-silicon conversion of <a href="https://huggingface.co/inclusionAI/Ling-3.0-flash">inclusionAI/Ling-3.0-flash</a>, quantized with the stock MLX-LM converter and packaged for MLX-LM and oMLX.
24
+ </p>
25
+
26
+ <p align="center">
27
+ <a href="https://huggingface.co/inclusionAI/Ling-3.0-flash">Original model</a> ·
28
+ <a href="https://modelscope.cn/organization/inclusionAI">InclusionAI on ModelScope</a> ·
29
+ <a href="https://openrouter.ai/inclusionai/ling-3.0-flash:free">OpenRouter</a>
30
+ </p>
31
+
32
+ ## About this conversion
33
+
34
+ This repository contains a **4-bit affine MLX conversion** of Ling 3.0 Flash. Ling is a 124B-parameter hybrid-linear mixture-of-experts model with approximately 5.1B active parameters per token. The conversion preserves the upstream tokenizer and chat template and includes an MLX architecture adapter for the model's KDA, MLA, and sparse-MoE layers.
35
+
36
+ | Item | Value |
37
+ | --- | --- |
38
+ | Base model | [`inclusionAI/Ling-3.0-flash`](https://huggingface.co/inclusionAI/Ling-3.0-flash) |
39
+ | Format | MLX safetensors |
40
+ | Quantization | 4-bit affine, group size 64 |
41
+ | Converter | Stock `mlx_lm.convert` from MLX-LM 0.31.3 |
42
+ | Effective weight precision | 4.502 bits per weight |
43
+ | Repository size | 70.03 GB (65.22 GiB) |
44
+ | Maximum configured context | 262,144 tokens |
45
+ | Architecture | `bailing_hybrid` |
46
+
47
+ > [!IMPORTANT]
48
+ > This model includes the custom architecture file `bailing_hybrid.py`. Review the file and enable **Trust Remote Code** before loading it. In oMLX, enable Trust Remote Code in the model settings. With MLX-LM, pass `--trust-remote-code`.
49
+
50
+ ## Apple-silicon validation
51
+
52
+ The converted weights were loaded strictly with both stock MLX-LM and the MLX runtime bundled with oMLX. End-to-end generation was also tested through the oMLX OpenAI-compatible API on an Apple-silicon Mac Studio.
53
+
54
+ One short local smoke test produced:
55
+
56
+ | Measurement | Result |
57
+ | --- | ---: |
58
+ | Prefill | 21.38 tokens/s |
59
+ | Decode | 76.41 tokens/s |
60
+ | Reported peak memory | 70.18 GB |
61
+ | oMLX API | HTTP 200, valid completion |
62
+
63
+ These figures confirm that the model runs; they are not a controlled benchmark. Prompt length, sampler settings, macOS memory pressure, thermal state, and MLX/oMLX versions can materially change performance.
64
+
65
+ ## Quick start with MLX-LM
66
+
67
+ Install recent MLX-LM and Hugging Face tooling:
68
+
69
+ ```bash
70
+ python -m pip install -U mlx-lm huggingface_hub
71
+ ```
72
+
73
+ Run a chat prompt directly from the Hub:
74
+
75
+ ```bash
76
+ mlx_lm.generate \
77
+ --model Vontra/Ling-3.0-flash-MLX-4bit \
78
+ --trust-remote-code \
79
+ --prompt "Explain why hybrid linear attention is useful." \
80
+ --max-tokens 512 \
81
+ --temp 0.6 \
82
+ --top-p 0.95 \
83
+ --top-k 20
84
+ ```
85
+
86
+ Thinking mode is enabled by the upstream chat template by default. It can be disabled with:
87
+
88
+ ```bash
89
+ mlx_lm.generate \
90
+ --model Vontra/Ling-3.0-flash-MLX-4bit \
91
+ --trust-remote-code \
92
+ --chat-template-config '{"enable_thinking": false}' \
93
+ --prompt "Write a short hello-world program in Swift."
94
+ ```
95
+
96
+ To download the repository first:
97
+
98
+ ```bash
99
+ hf download Vontra/Ling-3.0-flash-MLX-4bit \
100
+ --local-dir ~/.omlx/models/Vontra/Ling-3.0-flash-MLX-4bit
101
+ ```
102
+
103
+ ## Using it with oMLX
104
+
105
+ 1. Place the model at `~/.omlx/models/Vontra/Ling-3.0-flash-MLX-4bit`.
106
+ 2. Refresh the oMLX model registry.
107
+ 3. Open the model settings and enable **Trust Remote Code**.
108
+ 4. Load `Ling-3.0-flash-MLX-4bit` and use the normal chat or OpenAI-compatible endpoint.
109
+
110
+ Example request:
111
+
112
+ ```bash
113
+ curl http://localhost:8000/v1/chat/completions \
114
+ -H "Content-Type: application/json" \
115
+ -H "Authorization: Bearer $OMLX_API_KEY" \
116
+ -d '{
117
+ "model": "Ling-3.0-flash-MLX-4bit",
118
+ "messages": [{"role": "user", "content": "Say hello from MLX."}],
119
+ "temperature": 0.6,
120
+ "top_p": 0.95,
121
+ "max_tokens": 128
122
+ }'
123
+ ```
124
+
125
+ For long prompts, begin with a conservative context limit and increase it while watching memory pressure. The advertised 256K context is a model capability, not a promise that every host can prefill that context within its available unified memory.
126
+
127
+ ## Architecture
128
+
129
+ Ling 3.0 Flash is a native hybrid-linear MoE model. It alternates Kimi Delta Attention (KDA) and gated Multi-head Latent Attention (MLA) in a 5:1 ratio and uses highly sparse routed experts.
130
+
131
+ | Architecture detail | Upstream value |
132
+ | --- | ---: |
133
+ | Total / active parameters | 124B / 5.1B |
134
+ | Transformer layers | 35 KDA + 7 gated MLA |
135
+ | Dense layers | 2 |
136
+ | Routed / shared experts | 512 / 1 |
137
+ | Active routed experts | 8 |
138
+ | Attention heads | 32 |
139
+ | Hidden size | 2,560 |
140
+ | Expert intermediate size | 768 |
141
+ | Dense intermediate size | 6,144 |
142
+ | Vocabulary size | 157,184 |
143
+ | Context training schedule | 8K → 32K → 256K |
144
+
145
+ The included MLX adapter uses MLX-LM's native primitives for delta attention, absorbed MLA projections, RoPE, and quantized SwitchGLU experts. The auxiliary MTP training head is intentionally excluded from ordinary causal generation; this release does **not** claim MTP/DSpark speculative decoding support.
146
+
147
+ ## Upstream model highlights
148
+
149
+ InclusionAI describes Ling 3.0 Flash as a next-generation hybrid reasoning model designed for efficient long-context inference and agentic workloads. The upstream release reports strong results across software-engineering agents, tool use, deep research, general knowledge, mathematical reasoning, instruction following, and long-context understanding.
150
+
151
+ The upstream defaults are:
152
+
153
+ ```text
154
+ thinking: enabled
155
+ temperature: 0.6
156
+ top_p: 0.95
157
+ top_k: 20
158
+ ```
159
+
160
+ For benchmark methodology, scores, limitations, and framework-specific SGLang/vLLM deployment instructions, see the [original InclusionAI model card](https://huggingface.co/inclusionAI/Ling-3.0-flash).
161
+
162
+ ## Conversion notes
163
+
164
+ - Source weights: BF16 upstream checkpoint.
165
+ - Conversion command: stock `mlx_lm.convert` with `--quantize --q-bits 4 --q-group-size 64 --q-mode affine`.
166
+ - The upstream `chat_template.jinja` is included unchanged.
167
+ - All source tensors required for base causal generation were consumed by a strict load before conversion.
168
+ - The 42 base transformer layers are retained. The separate depth-5 MTP training/speculation stack is not part of this runtime adapter.
169
+
170
+ Four-bit weight quantization materially reduces memory use but may reduce output quality relative to BF16 or the 8-bit conversion.
171
+
172
+ This is a community conversion, not an official InclusionAI release. Because the architecture adapter is new, validate quality and numerical behavior on your own representative workload before production use.
173
+
174
+ ## License and attribution
175
+
176
+ The upstream model is released under the **MIT License**. This conversion preserves that license and is derived from [`inclusionAI/Ling-3.0-flash`](https://huggingface.co/inclusionAI/Ling-3.0-flash).
177
+
178
+ All model design, training, and benchmark credit belongs to InclusionAI and the original contributors. The MLX conversion and compatibility adapter are provided by [Vontra](https://huggingface.co/Vontra).