Add NoPE layer support and tied embeddings for SmolLM3-3B#46
Open
sdeeptan-aws wants to merge 1 commit intoaws-neuron:mainfrom
Open
Add NoPE layer support and tied embeddings for SmolLM3-3B#46sdeeptan-aws wants to merge 1 commit intoaws-neuron:mainfrom
sdeeptan-aws wants to merge 1 commit intoaws-neuron:mainfrom
Conversation
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.
Description
Updated SmolLM3-3B contrib model with NoPE (No Position Embedding) layer support where every 4th layer skips RoPE entirely, tied embeddings handling via
update_state_dict_for_tied_weights, and GQA with 4 KV heads. The model's unique feature is theno_rope_layersconfig array that controls per-layer RoPE application — layers at indices 3, 7, 11, 15, ... receive no positional encoding. Math prompts like"The square root of 144 is"achieve 100% token match; open-ended prompts diverge due to BF16 precision.Model Information
Model Name: SmolLM3-3B
Model Architecture: Decoder-only transformer (NoPE layers, GQA 16Q/4KV, tied embeddings, 36 layers, hidden_size=2048)
Purpose: Text generation
Checklist
Required Components
test/integration/test_model.py)src/)Optional Components
Folder Structure
Testing
Model was compiled and tested with TP=2, batch_size=1, seq_len=128, bfloat16. Three key architectural features validated:
no_rope_layersconfig array with 0/1 values — every 4th layer (indices 3, 7, 11, 15, ...) has0meaning no RoPE applied. Attention class checksno_rope_layers[layer_idx]and passesrotary_emb=NonetoNeuronAttentionBasefor NoPE layers.tie_word_embeddings=true— handled viaupdate_state_dict_for_tied_weightswhich copiesembed_tokens.weighttolm_head.weightin state dict, not by manual weight assignment in__init__.head_dim=128). TP degree must be compatible with KV head count.Test Results:
Multi-Prompt Accuracy:
Lower-scoring prompts reflect BF16 style divergence — both HF and Neuron produce correct outputs but differ in phrasing.
Compatibility
Tested with:
Additional Information
no_rope_layersin config — a per-layer array where0means skip RoPE entirely. This is different from partial RoPE (which applies to a fraction of head dimensions).NeuronSmolLM3Attentionchecksconfig.no_rope_layers[layer_idx]and createsrotary_emb=Nonefor NoPE layers, passing it toNeuronAttentionBase.lm_head.weight = embed_tokens.weightin__init__. Useupdate_state_dict_for_tied_weightsto clone the weight in the state dict."The square root of 144 is"gives 100% accuracy because the answer is deterministic. Open-ended prompts diverge due to close logits under BF16.CONVERT_TO_MHAfor incompatible TP degrees.Related Issues
N/A
vLLM Integration
By submitting this PR, I confirm that: