Skip to content

Add Sarvam 105B model support - #2097

Open
prayanks wants to merge 1 commit into
ml-explore:mainfrom
prayanks:add-sarvam-mla
Open

prayanks wants to merge 1 commit into
ml-explore:mainfrom
prayanks:add-sarvam-mla

Conversation

@prayanks

Copy link
Copy Markdown

Requirements

  • ☑️ I understand it is strictly prohibited to use AI to write PR description
  • AI usage disclosure:

I have used Codex to compare changes needed to the DeekSeek-V3 implementation in mlx.lm src and changed it to support Sarvam models in mlx. I have a Mac machine and I wanted to use the mlx ports of the model on my machine. Sarvam is a startup that is building sovereign models for India and Indian languages. I'm not employed by the company or an investor in the company - I was just curious to run it on my machine. And its past models also do not have MLX support. So I ported the HF model to MLX and needed to add this support in mlx.lm to be able to execute inference on the models on my mac.

I used codex first to understand difference between the executors for Deepseek V3,3.2,4. Then asked it to look at the HF Sarvam 105B-1711 model and see which of these three is closest to the Sarvam model. Then asked it to make the required changes in the mlx.lm source code. Then I asked it to help me all the tests required so that this PR can be accepted. I'm also uploading the mlx 6-bit version of the model to HF under my personal public HF repo.

I have reviewed the code changes manually, and run all the unit tests - and all is OK.

Model information

Supported checkpoints

Verification

Conversion command:

mlx_lm.convert \   
  --model sarvamai/sarvam-105b-1711-bf16 \
  --mlx-path ./output/sarvam-105b-1711-mlx-q6 \
  -q \
  --q-bits 6 \
  --q-group-size 64
mlx_lm.generate \
  --model ./output/sarvam-105b-1711-mlx-q6 \
  --prompt "The secret to baking a good cake is" \
  --max-tokens 1024 \
  --temp 0

Output:

[transformers] Loading a SarvamMLA config in the deprecated format (found head_dim). It has been converted to the DeepSeek-V3 format; re-save it with `config.save_pretrained()` to update it.
[transformers] Missing validation function in 'RotaryEmbeddingConfigMixin' for 'rope_type'='deepseek_yarn'
==========
<think>We need to answer the user's prompt. The user says: "The secret to baking a good cake is". It's an incomplete sentence, likely they want us to complete it or provide an answer about the secret to baking a good cake.

We need to respond helpfully. The user didn't ask a question explicitly but gave a prompt. We should provide a comprehensive answer about the secret to baking a good cake. We can list key factors: quality ingredients, accurate measurements, proper mixing techniques, oven temperature, not overmixing, using room temperature ingredients, proper pan preparation, not opening the oven too early, etc.

We should be concise but thorough. Maybe a short paragraph or bullet points.

The user might be looking for a creative completion. But likely they want the secret.

We can say: "The secret to baking a good cake is..." and then list things.

Let's craft a response.

We should ensure we don't violate any policies. It's safe.

We can say:

The secret to baking a good cake is actually a combination of a few disciplined habits rather than a single magic trick. Then list bullet points.

Let's do that.

We can also mention the importance of following the recipe, using fresh ingredients, measuring accurately, not overmixing, proper oven preheating, using the right pan, letting it cool properly.

Let's write a friendly, informative response.</think>
The secret to baking a good cake is really a combination of disciplined habits and a few non‑negotiable details rather than a single magic trick. Here are the most important ones:

- **Measure accurately** – Use a kitchen scale for dry ingredients and proper measuring cups for liquids. Even a small deviation in flour or leavening can throw off the texture.
- **Use quality ingredients** – Fresh eggs, real butter (not margarine), and good vanilla extract make a noticeable difference in flavor and crumb.
- **Bring ingredients to room temperature** – This helps the butter and eggs emulsify smoothly, creating a uniform batter and a tender crumb.
- **Don’t overmix** – Once the flour is incorporated, stop. Overmixing develops gluten and can make the cake tough or dense.
- **Preheat the oven properly** – A fully preheated oven ensures the cake starts rising immediately and sets before the structure collapses.
- **Use the right pan and prep it well** – Grease and flour (or line with parchment) the pan so the cake releases cleanly and bakes evenly.
- **Resist the urge to open the oven early** – Peeking can cause the cake to sink as the structure sets.
- **Cool it right** – Let the cake cool in the pan for a few minutes, then turn it out onto a wire rack. Cooling completely before frosting prevents melting and sliding.
- **Follow the recipe’s chemistry** – If a recipe calls for a specific leavening (baking soda vs. powder), use it; they react differently to acid and heat.

In short, the “secret” is treating baking as a science: respect the measurements, the temperatures, and the timing, and the cake will almost always turn out well.
==========
Prompt: 18 tokens, 2.043 tokens-per-sec
Generation: 668 tokens, 39.174 tokens-per-sec
Peak memory: 86.226 GB

Reference output (if you have access to CUDA hardware)

Do no have CUDA hardware

Validation

python -m unittest tests.models.test_sarvam_mla -v

All 3 focused Sarvam unit tests passed.
Screenshot 2026-11-23 at 10 57 00 AM

python -m unittest discover -v tests

All 437 project tests passed.
Screenshot 2026-11-23 at 10 55 50 AM

uvx pre-commit run --all
git status --short
git diff --cached --check

Black, isort, and Ruff passed.
Screenshot 2026-11-23 at 10 54 51 AM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant