Leo Sarvam 30B
A measured coding gain from an already strong baseline, using 400 coding examples.
Leo Sarvam 30B is an independent community coding fine-tune of Sarvam AI's Sarvam-30B, released by Leo contributors. This repository contains the exact step-50 LoRA adapter evaluated below. Load it with the pinned Sarvam base; it is an adapter release, not a standalone copy of the base weights. It is not an official Sarvam AI release or endorsement.
Recorded success
| Evaluation | Original Sarvam-30B | Leo step-50 | Observed gain |
|---|---|---|---|
| HumanEval, all 164 questions | 157/164 — 95.73% | 159/164 — 96.95% | +2 correct; +1.22 percentage points |
| MATH500, frozen 200-question subset | 194/200 — 97.00% | 195/200 — 97.50% | +1 correct; +0.50 percentage points |
Neither model omitted or exhausted the context on any answer in this completed 728-response comparison. The coding baseline already failed only 7 questions; Leo failed 5. The release highlights this small measured gain on a strong baseline while preserving math performance on the evaluated subset.
One stochastic response was generated per model per question. Coding had 4 paired gains and 2 losses; math had 3 gains and 2 losses. Exact paired McNemar p-values were 0.6875 and 1.0. These numerical gains do not establish statistically reliable general superiority or show that improvements near a high baseline are harder than improvements from lower baselines. Scores are from our matched protocol, not a reproduction of Sarvam's published benchmark settings.
What was trained
- Base:
sarvamai/sarvam-30b, revision071ae95e933605ca1104a6b4524a36a98488efa4. - Artifact: step-50 attention-only LoRA; rank 16, alpha 32, dropout 0; 38 attention projection modules. Original base, experts and routing weights were frozen.
- The checkpoint saw 400 coding examples over 50 optimizer updates, with gradient accumulation of 8. No math examples were used.
- These were the first 400 examples in a seeded shuffle of our prepared 5,000-example coding pool. They were not a separately hand-curated or independently correctness-validated set of 400.
- Questions originated from NVIDIA OpenCodeInstruct, via our prepared question pool. Targets were generated by Qwen3.5-27B served through DeepInfra; NVIDIA's original answers were not the training targets.
- Assistant reasoning and final responses were preserved, using native Sarvam chat serialization, assistant-only labels and end-of-turn token 26; no target truncation or answer repair was used.
- Training used NF4 QLoRA, AdamW, learning rate 1e-5, weight decay 0.01, 32-update warm-up and a schedule planned for 625 updates. The selected adapter is an early checkpoint from that trajectory.
- The training questions and teacher responses are not distributed in this repository. Provenance and training configuration are documented without exposing the private corpus.
Research lesson: checkpoint choice matters
More training was not monotonically better along this particular training trajectory:
| Checkpoint | Coding examples seen | Evidence |
|---|---|---|
| Step 50 | 400 | Completed all 164 coding + 200 math questions; small numerical gains in both domains; zero omitted/incomplete answers. |
| Step 100 | 800 | Completed a fresh original-versus-step100 small validation: coding 18/20 versus original 20/20; math 8/10 for both; no omissions. Failed the predeclared accuracy gate; no broad step100 run was started. |
| Step 625 | 5,000 | Evaluation stopped after regression: on the first 64 paired HumanEval cases, corrected grading gave adapter 53/64 versus original 64/64, including 9 adapter omissions. This is an interim, nonrandom prefix result, not a full HumanEval score. |
Step-50 is our best validated candidate, not a proven optimal checkpoint. Step-100 was not fully evaluated head-to-head with step-50; its small scores should not be treated as a statistically conclusive ranking. Forward diagnostics found increased end-of-turn probability in the step625 adapter on selected failure prefixes across NF4 and BF16 reference inference. The specific training choice responsible was not isolated. We also corrected an earlier answer-extraction bug uniformly for both models before the reported comparisons.
This experience supports validation and checkpoint selection instead of automatically releasing the final training checkpoint. It does not establish that more training data generally makes models worse; training duration and examples seen varied together here.
Evaluation details and reproducibility
The base and adapter were interleaved on the same A100 80GB GPU, using vllm/vllm-openai:v0.31.0, BF16 inference, native thinking prompts, temperature 1.0, top-p 1.0, top-k disabled, and per-case seed 20261013 + index. Native EOS was token 26. Each answer could use the full configured 131,072-token context minus its prompt length; there was no smaller reply cap. Answers were graded without rewriting or retries.
HumanEval used the original tests, with a fixed extractor selecting the last parseable final-answer Python block defining the requested function. Reasoning-only code was not accepted as a final answer. MATH500 used math-verify[antlr4_13_2]==0.9.0. HumanEval+ was not run. The math score covers the frozen 200-question subset, not all 500 questions. Exact dataset revisions, indices, prompt templates and grading code are included under evaluation/.
The included grading worker requires Linux and starts as root solely to drop privileges to UID/GID 65534 before executing generated code. It clears credentials, restricts operations and applies resource/time limits; it is not a general-purpose security sandbox. Do not execute untrusted generated code in a credentialed host process.
The evaluation resumed after a cost-conservation interruption: 240 existing response lines were preserved byte-for-byte and only the remaining outputs were generated. Final hashes, response counts, original tests, per-case outcomes, checkpoint hashes and paired statistics were independently audited. Arrival-order bias is absent from the completed denominator, but floating-point/batch variation and stochastic sampling remain possible.
Step-50 was selected using a small validation. Those cases are reported separately from additional cases:
| Group | Original | Leo step-50 |
|---|---|---|
| HumanEval: 20 small-validation overlap cases | 17/20 | 18/20 |
| HumanEval: 144 additional cases | 140/144 | 141/144 |
| Math: 4 small-validation overlap cases | 3/4 | 3/4 |
| Math: 196 additional cases | 191/196 | 192/196 |
These are the scores in the broader run; earlier small-run scores differ because those answers were generated separately. HumanEval was held out from training, with no normalized exact/substring match detected in the prepared question pool; semantic contamination was not ruled out. Additional languages, tool use, agentic tasks, other coding benchmarks and quantized/merged variants were not evaluated for this release.
Load the adapter
The base architecture uses custom Transformers code. Review the upstream code before allowing trust_remote_code=True. Adequate memory for the full base model is required; its small active parameter count does not mean only those weights need storage.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_id = "sarvamai/sarvam-30b"
base_revision = "071ae95e933605ca1104a6b4524a36a98488efa4"
tokenizer = AutoTokenizer.from_pretrained(
base_id, revision=base_revision, trust_remote_code=True
)
base = AutoModelForCausalLM.from_pretrained(
base_id, revision=base_revision, trust_remote_code=True,
torch_dtype=torch.bfloat16, device_map="auto"
)
model = PeftModel.from_pretrained(base, "DesaiJayM/Leo-Sarvam-30B").eval()
messages = [{"role": "user", "content": "Write a Python function that returns the sum of two integers."}]
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True, enable_thinking=True
)
inputs = tokenizer(text, return_tensors="pt", add_special_tokens=False).to(model.device)
assert inputs.input_ids.shape[1] < 131072
with torch.inference_mode():
result = model.generate(
**inputs, do_sample=True, temperature=1.0, top_p=1.0, top_k=0,
max_new_tokens=131072 - inputs.input_ids.shape[1],
eos_token_id=26, pad_token_id=tokenizer.pad_token_id or 26
)
print(tokenizer.decode(result[0, inputs.input_ids.shape[1]:], skip_special_tokens=False))
The Transformers/PEFT example is a loading example; the benchmark numbers above were obtained with vLLM. The reference training/diagnostic stack used Transformers 4.57.2 and PEFT 0.17.1. Do not assume another inference stack, merged weights or quantization reproduces the scores.
Research context
Small-data alignment, functional code evaluation and LoRA generalization studies motivate this checkpoint study. They do not prove the cause of our regressions. In particular, LoRA Learns Less and Forgets Less (TMLR 2024) reports better preservation of outside-domain performance than full fine-tuning; spectral intruder dimensions are studied in a separate paper, LoRA vs Full Fine-tuning: An Illusion of Equivalence. Our pilot has not measured spectral collapse or update-norm explosion.
The actual learning rate was 1e-5, with attention-only rank-16 LoRA, and step 50 was 8% of the 625 planned updates. Read the verified related-work notes for sources, limits and proposed future tests. Checkpoint selection used different data prefixes, so additional examples and additional updates are not isolated causal factors.
License, attribution and intended use
The adapter and original Leo release code are distributed under Apache 2.0. Sarvam AI's base model remains subject to its Apache 2.0 license. LICENSE and NOTICE accompany this release; names are used to identify the base and data origins, not to imply affiliation or endorsement.
OpenCodeInstruct is an NVIDIA dataset licensed under CC-BY-4.0; this provenance credit does not relicense the adapter under CC-BY or redistribute the dataset. Qwen3.5-27B is Apache-2.0 licensed. DeepInfra is credited as the teacher inference provider, not as the owner of a supplied training dataset. No teacher responses or private collection traces are published.
This is an experimental research adapter. Generated code still requires review and testing. See evaluation/results.json, evaluation/protocol.json, training_config.json and release_manifest.json for the recorded evidence and artifact provenance.