Instructions to use konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4") model = AutoModelForCausalLM.from_pretrained("konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4
- SGLang
How to use konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4 with Docker Model Runner:
docker model run hf.co/konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4
LFM2.5-8B-A1B-REAP-50-AWQ-INT4
Model Description
This is the REAP-pruned + AWQ INT4-quantized variant of LiquidAI/LFM2.5-8B-A1B, representing the full compression pipeline:
- REAP pruning (50% experts removed) →
konic-labs/LFM2.5-8B-A1B-REAP-50 - AWQ INT4 quantization (W4A16_ASYM, group_size=128) → this model
- Base: 8.47B params, 16.94 GB (bf16)
- This model: 2.79 GB on disk (83.5% total compression)
- Quant format: compressed-tensors
pack-quantized(INT4 weights, bf16 activations, asymmetric, group_size=128) - Runtime VRAM: ~8.6 GB (weights decompress to bf16 in memory)
- 1,122 weight tensors quantized; routers, layer norms, embeddings, and Conv1d internals left unquantized
⚠️ Loading Requires a Small Patch
The compressed-tensors pack-quantized format has two bugs in current transformers that prevent loading asymmetric-quantized MoE expert weights. A self-contained patch is included in patches/apply_int4_patch.py.
Upstream status: These bugs are fixed upstream in PR huggingface/transformers#47430. The fix is general for any MoE model with fused expert
nn.Parameterweights (LFM2.5, Qwen2-MoE family) quantized with an asymmetric compressed-tensors scheme. Once merged, this patch script becomes unnecessary — re-run it only until your installed transformers release includes the fix.
# Apply the patch (creates .orig backups, idempotent, --check to verify)
python patches/apply_int4_patch.py
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4",
trust_remote_code=True,
dtype=torch.bfloat16,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(
"konic-labs/LFM2.5-8B-A1B-REAP-50-AWQ-INT4", trust_remote_code=True
)
Re-run the patch after every pip install -U transformers. See patches/README.md for details and how to decompress to a vLLM-compatible bf16 checkpoint if you need vLLM inference (the INT4 pack-quantized format is not yet loadable by vLLM directly).
AWQ Quantization Details
- Method: AWQ (Activation-aware Weight Quantization) via llm-compressor
- Scheme: W4A16_ASYM (4-bit weights, 16-bit activations, asymmetric, group_size=128)
- Calibration: 256 samples from
evol-codealpaca-v1/train.jsonl - Custom LFM2.5 AWQ mappings:
operator_norm→ attention q/k/v projections,ffn_norm→ MoE expert w1/w3 projections (LFM2.5 uses non-standard layer-norm names).v_proj→out_projandconv.in_proj→conv.out_projwere skipped due to GQA dimension mismatch and Conv1d intermediary respectively. - Average AWQ smoothing error: ~5-7 × 10⁻⁴ (well-converged)
Benchmark Results
| Benchmark | Base (published) | REAP-50 (pruned) | This model (REAP+AWQ-INT4) | Retention |
|---|---|---|---|---|
| MATH500 | 88.76% | 77.0% | 72.0% | 81.1% |
| BFCLv3 (single-turn) | 64.79% | 59.07% | 57.36% | 88.5% |
MATH500 per-difficulty (this model)
| Level | Accuracy |
|---|---|
| L1 | 90.7% |
| L2 | 84.4% |
| L3 | 81.9% |
| L4 | 72.7% |
| L5 | 49.3% |
BFCLv3 per-category (this model)
| Category | Accuracy |
|---|---|
| simple_python | 69.25% |
| simple_java | 44.00% |
| simple_javascript | 38.00% |
| multiple | 79.00% |
| parallel | 69.50% |
| parallel_multiple | 66.00% |
| irrelevance | 83.75% |
| live_simple | 51.94% |
| live_multiple | 48.24% |
| live_parallel | 12.50% |
| live_parallel_multiple | 45.83% |
| live_irrelevance | 75.57% |
| live_relevance | 50.00% |
Key finding: Quantization adds only ~5pp MATH500 and ~1.7pp BFCLv3 degradation beyond pruning alone, while delivering a 67% disk-size reduction on top of REAP. L1-L3 math is completely unaffected; advanced/competition math (L4-L5) bears the cost.
Throughput (vLLM, NVIDIA L4)
| Concurrency | Tokens/sec |
|---|---|
| 64 | 2,227 |
| 128 | 3,334 |
| 256 | 4,809 (sweetspot) |
| 384 | 4,287 |
| 512 | 4,273 |
(Measured on the AWQ-scaled bf16 decompressed variant, which is functionally identical to this INT4 model at runtime.)
Intended Use
Research and deployment of compressed MoE models. This is the full-pipeline output of REAP pruning + AWQ INT4 quantization — the smallest deployable variant.
Citation
@software{reap-cuda,
title = {REAP: Ranking and Eliminating Experts via Activation Patterns},
author = {Konic Labs},
url = {https://github.com/egesabanci/reap-cuda}
}
License
Apache-2.0 (inherited from base model).
- Downloads last month
- 61