Repository navigation
[llama3] Use Llama 3.2's rope scaling factor for the 1B and 3B flavors - #5528
Conversation
The 1B and 3B flavors mirror meta-llama/Llama-3.2-1B and Llama-3.2-3B (tied embeddings, same dims), but their ComplexRoPE configs fall back to the Llama 3.1 default scaling_factor=8.0. Both published config.json files set rope_scaling.factor=32.0, so 17 of 32 (1B) and 35 of 64 (3B) rotary frequencies were off by up to 4x after an HF load. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
|
|
@claude review |
|
Claude finished @tianyu-l's task in 1m 13s —— View job Review: [llama3] Use Llama 3.2's rope scaling factor for the 1B and 3B flavors
Verdict: the fix is correct and I'd merge it. I have one suggestion for the test and one thing to call out in the release notes. Correctness
Behavior change to call out (
|
The
1Band3Bllama3 flavors mirrormeta-llama/Llama-3.2-1BandLlama-3.2-3B(same dims, tied embeddings), but theirComplexRoPE.Configdoesn't setscaling_factor, so they get the Llama 3.1 default of8.0. Both publishedconfig.jsonfiles userope_scaling = {"factor": 32.0, "low_freq_factor": 1.0, "high_freq_factor": 4.0, "original_max_position_embeddings": 8192, "rope_type": "llama3"}.With the default, a model loaded from those checkpoints computes different rotary frequencies from the ones it was trained with. A CPU comparison against transformers, with the flavor cut to 1 layer and a small vocab and both models given the same random weights:
This sets
scaling_factor=32.0in the two flavors. The 8B/70B/405B flavors (Llama 3.1) keep8.0.Note: a 1B or 3B model trained from scratch in torchtitan with the old frequencies will see different rotary frequencies after this change.
Test
tests/unit_tests/cpu/models/llama3/test_rope_scaling.pycompares the flavors' scaled inverse frequencies with transformers'llama3rope init, using each checkpoint's publishedrope_scaling. Onmainthe 1B and 3B cases fail and 8B passes; with this change all three pass.tests/unit_tests/cpu/models/llama3: 7 passed.🤖 Generated with Claude Code