Downloads · 30 days
38
12% of all-time downloads
rajib-sarwar/Llama-3.2-1B-Instruct-4bit-MLX
Llama-3.2-1B-Instruct-4bit-MLX is a text generation model from rajib-sarwar. Use it when you need the model to write or continue text. It is set up for mlx. The card lists the license as llama3.2.
This repository hosts a 4-bit quantized artifact of Meta's Llama-3.2-1B-Instruct foundation model, engineered specifically for high-throughput, low-latency on-device inference on Apple Silicon using Apple's open-sourc…
Downloads · 30 days
38
12% of all-time downloads
All-time downloads
317
Public
Parameters
1.2B
712 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors695 MB · 98%
How the weights are stored.
U321.2B · 100%
From the Hugging Face model README
This repository hosts a 4-bit quantized artifact of Meta's Llama-3.2-1B-Instruct foundation model, engineered specifically for high-throughput, low-latency on-device inference on Apple Silicon using Apple's open-source MLX framework.
Telemetry was recorded running native INT4 execution passes across unified memory on Apple Silicon:
| Metric | Measured Telemetry | Engineering Impact |
|---|---|---|
| Model Parameters | 1.23 Billion | Base foundation transformer weights |
| Quantization Precision | INT4 (~4.501 bits/weight) | Compressed from 16-bit float |
| Storage Footprint | ~695 MB (.safetensors) | Reduced from ~2.48 GB FP16 baseline |
| Peak Memory Allocation | 0.771 GB – 0.828 GB | Safely below iOS Jetsam (OOM) memory limits |
| Cold Start Prefill | 44.64 tokens/sec | High I/O penalty loading tensors from disk |
| Warm Start Prefill | 778.79 tokens/sec | ~17.4x throughput increase (Cached in RAM) |
| Sustained Throughput | ~319.62 – 321.88 tokens/sec | Real-time autoregressive token generation |
Thanks to Grouped-Query Attention (GQA with 8 KV heads vs. 32 query heads), memory allocation scales minimally over extended context lengths:
| Generated Output Length | Peak Unified Memory | Measured KV Cache Overhead |
|---|---|---|
| 300 Tokens | 0.737 GB | Base runtime |
| 600 Tokens | 0.718 GB | Active memory recycling |
| 1,200 Tokens | 0.759 GB | ~41 MB cache delta |
A primary bottleneck in on-device AI infrastructure is the latency disparity between uninitialized storage reads and active Unified Memory caching:
1. Cold Start Prefill (44.64 tok/s) — High I/O Storage Penalty
┌─────────────┐ Disk Read & Bus Transfer ┌────────────────┐ Compute Pass ┌──────────────┐
│ NVMe / SSD │ ───────────────────────────► │ Unified Memory │ ───────────────► │ GPU Compute │
└─────────────┘ (~22.4 ms/tok) └────────────────┘ └──────────────┘
2. Warm Start Prefill (778.79 tok/s) — Zero Storage Latency (~17.4x Acceleration)
┌────────────────┐ Direct Stream ┌──────────────┐
│ Resident Cache │ ───────────────► │ GPU Compute │
└────────────────┘ (~1.28 ms/tok) └──────────────┘
Prefill Latency Comparison (Tokens per Second)
──────────────────────────────────────────────────────────────────────────────
Cold Start (Disk I/O) | ██ (44.64 tok/s)
Warm Start (RAM Cached) | ████████████████████████████████████ (778.79 tok/s) [17.4x]
──────────────────────────────────────────────────────────────────────────────
Ensure an Apple Silicon Mac with macOS 14+ and an isolated virtual environment:
pip install mlx-lm huggingface_hub
Run text generation directly from your terminal using the MLX engine:
mlx_lm.generate \
--model rajib-sarwar/Llama-3.2-1B-Instruct-4bit-MLX \
--prompt "Explain how 4-bit quantization reduces memory pressure on Apple Silicon." \
--max-tokens 300
from mlx_lm import load, generate
# Load the 4-bit model directly from Hugging Face Hub
model, tokenizer = load("rajib-sarwar/Llama-3.2-1B-Instruct-4bit-MLX")
prompt = "Explain how 4-bit quantization reduces memory pressure on Apple Silicon."
response = generate(
model,
tokenizer,
prompt=prompt,
max-tokens=300,
verbose=True
)
print(response)
Converted from official meta-llama/Llama-3.2-1B-Instruct bfloat16 tensors using mlx_lm.convert:
# 1. Force snapshot metadata caching
python3 -c "from huggingface_hub import snapshot_download; snapshot_download('meta-llama/Llama-3.2-1B-Instruct')"
# 2. Execute 4-bit quantization
mlx_lm.convert \
--hf-path meta-llama/Llama-3.2-1B-Instruct \
-q \
--q-bits 4 \
--upload-repo rajib-sarwar/Llama-3.2-1B-Instruct-4bit-MLX
This model is a quantized derivative of Meta's Llama 3.2 family. Usage is subject to the Meta Llama 3.2 Community License Agreement.