Add Sarvam-30B (sarvam_moe) contrib model#144
Open
jimburtoft wants to merge 2 commits intoaws-neuron:mainfrom
Open
Add Sarvam-30B (sarvam_moe) contrib model#144jimburtoft wants to merge 2 commits intoaws-neuron:mainfrom
jimburtoft wants to merge 2 commits intoaws-neuron:mainfrom
Conversation
- Set neuron_config.fused_qkv = True so NxDI GQA preshard_hook correctly handles the fused query_key_value checkpoint layout - Set blockwise_matmul_config.use_shard_on_intermediate_dynamic_while = True to work around missing shard_hidden NKI kernel in SDK 2.29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: The below template includes items meant for model contributions only. For other contributions such as bug fixes, features, etc., only fill out the relevant portions of the form.
Description
NeuronX Distributed Inference implementation of sarvamai/sarvam-30b, a 32B total / 2.4B active parameter Mixture-of-Experts model with 128 routed experts + 1 shared expert, top-6 sigmoid routing, and GQA (64Q/4KV heads).
Key implementation details:
moe_block_tkgNKI kernel doesn't support shared experts, so they're extracted as a standalone module on the decoder layerModel Information
Model Name: Sarvam-30B (SarvamMoEForCausalLM)
Model Architecture: Decoder-only transformer with Mixture-of-Experts (128 routed + 1 shared, top-6 sigmoid routing, GQA)
Purpose: Text generation (multilingual, instruction-tuned)
Checklist
Required Components
Accuracy Test (
test/integration/test_sarvam_moe.py)check_accuracy_logits_v2with teacher forcing against CPU reference logitsREADME.md with the following sections:
Source Code (
src/)modeling_sarvam_moe.py: Full NxDI model implementation (~1180 lines)__init__.py: Exports all public classesOptional Components
Folder Structure
Testing
How did you test this change?
Tested on trn2.3xlarge (LNC=2, TP=4) with SDK 2.29. The model was compiled, loaded, and validated through:
check_accuracy_logits_v2with 5 diverse prompts × 20 tokens — 5/5 PASSTest Results:
Compatibility
Tested with:
Additional Information
trust_remote_code=Truefor HuggingFace loadingrouter_topk_nki_kernel_enabled=False) since the NKI router kernel expects softmaxRelated Issues
N/A
vLLM Integration
By submitting this PR, I confirm that: