Update GPT-2 with Conv1D transposition and vocab padding#42
Open
sdeeptan-aws wants to merge 1 commit intoaws-neuron:mainfrom
Open
Update GPT-2 with Conv1D transposition and vocab padding#42sdeeptan-aws wants to merge 1 commit intoaws-neuron:mainfrom
sdeeptan-aws wants to merge 1 commit intoaws-neuron:mainfrom
Conversation
aws-yishanm
approved these changes
Feb 19, 2026
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 GPT-2 contrib model with Conv1D weight transposition, vocab size padding for non-power-of-2 vocabulary (50257), tied embeddings handling, and learned absolute position embeddings (not RoPE). The model has several unique architectural features compared to modern LLMs: Conv1D layers store weights transposed vs standard Linear, the vocab size isn't divisible by common TP degrees requiring
pad=True, and embeddings are tied between input and lm_head. Validation achieves 100% token match and all LightEval benchmarks pass within ±2% of HuggingFace reference.Model Information
Model Name: GPT-2
Model Architecture: Decoder-only transformer (GPT-2 with Conv1D, learned position embeddings, tied embeddings)
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. Four key architectural features validated:
[in, out], Linear expects[out, in])pad=Trueon embedding and lm_headupdate_state_dict_for_tied_weights, not manual weight tying in__init__Test Results:
LightEval Benchmark Results (full evaluation, all samples):
All benchmarks within ±2% of HF reference. Largest delta: truthfulqa_mc2 at +1.8%.
Compatibility
Tested with:
Additional Information
nn.Linear. All projection weights (c_attn,c_proj,c_fc,mlp.c_proj) must be transposed during state dict conversionpad=Trueis critical for embedding and lm_head to avoid crashes or incorrect results from uneven shardingupdate_state_dict_for_tied_weights), not by assigninglm_head.weight = embed_tokens.weightin__init__wpeembedding table, not RoPE — simpler but requires correct weight loadingnn.LayerNorm, not RMSNormc_attnprojection split into Q, K, V (concatenated layout, not interleaved like GPTNeoX)Related Issues
N/A
vLLM Integration
By submitting this PR, I confirm that: