Text Generation
MLX
Safetensors
English
mistral3
mistral
devstral
code
tool-use
agentic
quantized
apple-silicon
conversational
3-bit
Instructions to use badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "badmadrad/Devstral-Small-2-24B-Instruct-2512-MLX-3bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Upload folder using huggingface_hub
Browse files- README.md +30 -16
- generation_config.json +0 -2
- model-00001-of-00002.safetensors +1 -1
- model-00002-of-00002.safetensors +1 -1
README.md
CHANGED
|
@@ -35,6 +35,26 @@ MLX-optimized 3-bit quantization of [mistralai/Devstral-Small-2-24B-Instruct-251
|
|
| 35 |
- **256K Context**: Supports up to 256K token context window
|
| 36 |
- **Speculative Decoding Compatible**: Works with Mistral Tekken tokenizer draft models
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
## Usage
|
| 39 |
|
| 40 |
```python
|
|
@@ -56,6 +76,7 @@ tools = [{"type": "function", "function": {"name": "read_file", "description": "
|
|
| 56 |
messages = [{"role": "user", "content": "Read the file main.py"}]
|
| 57 |
prompt = tokenizer.apply_chat_template(messages, tools=tools, tokenize=False, add_generation_prompt=True)
|
| 58 |
response = generate(model, tokenizer, prompt=prompt, max_tokens=200)
|
|
|
|
| 59 |
```
|
| 60 |
|
| 61 |
### With Speculative Decoding
|
|
@@ -70,27 +91,20 @@ draft_model, _ = load("badmadrad/Mistral-Small-3.1-DRAFT-0.5B-MLX-4bit")
|
|
| 70 |
# Draft model proposes tokens, main model verifies — faster generation
|
| 71 |
```
|
| 72 |
|
| 73 |
-
## Quantization Details
|
| 74 |
-
|
| 75 |
-
Converted using `mlx_lm.convert`:
|
| 76 |
-
|
| 77 |
-
```bash
|
| 78 |
-
mlx_lm.convert \
|
| 79 |
-
--hf-path mistralai/Devstral-Small-2-24B-Instruct-2512 \
|
| 80 |
-
--mlx-path ./devstral-v2-3bit \
|
| 81 |
-
--quantize --q-bits 3 --q-group-size 64
|
| 82 |
-
```
|
| 83 |
-
|
| 84 |
-
- **Method**: Affine quantization (3-bit with group size 64)
|
| 85 |
-
- **Effective bits/weight**: ~3.5
|
| 86 |
-
- **Memory savings**: ~75% vs BF16, ~20% vs 4-bit
|
| 87 |
-
|
| 88 |
## Hardware Requirements
|
| 89 |
|
| 90 |
- Apple Silicon Mac (M1/M2/M3/M4)
|
| 91 |
-
- Minimum 16 GB unified memory
|
| 92 |
- macOS 13.5+
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
## License
|
| 95 |
|
| 96 |
Apache 2.0 (same as base model)
|
|
|
|
| 35 |
- **256K Context**: Supports up to 256K token context window
|
| 36 |
- **Speculative Decoding Compatible**: Works with Mistral Tekken tokenizer draft models
|
| 37 |
|
| 38 |
+
## Quantization Method
|
| 39 |
+
|
| 40 |
+
This model was created using a **dequantize-requantize** workflow for optimal 3-bit quality:
|
| 41 |
+
|
| 42 |
+
```bash
|
| 43 |
+
# Step 1: Dequantize the MLX 4-bit model back to BF16
|
| 44 |
+
mlx_lm.convert \
|
| 45 |
+
--hf-path mlx-community/mistralai_Devstral-Small-2-24B-Instruct-2512-MLX-4Bit \
|
| 46 |
+
--mlx-path ./devstral-v2-bf16 \
|
| 47 |
+
--dequantize --dtype bfloat16
|
| 48 |
+
|
| 49 |
+
# Step 2: Requantize from BF16 to 3-bit
|
| 50 |
+
mlx_lm.convert \
|
| 51 |
+
--hf-path ./devstral-v2-bf16 \
|
| 52 |
+
--mlx-path ./devstral-v2-3bit \
|
| 53 |
+
--quantize --q-bits 3 --q-group-size 64
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
**Why this works**: Direct 3-bit quantization from the original HuggingFace BF16 weights produces degenerate output ("decay decay decay") due to weight distribution differences during the PyTorch-to-MLX conversion. Going through the MLX 4-bit model's dequantized BF16 preserves the weight structure that MLX inference requires.
|
| 57 |
+
|
| 58 |
## Usage
|
| 59 |
|
| 60 |
```python
|
|
|
|
| 76 |
messages = [{"role": "user", "content": "Read the file main.py"}]
|
| 77 |
prompt = tokenizer.apply_chat_template(messages, tools=tools, tokenize=False, add_generation_prompt=True)
|
| 78 |
response = generate(model, tokenizer, prompt=prompt, max_tokens=200)
|
| 79 |
+
# Output: [TOOL_CALLS]read_file[ARGS]{"path": "main.py"}
|
| 80 |
```
|
| 81 |
|
| 82 |
### With Speculative Decoding
|
|
|
|
| 91 |
# Draft model proposes tokens, main model verifies — faster generation
|
| 92 |
```
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
## Hardware Requirements
|
| 95 |
|
| 96 |
- Apple Silicon Mac (M1/M2/M3/M4)
|
| 97 |
+
- Minimum 16 GB unified memory
|
| 98 |
- macOS 13.5+
|
| 99 |
|
| 100 |
+
## Comparison
|
| 101 |
+
|
| 102 |
+
| Variant | Size | Quality | Tool Calling |
|
| 103 |
+
|---------|------|---------|-------------|
|
| 104 |
+
| BF16 (original) | ~48 GB | Best | Yes |
|
| 105 |
+
| 4-bit (mlx-community) | ~12 GB | Great | Yes |
|
| 106 |
+
| **3-bit (this model)** | **~9.6 GB** | **Good** | **Yes** |
|
| 107 |
+
|
| 108 |
## License
|
| 109 |
|
| 110 |
Apache 2.0 (same as base model)
|
generation_config.json
CHANGED
|
@@ -3,7 +3,5 @@
|
|
| 3 |
"eos_token_id": 2,
|
| 4 |
"max_length": 262144,
|
| 5 |
"pad_token_id": 11,
|
| 6 |
-
"do_sample": true,
|
| 7 |
-
"temperature": 0.15,
|
| 8 |
"transformers_version": "5.0.0.dev0"
|
| 9 |
}
|
|
|
|
| 3 |
"eos_token_id": 2,
|
| 4 |
"max_length": 262144,
|
| 5 |
"pad_token_id": 11,
|
|
|
|
|
|
|
| 6 |
"transformers_version": "5.0.0.dev0"
|
| 7 |
}
|
model-00001-of-00002.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 5326582403
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:86938c62379f1c361c27356ee8aa4f1730032278f9acb2b8de86fa5f08397c85
|
| 3 |
size 5326582403
|
model-00002-of-00002.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4987111828
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:05c48505b7530ff654777143594bd67f1a4ca8455cf71f021ec96ee7010b35cf
|
| 3 |
size 4987111828
|