Skip to content
·4 min read·Local AI / Systems

Deploying Quantized Open-Weight LLMs on Local Edge Infrastructure

What running open-weight models on Apple Silicon and Linux edge devices actually takes: quantization benchmarks, unified memory, and a custom streaming router.

#Local AI#MLX-LM#Python#Quantization#FastAPI

Why I stopped calling vendor APIs

Sending internal codebases, private documents, and customer logs to third-party commercial LLM endpoints creates two major problems:

  1. Data leaves your local perimeter.
  2. Costs scale with every token generated.

Open-weight models (Qwen 2.5, DeepSeek) running on local hardware eliminate data leaks and produce zero ongoing API fees.


Quantization Benchmarks: 4-Bit vs 8-Bit

FormatVRAM Footprint (14B Model)Memory Bandwidth SaturationQuality / Accuracy
FP16 (Unquantized)~28 GB (Exceeds safe limits)Saturated / Disk Paging100% baseline
8-Bit (INT8)~15 GBOptimal on 32GB hardware99.2% accuracy on coding benchmarks
4-Bit (INT4)~8.5 GBMaximum throughput (45+ t/s)97.8% accuracy, fastest streaming

For daily code generation and document analysis, 4-bit quantized Qwen 2.5-Coder delivers the best balance of responsiveness and memory headroom.


The FastAPI Streaming Router

from fastapi import FastAPI
from fastapi.responses import StreamingResponse
import mlx_lm

app = FastAPI(title="Local LLM Server")
model, tokenizer = mlx_lm.load("Qwen/Qwen2.5-Coder-7B-Instruct-4bit")

@app.post("/v1/stream")
async def stream_inference(prompt: str):
    def event_generator():
        for chunk in mlx_lm.stream_generate(model, tokenizer, prompt, max_tokens=512):
            yield f"data: {chunk.text}\n\n"
    return StreamingResponse(event_generator(), media_type="text/event-stream")

Related Project Case Study

Self-Hosted LLM Inference Server

A local LLM server: quantized open-weight models (Qwen 2.5) served through FastAPI on an M4 Mac Mini, with launchd auto-restart supervision and model hot-swapping so internal code and data never leave the network.

View Case Study →