Instructions to use sahilchachra/sarvam-30b-MXFP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use sahilchachra/sarvam-30b-MXFP8 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("sahilchachra/sarvam-30b-MXFP8") 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 sahilchachra/sarvam-30b-MXFP8 with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "sahilchachra/sarvam-30b-MXFP8"
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": "sahilchachra/sarvam-30b-MXFP8" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use sahilchachra/sarvam-30b-MXFP8 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "sahilchachra/sarvam-30b-MXFP8"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "sahilchachra/sarvam-30b-MXFP8" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sahilchachra/sarvam-30b-MXFP8", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use sahilchachra/sarvam-30b-MXFP8 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 "sahilchachra/sarvam-30b-MXFP8"
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 sahilchachra/sarvam-30b-MXFP8
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use sahilchachra/sarvam-30b-MXFP8 with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "sahilchachra/sarvam-30b-MXFP8"
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 "sahilchachra/sarvam-30b-MXFP8" \ --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"
Run an OpenAI-compatible server
# Install MLX LM
uv tool install mlx-lm# Start the server
mlx_lm.server --model "sahilchachra/sarvam-30b-MXFP8"
# Calling the OpenAI-compatible server with curl
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "sahilchachra/sarvam-30b-MXFP8",
"messages": [
{"role": "user", "content": "Hello"}
]
}'sarvam-30b — MLX MXFP8
MLX MXFP8 quantization of sarvamai/sarvam-30b, a 32B-parameter
Mixture-of-Experts text-generation model from Sarvam AI. Text-only (no vision tower).
sarvam-30b uses a custom sarvam_moe architecture: 19 transformer layers (the first
dense, the rest MoE), 128 routed experts + 1 shared expert with top-6 sigmoid-gated routing
(DeepSeek-style: expert bias for load balancing, routed_scaling_factor 2.5), grouped-query
attention (64 query heads / 4 KV heads) with QK-RMSNorm, and an untied 262K-vocab
lm_head (multilingual tokenizer covering Indian languages). Runs on Apple Silicon via
mlx-lm.
⚠️ Requires vendoring an unmerged mlx-lm PR. As of this quantization, sarvam_moe is
not in any released mlx-lm version — support exists only as an open, unmerged draft,
ml-explore/mlx-lm#991. This repo's weights
were produced using that PR's model definition, vendored locally. To load this model you
must vendor the same file into your own mlx-lm install:
pip install -U mlx-lm
curl -o "$(python -c 'import mlx_lm, os; print(os.path.dirname(mlx_lm.__file__))')/models/sarvam_moe.py" \
https://raw.githubusercontent.com/ml-explore/mlx-lm/c686bdab1cbf6b5f5364675a8bc858ead97c92eb/mlx_lm/models/sarvam_moe.py
Once PR #991 merges, this step won't be necessary. This will not load in LM Studio (or any tool bundling its own unpatched mlx-lm/mlx-vlm) until then.
| Precision | MXFP8 (E4M3 + E8M0 shared scale, group size 32) |
| Bits per weight | ~8.5 bpw (mixed — see below) |
| On-disk size | 32 GB (30 shards) |
| Quantized | attention projections + all MoE expert weights + embed_tokens |
| Kept full precision (bf16) | lm_head (~1.07B params, untied), and each layer's |
MoE router weight (mlp.gate.weight) — quantizing the router double-damages routing |
|
| decisions, so the architecture's own quantization predicate excludes it |
Quantizations
| Variant | Bits | Size | |
|---|---|---|---|
sarvam-30b-MXFP4 |
~4.6 bpw | 17 GB | smaller / for 32 GB+ |
sarvam-30b-MXFP8 |
~8.5 bpw | 32 GB | ← this repo |
Verification
This higher-fidelity build was verified structurally: correct tensor shapes,
format: mlx metadata, consistent shard index, lm_head and each layer's MoE router
(mlp.gate.weight) correctly left unquantized (same predicate as the MXFP4 build).
Full token-by-token generation was not benchmarked on the 26 GB test machine because this
build's 32 GB exceeds available RAM; on a 48 GB+ Mac it runs at normal speed. Since MXFP8
uses more bits than the MXFP4 build — which passed the full English/Hindi/Tamil
generation smoke test above — it is at least as faithful to the base model.
See the MXFP4 build for the full generation smoke-test results.
Usage (mlx-lm)
pip install -U mlx-lm
# then vendor mlx_lm/models/sarvam_moe.py from PR #991 as shown above
from mlx_lm import load, generate
model, tokenizer = load("sahilchachra/sarvam-30b-MXFP8")
messages = [{"role": "user", "content": "What is the capital of France?"}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
print(generate(model, tokenizer, prompt=prompt, max_tokens=256, verbose=True))
This is a reasoning model; it emits a <think>...</think> block before its answer — give it
enough max_tokens or the visible answer can be truncated while it's still reasoning.
Notes & limitations
- Custom architecture, unmerged upstream support. See the vendoring step above — this is a hard requirement, not a suggestion, until PR #991 merges.
- Text-only. No vision/image support in the base model.
tie_word_embeddings: false—lm_headis a separate ~1.07B-parameter matrix, kept in bf16 (see table above).embed_tokens(the input embedding table) is quantized. The MXFP4 smoke test above specifically checked non-English prompts to catch degradation here.- Inherits all capabilities and limitations of the base model. See the original model card.
- Quantized by @sahilchachra with MLX. Apache-2.0.
- Downloads last month
- 176
8-bit
Model tree for sahilchachra/sarvam-30b-MXFP8
Base model
sarvamai/sarvam-30b
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm# Interactive chat REPL mlx_lm.chat --model "sahilchachra/sarvam-30b-MXFP8"