-
Notifications
You must be signed in to change notification settings - Fork 485
[docs] Add supported models page #980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"uri": "https://www.llama.com/models/llama-3/"} |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Large Language Models | ||
|
|
||
| This section documents Large Language Models supported by Megatron Bridge, with examples for converting to/from 🤗 Hugging Face and links to training recipes. | ||
|
|
||
| ```{toctree} | ||
| :hidden: | ||
|
|
||
| llama3.md | ||
| qwen.md | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Llama 3 | ||
|
|
||
| [Meta’s Llama](https://www.llama.com/models/llama-3/) builds on the general transformer decoder framework with some key additions such as pre-normalization, SwiGLU activations, and Rotary Positional Embeddings (RoPE). More information is available in the companion paper [“Llama: Open and Efficient Foundation Language Models”](https://arxiv.org/abs/2302.13971). With a wide variety of model sizes - Llama has options for every inference budget. | ||
|
|
||
| Llama family models are supported via the Bridge system with auto-detected configuration and weight mapping. | ||
|
|
||
| ## Conversion with 🤗 Hugging Face | ||
|
|
||
| ### Load HF → Megatron | ||
| ```python | ||
| from megatron.bridge import AutoBridge | ||
|
|
||
| # Example: Llama 3.1 8B | ||
| bridge = AutoBridge.from_hf_pretrained("meta-llama/Llama-3.1-8B-Instruct") | ||
| provider = bridge.to_megatron_provider() | ||
|
|
||
| # Configure parallelism before instantiating the model | ||
| provider.tensor_model_parallel_size = 8 | ||
| provider.pipeline_model_parallel_size = 1 | ||
|
|
||
| model = provider.provide_distributed_model(wrap_with_ddp=False) | ||
| ``` | ||
|
|
||
| ### Export Megatron → HF | ||
| ```python | ||
| # Convert from a Megatron checkpoint directory to HF format | ||
| bridge.export_ckpt( | ||
| megatron_path="/results/llama3_8b/checkpoints/iter_00002000", | ||
| hf_path="./llama-hf-export", | ||
| ) | ||
| ``` | ||
|
|
||
| ## Examples | ||
| - Checkpoint import/export: [examples/conversion/convert_checkpoints.py](https://github.com/NVIDIA-NeMo/Megatron-Bridge/blob/main/examples/conversion/convert_checkpoints.py) | ||
| - Generate text (HF→Megatron): [examples/conversion/hf_to_megatron_generate_text.py](https://github.com/NVIDIA-NeMo/Megatron-Bridge/blob/main/examples/conversion/hf_to_megatron_generate_text.py) | ||
|
|
||
| ## Pretrain recipes | ||
| - See: [bridge.recipes.llama.llama3](../../apidocs/bridge/bridge.recipes.llama.llama3.md) | ||
|
|
||
| ## Related docs | ||
| - Recipe usage: [Recipe usage](../../recipe-usage.md) | ||
| - Customizing the training recipe configuration: [Configuration overview](../../training/config-container-overview.md) | ||
| - Training entry points: [Entry points](../../training/entry-points.md) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Qwen | ||
|
|
||
| Qwen2/2.5/3 models are supported via the Bridge with QK layernorm handling (Qwen3) and bias in QKV (Qwen2). | ||
|
|
||
| ## Conversion with 🤗 Hugging Face | ||
|
|
||
| ### Load HF → Megatron | ||
| ```python | ||
| from megatron.bridge import AutoBridge | ||
|
|
||
| # Example: Qwen3 7B | ||
| bridge = AutoBridge.from_hf_pretrained("Qwen/Qwen3-7B") | ||
| provider = bridge.to_megatron_provider() | ||
|
|
||
| provider.tensor_model_parallel_size = 8 | ||
| model = provider.provide_distributed_model(wrap_with_ddp=False) | ||
| ``` | ||
|
|
||
| ### Export Megatron → HF | ||
| ```python | ||
| bridge.save_hf_pretrained(model, "./qwen-hf-export") | ||
| # or convert a checkpoint directory | ||
| bridge.export_ckpt( | ||
| megatron_path="/results/qwen3_8b/checkpoints/iter_00002000", | ||
| hf_path="./qwen-hf-export", | ||
| ) | ||
| ``` | ||
|
|
||
| ### Examples | ||
| - Checkpoint import/export: `examples/conversion/convert_checkpoints.py` | ||
| - Generate text (HF→Megatron): `examples/conversion/hf_to_megatron_generate_text.py` | ||
|
|
||
| ## Pretrain recipes | ||
| - Example usage (Qwen3 8B) | ||
| ```python | ||
| from megatron.bridge.recipes.qwen import qwen3_8b_pretrain_config | ||
|
|
||
| cfg = qwen3_8b_pretrain_config( | ||
| hf_path="Qwen/Qwen3-8B", | ||
| data_paths=["/path/to/dataset.nvjsonl"], | ||
| dir="/results/qwen3_8b", | ||
| ) | ||
| ``` | ||
|
|
||
| - API reference for Qwen recipes: | ||
| - Qwen recipes overview: [bridge.recipes.qwen](../../apidocs/bridge/bridge.recipes.qwen.md) | ||
| - Qwen2 recipes: [bridge.recipes.qwen.qwen2](../../apidocs/bridge/bridge.recipes.qwen.qwen2.md) | ||
| - Qwen3 recipes: [bridge.recipes.qwen.qwen3](../../apidocs/bridge/bridge.recipes.qwen.qwen3.md) | ||
| - Qwen3 MoE recipes: [bridge.recipes.qwen.qwen3_moe](../../apidocs/bridge/bridge.recipes.qwen.qwen3_moe.md) | ||
|
|
||
| ## Finetuning recipes | ||
| - Coming soon | ||
|
|
||
| ## Hugging Face model cards | ||
| - Qwen2: `https://huggingface.co/Qwen/Qwen2-7B` | ||
| - Qwen2.5: `https://huggingface.co/Qwen/Qwen2.5-7B` | ||
| - Qwen3: `https://huggingface.co/Qwen/Qwen3-7B` | ||
|
|
||
| ## Related docs | ||
| - Recipe usage and customization: [Recipe usage](../../recipe-usage.md) | ||
| - Training configuration: [Configuration overview](../../training/config-container-overview.md) | ||
| - Training entry points: [Entry points](../../training/entry-points.md) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Vision Language Models | ||
|
|
||
| This section documents Vision Language Models supported by Megatron Bridge. | ||
|
|
||
| ```{toctree} | ||
| :hidden: | ||
|
|
||
| ``` |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we point users to an example training script and how to modify it (this one? https://github.com/NVIDIA-NeMo/Megatron-Bridge/tree/main/examples/recipes/llama), or generic documentation on training (maybe this one? https://docs.nvidia.com/nemo/megatron-bridge/latest/training/config-container-overview.html)