Susant-Achary commited on
Commit
e60d202
·
verified ·
1 Parent(s): 4c3e51f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +75 -25
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  model-index:
3
- - name: LFM2-8B-A1B — MLX (Apple Silicon), **8-bit**
4
  results: []
5
  license: apache-2.0
6
  language:
@@ -8,47 +8,97 @@ language:
8
  tags:
9
  - mlx
10
  - apple-silicon
11
- - text-generation
12
- - 8bit
 
 
 
 
13
  - quantized
14
- - 8b
15
- - MoE
16
  - Mixture of Experts
17
  pipeline_tag: text-generation
18
  library_name: mlx
19
- base_model:
20
- - LiquidAI/LFM2-8B-A1B
21
  ---
22
 
23
  # LFM2-8B-A1B — **MLX 8-bit** (Apple Silicon)
24
- **Maintainer / Publisher:** [**Susant Achary**](https://huggingface.co/Susant-Achary)
25
 
26
- This repository provides an **Apple-Silicon-optimized MLX build** of **LFM2-8B-A1B** with **8-bit** weight quantization.
27
- The goal is a **drop-in, on-device** experience on M-series Macs with **maximal fidelity** among quantized variants while keeping load times small and setup simple.
 
 
 
 
 
 
 
28
 
29
- > Source model: `mlx-community/LFM2-8B-A1B-8bit-MLX` (Apache-2.0).
30
- > Format: **MLX** (Metal/MPS), ready for `mlx_lm.generate`.
 
 
 
 
31
 
32
  ---
33
 
34
- ## 🔎 Model at a glance
35
 
36
- - **Type:** 8B-parameter decoder-only language model (dense Transformer family).
37
- - **This build:** **8-bit** quantized **MLX** weights for fast, Apple-native inference.
38
- - **Typical uses:** instruction following, summarization, drafting, QA, basic code/text utilities.
39
 
40
- > If you need a smaller RAM footprint on older/lower-RAM Macs, consider lower-bit MLX builds (4/5/6-bit). If you want the **closest behavior to FP16** while staying in MLX, **8-bit** is the right choice.
41
 
42
  ---
43
 
44
- ## 📦 Files in this repo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- - `config.json` (MLX config)
47
- - `mlx_model*.safetensors` (**8-bit** sharded weights)
48
- - `tokenizer.json`, `tokenizer_config.json`
49
- - `model_index.json` and basic metadata
 
50
 
51
- All assets are arranged for **direct loading** via `mlx_lm`.
52
 
53
  ---
54
 
@@ -58,8 +108,8 @@ All assets are arranged for **direct loading** via `mlx_lm`.
58
  ```bash
59
  python -m mlx_lm.generate \
60
  --model mlx-community/LFM2-8B-A1B-8bit-MLX \
61
- --prompt "Summarize the following notes into 5 bullet points:\n<your text>" \
62
  --max-tokens 256 \
63
  --temperature 0.0 \
64
  --device mps \
65
- --seed 0
 
1
  ---
2
  model-index:
3
+ - name: LFM2-8B-A1B — MLX (Apple Silicon), **8-bit** (with guidance on MoE + RAM planning)
4
  results: []
5
  license: apache-2.0
6
  language:
 
8
  tags:
9
  - mlx
10
  - apple-silicon
11
+ - liquidai
12
+ - lfm2
13
+ - moe
14
+ - transformer
15
+ - long-context
16
+ - instruct
17
  - quantized
18
+ - 8bit
 
19
  - Mixture of Experts
20
  pipeline_tag: text-generation
21
  library_name: mlx
 
 
22
  ---
23
 
24
  # LFM2-8B-A1B — **MLX 8-bit** (Apple Silicon)
 
25
 
26
+ **Maintainer / Publisher:** [**Susant Achary**](https://huggingface.co/Susant-Achary)
27
+ **Upstream model:** [LiquidAI/LFM2-8B-A1B](https://huggingface.co/LiquidAI/LFM2-8B-A1B)
28
+ **This repo (MLX 8-bit):** `mlx-community/LFM2-8B-A1B-8bit-MLX`
29
+
30
+ This repository provides an **Apple-Silicon-optimized MLX build** of **LFM2-8B-A1B** at **8-bit** quantization for fast, on-device inference.
31
+
32
+ ---
33
+
34
+ ## 🔎 What is LFM2-8B-A1B?
35
 
36
+ - **Architecture:** Mixture-of-Experts (**MoE**) Transformer.
37
+ - **Size:** ~**8B total parameters** with **~1B active** per token (the “A1B” suffix commonly denotes *~1B active params*).
38
+ - **Why MoE?** During generation, only a subset of experts is **activated per token**, reducing **compute per token** while keeping a larger total parameter pool for expressivity.
39
+
40
+ > **Important memory note (single-device inference):**
41
+ > Although *compute per token* benefits from MoE (fewer **active** parameters), **the full set of experts still resides in memory** for typical single-GPU/CPU deployments. In practice this means **RAM usage scales with total parameters**, not with the smaller *active* count.
42
 
43
  ---
44
 
45
+ ## 📦 What’s in this MLX build
46
 
47
+ - `config.json` (MLX), `mlx_model*.safetensors` (**8-bit** shards)
48
+ - Tokenizer files: `tokenizer.json`, `tokenizer_config.json`
49
+ - Model metadata (e.g., `model_index.json`)
50
 
51
+ Target platform: **macOS** on **Apple Silicon (M-series)** using **Metal/MPS**.
52
 
53
  ---
54
 
55
+ ## Intended use
56
+
57
+ - General **instruction-following**, chat, and summarization
58
+ - **RAG** back-ends and long-context workflows on device
59
+ - **Function-calling / structured outputs** with schema-style prompts
60
+
61
+ ## ⚠️ Limitations
62
+
63
+ - Even at 8-bit, **long contexts** (KV-cache) can dominate memory at high `max_tokens` or large batch sizes.
64
+ - As with any quantization, small regressions vs FP16 can appear on intricate math/code or edge-formatting.
65
+
66
+ ---
67
+
68
+ ## 🔢 RAM planning (8-bit, MoE, MLX)
69
+
70
+ You asked to **assume and decide** RAM usage in absence of your measurements. Below are **practical planning numbers** derived from first-principles + experience with MLX and similar MoE models. Treat them as **starting points** and validate on your hardware.
71
+
72
+ ### Rule-of-thumb components
73
+
74
+ - **Weights:** `~ total_params × 1 byte` (8-bit). For 8B params → **~8.0 GB** baseline.
75
+ - **Runtime overhead:** MLX graph + tensors + metadata → **~0.5–1.0 GB** typical.
76
+ - **KV cache:** grows with **context_length × layers × heads × dtype**; often **1–3+ GB** for long contexts.
77
+
78
+ ### Indicative peak RAM (single image/text, batch=1)
79
+
80
+ | Context window | Estimated peak RAM |
81
+ |---|---:|
82
+ | **4k tokens** | **~9.5–10.5 GB** |
83
+ | **8k tokens** | **~10.5–11.8 GB** |
84
+ | **16k tokens** | **~12.0–14.0 GB** |
85
+
86
+ > These ranges assume **8-bit** weights, **A1B MoE** (all experts resident), batch size = 1, and standard generation settings.
87
+ > On lower windows (≤2k), you may see **~9–10 GB**. Larger windows or batches will increase KV-cache and peak RAM.
88
+
89
+ ---
90
+
91
+ ## 🧭 Choosing precision for LFM2-8B-A1B
92
+
93
+ While this card is **8-bit**, teams often want a consistent lineup. If you later produce 6/5/4/3/2-bit MLX builds, here’s a practical guide (RAM figures are **indicative** for an 8B MoE LM; your results depend on context/batch):
94
 
95
+ | Variant | Typical Peak RAM | Relative Speed | Typical Behavior | When to choose |
96
+ |---|---:|:---:|---|---|
97
+ | **4-bit** | ~7–8 GB | 🔥🔥🔥 | Better detail retention | If 3-bit drops too much fidelity |
98
+ | **6-bit** | ~9–10.5 GB | 🔥🔥 | Near-max MLX quality | If you want accuracy under quant |
99
+ | **8-bit** *(this repo)* | **~9.5–12+ GB** | 🔥🔥 | **Highest** quality among quant tiers | When RAM allows and you want the most faithful outputs |
100
 
101
+ > **MoE caveat:** MoE **reduces compute per token**, but unless experts are **paged/partitioned** across devices and loaded on demand, **memory** still follows **total parameters**. On a single Mac, plan RAM as if the *whole 8B* parameter set is resident.
102
 
103
  ---
104
 
 
108
  ```bash
109
  python -m mlx_lm.generate \
110
  --model mlx-community/LFM2-8B-A1B-8bit-MLX \
111
+ --prompt "Summarize the following in 5 bullet points:\n<your text>" \
112
  --max-tokens 256 \
113
  --temperature 0.0 \
114
  --device mps \
115
+ --seed 0