Skip to content

Llama 3 Compatibility Support - #1409

Open
gauravsinghbitmesra-design wants to merge 1 commit into
meta-llama:mainfrom
gauravsinghbitmesra-design:feature/llama-3-compat
Open

Llama 3 Compatibility Support#1409
gauravsinghbitmesra-design wants to merge 1 commit into
meta-llama:mainfrom
gauravsinghbitmesra-design:feature/llama-3-compat

Conversation

@gauravsinghbitmesra-design

Copy link
Copy Markdown

Llama 3 Compatibility Support

Description

Refactors the model and tokenizer components to support Llama 3 specifications while maintaining backward compatibility with Llama 2.

Key Changes

  • Configurable RoPE: Added rope_theta to ModelArgs to support Llama 3's 500k base.
  • Tokenizer Support: Integrated tiktoken support in Tokenizer class to handle Llama 3 models, with automatic fallback to SentencePiece for Llama 2.
  • Flexible Chat Templates: Refactored generation.py to use a ChatFormatter system, enabling support for Llama 3's special token structure (<|start_header_id|>, etc.).

Verification

  • Added tests/test_llama3_compat.py to verify:
    • RoPE theta propagation.
    • Tokenizer backend selection (Tiktoken vs SentencePiece).
    • Correct chat template formatting for both Llama 2 and Llama 3 styles.
  • Manual verification of instantiation and parameter loading.

@meta-cla

meta-cla Bot commented Jan 25, 2026

Copy link
Copy Markdown

Hi @gauravsinghbitmesra-design!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 25, 2026
Production-ready implementation of Llama 3 compatibility:
- Configurable RoPE theta (500k context support)
- Dual tokenizer support (SentencePiece/Tiktoken)
- Flexible ChatFormatter system with Llama 2/3 templates
- Comprehensive validation and error handling
- Optimized performance and clean mutation-free logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant