Akahsizrr commited on
Commit
d74e868
·
verified ·
1 Parent(s): 97cc08f

Add vLLM, MLX, and llama.cpp deployment docs with working implementations

Browse files
Files changed (1) hide show
  1. README.md +87 -36
README.md CHANGED
@@ -188,13 +188,16 @@ print(response)
188
 
189
  ### Pre-quantized Versions
190
 
191
- | Version | Repo | VRAM | Format |
192
- |---------|------|------|--------|
193
  | **4-bit NF4** | [`Akahsizrr/fuse-1-Lite-4bit`](https://huggingface.co/Akahsizrr/fuse-1-Lite-4bit) | 3.36 GB | bitsandbytes |
194
  | **8-bit** | [`Akahsizrr/fuse-1-Lite-8bit`](https://huggingface.co/Akahsizrr/fuse-1-Lite-8bit) | 6.00 GB | bitsandbytes |
195
  | **bfloat16** | This repo | ~12 GB | safetensors |
 
 
 
196
 
197
- ### bitsandbytes 4-bit (NF4) — ~4.5 GB VRAM
198
 
199
  ```python
200
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
@@ -216,7 +219,7 @@ model = AutoModelForCausalLM.from_pretrained(
216
  tokenizer = AutoTokenizer.from_pretrained("Akahsizrr/fuse-1-Lite")
217
  ```
218
 
219
- ### bitsandbytes 8-bit — ~7 GB VRAM
220
 
221
  ```python
222
  from transformers import AutoModelForCausalLM, BitsAndBytesConfig
@@ -242,49 +245,93 @@ model.set_coding_enabled(False)
242
  model.set_coding_enabled(True)
243
  ```
244
 
245
- ### vLLM
246
 
247
- > **Note:** vLLM does not currently support the custom `Fuse3ForCausalLM` architecture.
248
- > The model uses LFM2's hybrid conv+attention backbone with augmented MoE layers,
249
- > which requires a custom vLLM model implementation. Use transformers for inference.
250
 
251
- To use with vLLM, you would need to:
252
- 1. Write a custom vLLM model definition for `Fuse3ForCausalLM`
253
- 2. Register it with vLLM's model registry
254
- 3. Handle the hybrid conv+attention layers and expert routing
255
 
256
- Contributions welcome — see the model code in `fuse3_model.py` for the full architecture.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
  ### MLX (Apple Silicon)
259
 
260
- > **Note:** MLX does not currently support the custom `Fuse3ForCausalLM` architecture.
261
- > The model's hybrid conv+attention layers and MoE expert routing require a custom
262
- > MLX model implementation. Use transformers with MPS backend on Apple Silicon.
263
 
264
  ```python
265
- # Run on Apple Silicon with MPS backend
266
- import torch
267
- from transformers import AutoModelForCausalLM, AutoTokenizer
268
 
269
- model = AutoModelForCausalLM.from_pretrained(
270
- "Akahsizrr/fuse-1-Lite",
271
- torch_dtype=torch.float16,
272
- device_map="mps",
273
- trust_remote_code=True,
274
  )
275
- tokenizer = AutoTokenizer.from_pretrained("Akahsizrr/fuse-1-Lite")
 
 
 
 
 
 
 
276
  ```
277
 
 
 
 
 
278
  ### GGUF / llama.cpp
279
 
280
- > **Note:** GGUF conversion is not currently supported. The custom `Fuse3ForCausalLM`
281
- > architecture is not recognized by llama.cpp's `convert_hf_to_gguf.py`. LFM2 itself
282
- > IS supported by llama.cpp (see `lfm2.cpp`), but the expert augmentation layers
283
- > require a custom llama.cpp model definition.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
 
285
- ### Transformers (Recommended)
286
 
287
- The recommended way to run fuse-1 Lite is with transformers:
288
 
289
  ```bash
290
  pip install transformers torch bitsandbytes accelerate
@@ -294,11 +341,15 @@ pip install transformers torch bitsandbytes accelerate
294
 
295
  ### VRAM Requirements
296
 
297
- | Precision | VRAM | Recommended GPU |
298
- |-----------|------|-----------------|
299
- | bfloat16 | ~12 GB | L4, A10G, RTX 4090 |
300
- | 8-bit | ~7 GB | T4, L4, RTX 3060 |
301
- | 4-bit | ~4.5 GB | T4, RTX 3060, M2 Pro |
 
 
 
 
302
 
303
  ### Sample Outputs
304
 
 
188
 
189
  ### Pre-quantized Versions
190
 
191
+ | Version | Repo | VRAM/Memory | Format |
192
+ |---------|------|-------------|--------|
193
  | **4-bit NF4** | [`Akahsizrr/fuse-1-Lite-4bit`](https://huggingface.co/Akahsizrr/fuse-1-Lite-4bit) | 3.36 GB | bitsandbytes |
194
  | **8-bit** | [`Akahsizrr/fuse-1-Lite-8bit`](https://huggingface.co/Akahsizrr/fuse-1-Lite-8bit) | 6.00 GB | bitsandbytes |
195
  | **bfloat16** | This repo | ~12 GB | safetensors |
196
+ | **MLX** | [`Akahsizrr/fuse-1-Lite-MLX`](https://huggingface.co/Akahsizrr/fuse-1-Lite-MLX) | ~12 GB | MLX safetensors |
197
+ | **GGUF F16** | [`Akahsizrr/fuse-1-Lite-GGUF`](https://huggingface.co/Akahsizrr/fuse-1-Lite-GGUF) | ~11.4 GB | GGUF |
198
+ | **vLLM plugin** | [`Akahsizrr/fuse-1-Lite-vLLM`](https://huggingface.co/Akahsizrr/fuse-1-Lite-vLLM) | ~12 GB | vLLM plugin |
199
 
200
+ ### bitsandbytes 4-bit (NF4) — 3.36 GB VRAM
201
 
202
  ```python
203
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
 
219
  tokenizer = AutoTokenizer.from_pretrained("Akahsizrr/fuse-1-Lite")
220
  ```
221
 
222
+ ### bitsandbytes 8-bit — 6.00 GB VRAM
223
 
224
  ```python
225
  from transformers import AutoModelForCausalLM, BitsAndBytesConfig
 
245
  model.set_coding_enabled(True)
246
  ```
247
 
248
+ ### vLLM — High-Throughput Serving
249
 
250
+ fuse-1 Lite is supported in vLLM via a plugin that extends vLLM's native LFM2
251
+ implementation with expert augmentation layers.
 
252
 
253
+ **Plugin repo**: [`Akahsizrr/fuse-1-Lite-vLLM`](https://huggingface.co/Akahsizrr/fuse-1-Lite-vLLM)
 
 
 
254
 
255
+ ```bash
256
+ # Install the plugin
257
+ pip install git+https://huggingface.co/Akahsizrr/fuse-1-Lite-vLLM
258
+
259
+ # Serve with vLLM
260
+ vllm serve Akahsizrr/fuse-1-Lite \
261
+ --mamba-cache-mode align \
262
+ --max-model-len 4096
263
+ ```
264
+
265
+ ```python
266
+ from vllm import LLM
267
+
268
+ llm = LLM(
269
+ model="Akahsizrr/fuse-1-Lite",
270
+ mamba_cache_mode="align",
271
+ max_model_len=4096,
272
+ )
273
+ output = llm.generate("Write a Python function to check if a number is prime.")
274
+ ```
275
+
276
+ The plugin registers `Fuse3ForCausalLM` with vLLM's `ModelRegistry` via the
277
+ `vllm.general_plugins` entry point. It reuses vLLM's native LFM2 attention
278
+ and short-conv layers, adding the expert MoE block after each augmented
279
+ layer's FFN.
280
 
281
  ### MLX (Apple Silicon)
282
 
283
+ fuse-1 Lite is available in MLX format for Apple Silicon (M1+).
284
+
285
+ **MLX repo**: [`Akahsizrr/fuse-1-Lite-MLX`](https://huggingface.co/Akahsizrr/fuse-1-Lite-MLX)
286
 
287
  ```python
288
+ from mlx_lm import load, generate
 
 
289
 
290
+ model, tokenizer = load("Akahsizrr/fuse-1-Lite-MLX", trust_remote_code=True)
291
+
292
+ prompt = tokenizer.apply_chat_template(
293
+ [{"role": "user", "content": "Write a Python function to check if a number is prime."}],
294
+ tokenize=False, add_generation_prompt=True,
295
  )
296
+
297
+ response = generate(model, tokenizer, prompt=prompt, max_tokens=512)
298
+ print(response)
299
+ ```
300
+
301
+ ```bash
302
+ # CLI
303
+ mlx_lm.generate --model Akahsizrr/fuse-1-Lite-MLX --trust-remote-code --prompt "Write a Python fizzbuzz"
304
  ```
305
 
306
+ The MLX model file (`fuse3_mlx.py`) extends MLX's native LFM2 implementation
307
+ with the same expert MoE augmentation. It uses `model_file` in config.json
308
+ with `trust_remote_code=True` for loading.
309
+
310
  ### GGUF / llama.cpp
311
 
312
+ fuse-1 Lite is available in GGUF format for llama.cpp.
313
+
314
+ **GGUF repo**: [`Akahsizrr/fuse-1-Lite-GGUF`](https://huggingface.co/Akahsizrr/fuse-1-Lite-GGUF)
315
+
316
+ > **Note:** The GGUF uses the custom `fuse3` architecture. Stock llama.cpp
317
+ > cannot load it — you need a llama.cpp fork with Fuse3 support. The GGUF
318
+ > repo includes the C++ graph builder (`src/models/fuse3.cpp`), Python
319
+ > converter (`conversion/fuse3.py`), and integration guide (`INTEGRATION.md`).
320
+
321
+ ```bash
322
+ # Build llama.cpp with Fuse3 support (see INTEGRATION.md in the GGUF repo)
323
+ ./llama-cli -m fuse-1-Lite-f16.gguf \
324
+ -p "Write a Python function to check if a number is prime." \
325
+ -n 512 --temp 0.1
326
+ ```
327
+
328
+ The C++ implementation reuses LFM2's attention and short-conv graph builders,
329
+ adding the expert MoE block (router → top-k → SwiGLU experts → scale → add)
330
+ after each augmented layer's dense FFN.
331
 
332
+ ### Transformers (Universal)
333
 
334
+ The recommended way to run fuse-1 Lite on any platform:
335
 
336
  ```bash
337
  pip install transformers torch bitsandbytes accelerate
 
341
 
342
  ### VRAM Requirements
343
 
344
+ | Backend | Precision | VRAM/Memory | Recommended Hardware |
345
+ |---------|-----------|-------------|---------------------|
346
+ | Transformers | bfloat16 | ~12 GB | L4, A10G, RTX 4090 |
347
+ | Transformers | 8-bit | 6.00 GB | T4, L4, RTX 3060 |
348
+ | Transformers | 4-bit | 3.36 GB | T4, RTX 3060, M2 Pro |
349
+ | vLLM | bfloat16 | ~12 GB | A10G, A100, H100 |
350
+ | MLX | float16 | ~12 GB | M1 Pro+, M2, M3, M4 |
351
+ | llama.cpp | F16 | ~11.4 GB | Any CPU/GPU |
352
+ | llama.cpp | Q4_K_M | ~4 GB | Any CPU/GPU |
353
 
354
  ### Sample Outputs
355