Fix interleaved RoPE and partial rotary factor for GLM-4#39
Open
sdeeptan-aws wants to merge 1 commit intoaws-neuron:mainfrom
Open
Fix interleaved RoPE and partial rotary factor for GLM-4#39sdeeptan-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 GLM-4-9B-Chat-HF contrib model with correct interleaved RoPE implementation, partial rotary factor handling, fused gate_up_proj splitting, and updated README with architecture details and validation results. Key discovery: the model uses
model_type="glm"(notglm4), which means HuggingFace loadsGlmForCausalLM— a different architecture with 2 RMSNorm layers per decoder (not 4), interleaved RoPE rotation (even/odd indices, not split-half), andpartial_rotary_factor=0.5. Validation achieves 90.62% token match (29/32 tokens before BF16 divergence).Model Information
Model Name: GLM-4-9B-Chat-HF
Model Architecture: Decoder-only transformer (GLM with interleaved RoPE, GQA 32Q/2KV)
Purpose: Text generation / Chat
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 were validated against HuggingFace reference:
x[..., 0::2]/x[..., 1::2]rotation withrepeat_interleavefor cos/sin — different from LLaMA's split-half patternTest Results:
Late divergence at token 29+ is expected BF16 vs FP32 numerical precision accumulation, not an implementation error.
Compatibility
Tested with:
Additional Information
GlmForCausalLMwhich has 2 RMSNorm layers per decoder, not 4. Using the wrong model type would load a completely different architecturerepeat_interleavefor cos/sin expansion, unlike LLaMA's split-half approach withcat[2*intermediate_size, hidden_size]weight that must be split atintermediate_sizeinto gate_proj and up_projRelated Issues
N/A
vLLM Integration
By submitting this PR, I confirm that: